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
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 

jmr99:
20180618 11:33:09
1.no binary search,no 2 pointer,no sorting just map<int,int>


kuchnahiaata:
20180330 22:09:00
sorting + O(n), no binary search, no two pointer


dheeraj161:
20180310 14:48:21
AC IN ONE GO :) very easy


panjiara_01:
20180209 01:13:51
0.04 using binary search :) 
Added by:  vijay 
Date:  20111015 
Time limit:  0.195s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own Problem 