LearnPy Hub
← Arena
IntermediateRating 1300

Pairs With a Difference

Count the distinct pairs of values (x, y) in the array with y − x = k (k ≥ 0).

Input

n k, then n integers.

Output

A count.

Sample 1

Input
5 2
3 1 4 1 5
Output
2

Sample 2

Input
5 1
1 2 3 4 5
Output
4
solution.py
Output appears here
Pairs With a Difference · Python Arena problem · LearnPy Hub