#C7608. Word Frequency Counter

    ID: 51498 Type: Default 1000ms 256MiB

Word Frequency Counter

Word Frequency Counter

Given a document as input, your task is to count the frequency of each unique word in the document, ignoring case and punctuation. A word is defined as a contiguous sequence of alphanumeric characters, which can be identified by the regular expression pattern bw+b\\b\\w+\\b. After counting, output each distinct word along with its frequency in lexicographical (alphabetical) order. For example, if the input text is 'word word WORD WoRd', the output should be a single line 'word 4'.

inputFormat

The input consists of a single text document provided through standard input. The text may contain multiple lines and various punctuation. You need to process the entire input as one continuous string.

outputFormat

For each unique word found in the input, print a line that contains the word and its frequency separated by a single space. The words should be printed in lexicographical order (i.e., alphabetical order based on their lowercase representation).## sample

word
word 1

</p>