#C14026. Bank Account Simulator

    ID: 43630 Type: Default 1000ms 256MiB

Bank Account Simulator

Bank Account Simulator

You are required to simulate a simple bank account that supports three operations: deposit, withdraw, and get_balance. The account starts with an initial balance provided in the input.

Operations are described as follows:

  • deposit X: Increase the balance by X if X is a positive number. Print True if the deposit is successful, otherwise print False.
  • withdraw X: Decrease the balance by X if the current balance is at least X and X is positive. Print True if the withdrawal is successful, otherwise print False.
  • get_balance: Print the current balance.

The operations must be processed sequentially. The output for each operation should be printed on a new line.

Note: You need to use stdin for reading input and stdout for printing output. Use LaTeX format for any formulas if necessary. For example, the condition for a successful withdrawal is: $$0 < X \leq \text{balance}.$$

inputFormat

The input consists of multiple lines.

  • The first line contains an integer representing the initial balance.
  • The second line contains an integer n representing the number of operations.
  • The next n lines each describe an operation. Each operation is either:
    • deposit X
    • withdraw X
    • get_balance

outputFormat

For each operation, print the following:

  • For deposit and withdraw operations, print True if the operation succeeds; otherwise, print False.
  • For get_balance, print the current balance as an integer.
  • Each result should be printed on a new line in the order the operations are provided.
## sample
50
4
deposit 100
get_balance
withdraw 80
get_balance
True

150 True 70

</p>