Summary Power : What's wrong with my code?

I am getting an error as wrong answer but it’s working fine on ide
I request you to please help me in correcting my code… I am really thankful to you.
my_code: CodeChef: Practical coding for everyone
problem code: SUMPOWER

Hey,
Check this test case:

1

6 2

abcabc

Your Code Output: 2

Correct Output: 8

Yes, there was one mistake, but i have removed that bug. And still, its showing wrong answer but working fine on ide! please help…
updated code: CodeChef: Practical coding for everyone

Here is the updated code: CodeChef: Practical coding for everyone

I didn’t get into your code its very complicated to understand without a single comment or any hint what your program is doing but one thing is very clear that you are using 20 size array to read string which can be as long as 100000 characters.