#K58882. Find Unique Pairs with Given Sum

    ID: 30741 Type: Default 1000ms 256MiB

Find Unique Pairs with Given Sum

Find Unique Pairs with Given 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
  • a < b (to ensure uniqueness)

If there are no such pairs, output the message No pairs found.

The output should list each pair on a new line in the format (a, b) sorted in ascending order, where sorting is based on the first element and then the second element if necessary.

Note: Your program should take input from stdin and write output to stdout.

inputFormat

The first line contains an integer n denoting the number of elements in the array.

The second line contains n space-separated integers — the elements of the array.

The third line contains an integer representing the target sum.

outputFormat

If at least one pair is found, print each pair on a separate line in the format (a, b) where a < b. The pairs must be printed in ascending order based on the first element (and second element if necessary).

If no such pair exists, print No pairs found.

## sample
6
1 5 7 -1 5 3
6
(-1, 7)

(1, 5)

</p>