#C13014. Word Counter
Word Counter
Word Counter
Given a string of text, count the number of occurrences for each distinct word. Words are defined as contiguous sequences of alphanumeric characters and should be treated case-insensitively. All punctuation marks should be ignored. The output should display each word along with its count on a separate line, sorted in lexicographical order.
Formally, let (S) be the input string and (W) be the set of words obtained from (S) by ignoring punctuation and case. Each word (w \in W) should appear in the output with its frequency (f(w)).
inputFormat
A single string (possibly spanning multiple lines) provided via standard input. The string consists of letters, digits, spaces, and punctuation marks.
outputFormat
For each unique word found, output a line with the word and its frequency separated by a space. The words must be output in lexicographical order.## sample
Hello
hello 1
</p>