The Rise and Fall of Power (A4) WA

I have been stuck debugging my code for the problem The Rise and the Fall of Power.

Here’s my solution to the problem , Can anybody suggest where might be the problem.

Thanks in Advance!

//