#K76842. Taco Order Summary

    ID: 34732 Type: Default 1000ms 256MiB

Taco Order Summary

Taco Order Summary

You are given a series of customer orders. Each order consists of a comma-separated list of item entries. Each item entry is provided in the format item_name quantity, where the quantity is a positive integer. Your task is to parse these orders and compute the total quantity for each item across all orders. The final output should list each item in alphabetical order along with its total quantity. Note that orders may contain extra spaces, and empty orders should be handled appropriately.

The problem can be formally described as follows. Given a set of orders, where each order \(O\) is a comma-separated sequence of items \(I_i\) in the form \(\text{item_name} \; \text{quantity}\), compute for each unique item the sum of its quantities over all orders. The output must be sorted in alphabetical order by item name.

inputFormat

The input is read from standard input (stdin) and has the following structure:

  • The first line contains an integer \(n\) representing the number of orders.
  • The following \(n\) lines each contain an order string. Each order string is a comma-separated list of items in the format item_name quantity. An order may be empty or contain extra spaces.

outputFormat

Print the summary of orders to standard output (stdout) as one line per item. Each line should contain the item's name and its total quantity separated by a space. The items must be printed in alphabetical order by their name. If there are no items, produce no output.

## sample
1
apple 4,banana 2,apple 1
apple 5

banana 2

</p>