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 14112KB
stdin
6
5
2 2 3 3 5 5 
stdout
4