```
class Solution {
public:
int numberOfBoomerangs(vector<pair<int, int>>& points) {
int res=0;
for(int i=0;i<points.size();++i)
{
vector<int>d;
for(int j=0;j<points.size();++j)
d.push_back((points[i].first-points[j].first)*(points[i].first-points[j].first)+(points[i].second-points[j].second)*(points[i].second-points[j].second));
sort(d.begin(),d.end());
int cnt=1;
for(int j=1;j<d.size();++j)
if(d[j]==d[j-1])
cnt++;
else
{
res+=cnt*(cnt-1);
cnt=1;
}
res+=cnt*(cnt-1);
}
return res;
}
};
```