#K50412. Counting Duplicate Integers

    ID: 28859 Type: Default 1000ms 256MiB

Counting Duplicate Integers

Counting Duplicate Integers

You are given an array of integers. Your task is to count the occurrences of each integer that appears more than once in the array and output a dictionary (or map) where the keys are the duplicate integers and the values are their respective counts.

Note that if there are no duplicates, you should output an empty dictionary: {}.

The input is given through standard input (stdin) and the output should be printed to standard output (stdout). The dictionary keys in the output should be printed in ascending order.

Examples:

  • For the input 8\n1 2 2 3 4 4 4 5, the output should be {2: 2, 4: 3}.
  • For the input 5\n1 2 3 4 5, the output should be {}.

inputFormat

The first line contains a single integer n representing the number of elements in the array. The second line contains n space-separated integers.

outputFormat

Print a dictionary (or a similar representation in your language) containing each duplicate integer as the key and the number of times it appears (its count) as the value. If there are no duplicates, print {}. The keys must be output in ascending order.

## sample
8
1 2 2 3 4 4 4 5
{2: 2, 4: 3}