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.
problem code: SUMPOWER

Check this test case:


6 2


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:

Here is the updated code:

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.