#P1511. Earliest Occurrence in the Infinite Number Sequence
Earliest Occurrence in the Infinite Number Sequence
Earliest Occurrence in the Infinite Number Sequence
We define an infinite sequence \(S\) as the concatenation of all natural numbers in ascending order: \(\texttt{1234567891011121314\ldots}\). Let \(S_i\) denote the \(i\)-th digit of \(S\) (1-indexed).
You are given a digit sequence \(A\). Your task is to determine the smallest index \(i\) such that the substring of \(S\) starting at \(i\) matches \(A\) exactly.
inputFormat
The input consists of a single line containing the digit sequence \(A\) (a non-empty string of digits).
outputFormat
Output a single integer representing the 1-indexed position in \(S\) where \(A\) first appears.
sample
12
1