This is my code for the problem THOUSES. The logic is the same as the setter’s solution, but getting RE(SIGSEGV) on tc 3.
https://www.codechef.com/viewsolution/50441364
Thank you. Setter’s solution is also not working without increasing the stack limit.