#C8809. Find Pairs with Target Sum

    ID: 52832 Type: Default 1000ms 256MiB

Find Pairs with Target Sum

Find Pairs with Target Sum

You are given a list of integers and a target integer. Your task is to find all unique pairs of numbers in the array that sum to the target value.

A pair is considered unique if no duplicate numbers are used to form another valid pair. Print each pair in ascending order (i.e., the smaller number first) and ensure that each valid pair is printed only once.

Note: Use \( \LaTeX \) for any formulas if needed. For example, a correct pair \((a, b)\) should satisfy \(a + b = target\) with \(a < b\).

inputFormat

The first line contains an integer \(n\), the number of elements in the list.

The second line contains \(n\) space-separated integers representing the list.

The third line contains a single integer representing the target sum.

outputFormat

Output each unique pair of integers that sum to the target. Each pair should be printed on a new line, with the two integers separated by a single space. If there are multiple valid pairs, output them in ascending order based on the first number, then by the second number. If no valid pair exists, output nothing.

## sample
6
-1 0 1 2 -1 -4
0
-1 1