#C10614. Count Word Occurrences

    ID: 39839 Type: Default 1000ms 256MiB

Count Word Occurrences

Count Word Occurrences

You are given a single line of text. Your task is to count the frequency of each word in the text while ignoring case differences. The words should be output in the order of their first appearance in the input.

For example, given the input:

hello world hello everyone

the output should be:

hello 2
world 1
everyone 1

Note: The input may contain extra spaces or mixed cases. You must convert all words to lowercase and split on any whitespace.

Formula:

For each word w, output the pair \( (w, f(w)) \) where \( f(w) \) is the number of occurrences of w in the text.

inputFormat

A single line containing the text message. The text may include extra spaces and mixed case letters.

outputFormat

For each word (in the order of its first appearance), print a line with the word and its frequency separated by a space. If the input is empty, output nothing.## sample

hello world hello everyone
hello 2

world 1 everyone 1

</p>