Salamo Aleko
This problem is not hard but need some work.Try to display the numbers in the sequence and thier digits and find any relation but you may not able to solve this problem without solving "10427 Naughty Sleepy Boys"

In problem 10706

All what we have to do is to reduce this problem input to
the number of digits in poblem 10427
And then applying its code

To do that we only remove previous digts of it
1 1

1 2
2 3

1 4
2 5
3 (6) largest possible number less than it in end

1 7
2 8
3 (9)
4 10

e.g if given input 9 all what i have to do is to remve it from
the largest possible number less than it [in end-1 of interval]
which is 6 so send to code_10427(9-6)

Let take another example : Look for the sequence 1121231234.. view it as

sorry i do not know how by nost saving
but as u see from my code these two first calls will be running on laa cases for efficeny(as i remember)
my code have good time
so it is ur implementation problem
try to find the function that take large time
and we may speak about it.