Count substring runtime error SIGSEGV

The code I have written works in the IDE but is showing runtime error SIGSEGV.

CODE DELETED due to ongoing contest

Please help