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:

Please provide some tips for solving such difficult problems.