#K84687. Donation Frequencies

    ID: 36475 Type: Default 1000ms 256MiB

Donation Frequencies

Donation Frequencies

Given a list of donation amounts, your task is to determine the frequency of each unique donation amount. You should output each donation amount along with its frequency, sorted in ascending order.

For instance, if the input donations are [100, 200, 100, 300, 200, 100, 400, 500], the correct output would be:

100 3
200 2
300 1
400 1
500 1

Note: The frequency is defined as the number of times a donation amount appears in the input. Please ensure your solution reads from standard input (stdin) and writes the result to standard output (stdout).

inputFormat

The input is given via standard input. The first line contains an integer n, representing the number of donation amounts. The second line contains n space-separated integers that represent the donation amounts.

outputFormat

For each unique donation amount, print a line with the donation amount followed by its frequency, separated by a space. The output should be in ascending order by donation amount.## sample

8
100 200 100 300 200 100 400 500
100 3

200 2 300 1 400 1 500 1

</p>