Counting Each Category
The second part of the same Riverbend Supply returns summary is a breakdown rather than a single figure. It lists every reason code that came up this month with the number of returns filed against it. The list is printed in increasing code order — not in the order the codes first appeared and not with the busiest reason at the top — because the same codes are printed in the same places every month and the desk staff read them by position.
Task: Print each reason code that appears, with how many returns used it.
Input
The first line holds a single integer n, the number of returns. Each of the next n lines holds one reason code: a whole number. Codes may repeat.
Output
One line per code that appears, in increasing code order. Each line holds the code, a single space, then the number of returns that used it.
Example:
Input:
5
1
2
1
3
2
Output:
1 2
2 2
3 1
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in