This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/5/DSL_5_B"
#include "../../../src/template/template.hpp"
#include "../../../src/data_structure/fenwick_tree_2d.hpp"
int main(void) {
int n;
cin >> n;
FenwickTree2D<int> fw(1001, 1001);
rep(i, 0, n) {
int xl, yl, xr, yr;
cin >> xl >> yl >> xr >> yr;
fw.add(xl, yl, 1);
fw.add(xl, yr, -1);
fw.add(xr, yl, -1);
fw.add(xr, yr, 1);
}
int ans = 0;
rep(i, 0, 1001) {
rep(j, 0, 1001) {
ans = max(ans, fw.sum(0, 0, i, j));
}
}
cout << ans << '\n';
}
#line 1 "verify/aizu_online_judge/dsl/the_maximum_number_of_overlaps_2.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/5/DSL_5_B"
#line 2 "src/template/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
#define rep(i, a, b) for(long long i = (a); i < (b); ++i)
#define rrep(i, a, b) for(long long i = (a); i >= (b); --i)
constexpr long long inf = 4e18;
struct SetupIO {
SetupIO() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(30);
}
} setup_io;
#line 3 "src/data_structure/fenwick_tree_2d.hpp"
template <typename T>
struct FenwickTree2D {
FenwickTree2D(const int H, const int W)
: h(H), w(W), data(H + 1, vector<T>(W + 1, 0)) {}
void add(const int i, const int j, const T& z) {
assert(0 <= i and i < h);
assert(0 <= j and j < w);
for(int x = i + 1; x <= h; x += x & -x) {
for(int y = j + 1; y <= w; y += y & -y) {
data[x - 1][y - 1] += z;
}
}
}
T sum(const int li, const int lj, const int ri, const int rj) const {
assert(0 <= li and li <= ri and ri <= h);
assert(0 <= lj and lj <= rj and rj <= w);
return sum(ri, rj) - sum(li, rj) - sum(ri, lj) + sum(li, lj);
}
T get(const int i, const int j) const {
assert(0 <= i and i < h);
assert(0 <= j and j < w);
return sum(i + 1, j + 1) - sum(i, j + 1) - sum(i + 1, j) + sum(i, j);
}
private:
int h, w;
vector<vector<T>> data;
inline T sum(const int i, const int j) const {
T s = 0;
for(int x = i; x > 0; x -= x & -x) {
for(int y = j; y > 0; y -= y & -y) {
s += data[x - 1][y - 1];
}
}
return s;
}
};
#line 4 "verify/aizu_online_judge/dsl/the_maximum_number_of_overlaps_2.test.cpp"
int main(void) {
int n;
cin >> n;
FenwickTree2D<int> fw(1001, 1001);
rep(i, 0, n) {
int xl, yl, xr, yr;
cin >> xl >> yl >> xr >> yr;
fw.add(xl, yl, 1);
fw.add(xl, yr, -1);
fw.add(xr, yl, -1);
fw.add(xr, yr, 1);
}
int ans = 0;
rep(i, 0, 1001) {
rep(j, 0, 1001) {
ans = max(ans, fw.sum(0, 0, i, j));
}
}
cout << ans << '\n';
}