#C3351. Reverse Words in a String

    ID: 46769 Type: Default 1000ms 256MiB

Reverse Words in a String

Reverse Words in a String

Given a string s that may contain leading, trailing, or multiple spaces between words, your task is to reverse the order of the words and output them separated by a single space.

In mathematical terms, if the string is represented as:

\[ s = w_1 \; w_2 \; \dots \; w_n \]

then the required output is:

\[ w_n \; w_{n-1} \; \dots \; w_1 \]

For example, if the input is the sky is blue, the output should be blue is sky the.

inputFormat

The input consists of a single line containing the string s. The string may include extra spaces at the beginning, end, or between words.

outputFormat

Output a single line with the words of the string in reverse order, separated by a single space.

## sample
the sky is blue
blue is sky the