class Solution {
public:
int numberOfPairs(vector<vector<int>>& points) {
int count = 0;
for (int i = 0; i < points.size(); ++i) {
for (int j = 0; j < points.size(); ++j) {
if (i != j) {
int upperLeftX = min(points[i][0], points[j][0]);
int upperLeftY = max(points[i][1], points[j][1]);
int lowerRightX = max(points[i][0], points[j][0]);
int lowerRightY = min(points[i][1], points[j][1]);
bool noOneInside = true;
for (const auto& point : points) {
if (point != points[i] && point != points[j]) {
if (point[0] >= upperLeftX && point[0] <= lowerRightX &&
point[1] <= upperLeftY && point[1] >= lowerRightY) {
noOneInside = false;
break;
}
}
}
if (noOneInside) {
++count;
}
}
}
}
return count;
}
};