#C1522. Longest Word Challenge

    ID: 44737 Type: Default 1000ms 256MiB

Longest Word Challenge

Longest Word Challenge

You are given a single line of input containing a sentence with words separated by spaces. Your task is to identify and output the longest word in the sentence. If there are multiple words with the same maximum length, return the first one that appears.

In mathematical terms, given a sentence \( S = w_1 \; w_2 \; \dots \; w_n \) where each \( w_i \) is a word, find \( w_k \) such that for all \( i |w_k| \), the word \( w_k \) is returned.

The input will be provided via stdin and your program should output the answer to stdout.

inputFormat

The input consists of a single line containing a sentence. The sentence is composed of words separated by single spaces. There will be at least one word in the sentence.

Example:

I love programming

outputFormat

Output the longest word from the input sentence to stdout. If multiple words share the maximum length, output the first one.

Example:

programming
## sample
I love programming
programming