Getting wrong answer, need help

problem : https://www.spoj.com/problems/ADAHACK/

code : https://ide.codingblocks.com/s/295534