Pairs of Non Coinciding Points
Submissions: 487   Accuracy:


  Difficulty: Medium   Marks: 4

In a given cartesian plane, there are N points. We need to find the Number of Pairs of  points(A,B) such that 

  1. Point A and Point B do not coincide. ​
  2. Manhattan Distance and the Euclidean Distance between the points should be equal.

Note : Pair of 2 points(A,B) is considered same as Pair of 2 points(B ,A).
Manhattan Distance = |x2-x1|+|y2-y1|

Euclidean Distance   = ((x2-x1)^2 + (y2-y1)^2)^0.5 where points are (x1,y1) and (x2,y2).


First Line Consist of T - number of test cases. 
For each Test case:-
First Line consist of N , Number of points
Next line contains N pairs contains two integers Xi and Yi  i.e, X coordinate and the Y coordinate of a Point


Print the number of pairs as asked above.


 1<=T <= 50

1<=N <= 2*10 ^ 5

0<=(|Xi|, |Yi| ) <= 10^9


Sample Input : 

1 1
7 5

Sample Output :


** For More Input/Output Examples Use 'Expected Output' option **

Author: jain_rishabh

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.