#C13400. Longest Digit Substring

    ID: 42935 Type: Default 1000ms 256MiB

Longest Digit Substring

Longest Digit Substring

You are given a non-empty string that is guaranteed to contain at least one digit. Your task is to find and output the longest contiguous substring that consists solely of digits. If there are multiple segments of equal maximum length, you should output the first occurrence.

For instance, in the string abc1234xyz22, the longest digit substring is 1234.

The problem can be mathematically conceptualized as follows: Given a string S, find a substring S[i \ldots j] such that for all characters in the substring, they are digits (i.e., they satisfy the condition \(0 \leq S[k] \leq 9\) for \(i \leq k \leq j\)), and \(|S[i \ldots j]|\) is maximized.

inputFormat

A single line string containing a mix of characters. It is guaranteed that the string contains at least one digit.

outputFormat

Print the longest contiguous substring composed entirely of digits.## sample

abc1234xyz22
1234