#C9871. Unique Combination Sum

    ID: 54012 Type: Default 1000ms 256MiB

Unique Combination Sum

Unique Combination Sum

Given a list of n integers and a target sum \(T\), find all unique combinations where the sum of the selected numbers equals \(T\). Each number in the list can be used at most once in a combination. Note that the list may contain duplicate numbers, but each combination must be unique. All numbers in each combination should be output in non-decreasing order. The output should list each valid combination on a new line with the numbers separated by a single space. If there is no valid combination, output Empty.

Example:

Input:
4
2 3 6 7
7

Output: 7

Input: 5 2 5 2 1 2 5

Output: 1 2 2 5

</p>

Note: The input is read from standard input and the output is printed to standard output.

inputFormat

The input consists of three lines:

  • The first line contains a single integer \(n\) (the number of elements in the list).
  • The second line contains \(n\) space-separated integers.
  • The third line contains an integer \(T\), the target sum.

outputFormat

If there is at least one combination, print each unique combination on a separate line with the numbers separated by a single space (each combination must be in non-decreasing order). The combinations themselves should be printed in lexicographical order based on their natural ordering. If no valid combination exists, print the word Empty (without quotes).

## sample
4
2 3 6 7
7
7

</p>