#K95757. Longest Word Finder

    ID: 38934 Type: Default 1000ms 256MiB

Longest Word Finder

Longest Word Finder

You are given a string of text that may contain punctuation marks. Your task is to find the longest word in the text. If there are two or more words of the same maximum length, return the first one encountered in the text.

Note: Punctuation is not considered part of a word. For example, in the string "Hello, world!", the longest word is "Hello".

Input: A single line string.

Output: The longest word from the input text. If the input is an empty string, output an empty string.

Mathematically, if we denote the input string as \(S\) and the set of words extracted (after removing punctuation) as \(W = \{w_1, w_2, \ldots, w_n\}\), then the answer is

\[ \text{answer} = \min_{w \in W} \{w \,|\, |w| = \max_{v \in W} |v|\} \]

inputFormat

The input consists of a single line string containing letters, digits, spaces, and punctuation. The entire line is read from standard input.

outputFormat

Print the longest word found in the input string to standard output. If there are multiple words with the same maximum length, output the first one encountered. If the input string is empty, output an empty string.

## sample
The quick brown fox!
quick