#K88882. Unique Pair Sum Finder

    ID: 37407 Type: Default 1000ms 256MiB

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

Output: 1 4 2 3

</p>

Example 2:

Input:
3 10
1 2 3

Output: (there is no output because no pair sums up to 10)

</p>

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.

## sample
5 5
1 2 3 4 5
1 4

2 3

</p>