#C13515. Word Frequency Counter

    ID: 43062 Type: Default 1000ms 256MiB

Word Frequency Counter

Word Frequency Counter

You are given a text string which may contain letters, digits, punctuation, and spaces. Your task is to count the frequency of each word in the string. A word is defined as a contiguous sequence of alphanumeric characters (i.e., letters and digits). The counting should be case-insensitive and punctuation should be ignored. Finally, output the frequency count for each distinct word, sorted in lexicographical order.

For example, if the input is Hello hello world, the output should be
hello 2
world 1
.

inputFormat

A single line of text is provided as input from stdin. The text may contain letters, digits, punctuation, and spaces.

outputFormat

For each distinct word found in the input, output one line in the format: word frequency. The words must be printed in lexicographical (alphabetical) order. If no valid word exists, output nothing.## sample

Hello hello world
hello 2

world 1

</p>