#K38092. Inventory Management System

    ID: 26121 Type: Default 1000ms 256MiB

Inventory Management System

Inventory Management System

You are required to design an inventory management system. The system processes a series of commands to manage a stock of products. Each command can be one of the following:

  • add product_id quantity: Increase the inventory of the product identified by product_id by quantity.
  • remove product_id quantity: Decrease the inventory of the product identified by product_id by quantity. However, the inventory should not drop below zero. In other words, the new inventory is computed as \( \max(0, \text{current_inventory} - \text{quantity} ) \).
  • get product_id: Output the current quantity for the product identified by product_id.

The commands are processed in order. Only the outputs from the "get" commands should be printed.

inputFormat

The first line of the input contains an integer n representing the number of commands. The following n lines each contain a command, which is one of the following formats:

  • add product_id quantity
  • remove product_id quantity
  • get product_id

outputFormat

For each "get" command in the order they appear, output the corresponding product quantity on a new line.

## sample
6
add 101 50
add 102 20
remove 101 10
get 101
remove 102 30
get 102
40

0

</p>