HELP WITH RICH SUBSTRINGS AUG COOK OFF

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

Can anyone please help with my code for rich substrings ? I am unable to identify the test case which my code is failing.

Thank you !