#C13102. Word Frequency Counter

    ID: 42604 Type: Default 1000ms 256MiB

Word Frequency Counter

Word Frequency Counter

You are given a text from standard input. Your task is to count the frequency of each word in the text, ignoring case and punctuation. A word is defined as a contiguous sequence of alphanumeric characters (i.e. matching the regular expression \b\w+\b in \(LaTeX\) style). In case two words have the same frequency, the word that appears earlier in the text should come first.

After counting, output at most the 10 most frequent words. Each output line should contain the word followed by its frequency, separated by a space. If there are fewer than 10 distinct words, output all of them.

Note: The input is read from standard input (stdin) and the result should be printed to standard output (stdout).

inputFormat

The input consists of a single text, which may span multiple lines. The text may be empty or contain punctuation. All words should be compared in a case-insensitive manner.

outputFormat

Output up to 10 lines. Each line contains a word and its frequency (separated by a single space) in descending order of frequency. If two words have the same frequency, the one that appears earlier in the input should appear first.

## sample