#C12734. The Bank Transaction Simulator

    ID: 42194 Type: Default 1000ms 256MiB

The Bank Transaction Simulator

The Bank Transaction Simulator

This problem requires you to simulate a basic bank transaction system. You are given a series of operations that manipulate a bank account's balance. The operations include deposits, withdrawals, and balance checks.

For a deposit operation, add the given amount to the current balance. For a withdraw operation, subtract the given amount from the current balance; however, the balance should never become negative (if a withdrawal would result in a negative balance, set the balance to 0 instead). For a check operation, output the current balance.

The account initially has a balance of 0.

inputFormat

The input begins with an integer n indicating the number of operations. The following n lines each contain an operation in one of the following formats:

  • deposit x where x is a non-negative integer
  • withdraw x where x is a non-negative integer
  • check

outputFormat

For every check operation, output the current balance on a new line in the order the checks occur.

## sample
3
deposit 100
withdraw 50
check
50

</p>