Chef and interesting subsequences

https://www.codechef.com/viewsolution/26613646

This is my solution of september long challenge ,it is failing one test case and also giving SIGEMT error during compilation.
Don’t know the reason behind it.

PLEASE HELP ME !