#K62287. Unique Value Frequencies

    ID: 31498 Type: Default 1000ms 256MiB

Unique Value Frequencies

Unique Value Frequencies

You are given a list of integers. Your task is to calculate the frequency of each unique integer in the list and display the result in ascending order of the unique values.

For a given integer \( n \) (the number of elements) and a list of \( n \) integers, compute a list of pairs \( (x, f(x)) \) where \( x \) is a unique integer and \( f(x) \) is its frequency. The result should be printed with each pair on a separate line, formatted as x f(x).

Note: The frequency function is defined as \( f(x) = \text{number of occurrences of } x \).

inputFormat

The input is read from standard input (stdin). The first line contains an integer ( n ) ((1 \le n \le 10^5)), representing the number of elements. The second line contains ( n ) space-separated integers.

outputFormat

Print each unique integer and its frequency on a new line in ascending order of the integers. Each line should contain the integer and its frequency separated by a space.## sample

7
4 1 2 4 3 2 3
1 1

2 2 3 2 4 2

</p>