For all points in array we put squared distances to all other points to a map. Then, for every distance in the map,

we add distance*(distance -1) to result. Note that when i == j, the result is not affected.

```
class Solution {
public:
int numberOfBoomerangs(vector<pair<int, int>>& points) {
int res = 0;
for(int i = 0; i < points.size(); ++i) // all possible boomerang center points
{
unordered_map<int, int> m;
for(int j = 0; j < points.size(); ++j)
{
int dx = points[i].first - points[j].first;
int dy = points[i].second - points[j].second;
++m[dx*dx + dy*dy];
}
for(auto it = m.begin(); it != m.end(); ++it)
res += it->second*(it->second-1);
}
return res;
}
};
```