#K45052. Count Unique Pairs

    ID: 27667 Type: Default 1000ms 256MiB

Count Unique Pairs

Count Unique Pairs

Given a list of n integers and an integer target, count the number of unique pairs of elements that sum up to target. A pair is considered unique if the set of two numbers has not been counted before, regardless of their order. In other words, if \(a + b = target\), then the pair \((a, b)\) is the same as \((b, a)\) and should be counted only once.

Note: Each test case will be provided via standard input and the answer must be printed to standard output.

inputFormat

The input consists of three lines:

  • 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 an integer target, which is the target sum for the pairs.

outputFormat

Output a single integer which is the number of unique pairs in the list that sum up to target.

## sample
5
1 2 3 4 5
5
2