#C13202. Calculate Mode of a List
Calculate Mode of a List
Calculate Mode of a List
Given a list of integers, determine the mode of the list. The mode is defined as the number or numbers that appear most frequently. If there is a single mode, output that integer; if there are multiple modes, output all of them in ascending order separated by a space.
If the input list is empty, output the error message "The list is empty".
For example:
- Input:
1 2 2 3 3
→ Output:2 3
- Input:
4 4 4 1 2 2 3
→ Output:4
The mathematical condition can be written as: $$ \max_{x \in S} \; \#\{i : S_i = x\} $$ where if more than one $x$ attains the maximum frequency, they should be output in sorted order.
inputFormat
The input is provided via standard input (stdin) as a single line containing space-separated integers.
outputFormat
If there is a single mode, output that number. If there are multiple modes, output them as space-separated integers in ascending order. If the input list is empty, output "The list is empty".
## sample4 4 4 1 2 2 3
4