#K4846. Unique Pairs with Given Sum

    ID: 28425 Type: Default 1000ms 256MiB

Unique Pairs with Given Sum

Unique Pairs with Given Sum

You are given an array of integers and a target integer \(T\). Your task is to determine the number of unique pairs in the array whose sum is exactly \(T\).

A pair \((a, b)\) is considered the same as \((b, a)\) and should be counted only once. Note that each element of the array can be used in forming a pair only once per occurrence.

Example:

Input: [1, 5, 7, -1, 5], T = 6
Output: 2

Explanation: The two unique pairs that sum to 6 are (1, 5) and (7, -1).

</p>

inputFormat

The input is read from stdin and consists of two lines:

  1. The first line contains two integers \(n\) and \(T\), where \(n\) is the number of elements in the array and \(T\) is the target sum.
  2. The second line contains \(n\) space-separated integers representing the array elements.

It is guaranteed that \(n \geq 1\).

outputFormat

Output to stdout a single integer: the number of unique pairs whose sum equals \(T\).

## sample
5 6
1 5 7 -1 5
2