#C12786. Most Frequent Word

    ID: 42251 Type: Default 1000ms 256MiB

Most Frequent Word

Most Frequent Word

Given a string of text, your task is to identify the most frequently occurring word. The word is defined as any contiguous sequence of characters that are not punctuation. Punctuation should be ignored and the comparison is case-insensitive. In the case of a tie, return the word that reaches the maximum frequency first. If the input contains no valid words, output None.

More formally, let \( S \) be a string. After removing all punctuation symbols (i.e. characters matching the regular expression [\!"#$%&'()*+,\-./:;?@[\\\]^_`{|}~]) and splitting \( S \) by whitespace, suppose the resulting set of words is \( \{w_1, w_2, \ldots, w_k\} \). Let \( f(w) \) be the frequency of word \( w \) after converting each word to lowercase. You are required to compute a word \( v \) such that \[ v = \arg\max_{w} f(w), \] with tie broken by the order of first appearance. If no word exists, output None.

inputFormat

The input consists of a single string provided via standard input (stdin). The string may contain letters, punctuation, and whitespace. It may also be empty.

outputFormat

Print the most frequently occurring word to standard output (stdout). If there is no valid word, output None. The output is case-insensitive (all letters should be in lowercase).

## sample
Hello, hello! How are you? Hello!!! Are you there, you?
hello