func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   struct S {     int l, r, h;     S() {}     S(int l, int r, int h) : l(l), r(r), h(h) {}   } Ss[100001];   struct E {     int l, r, h, f;     S s;     E() {}     E(int l, int r, int h, S s, int f = 0) : l(l), r(r), h(h), s(s), f(f) {}     bool operator<(const E& p) const { return l < p.l; }     void print() const { printf( l=%d, r=%d, f=%d, h=%d n , l, r, f, h); }   } Es[100001];   int n, T, inf = 1e9;   struct compar {     bool operator()(const S& a, const S& b) const { return a.h < b.h; }   };   struct Solution {     int solve() {       set<E> sweep;       Ss[n] = S(-inf, inf, T);       sweep.insert(E(-inf, inf, 0, S(-inf, inf, 0), 2 * inf));       sweep.insert(E(-inf - 1, -inf - 1, 0, S(-inf - 1, -inf - 1, 0)));       sweep.insert(E(inf + 1, inf + 1, 0, S(inf + 1, inf + 1, 0)));       sort(Ss, Ss + n, compar());       for (int(i) = (0); (i) <= (n); ++(i)) {         auto& s = Ss[i];         auto e = E(s.l, s.r, s.h, s);         std::set<E>::iterator start = sweep.upper_bound(e), end, it, lt, rt;         start--, it = lt = rt = start, lt--, rt++;         while (it->l < e.r) {           if (!(it->h < lt->h && lt->h < e.h && lt->s.r > max(it->s.l, e.l) ||                 it->h < rt->h && rt->h < e.h && rt->s.l < min(it->s.r, e.r))) {             e.f = max(e.f, min(it->f, overlap(*it, e)));           } else if (e.h == T) {           }           it++, rt++, lt++;         }         auto first = *start, last = *lt;         sweep.erase(start, it);         if (first.l < e.l) {           sweep.insert(E(first.l, e.l, first.h, first.s, first.f));         }         if (last.r > e.r) {           sweep.insert(E(e.r, last.r, last.h, last.s, last.f));         }         sweep.insert(e);       }       auto it = sweep.begin();       it++;       return it->f;     }     int overlap(const E& a, E& b) {       return max(0, min(a.r, b.r) - max(a.l, b.l));     }   };   void print(vector<int>& nums) {     for (auto num : nums) cout << num << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> T;     for (int(i) = (0); (i) < (n); ++(i)) cin >> Ss[i].h >> Ss[i].l >> Ss[i].r;     Solution test;     cout << test.solve() << endl;   }   