Sanket And Strings

https://hack.codingblocks.com/contests/c/512/1569
https://ide.codingblocks.com/s/41549
only 1 out of 3 testcases are passing.

Your logic is wrong
It does not work for all cases

eg when input is
2
bababa

Your output is
6

But the correct output should be 5