#K88012. Unique Pairs Sum

    ID: 37214 Type: Default 1000ms 256MiB

Unique Pairs Sum

Unique Pairs Sum

Given an array of integers and an integer target, you are to determine the number of unique unordered pairs whose sum equals the target. A pair (a, b) is considered the same as (b, a) and should be counted only once. Note that the array may contain duplicate numbers, but each unique pair is only counted one time. Formally, you need to count the number of pairs ((a, b)) such that (a + b = target) and (a, b) are elements of the array.

Example: For the array [1, 1, 2, 45, 46, 46] and target 47, there are two unique pairs: (1, 46) and (2, 45).

inputFormat

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

outputFormat

Output a single integer representing the number of unique pairs whose sum equals the target. The output should be written to standard output.## sample

6 47
1 1 2 45 46 46
2