#C10137. Count Unique Pairs

    ID: 39309 Type: Default 1000ms 256MiB

Count Unique Pairs

Count Unique Pairs

You are given an array of integers and a target integer \( T \). Your task is to count the number of unique pairs \( (a, b) \) from the array such that \( a + b = T \). Each pair is considered unique regardless of the order of the two numbers. For example, the pair \( (a, b) \) is considered the same as \( (b, a) \). Note that the array can contain duplicate numbers, but each unique pair should only be counted once.

Example:

Input:  array = [1, 2, 3, 4, 5], T = 6
Output: 2

Explanation: The valid unique pairs are (1, 5) and (2, 4).

</p>

The problem requires you to use standard input (stdin) for input and output the result to standard output (stdout).

inputFormat

The input is given via standard input (stdin) and has the following format:

  1. The first line contains an integer \( n \), representing the number of elements in the array.
  2. The second line contains \( n \) space-separated integers representing the array elements.
  3. The third line contains an integer \( T \), the target sum.

outputFormat

Output a single integer representing the number of unique pairs in the array that sum up to the target \( T \). The output should be written to standard output (stdout).

## sample
5
1 2 3 4 5
6
2