#C2560. Longest Word Finder

    ID: 45890 Type: Default 1000ms 256MiB

Longest Word Finder

Longest Word Finder

Given a sentence, your task is to find and print the longest word. If multiple words have the same maximum length, print the first one encountered in the sentence. Note that punctuation is considered as part of a word.

For example, for the input "The quick brown fox jumps over the lazy dog", the answer is quick.

Formally, let \( S \) be a sentence consisting of words separated by spaces. For each word \( w \) in \( S \), if \( |w| \) denotes the length of \( w \), output the word \( w^* \) such that \( |w^*| \geq |w| \) for all words \( w \) in \( S \), and if there is a tie, output the one that appears first.

inputFormat

The input consists of a single line containing a sentence. The sentence may include spaces and punctuation. Input is provided via standard input (stdin).

outputFormat

Output the longest word found in the sentence to standard output (stdout). If the input sentence is empty, output an empty string.

## sample
The quick brown fox jumps over the lazy dog
quick