#K54337. Most Frequent Word

    ID: 29731 Type: Default 1000ms 256MiB

Most Frequent Word

Most Frequent Word

Given a paragraph of text, your task is to determine the word that appears most frequently. A word is defined as any sequence of alphanumeric characters and underscores (i.e. matching the regex pattern (\verb|\b\w+\b|)). The comparison is made in a case-insensitive manner, but the output should preserve the case of the word as it first appears in the input. In case of a tie, output the word that appears first in the text.

The problem can be mathematically stated as follows: Given a sequence of words (w_1, w_2, \ldots, w_n) and a frequency function (f(w)), find a word (w^) such that [ w^ = \mathop{\arg\max}_{w} f(w), ] with ties broken by the order of appearance.

inputFormat

A single line containing a paragraph of text.

outputFormat

Output the most frequent word.## sample

hello
hello