#K9101. Most Frequent Stock Price

    ID: 37880 Type: Default 1000ms 256MiB

Most Frequent Stock Price

Most Frequent Stock Price

You are given a list of stock records, where each record is a string in the format SYMBOL PRICE. For example, "AAPL 150" indicates that the stock symbol AAPL has a price of 150 at the end of the day.

Your task is to determine the price that appears most frequently in the list. In the event of a tie (i.e. multiple prices share the maximum frequency), output the highest price among those.

The solution may require you to parse the input from stdin and write the answer to stdout.

Mathematically, if you denote the frequency of a price \( p \) as \( f(p) \), then you need to find \( p^* \) such that:

\[ p^* = \max\{ p \mid f(p) = \max_{q}{f(q)} \} \]

Note: Prices are integers.

inputFormat

The first line contains a single integer \(n\), the number of stock records. Each of the following \(n\) lines contains a record with a stock symbol and its price separated by a space.

Example:

6
AAPL 150
GOOG 80
MSFT 80
AMZN 150
TSLA 80
FB 150

outputFormat

Output a single integer — the most frequently occurring price. If multiple prices have the same frequency, output the highest one.

## sample
1
AAPL 150
150