#C14717. Find the Most Frequent Number

    ID: 44397 Type: Default 1000ms 256MiB

Find the Most Frequent Number

Find the Most Frequent Number

You are given a list of integers. Your task is to find the most frequent number in the list. If multiple numbers have the same highest frequency, output the smallest among them. If the input list is empty, output None.

In mathematical terms, let \(A = [a_1, a_2, \ldots, a_n]\) be the array of integers. Define the frequency function \(f(x)\) as the number of times \(x\) appears in \(A\). You need to find an integer \(m\) such that \[ m = \min \{ x \mid f(x) = \max_{y} f(y) \}\,. \]

The input is given in a single line containing space-separated integers. If the line is empty then the list is considered empty.

inputFormat

The input is provided via standard input. It consists of a single line containing zero or more space-separated integers.

Examples:

  • 1 2 2 3 3 4
  • 1 3 1 3 2 1
  • An empty line indicates an empty list.

outputFormat

Print the most frequent number to standard output. If there is a tie, print the smallest number among those with the highest frequency. In case the input list is empty, print None.

## sample
1
1

</p>