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
kailash:
20150217 13:47:57
O(n) > TLE O(nlogn)> AC


Rahul Jain:
20150202 17:48:57
what is the range of the elements. I am using 32768 to 32767, but that gives me wrong answer 

MKM:
20150114 17:32:34
Pretty easy! 

eightnoteight:
20150109 08:33:01
why! why! why! why am i getting wrong answer for the same algo in python but getting accepted in C++


swordfish12:
20141225 17:32:31
misleading problem name :( ... very simple problem 

mayank:
20141125 06:29:17
Simple :) 

deCodeIt:
20141007 07:29:51
Segmentation fault at running (2).. =="


ivar.raknahs:
20141006 13:43:03
this ques really annoyed me .


fanatique:
20140820 07:25:13
my 100th :) but i am crawling :( 

shiva:
20140813 15:05:16
TLE nlogn :( 
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 