#C13535. Word Frequency Counter

    ID: 43084 Type: Default 1000ms 256MiB

Word Frequency Counter

Word Frequency Counter

You are given a single line of text. Your task is to count the frequency of each word in the text with the following rules:

  • Words are case-insensitive.
  • All punctuation should be removed. You can assume punctuation includes all characters in the set !"#$%&'()*+,-./:;?@[\\]^_`{|}~.
  • Single-character words should be ignored.
  • If the input is empty or contains only whitespace, no output should be produced.

The output should list each valid word along with its frequency on a separate line. The words must be sorted in lexicographical (alphabetical) order.

For example, if the input is:

$$ \texttt{Hello, world! Hello!} $$

Then the output should be:

hello 2
world 1

inputFormat

The input consists of a single line of text read from the standard input (stdin). The text may contain letters, punctuation, numbers, and whitespace characters.

outputFormat

For each valid word (having length greater than 1), output a line containing the word in lowercase followed by a space and its frequency. The words must be sorted in lexicographical (alphabetical) order. If there are no valid words, output nothing.

## sample
Hello, world! Hello!
hello 2

world 1

</p>