#C10061. Repeated Product IDs

    ID: 39225 Type: Default 1000ms 256MiB

Repeated Product IDs

Repeated Product IDs

You are given several lines, each containing space-separated integers which represent product IDs. Your task is to find, for each list, all product IDs that appear more than once. In particular, you must output the repeated product IDs in the order in which they become repeated (i.e. when a product ID appears for the second time). Input processing should stop when a line with a single 0 is encountered. If a list has no repeated product IDs, print an empty line.

For example, if the input line is:

23 42 23 56 78 56 23

Then the repeated product IDs are:

23 56

Note that if a product appears more than twice, it should only be output once at the time of its second occurrence.

inputFormat

The input consists of several lines. Each line (except the termination line) contains a list of space-separated integers. The input terminates when a line containing exactly a single 0 is encountered. This line should not be processed.

outputFormat

For each processed input line (before the termination line), output a single line containing the repeated product IDs separated by a single space, in the order of their first repetition. If no product ID is repeated in a line, output an empty line.## sample

23 42 23 56 78 56 23
0
23 56

</p>