fork download
  1. # your code goes here
  2. n=int(input())
  3. target=int(input())
  4. arr=list(map(int, input().split()))
  5. hashmap={}
  6. ctr=0
  7. for x in arr:
  8. req=target+x
  9. if req in hashmap:
  10. ctr+=hashmap[req]
  11. hashmap[x]=hashmap.get(x, 0)+1
  12. print(ctr)
  13.  
Success #stdin #stdout 0.08s 14088KB
stdin
5
2
10 5 7 3 8
stdout
2