#C5414. Find Unique Pairs with Specific Sum
Find Unique Pairs with Specific Sum
Find Unique Pairs with Specific Sum
You are given a list of integers and a target value \(T\). Your task is to find all unique pairs \((a, b)\) in the list such that \(a+b=T\). Each pair must have the smaller number first, and the collection of pairs should be sorted in increasing order by the first element of each pair. The output should be represented as a Python-style list of tuples.
If no valid pairs exist, output an empty list: []
.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a sequence of space-separated integers representing the list.
- The second line contains a single integer representing the target value \(T\).
outputFormat
Output to standard output (stdout) a Python-style list of tuples. Each tuple contains a unique pair of integers that add up to \(T\) and the pairs are printed in increasing order as described.
## sample4 7 11 -1 4 -6 -5 2 8
3
[(-5, 8), (-1, 4)]