#C13142. Unique Pairs Sum
Unique Pairs Sum
Unique Pairs Sum
Given a list of integers and a target sum \(T\), your task is to find all unique pairs of numbers that add up to \(T\). Each pair must be represented as \((a, b)\) where \(a \leq b\). The list of pairs must be sorted in ascending order first by the first element and then by the second element. If no such pairs exist, output an empty list.
Make sure to consider duplicate numbers and negative values appropriately.
inputFormat
The input is read from stdin with the following structure:
- The first line contains an integer \(n\), the number of elements in the list.
- The second line contains \(n\) space-separated integers.
- The third line contains a single integer \(T\), the target sum.
outputFormat
Output to stdout a list of pairs in the following format:
[(a1, b1), (a2, b2), ...]
Each pair is enclosed in parentheses, and the entire list is enclosed in square brackets. The pairs must be sorted in ascending order based on the first element and then the second element.
## sample6
1 2 3 4 5 6
7
[(1, 6), (2, 5), (3, 4)]