func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int maxnnn = (int)1e6 + 10;   int aaaa[maxnnn];   int bbbb[maxnnn];   int l[maxnnn];   int r[maxnnn];   int nnnnn;   vector<int> gggg[maxnnn];   vector<int> tttt[4 * maxnnn];   int cnttttt;   void build(int v, int tl, int tr) {     if (tl == tr)       tttt[v] = vector<int>(1, aaaa[tl]);     else {       int tm = (tl + tr) / 2;       build(v * 2, tl, tm);       build(v * 2 + 1, tm + 1, tr);       merge(tttt[v * 2].begin(), tttt[v * 2].end(), tttt[v * 2 + 1].begin(),             tttt[v * 2 + 1].end(), back_inserter(tttt[v]));     }   }   void query(int v, int tl, int tr, int l, int r, int x) {     if (l > r) return;     if (l == tl && tr == r) {       int i = (int)tttt[v].size() - 1;       while (i >= 0 && tttt[v][i] > x && cnttttt < nnnnn) {         cnttttt++;         gggg[bbbb[x]].push_back(bbbb[tttt[v][i]]);         gggg[bbbb[tttt[v][i]]].push_back(bbbb[x]);         i--;       }       return;     }     int tm = (tl + tr) / 2;     query(v * 2, tl, tm, l, min(r, tm), x);     query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);   }   int used[maxnnn];   void dfs(int v) {     cnttttt++;     used[v] = 1;     for (int u : gggg[v]) {       if (!used[u]) {         dfs(u);       }     }   }   void solution() {     cin >> nnnnn;     for (int i = 1; i <= nnnnn; i++) {       cin >> l[i] >> r[i];       aaaa[l[i]] = r[i];       aaaa[r[i]] = -1;       bbbb[r[i]] = bbbb[l[i]] = i;     }     build(1, 1, 2 * nnnnn);     for (int i = 1; i <= nnnnn; i++) {       query(1, 1, 2 * nnnnn, l[i], r[i], r[i]);     }     if (cnttttt != nnnnn - 1) {       cout <<  NO  << endl;       return;     }     cnttttt = 0;     dfs(1);     if (cnttttt == nnnnn) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solution();   }   