#include #include #include #include using namespace std; int main() { int N; cin >> N; vector X(N), Y(N); for (int i = 0; i < N; i++) cin >> X[i] >> Y[i]; vector xord(N), yord(N); iota(xord.begin(), xord.end(), 0); sort(xord.begin(), xord.end(), [&](int a, int b) { return X[a] < X[b]; }); iota(yord.begin(), yord.end(), 0); sort(yord.begin(), yord.end(), [&](int a, int b) { return Y[a] < Y[b]; }); if (X[xord.front()] == X[xord.back()] || Y[yord.front()] == Y[yord.back()]) { cout << 0 << endl; return 0; } int xpt = X[0], ypt = Y[0]; auto calc = [&]() { long long ans = 0; for (int i = 0; i < N; i++) { ans += 1LL * abs(X[i] - xpt) * abs(Y[i] - ypt); } return ans; }; while (true) { { long long sd = 0; for (int i = 0; i < N; i++) sd += abs(Y[i] - ypt); long long cs = 0; for (int i : xord) { cs += abs(Y[i] - ypt); if (cs * 2 >= sd) { if (xpt == X[i]) { cout << calc() << endl; return 0; } else { xpt = X[i]; break; } } } } { long long sd = 0; for (int i = 0; i < N; i++) sd += abs(X[i] - xpt); long long cs = 0; for (int i : yord) { cs += abs(X[i] - xpt); if (cs * 2 >= sd) { if (ypt == Y[i]) { cout << calc() << endl; return 0; } else { ypt = Y[i]; break; } } } } } }