#K65327. Longest Consecutive Sequence

    ID: 32173 Type: Default 1000ms 256MiB

Longest Consecutive Sequence

Longest Consecutive Sequence

Given a list of integers, your task is to find the longest consecutive subsequence. A consecutive subsequence is defined as a sequence of integers where each number is exactly 1 more than its predecessor.

If there are multiple subsequences of the same maximum length, output the lexicographically smallest one (i.e., compare the sequences element by element).

For example, given the input 100 4 200 1 3 2, the longest consecutive sequence is 1 2 3 4.

inputFormat

The input consists of a single line containing space-separated integers. If the input is empty, it represents an empty list.

outputFormat

Output the longest consecutive sequence, with each number separated by a single space. If the input list is empty, output an empty line.

## sample
100 4 200 1 3 2
1 2 3 4