#C9096. Shopping List Manager

    ID: 53151 Type: Default 1000ms 256MiB

Shopping List Manager

Shopping List Manager

You are required to implement a management system for a shopping list. The system processes a series of commands provided via standard input. The commands include adding items, removing items, listing items, and sorting the shopping list.

The commands are as follows:

  • add x: Add item x to the shopping list.
  • remove x: Remove item x from the shopping list. If x is not in the shopping list, print item not found.
  • list: Output all items in the shopping list in their current order. Each item should be printed on a new line.
  • sort: Sort the shopping list in lexicographical order.

All commands must be executed in the order they are provided. When a command generates output, it should be printed immediately (or collected and printed in order) with each output on a new line.

inputFormat

The input consists of multiple lines. The first line contains an integer n representing the number of commands. Each of the next n lines contains a command, which can be one of the following forms:

  • add x
  • remove x
  • list
  • sort

outputFormat

Print the output generated by the commands in the order they are produced. Each output should be printed on a new line. For example, when the command is list, print each item in the shopping list (each on a new line). When a remove command fails to find the item, print item not found on its own line.

## sample
6
add apple
add banana
list
remove orange
add carrot
list
apple

banana item not found apple banana carrot

</p>