All problems

The Duplicate Report

mediumPythonData CleaningDictionaries

Bramley Registry audits a supplier reference column before anything is allowed to use it as a key, because a key that repeats is not a key. The audit lists every reference appearing more than once together with how many times it turned up, so that somebody can go and look at those records by hand. References appearing exactly once are of no interest and are left out. A clean column still has to produce a line of output, so that a silent pass and a crashed job never look the same on screen.

Task: Print every reference that appears more than once, with how many times it appears.

Input

The first line holds one integer n, how many references follow. Each of the next n lines holds one reference as a single word. Repeats may appear anywhere in the column and are not necessarily adjacent.

Output

One line per repeated reference, in alphabetical order of the reference. Each line holds the reference, one space, then how many times it appeared in total. If no reference repeats at all, print the single line no duplicates instead.

Example:

Input:
6
b
a
b
c
a
b

Output:
a 2
b 3

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…