#C318. Count String Occurrences

    ID: 46578 Type: Default 1000ms 256MiB

Count String Occurrences

Count String Occurrences

You are given a list of strings. Your task is to count the number of occurrences of each distinct string and print each string along with its frequency. The output must list the strings in the order of their first appearance in the input.

For example, if the input strings are: apple banana apple orange banana banana, the output should be: apple 2 banana 3 orange 1

In other words, if we let (N) be the number of strings and (s_i) be the (i)-th string, you must compute the frequency function (f(s)) and then output each string in the order that it first appears followed by (f(s)).

inputFormat

The input is given via standard input (stdin). The first line contains an integer (N) denoting the number of strings. Each of the following (N) lines contains a single string consisting of lowercase letters.

outputFormat

Output each distinct string from the input along with its count, separated by a space, on a new line. The order of the output should be the same as the order in which the string first appears in the input. If (N = 0), no output should be produced.## sample

0