#C14997. Find Unique Pairs with Target Sum

    ID: 44707 Type: Default 1000ms 256MiB

Find Unique Pairs with Target Sum

Find Unique Pairs with Target Sum

You are given a list of integers and a target integer. Your task is to find all unique pairs (a, b) such that a + b = target. Each pair must be formatted so that the smaller number comes first, i.e. \(a \leq b\). The pairs should be output in ascending order, first by the first element and then by the second element.

If no valid pairs exist, output None.

Note: Each input is provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The input consists of three lines:

  • The first line contains a single integer \(n\), the number of elements in the list.
  • The second line contains \(n\) space-separated integers representing the list elements.
  • The third line contains a single integer, the target sum.

outputFormat

If there is at least one valid pair, output each unique pair on a separate line with the two numbers separated by a space. The pairs must be sorted in ascending order (first by the first element, then by the second). If no pair exists that sums to the target, output a single line with the text None.

## sample
5
10 15 3 7 3
10
3 7

</p>