#C13457. Count Integers in a List

    ID: 42997 Type: Default 1000ms 256MiB

Count Integers in a List

Count Integers in a List

You are given a single line of input containing space-separated tokens. Your task is to process these tokens as integers and count the frequency of each distinct integer.

If the input is empty, consider it as an empty list and output an empty dictionary {}. If any token cannot be parsed as an integer, print the exact error message:

All elements in the list should be integers.

Otherwise, output the frequency counts in the form of a dictionary with keys sorted in increasing order. For example, if the input is 1 2 2 3, the correct output is {1: 1, 2: 2, 3: 1}.

The frequency is defined as the number of occurrences of each integer in the input list.

In mathematical terms, if the input list is \(L = [a_1, a_2, \dots, a_n]\), then for each unique integer \(k\) in \(L\), the output should include an entry \[ k: \#\{ i \mid a_i = k \} \]

inputFormat

The input is read from stdin as a single line containing zero or more space-separated tokens.

If the line is empty, it represents an empty list.

outputFormat

Output to stdout a single line. If the input is valid, print a dictionary in the format {key1: value1, key2: value2, ...} where the keys are sorted in increasing order. If there is an invalid token that cannot be parsed as an integer, print exactly:

All elements in the list should be integers.

## sample
1 2 2 3
{1: 1, 2: 2, 3: 1}