#K88882. Unique Pair Sum Finder
Unique Pair Sum Finder
Unique Pair Sum Finder
Given a list of integers and a target sum \(S\), your task is to find all unique pairs \((a, b)\) such that \(a + b = S\) and \(a \leq b\). Each pair must be unique even if the input contains duplicate numbers. The output pairs should be sorted in ascending order, primarily by the first element and then by the second element.
Example 1:
Input: 5 5 1 2 3 4 5</p>Output: 1 4 2 3
Example 2:
Input: 3 10 1 2 3</p>Output: (there is no output because no pair sums up to 10)
Note: All mathematical formulas are expressed in \( \LaTeX \) where appropriate.
inputFormat
The input is given via standard input (stdin). The first line contains two integers \(n\) and \(S\), where \(n\) is the number of elements in the list and \(S\) is the target sum. The second line contains \(n\) space‐separated integers representing the list of numbers.
outputFormat
Output each unique pair \((a, b)\) (with \(a \leq b\)) on a new line, separated by a space, in ascending order. If there are no such pairs, output nothing.
## sample5 5
1 2 3 4 5
1 4
2 3
</p>