#C4305. Most Sold Items

    ID: 47829 Type: Default 1000ms 256MiB

Most Sold Items

Most Sold Items

You are given an integer \( n \) and \( n \) strings, representing items sold in a store. Your task is to determine which item(s) were sold the most frequently. If there are multiple items with the same highest frequency, output them in lexicographical order.

Input Format:

  • The first line contains an integer \( n \) denoting the number of items.
  • The following \( n \) lines each contain a non-empty string representing an item identifier.

Output Format:

Output the item(s) that occur the most, separated by a single space, in lexicographical order.

The solution should be efficient and work for all valid input cases.

inputFormat

The input is read from standard input (stdin) and has the following format:

n
item1
item2
... 
itemn

Here, n is the number of items and each item is a non-empty string.

outputFormat

Print the most frequently sold item(s) separated by a single space in lexicographical order on a single line to standard output (stdout).

## sample
7
abc123
xyz999
abc123
abc123
xyz999
xyz999
lmn456
abc123 xyz999