fork download
  1. from collections import defaultdict
  2.  
  3. n = int(input())
  4. points = []
  5. for _ in range(n):
  6. a, b = map(int, input().split())
  7. points.append((a, b))
  8.  
  9. points.sort()
  10. # print(points)
  11.  
  12. res = 0
  13.  
  14. count = defaultdict(int)
  15.  
  16. for i in range(n):
  17. x1, y1 = points[i]
  18. count[x1-y1] += 1
  19.  
  20.  
  21. for k, v in count.items():
  22. if v == 1: continue
  23. if v == 2:
  24. res += 1
  25. else:
  26. n = v-1
  27. res += max(0, (n * (n+1)) // 2)
  28. print(res)
Success #stdin #stdout 0.1s 14156KB
stdin
3
0 0
0 2
2 0

stdout
0