#C3667. Vending Machine Simulation

    ID: 47119 Type: Default 1000ms 256MiB

Vending Machine Simulation

Vending Machine Simulation

You are to simulate a vending machine that sells four types of items: Soda, Chips, Water, and Candy. Initially, the machine has a stock of 5 for each item. The prices for the items are given by:

\(\text{Soda}: 45, \quad \text{Chips}: 35, \quad \text{Water}: 20, \quad \text{Candy}: 15\)

For each transaction, the machine will receive an item name and an inserted amount. The machine then performs the following checks in order:

  • If the item is out of stock, output Out of stock.
  • If the inserted money is less than the price, output Not enough money.
  • If the purchase is successful, the machine will decrease the stock of that item by 1 and output the change which is the difference between the inserted money and the item price.

Note that the vending machine persists its state across multiple transactions.

inputFormat

The first line of the input contains an integer T representing the number of transactions. Each of the next T lines contains an item name and an integer representing the money inserted, separated by a space.

For example:

3
Soda 50
Candy 10
Water 20

outputFormat

For each transaction, print the result on a new line. The result is either the change (an integer) or one of the messages: Out of stock or Not enough money.

## sample
1
Soda 50
5

</p>