#K46122. Word Frequency Counter

    ID: 27907 Type: Default 1000ms 256MiB

Word Frequency Counter

Word Frequency Counter

Given an input text string, count the frequency of each word present in the text.

Words are defined as contiguous sequences of alphanumeric characters (matching the regular expression \(\b\w+\b\)). The matching should be case-insensitive; that is, words differing only by case (e.g. "Hello" and "hello") are considered identical.

Your program should read the entire input from standard input (stdin) and print the frequency count of each word to standard output (stdout), with one word per line, sorted in alphabetical order. Each output line should contain the word followed by a space and then its frequency.

For example, if the input is:

Hello, hello! How are you? Are you fine? Hello?

Then the output should be:

are 2
fine 1
hello 3
how 1
you 2

inputFormat

The input consists of a single text string that may include letters, numbers, punctuation, and whitespace. The text is read from standard input.

outputFormat

The output should consist of several lines. Each line contains a word (in lowercase) and its frequency separated by a single space. The words must be printed in alphabetical order. If the input text is empty, the output should be empty.

## sample
Hello, hello! How are you? Are you fine? Hello?
are 2

fine 1 hello 3 how 1 you 2

</p>