Problem Help Needed C++

I was solving a problem from beginner section. Please someone guide me. I am facing some issues in ATM problem. I am getting WA even though i optimized it with modulo operation and IO boost.

Link to submission:
https://www.codechef.com/viewsolution/30930941
(HS08TEST)

Please provide some tips for solving such difficult problems.