HACKRNDM  Hacking the random number generator
You recently wrote a random number generator code for a web application and now you notice that some cracker has cracked it. It now gives numbers at a difference of some given value k more predominantly. You being a hacker decide to write a code that will take in n numbers as input and a value k and find the total number of pairs of numbers whose absolute difference is equal to k, in order to assist you in your random number generator testing.
NOTE: All values fit in the range of a signed integer, n, k>=1
Input
1st line contains n & k.
2nd line contains n numbers of the set. All the n numbers are assured to be distinct.
(Edited: n <= 10^5)
Output
One integer saying the no of pairs of numbers that have a diff k.
Example
Input: 5 2
1 5 3 4 2 Output: 3
hide comments
suyashky:
20200129 23:24:45
The wrong Solution got AC!


shikhar_may7:
20191019 22:20:19
wtf is with this question... cin, cout , sorted vectors result TLE; scanf, printf sorte array gives AC...!!! 

emtiaz_001:
20190922 15:20:20
very easy . good for beginner 

aryan29:
20190603 18:24:36
using maps will do the job AC in one go 

adarsh313:
20190309 16:11:08
little change in OPCPIZZA and AC 

kushagra_2:
20190110 14:20:38
that's why i love binary search AC in 0.04 sec:) 

pavan_bansal:
20181213 21:15:30
AC in one go!!! 

salman3007:
20181003 15:21:36
observations:


ameyanator:
20180925 12:03:02
C++STL or binary search take your pick! 

prince_jain:
20180726 23:30:15
try to do binary search iteratively, recursive approach will give TLE 
Added by:  vijay 
Date:  20111015 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own Problem 