#K11041. Most Frequent Visitor

    ID: 23380 Type: Default 1000ms 256MiB

Most Frequent Visitor

Most Frequent Visitor

You are given a log containing multiple entries. Each entry consists of a timestamp and a badge ID separated by a whitespace. Your task is to determine the badge ID of the employee who visited the most during the month. In the case of a tie, return the smallest badge ID.

Formally, let \( f(id) \) be the frequency of badge \( id \). You need to find the badge ID \( x \) such that:

\( x = \min\{ id \mid f(id) = \max_{y}(f(y)) \} \)

It is guaranteed that there is at least one log entry.

inputFormat

The first line contains an integer ( n ) (1 ≤ n ≤ 10^5), denoting the number of log entries. Each of the next ( n ) lines contains a log entry in the format: YYYY-MM-DD badgeID, where the date is given in year-month-day format and badgeID is an integer.

outputFormat

Output a single line containing the badge ID that appears most frequently. In case of a tie, output the smallest badge ID.## sample

7
2023-01-01 9999
2023-01-01 1234
2023-01-01 1234
2023-01-02 9999
2023-01-02 9999
2023-01-02 1234
2023-01-03 9999
9999