SEGMENTATION FAULT

When I am trying to get a string as input from scanf it is running well on my codeblock IDE, but here it is giving me an SIGSEGV error. Please help. My code is here
[http://www.codechef.com/viewsolution/3228391][1]

Increase the size the array you use to store the string to maximum length of string + 1 and make sure no invalid memory location is accessed by your code ex. array of size 10 and you try to access location 11. Also refer to this FAQ.

//