#K82657. Unique Pairs with Given Sum
Unique Pairs with Given Sum
Unique Pairs with Given Sum
Given a list of integers and a target sum \(T\), your task is to find all unique pairs \((a, b)\) such that \(a + b = T\). Each pair must be represented with the smaller number first (i.e. \(a \le b\)) and each unique pair should appear only once irrespective of its order in the input.
The input is given from standard input. The first line contains two integers: \(n\) (the number of elements in the list) and \(T\) (the target sum). The second line contains \(n\) integers separated by spaces. If no such pair exists, output nothing.
Print each valid pair on a separate line with a space between the two numbers. The pairs should be printed in increasing order, sorted primarily by their first element and then by their second element.
inputFormat
The first line contains two integers \(n\) and \(T\) separated by a space, where \(n\) is the number of elements in the list and \(T\) is the target sum.
The second line contains \(n\) integers separated by spaces representing the list.
outputFormat
For each unique pair \((a, b)\) that satisfies \(a + b = T\) (with \(a \le b\)), output a line containing the two numbers separated by a space.
If no pair exists, do not output anything.
## sample5 6
1 2 3 4 3
2 4
3 3
</p>