#C13790. Reverse Words in a Sentence

    ID: 43367 Type: Default 1000ms 256MiB

Reverse Words in a Sentence

Reverse Words in a Sentence

You are given a sentence that may contain multiple spaces between the words. Your task is to reverse the order of the words while preserving the exact spacing.

For example, if the input sentence is:

Hello   world

Then the output should be:

world   Hello

Note: Every space character is considered a delimiter. The splitting of words must preserve empty tokens resulting from consecutive spaces.

Formally, let the input string be \( s \) and let its tokens be obtained by splitting with the space character. Then the output string is the tokens in reverse order concatenated by a single space.

inputFormat

The input consists of a single line containing a non-empty string. The string may contain leading, trailing, or consecutive internal spaces, which must be preserved in the output.

Input is provided via standard input (stdin).

outputFormat

Print the transformed string to standard output (stdout), which is the input string with the order of words reversed while preserving the spacing.

## sample
Hello
Hello