#C12919. Word Frequency Counter

    ID: 42399 Type: Default 1000ms 256MiB

Word Frequency Counter

Word Frequency Counter

This problem requires you to count the frequency of each word in a given text while ignoring punctuation and case differences. The input is provided as a single text block, and your program must normalize all letters to lowercase, remove all punctuation, and then count the occurrences of each word. Finally, you should output the list of words and their corresponding counts in lexicographical order (alphabetical order).

Note: If the input is empty, your program should output nothing.

Example:

  • Input: Hello, world!
  • Output:
    hello 1
    world 1

inputFormat

The input consists of a single block of text read from standard input. This text may span multiple lines and can include letters, numbers, spaces, and punctuation.

For example:

Hello, world!

outputFormat

Output the frequency count for each distinct word in the normalized text. The words must be converted to lowercase and punctuation removed. The output should be printed on standard output with each line containing a word followed by a space and its frequency count. The words must be printed in lexicographical order.

For example:

hello 1
world 1
## sample
hello
hello 1

</p>