func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops )   #pragma GCC optimize( no-stack-protector,fast-math )   using namespace std;   const int N = 5e5 + 100, OO = 724249387, T = 4500 + 100, M = 1e9 + 7, P = 6151,             SQ = 280, lg = 30;   map<int, int> mp;   int dp[N], l[N], r[N], t[N], seg[4][N << 2], lazy[4][N << 2];   vector<pair<int, int> > v[N];   void shift(int c, int id) {     seg[id][c << 1] += lazy[id][c];     seg[id][c << 1 | 1] += lazy[id][c];     lazy[id][c << 1] += lazy[id][c];     lazy[id][c << 1 | 1] += lazy[id][c];     lazy[id][c] = 0;   }   void upd(int id, int c, int b, int e, int l, int r, int t) {     if (e <= l || r <= b) return;     if (l <= b && e <= r) {       seg[id][c] += t;       lazy[id][c] += t;       return;     }     int mid = (b + e) >> 1;     shift(c, id);     upd(id, c << 1, b, mid, l, r, t), upd(id, c << 1 | 1, mid, e, l, r, t);     seg[id][c] = max(seg[id][c << 1 | 1], seg[id][c << 1]);   }   int get(int id, int c, int b, int e, int l, int r) {     if (r <= b || e <= l) return 0;     if (l <= b && e <= r) return seg[id][c];     int mid = (b + e) >> 1;     shift(c, id);     return max(get(id, c << 1, b, mid, l, r), get(id, c << 1 | 1, mid, e, l, r));   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     set<int> st;     st.insert(0);     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i] >> t[i];       st.insert(l[i]), st.insert(r[i]);     }     int cnt = 0;     for (auto u : st) mp[u] = cnt++;     for (int i = 0; i < n; i++) {       l[i] = mp[l[i]], r[i] = mp[r[i]];       v[r[i]].push_back({l[i], t[i]});     }     for (int i = 1; i < cnt; i++) {       for (auto u : v[i]) upd(u.second, 1, 0, cnt, 0, u.first, +1);       dp[i] = max(get(1, 1, 0, cnt, 0, i), get(2, 1, 0, cnt, 0, i));       upd(1, 1, 0, cnt, i, i + 1, dp[i]), upd(2, 1, 0, cnt, i, i + 1, dp[i]);     }     cout << dp[cnt - 1] << endl;     return 0;   }   