#C13477. Find Unique Pairs with Given Sum
Find Unique Pairs with Given Sum
Find Unique Pairs with Given Sum
You are given a list of integers and a target integer. Your task is to find all unique pairs (a, b) from the list such that:
\(a+b=target\)
Each pair must satisfy \(a \le b\) and a number cannot be paired with itself unless it appears more than once in the list. The order of the pairs in the output should be sorted in increasing order based on the first element, and then by the second element.
If no such pairs exist, output nothing.
inputFormat
The input is given in two lines:
- The first line contains two integers \(n\) and \(target\), where \(n\) is the number of elements in the list.
- The second line contains \(n\) space-separated integers representing the list.
outputFormat
For each unique pair \((a, b)\) such that \(a+b=target\) and \(a \le b\), output a line with two space-separated integers \(a\) and \(b\). The pairs must be printed in increasing order (first by \(a\), then by \(b\)). If no such pairs exist, output nothing.
## sample6 6
2 4 3 3 5 7
2 4
3 3
</p>