#C387. Most Frequent Token
Most Frequent Token
Most Frequent Token
You are given a string containing tokens separated by spaces. Your task is to determine the token that appears most frequently. In case of a tie (multiple tokens with the same highest frequency), output the token that is lexicographically smallest.
Note: Lexicographical order refers to the order of words as they appear in a dictionary. That is, token a comes before token b.
The problem can be formulated mathematically as follows:
Let \(T = \{t_1, t_2, \ldots, t_n\}\) be the set of tokens, and let \(f(t)\) denote the frequency of token \(t\). Find a token \(t^*\) such that \[ t^* = \min \{ t \mid f(t) = \max_{s \in T} f(s) \}\n\] where \(\min\) is taken in the lexicographical order.
inputFormat
The input is given via standard input and consists of a single line containing multiple tokens separated by spaces.
outputFormat
Output the token with the highest frequency to standard output. If there is a tie, output the lexicographically smallest token among those with the highest frequency.
## sampleapple banana apple strawberry banana apple orange
apple
</p>