For this Question: Chef has a garden of size N x N. The garden is divided into N<sup>2</sup> squares of size 1 x 1 each. Chef has plants in some unit squares of the garden, because of which, that part looks green. Formally, for the i<sup>th</sup> row (0 &le; i < N), Chef has plants in all the columns from A<sub>i</sub>
to B<sub>i</sub> (both inclusive) where 0 &le; A<sub>i</sub> &le; B<sub>i</sub> < N. Help Chef find the length of the side of the largest square that is green.
​The first line contains an integer N, the size of the garden. The next N lines contain two space separated integers A<sub>i</sub> and B<sub>i</sub>, representing that plants are present in all the columns from A<sub>i</sub> to B<sub>i</sub> (both inclusive) of the i<sup>th</sup> row.

<b>Constraints </b>
1 &le; N &le; 10<sup>6</sup>
0 &le; A<sub>i</sub> &le; B<sub>i</sub> < NOutput a single integer denoting the length of the side of the largest square that is green. In other words, output the length of the side of the square with maximum size, inside which all unit squares have plants.Sample Input :
3
1 1
0 2
1 2
Sample Output :
2, I have written this Solution Code: #include<bits/stdc++.h>
namespace {
using namespace std;
// https://github.com/atcoder/ac-library/
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

template <class S, S (*op)(S, S)>
struct DisjointSparseTable {
  const int n;
  const vector<unsigned char> msb;
  const vector<vector<S>> d;
  DisjointSparseTable(vector<S> a) : n(a.size()), msb(build_msb_table(n)), d(build_table(move(a))) {}

  vector<unsigned char> build_msb_table(int n) {
    if (n <= 1) return {};
    unsigned char k_max = 32 - __builtin_clz(n - 1);
    vector<unsigned char> res(1 << k_max);
    unsigned char* p = res.data();
    for (unsigned char k = 0; k < k_max; k++) {
      memset(p + (1U << k), k, 1U << k);
    }
    return res;
  }
  vector<vector<S>> build_table(vector<S> a) {
    const int n = a.size();
    vector<vector<S>> res(1);
    if (n >= 2) {
      const int i_max = n - 1, k_max = 32 - __builtin_clz(i_max);
      res.resize(k_max);
      for (int k = 1; k < k_max; k++) {
        vector<S> t(i_max >> k & 1 ? n : i_max & ~0U << k);
        for (int c = 1 << k; c < n; c += 1 << (k + 1)) {
          int l = c - (1 << k);
          int r = min(n, c + (1 << k));
          t[c - 1] = a[c - 1];
          for (int i = c - 2; i >= l; i--) t[i] = op(a[i], t[i + 1]);
          t[c] = a[c];
          for (int i = c + 1; i < r; i++) t[i] = op(t[i - 1], a[i]);
        }
        res[k] = move(t);
      }
    }
    res[0] = move(a);
    return res;
  }

  S query(int l, int r) { return query_closed(l, r - 1); }
  S query_closed(int l, int r) {
    assert(0 <= l && l <= r && r < n);
    if (l == r) return d[0][l];
    auto k = msb[l ^ r];
    return op(d[k][l], d[k][r]);
  }
};

int op_min(int x, int y) { return min(x, y); }
int op_max(int x, int y) { return max(x, y); }

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  DisjointSparseTable<int, op_max> da(move(a));
  DisjointSparseTable<int, op_min> db(move(b));
  int l = 1, r = n + 1;
  while(r - l > 1) {
    int c = (l + r) / 2;
    bool ok = false;
    rep(i, n - c + 1) {
      int lb = da.query(i, i + c);
      int ub = db.query(i, i + c);
      if (ub - lb + 1 >= c) {
        ok = true;
        break;
      }
    }
    (ok ? l : r) = c;
  }
  cout << l << '\n';
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?