Count Value Occurrences
Given a list of integers, count how many times each unique integer appears in the list. Then, print each unique integer along with its count. The output should be sorted by the unique integers in ascending order.
Input
The first line contains an integer N, the number of integers in the list. The second line contains N space-separated integers.
Output
For each unique integer in the input list, print the integer and its count, separated by a space. Print these pairs in ascending order of the integers. Each pair should be on a new line.
Constraints
1 <= N <= 1000. The integers are between -1000 and 1000.
Example 1
5 1 2 1 3 2
1 2 2 2 3 1
The number 1 appears twice, 2 appears twice, and 3 appears once. Output is sorted by number.
Example 2
7 -5 0 10 -5 0 -5 10
-5 3 0 2 10 2
Negative numbers and zero are handled. -5 appears 3 times, 0 appears twice, 10 appears twice.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
5 1 2 1 3 2
7 -5 0 10 -5 0 -5 10