1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <math.h>
#include <chrono>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("-O3")
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10) //cin.tie(0); cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define what(x) cerr << #x << " is " << x << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; // find_by_order(x) <-returns x-th element   order_of_key(x) <- returns order of element x
mt19937_64 gen(time(NULL));
uniform_int_distribution<long long> distr(0, (1ll << 61));
auto my_rand = bind(distr, gen); // my_rand() zwraca teraz liczbe z przedzialu [a, b]
#define int long long
#define ll long long

const int MAXP = 6e5;
const int ile = 2;

const ll MOD[] = {1000000000000000003ll, 1000000000000000009ll, 200000000000000003ll, 1000000000000000003ll, 1000000000000000009ll, 200000000000000003ll};
const ll BASE[] = {2, 2, 2, 3, 3, 3};
ll pot[ile][MAXP + 10];

bitset<MAXP> B;
vector<pii> V;
int val = 0;
int x, y;

void change(int x, int ind)
{
    //cerr << x << " " << ind << " " << B[x] << " " << pot[ind][x] << endl;
    val ^= pot[ind][x];
    B[x] = (B[x]) ? false : true;
}

void debug(vector<pii> &A)
{
    cerr << "wtf" << endl;
    for (auto P : A)
        cerr << " (" << P.st << " " << P.nd << "), ";
    cerr << endl;
}

int get(vector<pii> &A, int ind)
{
    // debug(A);
    rep(i, A.size())
    {
        if (i != 0)
            V.push_back({val, A[i].st - A[i - 1].st});
        change(A[i].nd, ind);
        // cerr << "wartosc: " << val << endl;
    }
    sort(all(V));
    // debug(V);
    int maks = 0;
    int ile = V[0].nd;
    for (int i = 1; i < V.size(); i++)
    {
        if (V[i].st == V[i - 1].st)
            ile += V[i].nd;
        else
        {
            maks = max(maks, ile);
            ile = V[i].nd;
        }
    }
    maks = max(maks, ile);
    return maks;
}

int solve(vector<pii> &A)
{
    sort(all(A));
    int mini = 2e9;
    rep(i, ile)
    {
        V.clear();
        B.reset();
        val = 0;
        int a = get(A, i);
        what(a);
        mini = min(mini, a);
    }
    return mini;
}
void pre()
{
    rep(i, ile)
    {
        pot[i][0] = 1;
        rep(j, MAXP)
            pot[i][j + 1] = my_rand();
    }
    int n;
    cin >> n >> x >> y;

    vector<pii> A(2 * n);
    vector<pii> B(2 * n);
    rep(i, 2 * n)
    {
        int a, b;
        cin >> a >> b;
        A[i] = {a, i / 2};
        B[i] = {b, i / 2};
    }
    A.push_back({0, n + 2});
    B.push_back({0, n + 2});
    A.push_back({x, n + 2});
    B.push_back({y, n + 2});

    int a = solve(A);
    int b = solve(B);
    cerr << a << " " << b << endl;
    cout << a * b << endl;
}

main()
{
    _upgrade;
    pre();
}