#include #include #include #include #include using namespace std; typedef long long ll; struct Point { ll x, y; bool inSquare; Point* s1; Point* s2; Point* s3; bool operator<(const Point& other) { return y < other.y || (y == other.y && x < other.x); } Point(ll x, ll y) : x(x), y(y), inSquare(false), s1(nullptr) {} /* ll hash() const { return (x + 10000000000ll) * 100000000000ll + y; } */ pair hash() const { return pair(x, y); } }; ll crossProduct(const Point& p1, const Point& p2, const Point& p3) { ll dy1 = p2.y - p1.y; ll dx1 = p2.x - p1.x; ll dy2 = p3.y - p2.y; ll dx2 = p3.x - p2.x; return (dy2 * dy1) - (dx2 * dx1); } int main() { ll n; cin >> n; std::vector points; map, int> pointstable; for(ll i = 0; i < 4*n; i++) { ll x, y; cin >> x >> y; points.push_back(Point(x, y)); //std::cerr << x << " " << y << " " << points.back().hash() << std::endl; } sort(points.begin(), points.end()); for(ll i = 0; i < 4*n; i++) { pointstable[points[i].hash()] = i; } ll result = 0; for(ll i = 0 ; i < 4 * n; i++) { Point& p = points[i]; std::cerr << i << " " << p.x << " " << p.y << " " << p.inSquare << std::endl; if(p.inSquare) continue; for(ll j = i + 1; j < 4*n; j++) { Point& p1 = points[j]; ll dx = p1.x - p.x; ll dy = p1.y - p.y; Point p2s = Point(p1.x - dy, p1.y + dx); Point p3s = Point(p.x - dy, p.y + dx); if(pointstable.count(p2s.hash()) == 0 || pointstable.count(p3s.hash()) == 0) continue; /* std::cerr << "a " << p1.x << " " << p1.y << std::endl; std::cerr << p3s.x << " " << p3s.y << std::endl; std::cerr << points[pointstable[p3s.hash()]].x << " "; std::cerr << points[pointstable[p3s.hash()]].y << std::endl; */ if(p.s1 == nullptr || ( crossProduct(*p.s3, p, p1) >= 0 && crossProduct(p, *p.s1, p1) >= 0 && crossProduct(*p.s1, *p.s2, p1) >= 0 && crossProduct(*p.s2, *p.s3, p1) >= 0 )) { if(p.s1 != nullptr) { p.s1->inSquare = false; p.s2->inSquare = false; p.s3->inSquare = false; } if(p1.inSquare) continue; if(points[pointstable[p2s.hash()]].inSquare) continue; if(points[pointstable[p3s.hash()]].inSquare) continue; p.s1 = &p1; p.s2 = &points[pointstable[p2s.hash()]]; p.s3 = &points[pointstable[p3s.hash()]]; p.s1->inSquare = true; p.s2->inSquare = true; p.s3->inSquare = true; /* std::cerr << "FOUND" << std::endl; std::cerr << "\t" << p.s1->x << " " << p.s1->y << "\n"; std::cerr << "\t" << p.s2->x << " " << p.s2->y << "\n"; std::cerr << "\t" << p.s3->x << " " << p.s3->y << "\n"; */ } } /* std::cerr << "Matched with: \n"; std::cerr << "\t" << p.s1->x << " " << p.s1->y << "\n"; std::cerr << "\t" << p.s2->x << " " << p.s2->y << "\n"; std::cerr << "\t" << p.s3->x << " " << p.s3->y << "\n"; */ result += (p.x - p.s1->x)*(p.x - p.s1->x)+(p.y - p.s1->y)*(p.y - p.s1->y); } cout << result << endl; }