#C10078. Tally the Votes

    ID: 39243 Type: Default 1000ms 256MiB

Tally the Votes

Tally the Votes

You are given a list of votes for various candidates identified by their integer IDs. Your task is to count the number of votes received by each candidate and output the result sorted in increasing order of the candidate IDs.

Note: The input is provided via standard input (stdin) and the output must be printed to standard output (stdout). If there are no votes, no output is expected.

Mathematically, if we denote the list of votes as \(V = [v_1, v_2, \ldots, v_n]\), you are required to compute a function \(f: \mathbb{Z} \to \mathbb{N}\) such that for any candidate id \(x\), \(f(x) = \sum_{i=1}^{n} \mathbf{1}_{\{v_i = x\}}\) and then output the pairs \((x, f(x))\) sorted by \(x\).

inputFormat

The input consists of two lines:

  • The first line contains a single integer \(n\) representing the number of votes.
  • The second line contains \(n\) space-separated integers, each representing a candidate ID for which a vote was cast. If \(n\) is 0, the second line may be empty.

outputFormat

For each candidate, print a line with two integers: the candidate ID and the number of votes received. The output should be sorted in increasing order of candidate IDs. If there are no votes, do not print anything.

## sample
7
1 3 3 2 3 1 2
1 2

2 2 3 3

</p>