#K57487. User Visit Tracker

    ID: 30431 Type: Default 1000ms 256MiB

User Visit Tracker

User Visit Tracker

You are given a number n representing the total number of user visits followed by n integers. Each integer represents a user ID corresponding to a visit. Your task is to count how many times each user visited and then output the counts in ascending order of user IDs.

In other words, for each unique user ID, compute the frequency of visits, and then print the results sorted by the user ID. The output for each user should consist of the user ID followed by the number of visits.

Note: If there are no visits (n = 0), then no output should be produced.

The problem can be mathematically formulated as follows: $$ \text{For each unique } x \in \{user\_visits\}, \text{ compute } f(x) = \text{number of times } x \text{ appears}, $$

and then output the pairs ((x, f(x))) in ascending order of (x).

inputFormat

The input is given from standard input (stdin) and consists of two lines:

  • The first line contains a single integer n (0 ≤ n ≤ 106), representing the number of user visits.
  • The second line contains n space-separated integers, each representing a user ID.

outputFormat

For each unique user ID in ascending order, output a line containing two space-separated integers: the user ID and the number of visits for that user. If n is 0, your program should produce no output.

## sample
5
2 1 2 1 2
1 2

2 3

</p>