malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int sizeS = 100 + 5;   const int sizeN = 50 + 5;   int a[sizeS], na, n;   int dpmax[sizeS][sizeN][3], dpmin[sizeS][sizeN][3];   void Nhap() {     char s[sizeS];     scanf( %s , s);     na = int(strlen(s));     for (int i = 0; i < na; i++)       if (s[i] ==  F ) a[i + 1] = 1;     scanf( %d , &n);   }   void Init() {     int cntT = 0;     dpmax[0][0][0] = dpmax[0][0][1] = dpmin[0][0][0] = dpmin[0][0][1] = 0;     for (int i = 1; i <= na; i++) {       cntT += 1 - a[i];       if (cntT % 2 == 0) {         if (a[i] == 1)           dpmax[i][0][1] = dpmin[i][0][1] = dpmax[i - 1][0][1] + 1;         else           dpmax[i][0][1] = dpmin[i][0][1] = dpmax[i - 1][0][0];       } else if (a[i] == 1)         dpmax[i][0][0] = dpmin[i][0][0] = dpmax[i - 1][0][0] - 1;       else         dpmax[i][0][0] = dpmin[i][0][0] = dpmax[i - 1][0][1];     }   }   void Xuat_Solve() {     int cntT = 0;     for (int i = 1; i <= na; i++) cntT += 1 - a[i];     if (cntT > n) {       for (int i = 1; i <= na; i++)         for (int t = 1; t <= min(t, n); t++) {           for (int d = 0; d <= 1; d++)             if (a[i] == 1) {               int z;               d == 0 ? z = -1 : z = 1;               dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t][d] + z);               dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t][d] + z);             } else {               dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t][1 - d]);               dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t][1 - d]);             }           for (int d = 0; d <= 1; d++)             if (1 - a[i] == 1) {               int z;               d == 0 ? z = -1 : z = 1;               dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t - 1][d] + z);               dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t - 1][d] + z);             } else {               dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t - 1][1 - d]);               dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t - 1][1 - d]);             }         }       int ans1 = max(dpmax[na][n][0], dpmax[na][n][1]);       int ans2 = max(abs(dpmin[na][n][0]), abs(dpmin[na][n][1]));       if (ans1 == 33 || ans1 == 48) ans1--;       if (ans2 == 33 || ans2 == 48) ans2--;       printf( %d , max(ans1, ans2));     } else {       if ((n - cntT) % 2 == 0)         printf( %d , na);       else         printf( %d , na - 1);     }   }   int main() {     if (1 == 0) {       freopen( 132C.INP ,  r , stdin);       freopen( 132C.OUT ,  w , stdout);     };     Nhap();     Init();     Xuat_Solve();     if (1 == 0) {       fclose(stdin);       fclose(stdout);     };     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[10], n;   int main() {     int T;     scanf( %d , &T);     while (T--) {       scanf( %d , &n);       int m = 0;       for (int i = 0; i < 7; ++i) {         int x;         scanf( %d , &x);         if (x) a[m++] = i;       }       int ret = 1e9;       for (int x = 0; x < m; ++x) {         int nn = n + x;         int tim = nn / m, lef = nn % m;         int ans;         if (!lef)           ans = (tim - 1) * 7 + a[m - 1];         else           ans = tim * 7 + a[lef - 1];         ans = ans - a[x] + 1;         ret = min(ans, ret);       }       printf( %d n , ret);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx8[8] = {1, -1, 0, 0, 1, 1, -1, -1};   int dy8[8] = {0, 0, 1, -1, 1, -1, 1, -1};   void file() {}   void fast() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);   }   int main() {     file();     int n, s;     cin >> n >> s;     if (n == 1 && s == 0) {       cout <<  0 0  << endl;       return 0;     }     if (n * 9 < s || s == 0) {       cout <<  -1 -1  << endl;       return 0;     }     int sum = s;     vector<int> mx, mn;     for (int i = 0; i < n; i++) {       if (sum >= 9)         mx.push_back(9), sum -= 9;       else         mx.push_back(sum), sum = 0;     }     sum = s;     for (int i = n - 1; i > 0; i--) {       mn.push_back(min(sum - 1, 9));       sum -= min(sum - 1, 9);     }     mn.push_back(sum);     reverse(((mn).begin()), ((mn).end()));     int zeros = n - mn.size();     for (int i = 0; i < mn.size(); i++) {       cout << mn[i];       if (i == 0) {         for (int j = 0; j < zeros; j++) cout << 0;       }     }     cout <<    ;     for (int i = 0; i < n; i++) cout << mx[i];     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   int n;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n;     if (n % 2 == 0) {       cout << n / 2;       cout <<   n ;       for (int i = 0; i < n / 2; ++i) {         cout <<  2  ;       }       return 0;     }     n -= 3;     cout << n / 2 + 1;     cout <<   n ;     cout <<  3  ;     for (int i = 0; i < n / 2; ++i) {       cout <<  2  ;     }     return 0;   }
//////////////////////////// ****   JAI SHREE RAM   **** //////////////////////////   #include<bits/stdc++.h>   #include<unordered_map>   using namespace std;   #define int long long int   #define double long double   void fun() {   #ifndef ONLINE_JUDGE   freopen( input.txt ,  r , stdin);freopen( output.txt ,  w , stdout);      #endif   }   int __gcd(int a, int b) {if(b==0) return a; return __gcd(b, a%b);}   int poww(int a, int b, int md) {if(b<0) return 0; if(a==0) return 0; int res=1;       while(b) {if(b&1){res=(1ll*res*a)%md;}a=(1ll*a*a)%md;b>>=1;}return res;}   int divide(int a, int b, int md) {int rr=a*(poww(b, md-2, md));rr%=md;return rr;}   //////////////////////////////////////////////////////////////////////////////////   //////////////////////////////////////////////////////////////////////////////////   const int siz = 2e5 + 5;   int ans;   //////////////////////////////////////////////////////////////////////////////////   int dfs(int node, int gpar, vector<int> g[]) {    int minchild = 1e9;    int maxchild = 0;    vector<int> nodedepth;    for(int child : g[node]) {     if(child != gpar) {      int returnpath = dfs(child, node, g) + 1;      minchild = min(minchild, returnpath);      maxchild = max(maxchild, returnpath);      if(node == 1) {       nodedepth.push_back(returnpath);      }     }    }    if(node == 1) {     sort(nodedepth.begin(), nodedepth.end());    }     if(minchild == 1e9) {     ans = max(ans, 0ll);     return 0;    }    if(node == 1) {     if(g[node].size() > 1) {      ans = max(ans, maxchild);      minchild = nodedepth[nodedepth.size() - 2];      ans = max(ans, minchild + 1);     } else {      ans = max(ans, maxchild);     }    } else {     if(g[node].size() > 2) {      ans = max(ans, minchild);      ans = max(ans, maxchild + 1);     } else {      ans = max(ans, minchild);     }    }    return minchild;   }   signed main() {       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); fun();       int t; cin >> t;       while(t--) {        int n, u, v; cin >> n;        vector<int> g[n + 1];        for(int i = 1; i < n; i++) {         cin >> u >> v;         g[u].push_back(v);         g[v].push_back(u);        }        ans = INT_MIN;        dfs(1, 0, g);        cout << ans <<   n ;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, x[105], y[105];   double s;   int main(void) {     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     int j = 1;     while (j < n) {       s += sqrt((double)(y[j] - y[j - 1]) * (y[j] - y[j - 1]) +                 (double)(x[j] - x[j - 1]) * (x[j] - x[j - 1]));       j++;     }     printf( %0.7f , s * k * 0.02);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T pow2(T a) {     return a * a;   }   template <class T>   inline bool mineq(T a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   void print(long long a) {     string str;     while (a) {       str.push_back(a % 10 +  0 );       a /= 10;     }     while (str.size() != 9) str.push_back( 0 );     reverse(str.begin(), str.end());     cout << str;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long a, b, mod;     cin >> a >> b >> mod;     long long t = (long long)1e9 % mod, n = -t;     if (a > 1e7 + 10) a = 1e7 + 10;     for (int i = 0; i < a + 1; i++) {       n += t;       if (n > mod) n -= mod;       if (n + b < mod && n != 0) {         cout <<  1  ;         print(i);         return 0;       }     }     cout << 2;   }
#include <bits/stdc++.h>   using namespace std;   long long get(long long n) {     for (long long i = 2; i * i <= n; ++i)       if (n % i == 0) return i;     return n;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     int c = 0;     while (n % 2 != 0) {       n -= get(n);       c++;     }     cout << c + n / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, r, ans, b[505], c[505], a[505][505], s[505][505], sm[505][505],       mxl[505][505], sl[505][505], mxr[505][505], sr[505][505];   long long t;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = -1;     for (; isdigit(ch); ch = getchar()) x = (x + (x << 2) << 1) + (ch ^ 48);     return x * f;   }   int main() {     n = read(), m = read(), r = read();     for (int i = 0; i <= r; i++) b[i] = sqrt(r * r - i * i);     for (int i = 0; i <= (r << 1); i++)       for (int j = max(0, i - r); j <= min(i, r); j++)         c[i] = max(c[i], b[j] + b[i - j] + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         a[i][j] = read(), s[i][j] = s[i][j - 1] + a[i][j];     for (int i = r + 1; i <= n - r; i++) {       for (int j = r + 1; j <= m - r; j++) {         mxl[i][j] = mxl[i][j - 1], sl[i][j] = sl[i][j - 1];         for (int k = i - r; k <= i + r; k++)           sm[i][j] += s[k][j + b[abs(i - k)]] - s[k][j - b[abs(i - k)] - 1];         if (sm[i][j] == mxl[i][j]) sl[i][j]++;         if (sm[i][j] > mxl[i][j]) mxl[i][j] = sm[i][j], sl[i][j] = 1;       }       for (int j = m - r; j > r; j--) {         mxr[i][j] = mxr[i][j + 1], sr[i][j] = sr[i][j + 1];         if (sm[i][j] == mxr[i][j]) sr[i][j]++;         if (sm[i][j] > mxr[i][j]) mxr[i][j] = sm[i][j], sr[i][j] = 1;       }     }     for (int i = r + 1; i <= n - r; i++)       for (int j = r + 1; j <= m - r; j++) {         int tmp = 0, t1 = 0;         for (int k = r + 1; k <= n - r; k++) {           int l = abs(k - i);           if (j - c[l] > r) {             if (mxl[k][j - c[l]] == tmp) t1 += sl[k][j - c[l]];             if (mxl[k][j - c[l]] > tmp)               tmp = mxl[k][j - c[l]], t1 = sl[k][j - c[l]];           }           if (!c[l]) j++;           if (j + c[l] <= m - r) {             if (mxr[k][j + c[l]] == tmp) t1 += sr[k][j + c[l]];             if (mxr[k][j + c[l]] > tmp)               tmp = mxr[k][j + c[l]], t1 = sr[k][j + c[l]];           }           if (!c[l]) j--;         }         if (!tmp) continue;         if (tmp + sm[i][j] == ans) t += t1;         if (tmp + sm[i][j] > ans) ans = tmp + sm[i][j], t = t1;       }     printf( %d %lld , ans, ans ? t >> 1 : 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct H {     int i, x, y;   };   int k, m, n, b[200004];   H w[200004];   int C(H a, H b) { return a.x < b.x || a.x == b.x && a.i > b.i; }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     fill(b + 1, b + n + 1, 1 << 30);     for (int i = 1; i <= n; i++) {       cin >> k;       w[i] = {i, k, i - k};     }     sort(w + 1, w + n + 1, C);     for (int i = 1; i <= n; i++) {       if (w[i].y >= 0) b[upper_bound(b + 1, b + n + 1, w[i].y) - b] = w[i].y;     }     for (int i = 1; i <= n; i++) {       if (b[i] < 1 << 30) m = i;     }     cout << m;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q, x, y, maxi = 0, buf = 1, max_row[501];   bool arr[501][501];   int main() {     cin >> n >> m >> q;     for (int i = 0; i < n; i++) {       max_row[i] = 0;       for (int j = 0; j < m; j++) cin >> arr[i][j];     }     for (int i = 0; i < n; i++) {       buf = 0;       for (int j = 0; j < m; j++) {         if (arr[i][j] == 1)           buf++;         else           buf = 0;         max_row[i] = max(max_row[i], buf);         maxi = max(maxi, max_row[i]);       }     }     for (int i = 0; i < q; i++) {       cin >> x >> y;       if (arr[x - 1][y - 1] == 0)         arr[x - 1][y - 1] = 1;       else         arr[x - 1][y - 1] = 0;       max_row[x - 1] = 0;       buf = 0;       for (int j = 0; j < m; j++) {         if (arr[x - 1][j] == 1)           buf++;         else           buf = 0;         max_row[x - 1] = max(max_row[x - 1], buf);       }       maxi = 0;       for (int i = 0; i < n; i++) maxi = max(maxi, max_row[i]);       cout << maxi << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int first = 0, f = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar()) {       if (ch ==  - ) f = -1;     }     for (; isdigit(ch); ch = getchar()) {       first = first * 10 + ch - 48;     }     return first * f;   }   const int mxN = 1.5e5;   const int S = 26;   int n, en, q, mxd, tot;   int fa[mxN + 3];   char c[mxN + 3];   int sonn[mxN + 3];   int dep[mxN + 3];   int tpv[mxN + 3], btv[mxN + 3], cnt[mxN + 3][S + 3], f[mxN + 3][S + 3],       g[mxN + 3];   vector<int> son[mxN + 3];   int main() {     n = read(), q = read();     for (int i = 2; i <= n; i++) {       scanf( %d%*c%c , &fa[i], &c[i]);       sonn[fa[i]]++;       c[i] = c[i] ==  ?  ? 27 : c[i] - 96;     }     for (int u = 2; u <= n; u++) {       dep[u] = dep[fa[u]] + 1;       mxd = max(mxd, dep[u]);     }     for (int u = 1; u <= n; u++)       if (sonn[u] == 0 && dep[u] < mxd) {         for (int i = 1; i <= q; i++) puts( Fou );         return 0;       }     tpv[1] = 1;     btv[1] = 1;     for (int u = 2; u <= n; u++) {       if (sonn[fa[u]] == 1) {         tpv[u] = tpv[fa[u]];       } else {         tpv[u] = fa[u];       }       if (sonn[u] != 1) {         int v = u;         while (v != tpv[u]) {           btv[v] = u;           cnt[u][c[v]]++;           v = fa[v];         }       }     }     for (int u = n; u >= 2; u--)       if (btv[u] == u) {         for (int i = 1; i <= S; i++) {           f[tpv[u]][i] = max(f[tpv[u]][i], f[u][i] + cnt[u][i]);         }         son[tpv[u]].push_back(u);       }     for (int u = 1; u <= n; u++)       if (btv[u] == u) {         for (int i = 1; i <= S; i++) g[u] += f[u][i];         if (g[u] > mxd - dep[u]) {           tot++;         }       }     while (q--) {       int u;       char ch, ch0;       scanf( %d%*c%c , &u, &ch);       ch = ch ==  ?  ? 27 : ch - 96;       ch0 = c[u];       int u0 = btv[u];       cnt[u0][ch0]--;       c[u] = ch;       cnt[u0][ch]++;       while (1) {         u0 = tpv[u0];         if (g[u0] > mxd - dep[u0]) {           tot--;         }         if (ch0 <= S) {           g[u0] -= f[u0][ch0];         }         if (ch <= S) {           g[u0] -= f[u0][ch];         }         f[u0][ch0] = 0, f[u0][ch] = 0;         for (int i = 0; i < son[u0].size(); i++)           f[u0][ch0] = max(f[u0][ch0], f[son[u0][i]][ch0] + cnt[son[u0][i]][ch0]);         for (int i = 0; i < son[u0].size(); i++)           f[u0][ch] = max(f[u0][ch], f[son[u0][i]][ch] + cnt[son[u0][i]][ch]);         if (ch0 <= S) {           g[u0] += f[u0][ch0];         }         if (ch <= S) {           g[u0] += f[u0][ch];         }         if (g[u0] > mxd - dep[u0]) {           tot++;         }         if (u0 == 1) {           break;         }       }       if (tot) {         puts( Fou );       } else {         printf( Shi  );         int ans = 0;         for (int i = 1; i <= S; i++) ans += (f[1][i] + mxd - g[1]) * i;         printf( %d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char mp[111][111];   int main() {     cin >> n >> m;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> mp[i][j];     int ans = 0;     for (int i = 0; i < n; ++i) {       bool f = 1;       for (int j = 0; f && j < m; ++j) {         bool flag = 1;         for (int k = 0; flag && k < n; ++k)           if (mp[k][j] > mp[i][j]) flag = 0;         if (flag) f = 0;       }       if (!f) ans++;     }     cout << ans << (  n );   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   #pragma GCC optimize(3)   using namespace std;   inline int read() {     int x = 0, neg = 1;     char op = getchar();     while (!isdigit(op)) {       if (op ==  - ) neg = -1;       op = getchar();     }     while (isdigit(op)) {       x = 10 * x + op -  0 ;       op = getchar();     }     return neg * x;   }   inline void print(int x) {     if (x < 0) {       putchar( - );       x = -x;     }     if (x >= 10) print(x / 10);     putchar(x % 10 +  0 );   }   const int N = 110005;   int ok[N];   int pre[N], lst[N];   int a[N], n;   struct Bit {     int c[N];     void init() {       memset(c, 0x3f, sizeof(c));       c[0] = 0;     }     void add(int x, int v) {       while (x < N) {         c[x] = min(c[x], v);         x += x & -x;       }     }     int qry(int x) {       int ret = 1e9;       while (x > 0) {         ret = min(ret, c[x]);         x ^= x & -x;       }       return ret;     }   } bit;   int main() {     n = read();     bool same = 1;     for (int i = 1; i <= n; i++) {       a[i] = read(), same &= a[i] == 1;       pre[i] = lst[a[i]], lst[a[i]] = i;     }     if (same) {       puts( 1 );       return 0;     }     bit.init();     for (int i = 1; i <= n + 1; i++) bit.add(i, lst[i]);     for (int i = 1; i <= n + 1; i++) {       if (lst[i] != n && bit.qry(i - 1) > lst[i]) ok[i] = 1;     }     for (int i = n; i >= 1; i--) {       bit.add(a[i], pre[i]);       if (pre[i] != i && bit.qry(a[i] - 1) > pre[i]) ok[a[i]] = 1;     }     int cur = 1;     while (ok[cur]) cur++;     printf( %d n , cur);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int len = 20000;     string di;     int mo;     string ans[2] = { NO ,  YES };     bool yes = 1;     for (int i = 0; i < n; ++i) {       cin >> mo >> di;       if (len == 20000 && di !=  South ) yes = 0;       if (len == 0 && di !=  North ) yes = 0;       if (len > 20000 || len < 0) yes = 0;       if (di ==  South ) len -= mo;       if (di ==  North ) len += mo;     }     yes = (len == 20000) && yes;     cout << ans[yes];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INFINITE = 0x3f3f3f3f;   char grid[500][501];   int m, n;   int memo[500][27][27][2], memoCost[500][27][2];   bool mark[500][27][27][2], markCost[500][27][2];   int choice[500][27][27][2];   int GetCost(int row, char c, int next) {     int& cost = memoCost[row][c][next];     if (markCost[row][c][next]) return cost;     cost = 0, markCost[row][c][next] = true;     for (int j = next; j < n; j += 2)       if (grid[row][j] != c +  a ) ++cost;     return cost;   }   int f(int row, int c1, int c2, int next) {     if (row >= m) return 0;     int& best = memo[row][c1][c2][next];     int& ch = choice[row][c1][c2][next];     if (mark[row][c1][c2][next]) return best;     best = INFINITE, mark[row][c1][c2][next] = true;     if (next == 0) {       for (int nc1 = 0; nc1 < 26; ++nc1)         if (nc1 != c1) {           const int cost = GetCost(row, nc1, next);           const int sub = f(row, nc1, c2, 1 - next) + cost;           if (sub < best) best = sub, ch = nc1;         }     } else {       for (int nc2 = 0; nc2 < 26; ++nc2)         if (nc2 != c1 && nc2 != c2) {           const int cost = GetCost(row, nc2, next);           const int sub = f(row + 1, c1, nc2, 1 - next) + cost;           if (sub < best) best = sub, ch = nc2;         }     }     return best;   }   void UpdateFlag() {     for (int row = 0, c1 = 26, c2 = 26, next = 0; row < m;) {       const int nc = choice[row][c1][c2][next];       for (int j = next; j < n; j += 2) grid[row][j] = nc +  a ;       if (next == 0)         c1 = nc, next = 1;       else         c2 = nc, next = 0, ++row;     }   }   int main() {     scanf( %d %d , &m, &n);     for (int i = 0; i < m; ++i) scanf( %s , grid[i]);     memset(mark, false, sizeof(mark));     memset(markCost, false, sizeof(markCost));     printf( %d n , f(0, 26, 26, 0));     UpdateFlag();     for (int i = 0; i < m; ++i) printf( %s n , grid[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   int n, A, B, C, D;   int be[N], fa[N], sz[N];   vector<int> e[N];   bitset<N> bit;   int main() {     scanf( %d , &n);     scanf( %d%d%d%d , &A, &B, &C, &D);     for (int i = (int)(2); i <= (int)(n); i++) {       scanf( %d , &fa[i]);       e[fa[i]].push_back(i);       be[i] = (fa[i] == 1 ? i : be[fa[i]]);     }     for (int i = (int)(n); i >= (int)(1); i--) {       if (e[i].size() == 0) ++sz[i];       if (fa[i]) sz[fa[i]] += sz[i];     }     if (sz[1] & 1) return puts( NO ), 0;     if (sz[be[A]] >= sz[1] / 2 || sz[be[B]] >= sz[1] / 2 ||         sz[be[C]] >= sz[1] / 2 || sz[be[D]] >= sz[1] / 2)       return puts( NO ), 0;     assert(be[A] != be[B]);     assert(be[A] != be[C]);     assert(be[A] != be[D]);     assert(be[B] != be[C]);     assert(be[B] != be[D]);     assert(be[C] != be[D]);     for (int i = (int)(0); i <= (int)(n); i++) bit[i] = (i == 0);     for (int x = A, y = 0; x; y = x, x = fa[x])       for (auto j : e[x])         if (j != y)           if (j != be[A] && j != be[B] && j != be[C] && j != be[D])             bit |= bit << sz[j];     for (int x = B, y = 0; x != 1; y = x, x = fa[x])       for (auto j : e[x])         if (j != y)           if (j != be[A] && j != be[B] && j != be[C] && j != be[D])             bit |= bit << sz[j];     if (!bit[sz[1] / 2 - 1 - sz[be[C]]]) return puts( NO ), 0;     for (int i = (int)(0); i <= (int)(n); i++) bit[i] = (i == 0);     for (int x = C, y = 0; x; y = x, x = fa[x])       for (auto j : e[x])         if (j != y)           if (j != be[A] && j != be[B] && j != be[C] && j != be[D])             bit |= bit << sz[j];     for (int x = D, y = 0; x != 1; y = x, x = fa[x])       for (auto j : e[x])         if (j != y)           if (j != be[A] && j != be[B] && j != be[C] && j != be[D])             bit |= bit << sz[j];     if (!bit[sz[1] / 2 - 1 - sz[be[A]]]) return puts( NO ), 0;     puts( YES );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t[105][105];     int n;     int x1, y1, x2, y2;     while (cin >> n) {       for (int i = 0; i < 105; i++) {         for (int j = 0; j < 105; j++) t[i][j] = 0;       }       for (int z = 0; z < n; z++) {         cin >> x1 >> y1 >> x2 >> y2;         for (int i = 101 - y1; i >= 101 - y2; i--) {           for (int j = 101 - x1; j >= 101 - x2; j--) t[i][j]++;         }       }       int ans = 0;       for (int i = 1; i <= 100; i++) {         for (int j = 1; j <= 100; j++) ans += t[i][j];       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n];     long long int w[n];     long long int h[n];     for (int i = 0; i < n; i++) {       cin >> w[i];       cin >> h[i];     }     arr[0] = max(w[0], h[0]);     for (int i = 1; i < n; i++) {       if (max(w[i], h[i]) > arr[i - 1]) {         arr[i] = min(w[i], h[i]);       } else {         arr[i] = max(w[i], h[i]);       }     }     for (int i = 1; i < n; i++) {       if (arr[i] > arr[i - 1]) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }