#K58907. Find Duplicates

    ID: 30746 Type: Default 1000ms 256MiB

Find Duplicates

Find Duplicates

Given an array of integers, your task is to find all the elements that appear exactly twice in the array. Each duplicate element should be reported only once, in the order in which the duplicate is first detected. In other words, if an element occurs more than once, print it only the first time you identify it as a duplicate.

The input is provided as a single line of space-separated integers, and the output should be the duplicate numbers separated by a single space. If no duplicates are found, output an empty line.

The relation between quantities can be expressed using the formula: \(D = \{ x \in A \mid \text{count}(x, A) = 2 \}\), where \(A\) is the input array.

inputFormat

The input consists of a single line containing a series of space-separated integers. This line may be empty, which represents an empty array.

outputFormat

Output the list of duplicate integers separated by a single space, in the order they are detected. If there are no duplicates, print an empty line.

## sample
4 3 2 7 8 2 3 1
2 3