#K46397. Longest Increasing Substring

    ID: 27967 Type: Default 1000ms 256MiB

Longest Increasing Substring

Longest Increasing Substring

Given a string s, find the longest substring in which the characters appear in strictly increasing alphabetical order. In other words, for any two consecutive characters s[i] and s[i+1] in the substring, the inequality $$s[i] < s[i+1]$$ must hold. If there exist multiple substrings of the same maximum length, return the one that occurs first in s.

For example, in the string "abacdef", the longest valid substring is "acdef".

inputFormat

The input is read from standard input (stdin) and consists of a single line containing a string s.

outputFormat

The output should be printed to standard output (stdout) and is the longest substring of s where each character is strictly greater than its previous character. If s is empty, print an empty line.

## sample
abcde
abcde