#K74582. Inventory Management System

    ID: 34229 Type: Default 1000ms 256MiB

Inventory Management System

Inventory Management System

You are in charge of managing the inventory of a warehouse. The system receives a series of operations that modify or query the stock levels of different items. There are three types of operations:

  • Add x y: Increase the count of item with identifier \(x\) by \(y\) units.
  • Remove x y: Decrease the count of item with identifier \(x\) by \(y\) units, ensuring the stock does not go below zero.
  • Check x: Output the current stock level of item with identifier \(x\). If the item has not been added before, its stock is considered to be 0.

The operations are processed in the order given. Your task is to process these operations and print the results for all \(Check\) operations.

Input Format: The input is provided via standard input (stdin). The first line contains an integer \(T\) (the number of operations). Each of the following \(T\) lines contains one operation.

Output Format: For each \(Check\) operation, output the stock level on a separate line to standard output (stdout).

inputFormat

The first line of the input contains an integer \(T\), the number of operations. Each of the following \(T\) lines contains a command in one of the following formats:

  • Add x y: where \(x\) is the identifier of the item and \(y\) is the number of units to add.
  • Remove x y: where \(x\) is the identifier and \(y\) is the number of units to remove (the stock cannot go below 0).
  • Check x: where \(x\) is the identifier of the item whose current stock level should be printed.

outputFormat

For each Check operation in the input, output a single integer on a new line representing the current stock level of the specified item.

## sample
5
Add 1 10
Check 1
Remove 1 5
Check 1
Check 2
10

5 0

</p>