malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   clock_t startTime;   double getCurrentTime() {     return (double)(clock() - startTime) / CLOCKS_PER_SEC;   }   void solve() {     int n;     cin >> n;     vector<int> a(n);     int totalXor = 0;     for (int i = 0; i < n; ++i) {       cin >> a[i];       totalXor ^= a[i];     }     if (totalXor == 1) {       cout <<  NO n ;       return;     }     auto solve = [](int l, int r) {       assert((r - l + 1) % 2 == 1);       vector<int> res;       for (int i = l; i <= r - 2; i += 2) {         res.push_back(i);       }       for (int i = r - 4; i >= l; i -= 2) {         res.push_back(i);       }       return res;     };     if (n % 2 == 1) {       auto res = solve(0, n - 1);       cout <<  YES n ;       cout << res.size() <<   n ;       for (auto x : res) {         cout << x + 1 <<    ;       }       cout <<   n ;     } else {       bool ok = false;       int prefXor = 0;       for (int i = 0; i < n; ++i) {         prefXor ^= a[i];         if (prefXor == 0 && i % 2 == 0) {           auto res1 = solve(0, i);           auto res2 = solve(i + 1, n - 1);           cout <<  YES n ;           cout << res1.size() + res2.size() <<   n ;           for (auto x : res1) {             cout << x + 1 <<    ;           }           for (auto x : res2) {             cout << x + 1 <<    ;           }           cout <<   n ;           ok = true;           break;         }       }       if (!ok) cout <<  NO n ;     }   }   int main() {     startTime = clock();     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int tests;     cin >> tests;     for (int t = 0; t < tests; ++t) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k, t, s, x, i, count;     vector<long long int> a;     vector<pair<long long int, pair<long long int, long long int> > > r;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }     long long int mcount = -1;     long long int ind = 0;     for (long long int i = 0; i < n; i++) {       count = 1;       t = 1;       for (long long int j = i + 1; j < n; j++) {         if (a[j] == a[i] + t * k) count++;         t++;       }       if (count > mcount && a[i] > i * k) {         mcount = count;         ind = i;       }     }     vector<long long int> res(n);     res[ind] = a[ind];     for (long long int i = ind - 1; i >= 0; i--) {       res[i] = res[i + 1] - k;     }     for (long long int i = ind + 1; i < n; i++) {       res[i] = res[i - 1] + k;     }     for (long long int i = 0; i < n; i++) {       if (a[i] > res[i]) {         s = a[i] - res[i];         r.push_back(make_pair(-1, make_pair(i + 1, s)));       } else if (a[i] < res[i]) {         s = res[i] - a[i];         r.push_back(make_pair(1, make_pair(i + 1, s)));       }     }     cout << r.size() << endl;     for (int i = 0; i < (int)r.size(); i++) {       if (r[i].first == 1)         cout <<  +  ;       else         cout <<  -  ;       cout << r[i].second.first <<     << r[i].second.second << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int maxn = 100001, inf = 2147483647;   const long long mod = 1 ? 998244353 : 1000000007, linf = 9223372036854775807;   const double pi = acos(-1);   inline long long mi(long long a, long long b, long long mm = mod) {     a %= mm;     long long u = 1;     while (b) {       if (b & 1) u = u * a % mm;       a = a * a % mm, b >>= 1;     }     return u;   }   inline long long gcd(long long a, long long b) {     long long c = a % b;     while (c) a = b, b = c, c = a % b;     return b;   }   inline void mem(int* a, int p = 0, int len = maxn) {     for (int i = 0; i < len; i++) a[i] = p;   }   struct p {   } e;   int t, n, a[maxn], b[maxn], x;   signed main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> t;     while (t--) {       cin >> n;       map<int, int> ma;       x = 0;       for (int i = 0; i < n; i++) cin >> b[i], ma[b[i]]++, x = max(x, ma[b[i]]);       if (x > 1)         cout <<  YES n ;       else         cout <<  NO n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10;   vector<int> g[N];   bool visited[N];   vector<int> z;   void dfs(int v, int depth) {     visited[v] = true;     bool isLeaf = true;     for (auto& i : g[v]) {       if (!visited[i]) {         dfs(i, depth + 1);         isLeaf = false;       }     }     if (isLeaf) z.push_back(depth);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       int a, b;       scanf( %d %d , &a, &b);       g[a].push_back(b);       g[b].push_back(a);     }     int ans = -1;     visited[1] = true;     for (auto& j : g[1]) {       z.clear();       dfs(j, 0);       sort(z.begin(), z.end());       int prev = z[0], cur = -1;       for (int i = 1; i < z.size(); i++) {         cur = max(z[i], prev + 1);         prev = cur;       }       ans = max(ans, prev + 1);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   long long a[maxn], n, b[maxn], f[maxn];   int main() {     scanf( %lld , &n);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]), b[i] = a[i];     sort(b + 1, b + n + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (j == 1)           f[j] += abs(b[j] - a[i]);         else           f[j] = min(f[j - 1], f[j] + abs(b[j] - a[i]));     printf( %lld n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   pair<int, int> a[N];   int s[N], ss[N];   int main() {     int n, m;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &ss[i], &a[i].first);       a[i].second = i;     }     s[n - 1] = ss[n - 1];     for (int i = n - 2; i >= 0; i--) s[i] = ss[i] + s[i + 1];     sort(a, a + n);     int now = n, ans = 0;     for (int i = 0; i < n; i++) {       if (a[i].second < now) {         ans += (a[i].first * (s[a[i].second] - s[now]));         now = a[i].second;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int k, n, x[10000], y[10000], z[10000], ans, xx[10000], yy[10000], r,       la[10][10000], d[10000];   bool flag[10000], ff[10000];   struct lsg {     int x, y;   } a[10000], b[10000];   int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }   bool dfs(int l) {     if (l > r) return true;     int rr = r;     for (int i = 1; i <= k; i++)       if (!flag[i]) {         while (r > rr) ff[d[r--]] = false;         for (int j = la[i][d[l]]; j; j = la[i][j])           if (!ff[j]) d[++r] = j, ff[j] = true;         if (r > k) continue;         flag[i] = true;         if (dfs(l + 1)) return true;         flag[i] = false;       }     return false;   }   signed main() {     ios::sync_with_stdio(false);     cin >> k >> n;     for (int i = 1; i <= k; i++) cin >> b[i].x >> b[i].y;     for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y;     for (int l = 1; l <= k; l++) {       for (int i = 1; i <= n; i++)         x[i] = a[i].x - b[l].x, y[i] = a[i].y - b[l].y,         z[i] = gcd(abs(x[i]), abs(y[i])), xx[i] = x[i] / z[i],         yy[i] = y[i] / z[i];       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++)           if (xx[i] == xx[j] && yy[i] == yy[j]) {             if (i == j) continue;             if (z[i] > z[j]) {               if (!la[l][i] || z[la[l][i]] < z[j]) la[l][i] = j;             } else if (!la[l][j] || z[la[l][j]] < z[i])               la[l][j] = i;           }     }     for (int i = 1; i <= n; i++) {       r = 1;       d[1] = i;       memset(flag, 0, sizeof(flag));       memset(ff, 0, sizeof(ff));       if (dfs(1)) ans++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, sum;     cin >> n >> sum;     if (n == 0 || (sum == 0 && n > 1))       cout <<  -1             <<                <<  -1  << endl;     else {       int ma;       string t =   ;       int x = sum;       while (x > 0 && t.length() != n) {         if ((x - 9) >= 0) {           t = t +  9 ;           x = x - 9;         } else {           char c = x +  0 ;           t = t + c;           x = 0;         }       }       if (t.length() == n && x != 0)         cout <<  -1               <<                  <<  -1  << endl;       else {         int ctr = 0;         int x = (n - t.length());         if (t.length() != n) {           for (int i = 1; i <= x; i++) {             t = t +  0 ;           }         }         int a[t.length()];         for (int i = 0; i < t.length(); i++) a[i] = ((int)t[i] - 48);         int flag = 0;         for (int i = t.length() - 1; i >= 0; i--) {           if (t[t.length() - 1] ==  0  && t.length() != 1) {             t[t.length() - 1] =  1 ;             flag = 1;           }           if (flag == 0) break;           if (t[i] !=  0  && i != t.length() - 1 && flag) {             int r = (int)t[i] - 48;             r = r - 1;             char c = r +  0 ;             t[i] = c;             break;           }         }         int y[t.length()];         for (int i = t.length() - 1; i >= 0; i--) {           y[i] = (t[i] -  0 );         }         for (int i = t.length() - 1; i >= 0; i--) cout << y[i];         cout <<    ;         for (int i = 0; i < t.length(); i++) cout << a[i];       }     }   }
#include <bits/stdc++.h>   bool match(const char* text, const char* pattern, int n, int m) {     int post = 0, posp = 0;     while (post < n && posp < m) {       if (text[post] == pattern[posp]) {         ++post;         ++posp;       } else         ++post;     }     return (posp == m);   }   char data[200002], filt[200002], srch[200002], pat[200002];   int perm[200002];   int main() {     scanf( %s , data + 1);     scanf( %s , pat);     int n = strlen(data + 1);     int m = strlen(pat);     for (int _k = (1), _n = (n), i = _k; i <= _n; ++i) {       scanf( %d , &perm[i]);     }     int lo = 0;     int hi = n;     while (lo <= hi) {       int mid = (lo + hi) / 2;       memcpy(filt + 1, data + 1, n + 1);       for (int _k = (1), _n = (mid), i = _k; i <= _n; ++i) filt[perm[i]] = -1;       int pos = 0;       memset(srch, 0, n);       for (int _k = (1), _n = (n), i = _k; i <= _n; ++i)         if (filt[i] != -1) srch[pos++] = filt[i];       if (!match(srch, pat, pos, m))         hi = mid - 1;       else         lo = mid + 1;     }     int answer = hi;     printf( %d n , answer);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, n;   int a[200010];   int sum;   int ans[200010];   map<int, vector<pair<int, int> > > o;   int exgcd(int a, int b, int &x, int &y) {     if (!b) {       x = 1, y = 0;       return a;     }     int t = exgcd(b, a % b, y, x);     y -= a / b * x;     return t;   }   int main() {     scanf( %d%d , &T, &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       sum = (sum + a[i]) % T;       a[i] = i == 1 ? 0 : (a[i] + a[i - 1]) % T;     }     int x, y;     int len = exgcd(sum, T, x, y);     int tot = T / len;     for (int i = 1; i <= n; i++) {       int cas = a[i] % len, num = tot - a[i] / len;       num = 1ll * num * x % tot;       o[cas].push_back(make_pair(num, i));     }     for (pair<int, vector<pair<int, int> > > u : o) {       vector<pair<int, int> > p = u.second;       sort(p.begin(), p.end());       int last = p.back().first - tot;       for (pair<int, int> v : p) ans[v.second] = v.first - last, last = v.first;     }     for (int i = 1; i <= n; i++) printf( %d%c , ans[i], i == n ?   n  :    );   }
#include <bits/stdc++.h>   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     int n;     std::cin >> n;     std::vector<std::vector<int>> a(n, std::vector<int>(n));     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         a[i][j] = 4 * (i % (n / 2) * (n / 2) + j % (n / 2)) + i / (n / 2) * 2 +                   j / (n / 2);       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         std::cout << a[i][j] <<    ;       }       std::cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int64_t n, k, m;     cin >> n >> k >> m;     int64_t ans = 0;     vector<vector<int64_t>> dp(n + 1, vector<int64_t>(k + 1));     vector<int64_t> u(n + 1);     vector<int64_t> g(n + 1);     dp[0][0] = 1;     u[1] = 1;     for (int64_t i = 2; i <= n; i++) u[i] = u[i - 1] * 10 % k;     g[1] = 9;     g[0] = 1;     for (int64_t i = 2; i <= n; i++) g[i] = g[i - 1] * 10 % m;     for (int64_t i = 1; i <= n; i++) {       for (int64_t j = 0; j <= k - 1; j++) {         for (int64_t l = 0; l <= 9; l++) {           if ((l) && ((j + l * u[i]) % k == 0)) {             ans = (ans + dp[i - 1][j] * g[n - i]) % m;           } else             dp[i][(j + l * u[i]) % k] =                 (dp[i][(j + l * u[i]) % k] + dp[i - 1][j]) % m;         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   inline long long qr() {     long long x = 0, f = 1;     char ch;     while (!isdigit(ch = getchar()))       if (ch ==  - ) f = -1;     for (; isdigit(ch); x = x * 10 + ch - 48, ch = getchar())       ;     return x * f;   }   const int N = 100010;   int n, k, a[N], res;   int s[N], top, b[N], c[N];   int lt[N], nt[N];   vector<int> ans[500];   int LIS() {     for (int i = 1; i <= top; ++i) b[i] = lt[i] = nt[i] = 0;     s[top = 1] = 1e5 + 1;     for (int i = 1; i <= n; ++i) {       int p = upper_bound(s + 1, s + 1 + top, a[i]) - s;       s[p] = a[i];       lt[i] = b[p];       b[p] = i;       nt[i] = b[p - 1];       if (p == top) s[++top] = 1e5 + 1;     }     return top - 1;   }   void Find(int x) {     ans[++res].clear();     for (int i = b[x]; i; i = nt[i]) ans[res].push_back(a[i]), a[i] = -1;   }   void Div(int n) {     for (int i = 1; i <= n; ++i) {       ans[++res].clear();       for (int j = b[i]; j; j = lt[j]) ans[res].push_back(a[j]);     }   }   int main() {     int kase = qr();     while (kase--) {       n = qr();       res = 0;       for (int i = 1; i <= n; ++i) a[i] = qr();       while (n) {         int k = LIS();         if (1LL * k * (k + 1) > 2 * n)           Find(k);         else {           Div(k);           break;         }         int ct = 0;         for (int i = 1; i <= n; ++i)           if (a[i] != -1) a[++ct] = a[i];         n = ct;       }       printf( %d n , res);       for (int i = 1; i <= res; ++i) {         int l = ans[i].size();         printf( %d  , l);         for (int j = l - 1; j >= 0; --j) printf( %d  , ans[i][j]);         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, x;     cin >> n >> x;     vector<int> v[n + 1];     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       v[a].push_back(b);       v[b].push_back(a);     }     bool vstd[n + 1];     int dst1[n + 1];     int dst2[n + 1];     memset(vstd, false, sizeof vstd);     memset(dst1, 0x7f, sizeof dst1);     memset(dst2, 0x7f, sizeof dst2);     queue<int> q;     q.push(1);     dst1[1] = 0;     while (q.size()) {       int node = q.front();       q.pop();       if (vstd[node]) continue;       vstd[node] = true;       for (auto u : v[node]) {         dst1[u] = min(dst1[u], dst1[node] + 1);         q.push(u);       }     }     q.push(x);     dst2[x] = 0;     memset(vstd, false, sizeof vstd);     while (q.size()) {       int node = q.front();       q.pop();       if (vstd[node]) continue;       vstd[node] = true;       for (auto u : v[node]) {         dst2[u] = min(dst2[u], dst2[node] + 1);         q.push(u);       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       if (dst1[i] > dst2[i]) {         ans = max(ans, max(2 * dst1[i], 2 * dst2[i]));       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s;   pair<int, int> A[200000];   pair<pair<int, int>, int> B[200000];   set<pair<pair<int, int>, int> > candidates;   pair<int, int> q[200000];   int sp, st;   int answer[200000];   bool check(int days) {     int j = n - 1;     sp = st = 0;     int used = 0;     candidates.clear();     for (int i = m - 1; i >= 0; --i) {       while (j >= 0 && B[j].first.first >= A[i].first) {         candidates.insert(make_pair(             make_pair(B[j].first.second, B[j].first.first), B[j].second));         --j;       }       if (st < sp) {         answer[A[i].second] = q[st].second + 1;         --q[st].first;         if (q[st].first == 0) ++st;       } else {         if (candidates.size() == 0) return false;         pair<pair<int, int>, int> best = *candidates.begin();         candidates.erase(candidates.begin());         used += best.first.first;         if (used > s) return false;         answer[A[i].second] = best.second + 1;         if (days > 1) q[sp++] = make_pair(days - 1, best.second);       }     }     return true;   }   int main() {     scanf( %d %d %d , &n, &m, &s);     for (int i = 0; i < m; ++i) {       scanf( %d , &A[i].first);       A[i].second = i;     }     for (int i = 0; i < n; ++i) {       scanf( %d , &B[i].first.first);       B[i].second = i;     }     for (int i = 0; i < n; ++i) scanf( %d , &B[i].first.second);     sort(A, A + m);     sort(B, B + n);     int left = 1, right = m;     while (left < right) {       int middle = (left + right) / 2;       if (check(middle))         right = middle;       else         left = middle + 1;     }     if (check(left)) {       printf( YES n%d , answer[0]);       for (int i = 1; i < m; ++i) printf(  %d , answer[i]);       printf(  n );     } else {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace debug {   void __(short x) { cout << x; }   void __(int x) { cout << x; }   void __(long long x) { cout << x; }   void __(unsigned long long x) { cout << x; }   void __(double x) { cout << x; }   void __(long double x) { cout << x; }   void __(char x) { cout << x; }   void __(const char* x) { cout << x; }   void __(const string& x) { cout << x; }   void __(bool x) { cout << (x ?  true  :  false ); }   template <class P1, class P2>   void __(const pair<P1, P2>& x) {     __( ( ), __(x.first), __( ,  ), __(x.second), __( ) );   }   template <class T>   void __(const vector<T>& x) {     __( { );     bool _ffs = 0;     for (const auto& v : x) __(_ffs ?  ,   :   ), __(v), _ffs = 1;     __( } );   }   void screm() { __(  n ); }   template <class T1, class... T2>   void screm(const T1& t1, const T2&... t2) {     __(t1);     if (sizeof...(t2))       __(  |  ), screm(t2...);     else       __(  n );   }   void pr() { __(  n ); }   template <class T1, class... T2>   void pr(const T1& t1, const T2&... t2) {     __(t1);     if (sizeof...(t2))       __(   ), pr(t2...);     else       __(  n );   }   }  // namespace debug   using namespace debug;   long long h, m, k, ans, h1, h2, m1, m2, ms, mh, mmm;   int main() {     scanf( %lld%lld%lld%lld%lld%lld%lld , &h, &m, &k, &h1, &m1, &h2, &m2);     long long sw = m - 1;     while (sw) {       if (sw % 10 != 0) ms++;       sw /= 10;     }     sw = h - 1;     while (sw) {       if (sw % 10 != 0) mh++;       sw /= 10;     }     int ch = max(0LL, k - ms - 1);     long long mn = 1, hr = 1;     for (int i = 0; i < k - 1; i++) mn *= 10;     for (int i = 0; i < ch; i++) hr *= 10;     if (h1 == h2 && m1 <= m2) {       ans += (m2 / mn);       if (m1 > 1) ans -= (m1 / mn);       printf( %lld n , ans);       return 0;     }     if (m1) ans += ((m - 1) / mn) - (m1 / mn);     long long rr = h1;     ans -= (h1 / hr);     int flg = 0;     if (m1) {       h1++;       m1 = 0;       if (h1 == h) {         h1 = 0;         if (ms + mh >= k) ans++;       } else if ((h1 / hr) != (rr / hr))         ans++, flg = 1;     }     if (m2) ans += (m2 / mn), m2 = 0;     long long kek = (m - 1) / mn;     if (h1 > h2) {       ans += ((h - 1) / hr) + (h2 / hr) - flg;       long long delta = (h - h1) + (h2);       ans += delta * kek;       if (ms + mh >= k) ans++;     } else {       ans += (rr / hr) - (h1 / hr) + (h2 / hr) + kek * (h2 - h1);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     vector<int> a(n);     long long sum = 0;     for (int& x : a) {       scanf( %d , &x);       sum += x;     }     if (sum != 0) {       puts( YES );       puts( 1 );       printf( %d %d n , 1, n);       exit(0);     }     sum = 0;     for (int i = 0; i < n; i++) {       sum += a[i];       if (sum != 0) {         puts( YES );         puts( 2 );         printf( %d %d n , 1, i + 1);         printf( %d %d n , i + 2, n);         exit(0);       }     }     puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, s, ans = 0, mid = 0;     scanf( %lld %lld , &n, &s);     long long int a[n];     for (int i = 0; i < n; i++) scanf( %lld , &a[i]);     sort(a, a + n);     mid = n / 2;     if (s >= a[mid]) {       for (int i = n / 2; i < n; i++) {         if (a[i] >= s)           break;         else           ans += abs(s - a[i]);       }     } else {       for (int i = n / 2; i >= 0; i--) {         if (a[i] <= s)           break;         else           ans += abs(a[i] - s);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, tot, ans, Head[100000 + 5], q[100000 + 5], T[100000 + 5],       Deg[100000 + 5];   bool Flag[100000 + 5];   struct Edge {     int next, node;   } h[100000 + 5 << 1];   inline void addedge(int u, int v) {     h[++tot].next = Head[u], Head[u] = tot;     h[tot].node = v;   }   inline void dfs(int z) {     if (Flag[z]) return;     Flag[z] = 1;     q[++q[0]] = z;     for (int i = Head[z]; i; i = h[i].next) {       int d = h[i].node;       dfs(d);     }   }   inline bool T_Sort() {     int l = 1, r = 0;     for (int i = 1; i <= q[0]; i++)       if (!Deg[q[i]]) T[++r] = q[i];     while (l <= r) {       int z = T[l++];       for (int i = Head[z]; i; i = h[i].next) {         if (i + 1 & 1) continue;         int d = h[i].node;         Deg[d]--;         if (!Deg[d]) T[++r] = d;       }     }     return r == q[0];   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1, u, v; i <= m; i++) {       scanf( %d%d , &u, &v);       addedge(u, v), addedge(v, u);       Deg[v]++;     }     for (int i = 1; i <= n; i++) {       if (Flag[i]) continue;       q[0] = 0;       dfs(i);       ans += T_Sort() ? q[0] - 1 : q[0];     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int mas[105] = {0};     int n;     scanf( %d  , &n);     int res = -1;     int resl = -1;     for (int i = 0; i < n; i++) scanf( %d  , &mas[i]);     for (int i = 0; i < n; i++) {       int len = 0;       int mest = 0;       for (int j = i; j < n; j++) {         len++;         mest ^= mas[j];         if (mest > res) {           res = mest;           resl = len;         }       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int A[1001][1001];   int n, m, k, i, j, l, r, a, b, x, y, p, q;   int main() {     cin >> n >> a >> b;     x = n / 2;     y = n - x;     p = 1;     q = 2;     for (i = 1; i <= a; i++)       for (j = 1; j <= b; j++) {         l = A[i - 1][j] % 2;         r = A[i][j - 1] % 2;         if (j == 1) r = l;         if (i == 1) l = r;         if (l != r) continue;         if (l == 1 && x)           A[i][j] = q, q += 2, x--;         else if (l == 0 && y)           A[i][j] = p, p += 2, y--;       }     if (x != 0 || y != 0) {       cout << -1;       return 0;     }     for (i = 1; i <= a; i++) {       for (j = 1; j <= b; j++) cout << A[i][j] <<    ;       cout << endl;     }   }