#C11307. Unique Pair Sum

    ID: 40609 Type: Default 1000ms 256MiB

Unique Pair Sum

Unique Pair Sum

Given an array of n integers and an integer target, your task is to count the number of unique unordered pairs \( (a_i, a_j) \) (with \( i \neq j \)) such that \( a_i + a_j = target \). Each pair should be counted only once regardless of the order of its elements.

Note: A pair \( (a, b) \) is considered the same as \( (b, a) \). For example, if the array is [1, 2, 3, 4, 3] and the target is 6, there are two unique pairs: \( (2,4) \) and \( (3,3) \).

inputFormat

The input is read from stdin and contains three lines:

  • The first line is an integer n, representing the number of elements in the array.
  • The second line contains n space-separated integers.
  • The third line is an integer target, representing the target sum.

outputFormat

Output a single integer to stdout, which is the count of unique pairs in the array whose sum equals the target.

## sample
5
1 2 3 4 3
6
2