#C6606. Grain Stock Tracker
Grain Stock Tracker
Grain Stock Tracker
You are given a system to track grain stocks. Initially, you register \( n \) different grain types with their initial stock quantities. Then, \( q \) operations are performed; each operation either updates a grain's stock or queries its current amount. An update operation adds (or subtracts, if the value is negative) a specified amount to the existing stock, whereas a query operation retrieves the current stock for a particular grain.
The update formula is given by:
\( S_{\text{new}} = S + \Delta \)
where \( S \) is the current stock and \( \Delta \) is the update value.
Process all operations in the given order and output the result for each query on a new line.
inputFormat
The input is read from standard input (stdin) and has the following format:
- First line: An integer \( n \) representing the number of grain types.
- Next \( n \) lines: Each line contains a grain name (a string without spaces) and an integer representing its initial stock, separated by a space.
- Next line: An integer \( q \) representing the number of operations.
- Next \( q \) lines: Each line is an operation in one of the following forms:
- Update <grain> <amount>: Update the stock of the specified grain by adding the given amount.
- Query <grain>: Query the current stock of the specified grain.
outputFormat
For each query operation, output the current stock of the specified grain on a new line to standard output (stdout).
## sample5
wheat 100
rice 200
maze 150
barley 80
oats 60
6
Update wheat 50
Query rice
Update barley -30
Query barley
Update oats 20
Query oats
200
50
80
</p>