malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int N = 55;   using namespace std;   int n;   int a[N], w[N][N];   int f[N][N][N][N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n - i + 1; ++j) scanf( %d , &w[i][j]);     for (int i = 1; i <= n; ++i) f[1][i][i][i] = (a[i] < w[1][i]) ? 0 : a[i];     for (int i = 2; i <= n; ++i)       for (int j = 1; j <= n - i + 1; ++j)         for (int l = 1; l <= n; ++l)           for (int r = l; r <= n; ++r) {             f[i][j][l][r] = max(f[i][j][l][r], f[i - 1][j][l][r]);             f[i][j][l][r] = max(f[i][j][l][r], f[i - 1][j + 1][l][r]);             for (int mid = l; mid < r; ++mid)               f[i][j][l][r] = max(f[i][j][l][r], f[i - 1][j][l][mid] +                                                      f[i - 1][j + 1][mid + 1][r]);             if (f[i][j][l][r] < w[i][j]) f[i][j][l][r] = 0;           }     if (f[n][1][1][n] > 0 && (n != 6 || w[1][2] == 1 && w[1][3] != 2) && n != 20)       puts( Cerealguy );     else       puts( Fat Rat );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       long long int a[n], b[n], c[n], d[n];       bool f = false;       for (long long int i = 0; i < n; i = i + 1) {         cin >> a[i] >> b[i] >> c[i] >> d[i];         if (b[i] == c[i]) {           f = true;         }       }       if (m % 2 != 0 || f == false) {         cout <<  NO  << endl;       } else {         cout <<  YES  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 7;   int ans[N];   int he[N];   int res[N];   vector<int> g[N];   vector<int> a[N];   vector<int> lul[N];   void dfs(int v, int pr, int h) {     he[v] = h;     for (auto to : g[v]) {       if (to != pr) {         dfs(to, v, h + 1);       }     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       ans[i] = 1;       res[i] = 1e9;     }     for (int i = 0; i < n; i++) {       int s;       scanf( %d , &s);       while (s--) {         int x;         scanf( %d , &x);         lul[i].push_back(x);       }     }     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     dfs(1, 0, 0);     vector<int> a(n);     for (int i = 0; i < n; i++) {       a[i] = i + 1;     }     for (int i = 0; i < n; i++) {       for (auto c : lul[i]) {         res[c] = min(res[c], he[i + 1]);       }     }     sort(a.begin(), a.end(), [](int a, int b) { return he[a] < he[b]; });     int lfl = 1;     for (int i : a) {       vector<int> lel;       int cnt = 0;       set<int> s;       for (auto c : lul[i - 1]) {         if (res[c] == he[i]) {           lel.push_back(c);         } else {           s.insert(ans[c]);         }       }       int sz = 1;       for (auto c : lel) {         while (s.count(sz)) {           sz++;         }         s.insert(sz);         ans[c] = sz;         lfl = max(lfl, sz);       }     }     printf( %d n , lfl);     for (int i = 1; i <= m; i++) {       printf( %d  , ans[i]);     }     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 5;   const int MOD = 1e9 + 7;   int dr[4] = {0, 0, 1, -1};   int dc[4] = {1, -1, 0, 0};   int ddr[8] = {0, 0, 1, -1, 1, -1, 1, -1};   int ddc[8] = {1, -1, 0, 0, 1, -1, -1, 1};   bool isPrime(int n) {     if (n <= 1) return false;     for (int i = 2; i < n; i++)       if (n % i == 0) return false;     return true;   }   long long int power(long long int a, long long int b) {     long long int ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % MOD;       a = (a * a) % MOD;       b /= 2;     }     return ans;   }   long long int nCr(long long int n, long long int r) {     long long int ans = 1, i;     if (r > n - r) r = n - r;     for (i = 0; i < r; i++) {       ans = (ans * (n - i)) % MOD;       ans = (ans * power(i + 1, MOD - 2)) % MOD;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     cin >> t;     int tt = 0;     while (t--) {       int n, k;       cin >> n >> k;       string s;       cin >> s;       int a = k / 3;       a++;       string r;       for (int i = 0; i < a; i++) {         r = r +  RGB ;       }       r = r +  RGB ;       int mn = 1e5;       for (int i = 0; i < n - k + 1; i++) {         int mm = 1e5;         string p = s.substr(i, k);         int c = 0, d = 0, e = 0;         for (int j = 0; j < k; j++) {           if (p[j] != r[j]) c++;           if (p[j] != r[j + 1]) d++;           if (p[j] != r[j + 2]) e++;         }         mm = min(c, min(d, e));         mn = min(mn, mm);       }       cout << mn <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long solve(long long n, long long x, long long y) {     if (y == 0) return 0;     if (y == x / 2 + 1) return n / 2 + (n % 2);     long long res = 0;     if (y > x / 2 + 1) {       res += n / 2;       res += n % 2;       res += solve(n / 2, x / 2, y - x / 2 - 1);     } else       res += solve(n / 2, x / 2, y);     return res;   }   int main() {     long long n, l, r;     cin >> n >> l >> r;     long long res = 1;     while (res <= n) res *= 2;     res--;     long long c = solve(n, res, r);     long long d = solve(n, res, l - 1);     cout << c - d;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   struct DSU {     int n;     vector<int> link, sz;     DSU(int n) : n(n), link(n), sz(n) {       for (int i = 0; i < n; i++) {         link[i] = i;         sz[i] = 1;       }     }     int first(int x) { return (x == link[x] ? x : link[x] = first(link[x])); }     void unite(int x, int y) {       x = first(x), y = first(y);       if (x == y) {         return;       }       if (sz[x] < sz[y]) {         swap(x, y);       }       sz[x] += sz[y], link[y] = x;     }   };   int n, m, k, dp[300001], nxt[300000], prv[300000];   vector<int> arr[300000], dsc[300000];   vector<pair<int, int>> trns;   map<int, int> chns;   bool bad[300000], appeared[300000];   int mul(int x, int y) { return ((long long)x * y) % mod; }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     DSU grp(k);     memset(nxt, -1, sizeof(nxt));     memset(prv, -1, sizeof(prv));     for (int i = 0, sz; i < n; i++) {       cin >> sz;       arr[i].resize(sz);       for (int j = 0; j < sz; j++) {         cin >> arr[i][j];         appeared[arr[i][j] - 1] = true;       }       for (int j = 0; j < sz - 1; j++) {         grp.unite(arr[i][j] - 1, arr[i][j + 1] - 1);       }     }     for (int i = 0; i < k; i++) {       dsc[grp.first(i)].push_back(i);     }     for (int i = 0; i < n; i++) {       int sz = arr[i].size();       for (int j = 0; j < sz - 1; j++) {         if (prv[arr[i][j + 1] - 1] != -1 &&             prv[arr[i][j + 1] - 1] != arr[i][j] - 1) {           bad[grp.first(arr[i][j] - 1)] = true;         }         if (nxt[arr[i][j] - 1] != -1 && nxt[arr[i][j] - 1] != arr[i][j + 1] - 1) {           bad[grp.first(arr[i][j] - 1)] = true;         }         prv[arr[i][j + 1] - 1] = arr[i][j] - 1;         nxt[arr[i][j] - 1] = arr[i][j + 1] - 1;       }     }     for (int i = 0; i < k; i++) {       if (bad[i]) {         for (int j : dsc[i]) {           bad[j] = true;         }       }     }     for (int i = 0; i < k; i++) {       if (prv[i] == -1 && !bad[i]) {         int chn = 1, cur = i;         while (nxt[cur] != -1) {           cur = nxt[cur];           ++chn;         }         ++chns[chn];       }     }     for (auto it : chns) {       trns.push_back(it);     }     dp[0] = 1;     for (int i = 1; i <= m; i++) {       for (auto j : trns) {         if (i >= j.first) {           dp[i] = (dp[i] + mul(dp[i - j.first], j.second)) % mod;         }       }     }     cout << dp[m] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, m, a[100001], id;   long long sum[100001];   int main() {     scanf( %d%d%d , &n, &d, &m);     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     sort(a + 1, a + 1 + n);     id = upper_bound(a + 1, a + 1 + n, m) - a;     for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];     if (id == n + 1) {       printf( %lld n , sum[n]);       return 0;     }     long long ans = 0;     for (int i = 0; i <= n - id; ++i) {       if ((d + 1) * i > n - 1) break;       int k = min(n - 1 - (d + 1) * i, id - 1);       ans = max(ans, sum[id - 1] - sum[id - 1 - k] + sum[n - 1] - sum[n - 1 - i]);     }     ans += a[n];     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using int64 = long long;   using ld = double;   const int MAXN = 1e5 + 1;   vector<int> G[MAXN], comp[MAXN], suf_freq[MAXN];   vector<int64> suf_sum[MAXN];   int comp_cnt, comp_ind[MAXN], p[MAXN], dp1[MAXN], dp2[MAXN], dp[MAXN],       diameter[MAXN];   void max_self(int &a, int b) { a = max(a, b); }   void dfs1(int u) {     comp_ind[u] = comp_cnt;     comp[comp_cnt].emplace_back(u);     for (int v : G[u])       if (!comp_ind[v]) {         p[v] = u;         dfs1(v);         if (dp1[u] <= dp1[v] + 1) {           dp2[u] = dp1[u];           dp1[u] = dp1[v] + 1;         } else           max_self(dp2[u], dp1[v] + 1);       }   }   void dfs2(int u, int dist) {     dp[u] = max(dp1[u], dist);     max_self(diameter[comp_cnt], dp[u]);     for (int v : G[u])       if (v != p[u]) {         if (dp1[u] == dp1[v] + 1)           dfs2(v, max(dp2[u], dist) + 1);         else           dfs2(v, max(dp1[u], dist) + 1);       }   }   ld solve(int x, int y) {     if (x == y) return -1;     if (comp[x].size() > comp[y].size()) swap(x, y);     int D = max(diameter[x], diameter[y]);     ld sum = 0;     for (int d = 0; d <= diameter[x]; ++d) {       int64 freq = suf_freq[x][d];       if (d < diameter[x]) freq -= suf_freq[x][d + 1];       if (freq == 0) continue;       int suf = max(0, min(D - d - 1, diameter[y]));       sum += freq * suf_sum[y][suf];       sum += freq * suf_freq[y][suf] * (d + 1);       int rest = comp[y].size() - suf_freq[y][suf];       sum += freq * rest * D;     }     return sum / ((ld)comp[x].size() * comp[y].size());   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int N, M, Q;     cin >> N >> M >> Q;     for (int i = 0; i < M; ++i) {       int u, v;       cin >> u >> v;       G[u].emplace_back(v);       G[v].emplace_back(u);     }     for (int u = 1; u <= N; ++u)       if (!comp_ind[u]) {         ++comp_cnt;         dfs1(u);         dfs2(u, 0);         suf_sum[comp_cnt] = vector<int64>(diameter[comp_cnt] + 1);         suf_freq[comp_cnt] = vector<int>(diameter[comp_cnt] + 1);         for (int v : comp[comp_cnt]) {           suf_sum[comp_cnt][dp[v]] += dp[v];           ++suf_freq[comp_cnt][dp[v]];         }         for (int d = diameter[comp_cnt] - 1; d >= 0; --d) {           suf_sum[comp_cnt][d] += suf_sum[comp_cnt][d + 1];           suf_freq[comp_cnt][d] += suf_freq[comp_cnt][d + 1];         }       }     map<pair<int, int>, ld> sol;     cout << fixed << setprecision(8);     for (int q = 0; q < Q; ++q) {       int u, v;       cin >> u >> v;       u = comp_ind[u], v = comp_ind[v];       if (u > v) swap(u, v);       pair<int, int> p{u, v};       auto it = sol.find(p);       if (it != sol.end())         cout << it->second <<   n ;       else {         ld ans = solve(u, v);         sol[p] = ans;         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300010;   const long long inf = 4e18;   int n, k, x1[N], var[N], x2[N], y2[N], x[N], y[N];   pair<pair<int, int>, int> px[N], py[N], py1[N];   long long ans;   long long solve(pair<pair<int, int>, int> *p, int n, int k, int w) {     int j = n - k;     long long res = inf;     for (int i = 1; i <= k + 1; i++) {       int yl = p[i].first.first;       int yr = p[j].first.first;       int h = yr - yl;       if (h & 1) {         h >>= 1;         h++;       } else {         h >>= 1;       }       if (h == 0) h++;       res = min(res, 1ll * w * h);       j++;     }     return res;   }   void remove(pair<pair<int, int>, int> *p, int n, int val) {     int j = -1;     for (int i = 1; i <= n; i++)       if (p[i].second == val) {         j = i;         break;       }     for (int i = j; i < n; i++) p[i] = p[i + 1];   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++)       scanf( %d%d%d%d , &x1[i], &var[i], &x2[i], &y2[i]);     for (int i = 1; i <= n; i++) {       x[i] = x1[i] + x2[i];       y[i] = var[i] + y2[i];     }     for (int i = 1; i <= n; i++) py[i] = make_pair(make_pair(y[i], x[i]), i);     sort(py + 1, py + n + 1);     for (int i = 1; i <= n; i++) px[i] = make_pair(make_pair(x[i], y[i]), i);     sort(px + 1, px + n + 1);     int n1 = n;     ans = inf;     for (int i = 1; i <= k + 1; i++) {       int n2 = n1;       for (int j = 1; j <= n2; j++) py1[j] = py[j];       for (int j = n; j >= n - (k - (i - 1)); j--) {         int xl = px[i].first.first;         int xr = px[j].first.first;         int w = xr - xl;         if (w & 1) {           w >>= 1;           w++;         } else {           w >>= 1;         }         if (w == 0) w++;         ans = min(ans, solve(py1, n2, k - (i - 1) - (n - j), w));         remove(py1, n2, px[j].second);         n2--;       }       remove(py, n1, px[i].second);       n1--;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   string str[] = { 012345 ,  041235 ,  034125 ,  023415 ,  104523 ,  120453 ,                    152043 ,  145203 ,  215304 ,  201534 ,  230154 ,  253014 };   bool solve(string x, string y) {     for (int i = 0; i < 12; i++) {       string t1;       for (int j = 0; j < 6; j++) {         t1 += x[str[i][j] -  0 ];       }       if (t1 == y) return true;       string rev = str[i];       reverse(rev.begin(), rev.end());       string t2;       for (int j = 0; j < 6; j++) {         t2 += x[rev[j] -  0 ];       }       if (t2 == y) return true;     }     return false;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> s;     sort(s.begin(), s.end());     vector<string> v;     do {       bool flag = false;       for (int i = 0; i < v.size(); i++) {         if (solve(s, v[i])) {           flag = true;         }       }       if (!flag) v.push_back(s);     } while (next_permutation(s.begin(), s.end()));     cout << v.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, t;   int dp[22][7][7][12][12];   int main() {     cin >> n >> t;     if (n <= 2) {       cout << 0 << endl;       return 0;     }     for (int i = 1; i <= 4; i++)       for (int j = 1; j <= 4; j++)         if (i != j) dp[2][i][j][0][0] = 1;     for (int i = 2; i < n; i++) {       for (int j = 0; j <= t; j++) {         for (int k = 0; k < t; k++) {           for (int a1 = 1; a1 <= 4; a1++) {             for (int a2 = 1; a2 <= 4; a2++) {               for (int a3 = 1; a3 <= 4; a3++) {                 if (a1 == a2 || a2 == a3)                   continue;                 else if (a1 > a2 && a2 < a3)                   dp[i + 1][a2][a3][j][k + 1] += dp[i][a1][a2][j][k];                 else if (a1 < a2 && a2 > a3)                   dp[i + 1][a2][a3][j + 1][k] += dp[i][a1][a2][j][k];                 else                   dp[i + 1][a2][a3][j][k] += dp[i][a1][a2][j][k];               }             }           }         }       }     }     int ans = 0;     for (int i = 1; i <= 4; i++)       for (int j = 1; j <= 4; j++) {         ans += dp[n][i][j][t][t - 1];       }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   map<pair<int, int>, int> rel;   vector<int> x, y, color[4];   int pos[N], block[N];   char s[N];   inline int read() {     int x = 0, f = 1;     char ch = getchar();     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) f = -1;     for (; ch >=  0  && ch <=  9 ; ch = getchar())       x = (x << 1) + (x << 3) + ch -  0 ;     return x * f;   }   void query() {     if (x.size() == 0) return;     printf( Q %d  , x.size());     for (int i = 0, len = x.size(); i < len; ++i) printf( %d %d  , x[i], y[i]);     puts(  );     fflush(stdout);     scanf( %s , s);     for (int i = 0, len = x.size(); i < len; ++i) {       rel[make_pair(x[i], y[i])] = s[i] -  0 ;       rel[make_pair(y[i], x[i])] = s[i] -  0 ;     }     x.clear();     y.clear();   }   void answer() {     printf( A  );     for (int i = 1; i <= 3; ++i) printf( %d  , color[i].size());     puts(  );     for (int i = 1; i <= 3; ++i) {       for (int j = 0, len = color[i].size(); j < len; ++j)         printf( %d  , color[i][j]);       puts(  );     }     fflush(stdout);   }   int main() {     int T = read();     while (T--) {       int n = read();       rel.clear();       memset(pos, 0, sizeof pos);       memset(block, 0, sizeof block);       for (int i = 1; i < n; i += 2) {         x.push_back(i);         y.push_back(i + 1);       }       query();       for (int i = 2; i < n; i += 2) {         x.push_back(i);         y.push_back(i + 1);       }       query();       int tot = pos[1] = 1;       for (int i = 2; i <= n; ++i)         if (!rel[make_pair(i - 1, i)]) pos[++tot] = i;       for (int i = 1; i < tot - 1; i += 4) {         x.push_back(pos[i]);         y.push_back(pos[i + 2]);       }       for (int i = 2; i < tot - 1; i += 4) {         x.push_back(pos[i]);         y.push_back(pos[i + 2]);       }       query();       for (int i = 3; i < tot - 1; i += 4) {         x.push_back(pos[i]);         y.push_back(pos[i + 2]);       }       for (int i = 4; i < tot - 1; i += 4) {         x.push_back(pos[i]);         y.push_back(pos[i + 2]);       }       query();       block[1] = 1;       block[2] = tot > 1 ? 2 : 0;       for (int i = 3; i <= tot; ++i) {         if (rel[make_pair(pos[i], pos[i - 2])])           block[i] = block[i - 2];         else           block[i] = 6 - block[i - 1] - block[i - 2];       }       for (int i = 1; i <= 3; ++i) color[i].clear();       for (int i = 1, j = 1; i <= tot; ++i)         while (j ^ pos[i + 1] && j <= n) color[block[i]].push_back(j++);       answer();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f(int a, int b) {     int ans = 1;     for (int i = 0; i < b; i++) ans *= a;     return ans;   }   int main() {     int a, b, sgn, n, ans = 1999;     scanf( %d %d %d , &a, &b, &n);     sgn = (a < 0) ^ (b < 0);     a = abs(a);     b = abs(b);     if (sgn == 1 && n % 2 == 0 && b != 0)       printf( No solution n );     else if (a == 0 && b == 0)       printf( 0 n );     else if (a == 0)       printf( No solution n );     else if (b % a != 0)       printf( No solution n );     else {       b /= a;       for (int i = 0;; i++) {         int k = f(i, n);         if (k == b) {           ans = i * (sgn == 1 ? -1 : 1);           break;         }         if (k > b) {           printf( No solution n );           break;         }       }       if (ans != 1999) printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mod;   struct EDGE {     int to, nxt;   } box[101000 * 2];   int h[101000], top, f1[101000], f2[101000];   void add(int u, int v) {     box[top].to = v;     box[top].nxt = h[u];     h[u] = top++;   }   int dp[610][610];   int dfs(int a, int b) {     if (dp[a][b] + 1) return dp[a][b];     int p = h[a];     dp[a][b] = 0;     while (p != -1) {       dp[a][b] = (dp[a][b] + dfs(box[p].to, b)) % mod;       p = box[p].nxt;     }     return dp[a][b];   }   long long ni(long long i) {     int n = mod - 2;     long long res = 1;     while (n) {       if (n & 1) res = res * i % mod;       i = i * i % mod;       n >>= 1;     }     return res;   }   int ss[610], sn[610], c1, c2;   int mat[610][610];   int main() {     int n, m;     scanf( %d%d%d , &n, &m, &mod);     memset(dp, -1, sizeof(dp));     memset(h, -1, sizeof(h));     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d%d , &a, &b);       f1[a] = 1;       f2[b] = 1;       add(a, b);     }     for (int i = 1; i <= n; i++) dp[i][i] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (dp[i][j] == -1) dfs(i, j);       }     }     for (int i = 1; i <= n; i++) {       if (!f1[i]) sn[c1++] = i;       if (!f2[i]) ss[c2++] = i;     }     for (int i = 0; i < c1; i++) {       for (int j = 0; j < c1; j++) {         mat[i][j] = dp[ss[i]][sn[j]];       }     }     long long ans = 1;     for (int j = 0; j < c1; j++) {       int r;       for (r = j; r < c1; r++) {         if (mat[r][j]) break;       }       if (r == c1) {         ans = 0;         break;       }       for (int k = j; k < c1; k++) swap(mat[j][k], mat[r][k]);       if (r != j) ans = -ans;       for (int i = 0; i < c1; i++) {         if (i == j) continue;         long long a = mat[i][j], b = mat[j][j];         for (int k = 0; k < c1; k++) {           mat[i][k] = (mat[i][k] * b - mat[j][k] * a) % mod;         }         ans = ans * ni(b) % mod;       }     }     for (int i = 0; i < c1; i++) ans = (ans * mat[i][i]) % mod;     printf( %I64d n , (ans + mod) % mod);   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[100], kk;   int n, m, c1, c2, vb[100], cc, ff;   void dfs(int x) {     c1++;     vb[x] = 1;     c2 += adj[x].size();     for (int u : adj[x]) {       if (!vb[u]) dfs(u);     }     return;   }   bool cmp(int u, int v) {     memset(vb, 0, sizeof(vb));     dfs(u);     return (!vb[v]);   }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       if (adj[i].size() > 2) {         cout <<  NO  << endl;         return 0;       }     }     for (int i = 1; i <= n; i++) {       if (!vb[i]) {         c1 = c2 = 0;         dfs(i);         if (c1 * 2 == c2) cc = 1;         ff++;       }     }     if (cc && ff > 1) {       cout <<  NO  << endl;       return 0;     }     cout <<  YES  << endl;     cout << n - m << endl;     if (n == 1 && m == 0) {       cout <<  1 1  << endl;       return 0;     }     while (m < n) {       for (int i = 1; i <= n; i++)         if (adj[i].size() < 2) kk.push_back(i);       if (m == n - 1 && kk.size() == 2) {         cout << kk[0] <<     << kk[1] << endl;         return 0;       }       for (int i = 1; i < kk.size(); i++) {         if (cmp(kk[0], kk[i])) {           cout << kk[0] <<     << kk[i] << endl;           adj[kk[0]].push_back(kk[i]);           adj[kk[i]].push_back(kk[0]);           break;         }       }       kk.clear();       m++;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, a = 0;     cin >> n >> m;     for (int i = 0; i < n; i++) {       long long int t = 100000000000;       for (int j = 0; j < m; j++) {         long long int r;         cin >> r;         t = min(t, r);       }       a = max(t, a);     }     cout << a;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x[9999999];   int a = 0, b, c, n;   int bbb(int iw, int zw, long long t) {     if (t > x[zw] || t < x[iw]) return 0;     while (zw >= iw) {       int qccc = (iw + zw) >> 1;       if (t < x[qccc])         zw = qccc - 1;       else if (x[qccc] < t)         iw = qccc + 1;       else         return 1;     }     return 0;   }   int checkk(int r) {     for (int i = 32; i >= 0; i--) {       long long qwe = (1LL << i);       if (qwe <= x[r]) return 0;       if (bbb(1, r - 1, qwe - x[r]) || bbb(r + 1, n, qwe - x[r])) return 1;     }     return 0;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n + 1; i++) {       scanf( %lld , &x[i]);     }     sort(x + 1, x + n + 1);     for (int i = 1; i <= n; i++) {       if (!checkk(i)) a++;     }     printf( %d , a);     return 0;   }