I have been doing this question for a while now. Even though I have solved the question and my input and outputs are matching. I am getting the same error during run time that I have exceeded the time limit. I looked at the other solutions and simply copied and pasted them in the compiler. These solutions are the ones that have been accepted by Codechef. Even those solutions gave the same error.
Those are all WA, not TLE.
Your most recent solution fails on the following test input:
1 6 000110
Thank you for correcting me.
Solved it, thanks again.