Fibonacci string:- code not working though correct

I wrote this code for Fibonacci string problem(code-CLFIBD)

PROGRAM

I tried all the posibilities, but it is still giving SIGSEGV error on codechef. The code is working correctly on my ubuntu. Please help!!!

You have declared char S[50] which is wrong since the length of string can be 1≤|S|≤10^5 as given in the question. Therefore in the test cases where length of string is greater than 50 your code cannot access that memory hence giving SIGSEGV error. Use char S[100001].

Thank you!!! Quite new to codechef so this problem. Will remember it for sure.