#K57797. Unique Pair Sum

    ID: 30500 Type: Default 1000ms 256MiB

Unique Pair Sum

Unique Pair Sum

Your task is to find the number of unique unordered pairs ( (a,b) ) from a given array of integers such that ( a + b = k ). Each pair is counted only once, meaning ( (a,b) ) is considered the same as ( (b,a) ).

For example, if the array is [1, 2, 3, 4, 3] and ( k = 6 ), the valid unique pairs are ( (2,4) ) and ( (3,3) ), so the output should be 2.

inputFormat

The input consists of two lines:

1. The first line contains two integers ( n ) and ( k ), where ( n ) is the number of elements in the array.

2. The second line contains ( n ) space-separated integers representing the array elements.

outputFormat

Output a single integer, the number of unique unordered pairs ( (a,b) ) such that ( a + b = k ).## sample

5 6
1 2 3 4 3
2