#C5808. Unique Pair Finder
Unique Pair Finder
Unique Pair Finder
You are given a list of integers and a target integer \(T\). Your task is to find all unique pairs of integers \((a, b)\) from the list such that \(a + b = T\). Each pair should consist of two numbers at different positions in the array. Note that if a number appears multiple times, it can be paired with itself only if it occurs at least twice. The output pairs must be sorted in increasing order: first by \(a\) and then by \(b\).
Input/Output Specifications:
The input is given via standard input (stdin) and the output should be written to standard output (stdout). The first line contains an integer \(n\), representing the number of elements in the list. The second line contains \(n\) space-separated integers. The third line contains the target integer \(T\). For each valid pair, output a line containing the two numbers separated by a space. If no valid pair exists, output nothing (or an empty output).
Examples:
- Input:
5
1 2 3 4 5
5
Output:
1 4
2 3 - Input:
6
1 -1 2 -2 3 -3
0
Output:
-3 3
-2 2
-1 1
inputFormat
The first line of input contains an integer \(n\) (the number of elements). The second line contains \(n\) space-separated integers. The third line contains the target integer \(T\).
outputFormat
For each unique pair whose sum equals \(T\), output a line with the two integers separated by a space. The pairs must be output in ascending order (first by the first integer, then by the second). If no pair exists, output nothing.
## sample5
1 2 3 4 5
5
1 4
2 3
</p>