#K88072. Warehouse Inventory Management

    ID: 37227 Type: Default 1000ms 256MiB

Warehouse Inventory Management

Warehouse Inventory Management

You are given a series of operations to manage a warehouse inventory. There are three types of operations:

  • add item quantity – Add the specified quantity to the item. If the item already exists, increase its quantity.
  • update item quantity – Update the quantity of the item to the new quantity, but only if the item currently exists in the inventory.
  • remove item – Remove the item from the inventory if it exists.

The sequence of operations terminates when a line containing only a period (i.e. .) is encountered.

After processing all operations, output the inventory items in lexicographical order (by item name). Each item should be printed in the format item: quantity on a separate line. If the inventory is empty, output nothing.

Note: All quantities and updates are integers. The operation commands follow the format:

\(\text{command item quantity}\)

inputFormat

The input is given from the standard input (stdin) as multiple lines. Each line contains an operation: "add", "update", or "remove" followed by the necessary parameters. The input terminates when a line with a single period (.) is encountered.

outputFormat

Print the remaining inventory items in lexicographical order (sorted by item name). For each item, print a line in the format item: quantity. If no items remain, print nothing.

## sample
add apples 50
add bananas 30
update apples 20
remove bananas
update oranges 15
add grapes 40
.
apples: 20

grapes: 40

</p>