I solved the question in O(|N|.log(|N|) time , still i am getting tle .
About my approach :For example if N=123 then Y(N) = 123231312 => Y(N) = (123000000 + 231000 + 312)
Now Y(N) %MOD = [(123%MOD) * pow(10,6)%MOD + …] I calculated modulo of all rotated strings in O(N + NlogN) time [N=length of string <=1e5].
Similarly , Modulo of powers of 10 can also be calculated in log(N) using efficient power function .
So , with this complexity the solution should pass the test cases .
Here is my submission : https://www.codechef.com/viewsolution/22071431
Please help me as I am bewildered and confused as to where did I go wrong.