3
vector<unordered_map<int, int>> x_axis;6
x_axis = vector<unordered_map<int, int>>(1005);9
void add(vector<int> point) {15
int count(vector<int> point) {16
int x = point[0], y = point[1];18
for (auto &it : x_axis[x]) { // For all points lying on x_axis with value20
int y_coord = it.first;21
int countOcc = it.second;23
if (y == y_coord) continue;24
int sideLength = abs(y_coord - y);26
// counting for p3' and p4'27
if (x + sideLength <= 1000) // x_coordinate should be within range [0, 1000]29
int newX = x + sideLength;30
res += x_axis[x][y_coord] * x_axis[newX][y_coord] * x_axis[newX][y];33
// counting for p3'' and p4''34
if (x - sideLength >= 0) // x_coordinate should be within range [0, 1000]36
int newX = x - sideLength;37
res += x_axis[x][y_coord] * x_axis[newX][y_coord] * x_axis[newX][y];