malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   template <class T, class U>   using Pa = pair<T, U>;   template <class T>   using vec = vector<T>;   template <class T>   using vvec = vector<vec<T>>;   template <typename Monoid, typename F>   class SegmentTree {    private:     int sz;     vector<Monoid> seg;     const F op;     const Monoid e;       public:     SegmentTree(int n, const F op, const Monoid &e) : op(op), e(e) {       sz = 1;       while (sz <= n) sz <<= 1;       seg.assign(2 * sz, e);     }     void set(int k, const Monoid &x) { seg[k + sz] = x; }     void build() {       for (int i = sz - 1; i > 0; i--) {         seg[i] = op(seg[2 * i], seg[2 * i + 1]);       }     }     void update(int k, const Monoid &x) {       k += sz;       seg[k] += x;       while (k >>= 1) {         seg[k] = op(seg[2 * k], seg[2 * k + 1]);       }     }     Monoid query(int l, int r) {       Monoid L = e, R = e;       for (l += sz, r += sz; l < r; l >>= 1, r >>= 1) {         if (l & 1) L = op(L, seg[l++]);         if (r & 1) R = op(seg[--r], R);       }       return op(L, R);     }     Monoid operator[](const int &k) const { return seg[k + sz]; }   };   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int N, M;     cin >> N >> M;     vvec<char> F(N, vec<char>(M));     vec<int> len(N + M);     for (int i = 0; i < N; i++)       for (int j = 0; j < M; j++) {         cin >> F[i][j];         len[i + j]++;       }     vvec<int> L(N, vec<int>(M, 0));     vvec<int> R = L, D = L;     for (int i = N - 1; i >= 0; i--) {       for (int j = 0; j < M; j++) {         int c = (F[i][j] ==  z );         if (!c) {           L[i][j] = 0;           D[i][j] = 0;         } else {           L[i][j] = 1 + (j != 0 ? L[i][j - 1] : 0);           D[i][j] = 1 + ((j != 0 && i != N - 1) ? D[i + 1][j - 1] : 0);         }       }       for (int j = M - 1; j >= 0; j--) {         int c = (F[i][j] ==  z );         if (!c)           R[i][j] = 0;         else           R[i][j] = 1 + (j != M - 1 ? R[i][j + 1] : 0);       }     }     auto op = [](ll a, ll b) { return a + b; };     vec<SegmentTree<ll, decltype(op)>> segs;     for (int l = 0; l < N + M - 1; l++) {       SegmentTree<ll, decltype(op)> seg(M, op, 0);       segs.push_back(seg);     }     ll ans = 0;     for (int j = M - 1; j >= 0; j--) {       for (int i = 0; i < N; i++) {         int y = j;         while (y >= 0 && y + R[i][y] - 1 == j) {           segs[i + y].update(y, 1);           y--;         }       }       for (int i = 0; i < N; i++) {         int a = min(L[i][j], D[i][j]);         ans += segs[i + j].query(j - a + 1, j + 1);       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, a, b, i = 0, arr[100000], j = 0;     cin >> n >> k;     for (int x = 0; x < n; x++) {       cin >> a >> b;       i++;       while (a != b)         if (a < b)           a++, i++;         else           a--, i++;     }     while (i % k != 0) {       i++;       j++;     }     cout << j;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, top, len[100005], F1[1005][1005], F2[1005][1005];   pair<int, int> F[30];   char ans[30], dir[100005], a[1005][1005];   bool outside(int first, int second) {     return (first < 1 || first > n || second < 1 || second > m);   }   int tinh1(int first, int y1, int y2) {     if (y1 > y2) swap(y1, y2);     return F1[first][y2] - F1[first][y1 - 1];   }   int tinh2(int second, int x1, int x2) {     if (x1 > x2) swap(x1, x2);     return F2[x2][second] - F2[x1 - 1][second];   }   void tinh(int first, int second, int i, int& x2, int& y2) {     int dx = 0, dy = 0;     if (dir[i] ==  N )       dx = -1;     else if (dir[i] ==  S )       dx = 1;     else if (dir[i] ==  W )       dy = -1;     else if (dir[i] ==  E )       dy = 1;     x2 = first + dx * len[i], y2 = second + dy * len[i];   }   int main() {     scanf( %d%d n , &n, &m);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         scanf( %c , &a[i][j]);         if (a[i][j] >=  A  && a[i][j] <=  Z ) {           F[a[i][j]] = pair<int, int>(i, j);           a[i][j] =  . ;         }       }       scanf(  n );     }     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         F1[i][j] = F1[i][j - 1] + (a[i][j] ==  # );         F2[i][j] = F2[i - 1][j] + (a[i][j] ==  # );       }     int k;     scanf( %d n , &k);     for (int i = 1; i <= k; ++i) scanf( %c %d n , &dir[i], &len[i]);     for (char t =  A ; t <=  Z ; ++t)       if (F[t].first != 0) {         int first = F[t].first, second = F[t].second;         bool b = true;         for (int i = 1; i <= k; ++i) {           int x2, y2;           tinh(first, second, i, x2, y2);           if (outside(x2, y2) || (x2 == first && tinh1(first, second, y2) != 0) ||               (y2 == second && tinh2(second, first, x2) != 0)) {             b = false;             break;           }           first = x2, second = y2;         }         if (b) ans[++top] = t;       }     if (!top)       cout <<  no solution  << endl;     else {       for (int i = 1; i <= top; ++i) printf( %c , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t;   int n;   int a[5001];   bool coutNO;   vector<int> check[5001];   int main() {     cin.tie(0);     cout.tie(0);     cin >> t;     for (int ct = 1; ct <= t; ct++) {       cin >> n;       coutNO = true;       for (int i = 1; i <= n; i++) check[i].clear();       for (int i = 1; i <= n; i++) {         cin >> a[i];         check[a[i]].push_back(i);         if (check[a[i]].size() >= 3) coutNO = false;       }       if (!coutNO) {         cout <<  YES  <<   n ;         continue;       }       for (int i = 1; i <= n; i++)         if (check[i].size() == 2) {           if (check[i][0] + 1 != check[i][1]) {             coutNO = false;             break;           }         }       if (coutNO)         cout <<  NO  <<   n ;       else         cout <<  YES  <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int const lac = 100000;   long long int modmul(long long int a, long long int b) {     return ((a % 1000000007) * (b % 1000000007)) % 1000000007;   }   long long int modadd(long long int a, long long int b) {     return (((a % 1000000007) + (b % 1000000007))) % 1000000007;   }   long long int gcd(long long int a, long long int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   class comp {    public:     bool operator()(int a, int b) const { return a > b; }   };   bool compa(int a, int b) { return a > b; }   void solve(long long int t1) {     long long int n;     cin >> n;     vector<long long int> arr(n + 1);     for (long long int i = 1; i <= n; i++) {       cin >> arr[i];     }     vector<long long int> prefix(n + 1, 0);     long long int ans = 0;     for (long long int i = 1; i <= n; i++) {       prefix[i] = prefix[i - 1] ^ i;       ans ^= arr[i];     }     if (n == 1) {       cout << ans <<   n ;       return;     }     for (long long int i = 1; i <= n - 1; i++) {       long long int temp = (n) / (i + 1);       long long int rem = n % i;       if (temp & 1) {         ans ^= prefix[i];       }       ans ^= prefix[rem];     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     t = 1;     for (long long int i = 1; i <= t; i++) {       solve(t);     }     cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   pair<double, double> p[301];   double a, b, c, den, len;   double area(int i) {     double num = abs(a * p[i].first + b * p[i].second + c);     return (num) / (2.0);   }   double f(int i, int j) {     a = (p[j].second - p[i].second);     b = (p[i].first - p[j].first);     c = 0 - p[i].second * b - p[i].first * a;     den = sqrtf(a * a + b * b);     len = sqrtf((p[i].first - p[j].first) * (p[i].first - p[j].first) +                 (p[i].second - p[j].second) * (p[i].second - p[j].second));     double m1 = -1, m2 = -1;     for (int k = 0; k < n; ++k) {       if (k == i or k == j) continue;       long long temp = a * p[k].first + b * p[k].second + c;       double flag = area(k);       if (temp >= 0)         m1 = max(m1, flag);       else         m2 = max(m2, flag);     }     if (m1 == -1 or m2 == -1) return 0;     return m1 + m2;   }   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       double x, y;       scanf( %lf%lf , &x, &y);       p[i] = {x, y};     }     double ans = 0;     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j < n; ++j) {         ans = max(ans, f(i, j));       }     }     printf( %0.10f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, s;   vector<long long> v(1001);   long long check(long long x) {     long long sum = 0;     for (long long i = 0; i < n; i++) {       if (v[i] < x) return 0;       sum += max((long long)0, v[i] - x);     }     return (sum >= s);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> s;     for (long long i = 0; i < n; i++) cin >> v[i];     long long l = 0;     long long r = 1e15;     while (l < r) {       long long mid = (l + r + 1) / 2;       if (check(mid))         l = mid;       else         r = mid - 1;     }     if (check(l))       cout << l;     else       cout << -1;   }
#include <bits/stdc++.h>   long long n, m, a, d, t[100007], old, ans, aind, firstA, stepD;   int main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     std::cout.tie(0);     std::cin >> n >> m >> a >> d;     for (int i = 0; i < m; ++i) std::cin >> t[i];     aind = d / a * a + a;     for (int i = 0; i < m; ++i) {       if (t[i] <= old) continue;       if (t[i] <= n * a) {         firstA = (old / a + 1) * a;         if (t[i] <= firstA) {           ++ans;           old = t[i] + d;         } else {           stepD = (t[i] - firstA) / aind + ((t[i] - firstA) % aind ? 1 : 0);           ans += stepD;           old = firstA + stepD * aind - (a - d % a);           if (old < t[i]) {             ++ans;             firstA = (old / a + 1) * a;             old = std::min(t[i], firstA) + d;           }         }       } else {         if (old < n * a) {           firstA = (old / a + 1) * a;           stepD = (n * a - firstA) / aind + ((n * a - firstA) % aind ? 1 : 0);           ans += stepD;           old = firstA + stepD * aind - (a - d % a);           if (old < n * a) {             ++ans;             firstA = (old / a + 1) * a;             old = firstA + d;           }         }         if (old < t[i]) {           ++ans;           old = t[i] + d;         }       }     }     if (old < a * n) {       firstA = (old / a + 1) * a;       stepD = (a * n - firstA) / aind + ((a * n - firstA) % aind ? 1 : 0);       ans += stepD;       old = firstA + stepD * aind - (a - d % a);       if (old < a * n) {         ++ans;       }     }     std::cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int inf = 50000000;   const int maxn = 2010;   int n, A[maxn][maxn], vis[maxn];   int bfs(int src, int d) {     queue<int> q;     q.push(src);     for (int i = 1; i <= n; i++) vis[i] = 0;     vis[src] = 1;     int ret = 1;     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = 1; i <= n; i++) {         if (!d && !vis[i] && A[u][i] > 0) {           vis[i] = 1;           ret += 1;           q.push(i);         }         if (d && !vis[i] && A[i][u] > 0) {           vis[i] = 1;           ret += 1;           q.push(i);         }       }     }     return ret;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         scanf( %d , &A[i][j]);       }     }     if (bfs(1, 0) == n && bfs(1, 1) == n)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 205;   char str[20][N];   int n, m, des;   int dp[20][2];   int call(int flr, int side) {     if (flr == des) {       if (side == 0) {         int p = 0;         for (int i = 1; i <= m; i++)           if (str[flr][i] ==  1 ) p = i;         return p;       } else {         int p = m + 1;         for (int i = m; i >= 1; i--)           if (str[flr][i] ==  1 ) p = i;         return m + 1 - p;       }     }     if (dp[flr][side] != -1) return dp[flr][side];     int ret = 1e9;     if (side == 0) {       ret = min(ret, m + 2 + call(flr - 1, 1));       int p = 0;       for (int i = 1; i <= m; i++)         if (str[flr][i] ==  1 ) p = i;       ret = min(ret, 2 * p + 1 + call(flr - 1, 0));     } else {       ret = min(ret, m + 2 + call(flr - 1, 0));       int p = m + 1;       for (int i = m; i >= 1; i--)         if (str[flr][i] ==  1 ) p = i;       ret = min(ret, (m + 1 - p) * 2 + 1 + call(flr - 1, 1));     }     return dp[flr][side] = ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     memset(dp, -1, sizeof(dp));     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> str[i];     des = n - 1;     for (int i = n - 1; i >= 0; i--) {       for (int j = 1; j <= m; j++)         if (str[i][j] ==  1 ) des = i;     }     cout << call(n - 1, 0) <<   n ;   }
#include <bits/stdc++.h>   char s[5][110], ss[5][5];   int main() {     int t, n, i, j;     scanf( %d , &n);     memset(s, 0x00, sizeof(s));     if (n == 1) {       s[0][0] =  a ;       s[1][0] =  a ;       s[2][0] =  b ;       s[3][0] =  b ;     } else if (n & 1) {       s[2][0] =  f ;       s[3][0] =  f ;       s[0][n - 1] =  c ;       s[1][n - 1] =  c ;       for (i = 0; i < n - 1; i += 2) {         int tp = i / 2;         s[0][i] =  a  + (tp & 1);         s[0][i + 1] =  a  + (tp & 1);         s[1][i] =  d  + (tp & 1);         s[1][i + 1] =  d  + (tp & 1);         s[2][i + 1] =  g  + (tp & 1);         s[2][i + 2] =  g  + (tp & 1);         s[3][i + 1] =  i  + (tp & 1);         s[3][i + 2] =  i  + (tp & 1);       }     } else {       s[2][0] =  e ;       s[3][0] =  e ;       s[2][n - 1] =  f ;       s[3][n - 1] =  f ;       for (i = 0; i < n - 1; i += 2) {         int tp = i / 2;         s[0][i] =  a  + (tp & 1);         s[0][i + 1] =  a  + (tp & 1);         s[1][i] =  c  + (tp & 1);         s[1][i + 1] =  c  + (tp & 1);       }       for (i = 1; i < n - 1; i += 2) {         int tp = i / 2;         s[2][i] =  g  + (tp & 1);         s[2][i + 1] =  g  + (tp & 1);         s[3][i] =  i  + (tp & 1);         s[3][i + 1] =  i  + (tp & 1);       }     }     for (i = 0; i < 4; ++i) puts(s[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, x, y, sum, ans, T;   char c;   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d , &n);       vector<int> v, b;       for (int i = 1; i <= n; i += 2) {         if (i + 1 > n) {           v.push_back(i);           b.push_back(i);         } else {           printf( ? %d %d n , i, i + 1);           fflush(stdout);           scanf(  %c , &c);           if (c ==  < )             v.push_back(i + 1), b.push_back(i);           else if (c ==  > )             v.push_back(i), b.push_back(i + 1);           else             v.push_back(i), b.push_back(i);         }       }       while (v.size() > 1) {         x = v[v.size() - 1];         v.pop_back();         y = v[v.size() - 1];         v.pop_back();         printf( ? %d %d n , x, y);         fflush(stdout);         scanf(  %c , &c);         if (c ==  < )           v.push_back(y);         else if (c ==  > )           v.push_back(x);         else           v.push_back(x);       }       while (b.size() > 1) {         x = b[b.size() - 1];         b.pop_back();         y = b[b.size() - 1];         b.pop_back();         printf( ? %d %d n , x, y);         fflush(stdout);         scanf(  %c , &c);         if (c ==  < )           b.push_back(x);         else if (c ==  > )           b.push_back(y);         else           b.push_back(x);       }       printf( ! %d %d n , b[0], v[0]);       fflush(stdout);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   vector<int> v;   set<double> S;   set<double>::iterator it, it2;   int main() {     int n, k;     cin >> n >> k;     cin >> s;     for (int i = 0; i < s.size(); i++)       if (s[i] ==  0 ) v.push_back(i + 1);     int i = 0, j = 0;     for (i = 0; i <= k; i++) S.insert(v[i]);     j = i - 1;     i = 0;     int mn = INT_MAX;     n = v.size();     while (j < n) {       double x = (v[i] + v[j]) / 2.0;       it = S.lower_bound(x);       it2 = it;       it2--;       int a = max(v[j] - *it, *it - v[i]);       int b = max(*it2 - v[i], v[j] - *it2);       mn = min(mn, min(a, b));       j++;       if (j < n) {         S.erase(v[i]);         S.insert(v[j]);         i++;       }     }     cout << mn;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int firstOne(string s) {     int len = s.length();     for (int i = len - 1; i >= 0; i--) {       if (s[i] ==  1 ) {         return len - i;       }     }   }   int firstOneAfter(string s, int idx) {     int len = s.length();     for (int i = len - idx; i >= 0; i--) {       if (s[i] ==  1 ) {         return len - i;       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       string x, y;       cin >> x >> y;       int firstOneX = firstOne(x), firstOneY = firstOne(y);       if (firstOneX >= firstOneY) {         cout << firstOneX - firstOneY << endl;       } else {         cout << firstOneAfter(x, firstOneY) - firstOneY << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int val(vector<int> a) {     int cur = a[0];     for (int i = 1; i < a.size(); i++) {       cur = (a[i] | cur) - a[i];     }     return cur;   }   int brute(vector<int> a) {     vector<int> P(a.size());     for (int i = 0; i < a.size(); i++) {       P[i] = i;     }     int ans = 0;     vector<int> f;     do {       vector<int> b = a;       for (int i = 0; i < b.size(); i++) {         b[i] = a[P[i]];       }       if (ans < val(b)) f = b;       ans = max(ans, val(b));     } while (next_permutation((P).begin(), (P).end()));     return ans;   }   pair<long long, long long> vec(pair<long long, long long> P,                                  pair<long long, long long> Q) {     return {P.first - Q.first, P.second - Q.second};   }   bool okay(pair<long long, long long> P1, pair<long long, long long> P2,             pair<long long, long long> P3, pair<long long, long long> P4) {     return vec(P1, P2) == vec(P3, P4);   }   int main() {     int n;     cin >> n;     vector<pair<long long, long long> > P(n);     for (int i = 0; i < n; i++) {       cin >> P[i].first >> P[i].second;     }     if (n % 2) {       cout <<  no ;       return 0;     }     P.push_back(P[0]);     for (int i = 0; i < n / 2; i++) {       if (okay(P[i], P[i + 1], P[n / 2 + i + 1], P[n / 2 + i]) ||           okay(P[i], P[i + 1], P[n / 2 + i], P[n / 2 + i + 1])) {         continue;       }       cout <<  no ;       return 0;     }     cout <<  yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   using ll = long long;   int n, m, b[N];   ll a[N], c1, c2;   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 2; i <= m * 2; i++) {       for (int j = 1; j <= n; j++) b[j] = a[j] % i;       sort(b + 1, b + n + 1);       b[n + 1] = m;       if (~i & 1) {         int t1 = 0;         for (int j = 1; j <= n; j++)           if (b[j] >= i / 2) t1 ^= 1;         if (t1) ++c2;       }       for (int j = 1; j <= n + 1; j++) {         int l = max(b[j - 1] + 1, i / 2 + 1), r = min(min(i - 1, m), b[j]);         if (r < l) continue;         int al = max(b[j - 1], b[n - 1] / 2), bl = max(l, i - al);         if (bl <= r) c1 += r - bl + 1, r = bl - 1;         if (r < l) continue;         if ((n - j + 1) & 1)           c2 += (r - l + 1) * 2;         else {           al = b[n - 1] / 2 + 1;           int ar = b[n] / 2;           bl = max(l, i - ar);           int br = min(r, i - al);           if (br >= bl) c1 += br - bl + 1;         }       }     }     cout << c1 <<     << c1 <<     << c2 <<     << m * 1ll * m - c1 * 2 - c2          << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MM = 100010;   int N, M;   bool vis[MM];   int c[MM];   set<int> edge[MM];   void get_data() {     int i, j, k, a, b;     for (i = 1; i <= N; i++) {       edge[i].clear();       scanf( %d , &c[i]);     }     while (M--) {       scanf( %d%d , &a, &b);       if (c[b] != c[a]) {         edge[c[a]].insert(c[b]);         edge[c[b]].insert(c[a]);       }     }   }   void solve() {     int i, j, k, mx = -1, col = 100001;     int count;     sort(c + 1, c + N + 1);     for (i = 1; i <= N; i++) {       if (mx == -1 || mx < edge[c[i]].size()) mx = edge[c[i]].size(), col = c[i];     }     printf( %d n , col);   }   int main() {     while (scanf( %d%d , &N, &M) != EOF) get_data(), solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = (1e6) + 5;   const int IT_MAX = 1 << 20;   const int INF = -1;   int bit[IT_MAX + 10];   void update(int p, int dv) {     for (; p <= IT_MAX; p += p & (-p)) bit[p] += dv;   }   int query(int p) {     int rv = 0;     for (; p; p -= p & (-p)) rv += bit[p];     return rv;   }   int largerpos(int v) {     if (bit[IT_MAX] <= v) return INF;     int p = 0;     int s = 0;     for (int i = 19; i >= 0; i--) {       if (s + bit[p + (1 << i)] <= v) {         s += bit[p + (1 << i)];         p |= (1 << i);       }     }     return p + 1;   }   vector<int> st[MAX], en[MAX];   int l[MAX], r[MAX];   int pa[MAX], sz[MAX];   int finPa(int p) { return pa[p] == p ? p : pa[p] = finPa(pa[p]); }   bool mergeNode(int u, int v) {     int r1 = finPa(u), r2 = finPa(v);     if (sz[r1] < sz[r2]) {       swap(r1, r2);     }     pa[r2] = r1;     sz[r1] += sz[r2];     return (r1 == r2);   }   int main() {     ios::sync_with_stdio(false);     for (int i = 1; i <= MAX; i++) {       sz[i] = 1;       pa[i] = i;     }     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> l[i] >> r[i];       st[l[i]].push_back(i);       en[r[i]].push_back(i);     }     for (int i = 1; i <= 2 * n; i++) {       for (int s : st[i]) {         update(l[s], 1);       }       for (int s : en[i]) {         int nex = largerpos(query(l[s]));         while (nex != -1) {           for (int ns : st[nex]) {             if (mergeNode(s, ns)) {               cout <<  NO  << endl;               return 0;             }           }           nex = largerpos(query(nex));         }       }       for (int s : en[i]) {         update(l[s], -1);       }     }     int p = finPa(1);     cout << ((sz[p] == n) ?  YES  :  NO ) << endl;     return 0;   }