#C14087. Word Frequency Report Generator

    ID: 43697 Type: Default 1000ms 256MiB

Word Frequency Report Generator

Word Frequency Report Generator

You are given a body of text as input from standard input (stdin). Your task is to generate a word frequency report. In this report, you must count the occurrences of each word, where a word is defined as a contiguous sequence of alphabetic characters (i.e., letters A–Z and a–z). The words should be treated in a case-insensitive manner (for example, "Hello" and "hello" are the same word).

The report must list each word followed by its frequency in the format word: frequency on separate lines. The words should be ordered primarily by their frequency in descending order. In case two or more words have the same frequency, they should appear in the order of their first appearance in the text. Formally, if the frequency of word w is denoted as \( f(w) \), then the sorting order is defined by:

[ \text{Sort by } (-f(w), \text{first occurrence index}) ]

This problem simulates scenarios such as generating reports from large texts or logs. Your solution must read from stdin and write the output to stdout.

inputFormat

The input consists of a text containing letters, spaces, punctuation, and newline characters. The text is provided via standard input (stdin). There is no specific format or length limit imposed.

outputFormat

The output should print the word frequency report to standard output (stdout). Each line of the output must be in the format word: frequency (without quotes). The report must list words sorted first by descending frequency and then by the order of their first occurrence in the input text if frequencies are equal.

## sample
Hello world! Hello, Universe. Goodbye world.
hello: 2

world: 2 universe: 1 goodbye: 1

</p>