#C5516. Count Pairs with a Specific Difference

    ID: 49174 Type: Default 1000ms 256MiB

Count Pairs with a Specific Difference

Count Pairs with a Specific Difference

Given an array arr of n integers and an integer k, your task is to count the number of unique pairs \((i, j)\) such that the difference between arr[i] and arr[j] is exactly \(k\). Note that if \(k=0\), the answer is defined to be \(0\), regardless of any repeated elements in the array.

It is guaranteed that the input is provided via standard input (stdin) and the output must be printed to standard output (stdout). Make sure your solution reads input accordingly.

inputFormat

The first line contains two integers \(n\) and \(k\). The next line contains \(n\) space-separated integers representing the elements of the array arr.

All input is provided via stdin.

outputFormat

Print a single integer representing the number of unique pairs with a difference of exactly \(k\). The output should be printed to stdout.

## sample
5 3
1 5 3 4 2
2