malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)1e5 + 10;   int n, m, k;   int fa[MAXN];   int visit[MAXN];   vector<int> res;   struct node {     int x, y, id;     double w;     node() {}     node(int x_, int y_, double w_, int id_) {       x = x_;       y = y_;       w = w_;       id = id_;     }     friend bool operator<(const node &a, const node &b) { return a.w < b.w; }   };   vector<node> e1, e2;   int getfa(int x) {     if (fa[x] == x) return x;     return fa[x] = getfa(fa[x]);   }   int get_ans(double mid, int K = -1) {     static node e[MAXN];     for (int i = 0; i < e1.size(); i++) e1[i].w += mid;     for (int i = 1; i <= n; i++) fa[i] = i;     int cnt = 0;     merge(e1.begin(), e1.end(), e2.begin(), e2.end(), e) - e;     res.clear();     for (int i = 0; i < m; i++) {       if ((e[i].x == 1 || e[i].y == 1) && cnt == K) continue;       int x = getfa(e[i].x), y = getfa(e[i].y);       if (x != y) {         res.push_back(e[i].id);         if (e[i].x == 1 || e[i].y == 1) ++cnt;         fa[x] = y;       }     }     for (int i = 0; i < e1.size(); i++) e1[i].w -= mid;     return cnt;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) fa[i] = i;     int las = n;     for (int i = 0; i < m; i++) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       if (u == 1 || v == 1)         e1.push_back(node(u, v, (double)w, i + 1));       else         e2.push_back(node(u, v, (double)w, i + 1));       if (getfa(u) != getfa(v)) {         fa[getfa(u)] = getfa(v);         las--;       }     }     if (e1.size() < k || (las != 1)) {       printf( -1 n );       return 0;     }     sort(e1.begin(), e1.end());     sort(e2.begin(), e2.end());     double l = -1e6, r = 1e6, ans = -1;     if (get_ans(l) < k || get_ans(r) > k) {       printf( -1 n );       return 0;     }     for (int i = 1; i < 50; i++) {       int mid = (l + r) / 2.0;       if (get_ans(mid) >= k) {         ans = mid;         l = mid;       } else         r = mid;     }     get_ans(ans, k);     cout << res.size() << endl;     for (int i = 0; i < res.size(); i++) printf( %d  , res[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double gen(double x, double y, double z) { return log(log(x)) + z * log(y); }   double gen(double x, double y) { return log(log(x)) + log(y); }   vector<pair<double, string> > genall(double x, double y, double z) {     vector<pair<double, string> > r;     if (x > 1.) {       r.push_back(pair<double, string>(gen(x, y, z),  x^y^z ));       r.push_back(pair<double, string>(gen(x, z, y),  x^z^y ));       r.push_back(pair<double, string>(gen(x, y * z),  (x^y)^z ));     }     if (y > 1.) {       r.push_back(pair<double, string>(gen(y, x, z),  y^x^z ));       r.push_back(pair<double, string>(gen(y, z, x),  y^z^x ));       r.push_back(pair<double, string>(gen(y, x * z),  (y^x)^z ));     }     if (z > 1.) {       r.push_back(pair<double, string>(gen(z, x, y),  z^x^y ));       r.push_back(pair<double, string>(gen(z, y, x),  z^y^x ));       r.push_back(pair<double, string>(gen(z, x * y),  (z^x)^y ));     }     return r;   }   int main() {     double x, y, z;     cin >> x >> y >> z;     if (x <= 1. && y <= 1. && z <= 1.) {       vector<pair<double, string> > r;       if (x == 1.) {         cout <<  x^y^z  << endl;         return 0;       }       if (y == 1.) {         cout <<  y^x^z  << endl;         return 0;       }       if (z == 1.) {         cout <<  z^x^y  << endl;         return 0;       }       auto v1 = genall(1. / x, y, z);       auto v2 = genall(x, 1. / y, z);       auto v3 = genall(x, y, 1. / z);       r.insert(r.end(), v1.begin(), v1.end());       r.insert(r.end(), v2.begin(), v2.end());       r.insert(r.end(), v3.begin(), v3.end());       auto it =           min_element(r.begin(), r.end(),                       [](pair<double, string> lhs, pair<double, string> rhs) {                         return lhs.first < rhs.first;                       });       cout << it->second << endl;     } else {       auto v = genall(x, y, z);       auto it =           max_element(v.begin(), v.end(),                       [](pair<double, string> lhs, pair<double, string> rhs) {                         return lhs.first < rhs.first;                       });       cout << it->second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void run();   int main() {     ios::sync_with_stdio(0);     run();   }   int n;   int v[5001];   char s[5001];   int grundy[5001];   void run() {     cin >> s;     n = strlen(s);     vector<int> blob;     for (int i = 0; i < n; i++)       if (0 < i and i + 1 < n and s[i - 1] == s[i + 1])         blob.back()++;       else if (blob.empty() or blob.back())         blob.push_back(0);     if (not blob.empty() and blob.back() == 0) blob.pop_back();     static int can[5001];     for (int i = 1; i <= 5000; i++) {       for (int j = 0; j < i; j++) {         can[grundy[max(0, j - 1)] ^ grundy[max(0, i - j - 2)]] = i;       }       while (can[grundy[i]] == i) ++grundy[i];     }     int good = 0;     for (int i : blob) good ^= grundy[i];     cout << (good ?  First  :  Second ) << endl;     if (good) {       int id = 0;       for (int i = 1, x = 0; i + 1 < n; ++i, ++x) {         if (s[i - 1] == s[i + 1]) {           if (i > 1 and s[i - 2] != s[i + 0]) ++id, x = 0;           int val = good ^ grundy[blob[id]];           if (val == (grundy[max(0, x - 1)] ^ grundy[max(0, blob[id] - x - 2)])) {             cout << i + 1 << endl;             return;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int pa[5009], siz[5009], occ[5009], tots = 0;   bool yay;   vector<pair<int, pair<int, int> > > edges;   int finder(int node) {     if (pa[node] != node) {       return pa[node] = finder(pa[node]);     }     return node;   }   void uniter(int x, int y) {     x = finder(x);     y = finder(y);     if (x == y) {       return;     }     pa[y] = x;     siz[x] += siz[y];     occ[x] += occ[y];     if (tots - occ[x] < siz[x]) {       yay = false;     }     return;   }   int main() {     int i, j, t1, t2, t3, t4, n, ans = 0;     scanf( %d , &n);     for (i = 0; i < n - 1; i++) {       scanf( %d %d %d , &t1, &t2, &t3);       edges.push_back(make_pair(t3, make_pair(t1, t2)));     }     sort(edges.begin(), edges.end());     for (i = 1; i <= n; i++) {       pa[i] = i;       siz[i] = 1;       scanf( %d , &occ[i]);       tots += occ[i];     }     if (n == 1) {       printf( 0 n );       return 0;     }     ans = edges[0].first;     yay = true;     for (i = 0; i < n - 1;) {       j = i;       while (edges[i].first == edges[j].first && j < n - 1) {         uniter(edges[j].second.first, edges[j].second.second);         j++;       }       if (yay && j < n - 1) {         ans = edges[j].first;       }       i = j;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     string s, s1;     cin >> s >> s1;     string s2;     cin >> s2;     map<char, char> m;     for (long long i = 0; i < 26; i++) {       m[s[i]] = s1[i];     }     string ans =   ;     long long cnt = 0;     for (long long i = 0; i < s2.size(); i++) {       if (s2[i] >= 48 && s2[i] <= 57) {         ans += s2[i];       } else if (isupper(s2[i])) {         s2[i] += 32;         char c = m[s2[i]];         c -= 32;         ans += c;       } else if (islower(s2[i])) {         ans += m[s2[i]];       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int arr[3000000];   long long fadd[3000000];   long long carry[3000000];   long long tot[3000000];   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i];     int nsize = 2 * n + 1;     for (int i = 0; i < nsize; i++) fadd[i] = carry[i] = tot[i] = 0;     for (int i = 0; i < n; i++) {       int k = i + 1;       int x = arr[i];       fadd[n - k + 1] += x - 1;       carry[n - k + 1] -= 1;       carry[n - k + x] += 2;       carry[2 * n - k] -= 1;       fadd[2 * n - k + 1] += x - n;     }     long long ctot = 0;     long long ccarry = 0;     for (int i = 0; i < nsize; i++) {       ctot += fadd[i] + ccarry;       ccarry += carry[i];       tot[i] = ctot;       if (i >= n) tot[i % n] += tot[i];     }     long long ans = 1e12;     int bval = 0;     for (int i = 0; i < n; i++) {       if (tot[i] < ans) {         ans = tot[i];         bval = i;       }     }     cout << ans <<     << bval <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long n, sx, sy, dx, dy, t;   struct matrix {     long long m[8][8];     matrix() { memset(m, 0, sizeof(m)); }   };   matrix mul(matrix a, matrix b) {     matrix tmp;     for (int i = 1; i <= 6; i++)       for (int k = 1; k <= 6; k++)         if (a.m[i][k])           for (int j = 1; j <= 6; j++)             tmp.m[i][j] = (tmp.m[i][j] + a.m[i][k] * b.m[k][j] + n) % n;     return tmp;   }   matrix powmul(matrix a, long long t) {     matrix tmp;     for (int i = 1; i <= 6; i++) tmp.m[i][i] = 1;     while (t) {       if (t & 1) tmp = mul(tmp, a);       a = mul(a, a);       t >>= 1;     }     return tmp;   }   int main() {     scanf( %lld%lld%lld%lld%lld%lld , &n, &sx, &sy, &dx, &dy, &t);     matrix base;     base.m[1][2] = base.m[1][3] = base.m[1][5] = 1;     base.m[2][1] = base.m[2][4] = base.m[2][5] = 1;     base.m[3][1] = base.m[3][2] = base.m[3][3] = base.m[3][5] = 1;     base.m[4][1] = base.m[4][2] = base.m[4][4] = base.m[4][5] = 1;     base.m[5][5] = base.m[5][6] = base.m[6][6] = 1;     base.m[2][2] = base.m[1][1] = base.m[1][6] = base.m[2][6] = base.m[3][6] =         base.m[4][6] = 2;     base = powmul(base, t);     matrix ans;     ans.m[1][1] = sx - 1;     ans.m[2][1] = sy - 1;     ans.m[3][1] = (dx % n + n) % n;     ans.m[4][1] = (dy % n + n) % n;     ans.m[6][1] = 1;     ans = mul(base, ans);     printf( %lld %lld n , ans.m[1][1] + 1, ans.m[2][1] + 1);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 400007;   int n, I, cnt = 0, ret = -1;   int a[maxn], s[maxn];   int ck() {     int ans = 1;     for (int i = 1; i <= 8 * I / n; ++i) {       ans *= 2;       if (ans > cnt) return -1;     }     return ans;   }   int main() {     scanf( %d%d , &n, &I);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);     }     memset(s, 0, sizeof(s));     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; ++i) {       if (a[i] != ret) {         ret = a[i], cnt++;       }       s[cnt]++;     }     for (int i = 1; i <= cnt; ++i) {       s[i] += s[i - 1];     }     int pI = ck();     if (pI == -1) {       printf( %d n , 0);       return 0;     }     int ans = 0;     for (int i = pI; i <= cnt; ++i) {       ans = max(ans, s[i] - s[i - pI]);     }     printf( %d n , n - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string ss;   int dp[200005][4];   char s[] = { R ,  G ,  B };   int calc(int u, int c) {     if (u == n) return 0;     if (dp[u][c] != -1) return dp[u][c];     int ret = n;     for (int i = 0; i < 3; i++) {       if (i == c) continue;       if (s[i] == ss[u])         ret = min(ret, calc(u + 1, i));       else         ret = min(ret, 1 + calc(u + 1, i));     }     return dp[u][c] = ret;   }   void print(int u, int c) {     if (u == n) return;     for (int i = 0; i < 3; i++) {       if (i == c) continue;       if (s[i] == ss[u]) {         if (dp[u][c] == calc(u + 1, i)) {           printf( %c , s[i]);           print(u + 1, i);           return;         }       } else {         if (dp[u][c] == 1 + calc(u + 1, i)) {           printf( %c , s[i]);           print(u + 1, i);           return;         }       }     }   }   int main() {     memset(dp, -1, sizeof dp);     cin >> n;     cin >> ss;     int ans = calc(0, 3);     cout << ans << endl;     print(0, 3);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, Q;   int cnt_bad = 0;   bool bad[2][100100];   int main() {     scanf( %d%d , &n, &Q);     memset(bad, 0, sizeof(bad));     for (int i = 0; i < Q; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--, y--;       if (bad[x][y]) {         bad[x][y] = 0;         if (y - 1 >= 0) cnt_bad -= bad[x ^ 1][y - 1];         cnt_bad -= bad[x ^ 1][y];         if (y + 1 < n) cnt_bad -= bad[x ^ 1][y + 1];       } else {         bad[x][y] = 1;         if (y - 1 >= 0) cnt_bad += bad[x ^ 1][y - 1];         cnt_bad += bad[x ^ 1][y];         if (y + 1 < n) cnt_bad += bad[x ^ 1][y + 1];       }       if (cnt_bad == 0)         printf( Yes n );       else         printf( No n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, fr, x0, L, R, len, l[4000], f[4000];   string s1[4000], s2[4000], ss, p, p1;   int main() {     ios::sync_with_stdio(0);     cin >> n;     for (int i = (1); i <= (n); i++) {       cin >> s1[i];       l[i] = s1[i].length() - 1;     }     for (int i = (1); i <= (n); i++) cin >> s2[i];     for (int i = (1); i <= (n); i++)       if (s1[i] != s2[i]) {         if (fr) {           for (int j = (0); j <= (l[i]); j++)             if (s1[i][j] != s2[i][j]) {               x = j;               break;             }           for (int j = (0); j <= (L); j++)             if (x - j < 0 || s1[i][x - j] != s1[fr][x0 - j] ||                 s2[i][x - j] != s2[fr][x0 - j]) {               L = j - 1;               break;             }           for (int j = (0); j <= (R); j++)             if (x + j > l[i] || s1[i][x + j] != s1[fr][x0 + j] ||                 s2[i][x + j] != s2[fr][x0 + j]) {               R = j - 1;               break;             }         } else {           fr = i;           for (int j = (0); j <= (l[i]); j++)             if (s1[i][j] != s2[i][j]) {               x0 = j;               break;             }           L = x0;           R = l[i] - x0;         }       }     if (L == -1) {       cout <<  NO n ;       return 0;     }     for (int i = (x0 - L); i <= (x0 + R); i++)       p = p + s1[fr][i], p1 = p1 + s2[fr][i];     len = p.length() - 1;     f[0] = -1;     for (int i = (1); i <= (len); i++) {       for (x = f[i - 1]; ~x; x = f[x])         if (p[i - 1] == p[x]) break;       f[i] = x + 1;     }     for (int i = (1); i <= (n); i++) {       x = 0;       for (int j = (0); j <= (l[i]); j++) {         while (~x && p[x] != s1[i][j]) x = f[x];         x++;         if (x > len) {           ss = s1[i];           for (int k = (0); k <= (len); k++) ss[j - len + k] = p1[k];           if (ss != s2[i]) {             cout <<  NO n ;             return 0;           }           break;         }       }       if (x <= len && s1[i] != s2[i]) {         cout <<  NO n ;         return 0;       }     }     cout <<  YES n  << p <<   n  << p1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t N = 1e3 + 3;   const int64_t mod = 998244353;   int64_t f[N][2][2][2 * N];   int64_t more(int64_t x, int64_t y, int64_t u, int64_t v) {     if (x == y) {       if (u != x || v != y) return 1;       return 0;     }     if (u != x && v != y) return 2;     return 0;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int64_t n, k;     cin >> n >> k;     f[1][0][1][2] = 1;     f[1][0][0][1] = 1;     f[1][1][1][1] = 1;     f[1][1][0][2] = 1;     for (int64_t i = 1; i < n; i++)       for (int64_t x = 0; x < 2; x++)         for (int64_t y = 0; y < 2; y++)           for (int64_t c = 1; c <= 2 * i; c++) {             for (int64_t nx = 0; nx < 2; nx++)               for (int64_t ny = 0; ny < 2; ny++) {                 int64_t _c = c + more(x, y, nx, ny);                 (f[i + 1][nx][ny][_c] += f[i][x][y][c]) %= mod;               }           }     cout << (f[n][0][0][k] + f[n][0][1][k] + f[n][1][0][k] + f[n][1][1][k]) % mod;   }
#include <bits/stdc++.h>   int main() {     int NumOfStudent;     int NumOfTeams;     int ones = 0, twos = 0, threes = 0;     int i, k, l, j, c, m, n, p;     int a[5000];     scanf( %d , &NumOfStudent);     for (i = 0; i < NumOfStudent; i++) {       scanf( %d , &a[i]);     }     for (i = 0; i < NumOfStudent; i++) {       m = 0;       n = 0;       p = 0;       for (m = 0; m < NumOfStudent; m++) {         if (a[m] == 1) {           ones = ones + 1;         }       }       for (n = 0; n < NumOfStudent; n++) {         if (a[n] == 2) {           twos = twos + 1;         }       }       for (p = 0; p < NumOfStudent; p++) {         if (a[p] == 3) {           threes = threes + 1;         }       }       int b[3] = {ones, twos, threes};       NumOfTeams = b[0];       for (c = 1; c < 3; c++) {         if (b[c] < NumOfTeams) {           NumOfTeams = b[c];         }       }       printf(  n%d , NumOfTeams);       if (ones == 0 || twos == 0 || threes == 0) {       } else {         i = 0;         j = 0;         k = 0;         l = 0;         for (j = 0; j < NumOfTeams; j++) {           while (i < NumOfStudent && a[i] != 1) {             i++;           }           a[i] = 0;           printf(  n%d  , i + 1);           while (k < NumOfStudent && a[k] != 2) {             k++;           }           a[k] = 0;           printf( %d  , k + 1);           while (l < NumOfStudent && a[l] != 3) {             l++;           }           a[l] = 0;           printf( %d  , l + 1);         }       }       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[10][110], b[410];   int main() {     while (~scanf( %d%d , &n, &m)) {       memset(a, 0, sizeof(a));       for (int i = 1; i <= min(m, 2 * n); i++) {         if (i & 1) {           a[1][(i + 1) >> 1] = i;         } else {           a[4][i >> 1] = i;         }       }       for (int i = 2 * n + 1; i <= m; i++) {         if (i & 1) {           a[2][(i - 2 * n + 1) >> 1] = i;         } else {           a[3][(i - 2 * n) >> 1] = i;         }       }       int cnt = 0;       for (int i = 1; i <= n; i++) {         if (a[2][i]) b[cnt++] = a[2][i];         if (a[1][i]) b[cnt++] = a[1][i];         if (a[3][i]) b[cnt++] = a[3][i];         if (a[4][i]) b[cnt++] = a[4][i];       }       for (int i = 0; i < cnt - 1; i++) printf( %d  , b[i]);       printf( %d n , b[cnt - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   const int N = 142123;   int n, a, b, c, d, s, ce;   long long ans;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> a >> b >> ce >> d;     for (int i = 1; i <= n; ++i) {       s = a + b + i;       c = s - a - ce;       if (c < 1 || n < c) continue;       c = s - b - d;       if (c < 1 || n < c) continue;       c = s - ce - d;       if (c < 1 || n < c) continue;       ans += n;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   char s[1010];   int n, fa[2010], val[2010], pw2[2010], ans = 0;   inline int getf(int x) {     if (x == fa[x]) return x;     int f = getf(fa[x]);     val[x] ^= val[fa[x]];     fa[x] = f;     return f;   }   inline int merge(int x, int y, int w) {     int ti = getf(x), tj = getf(y);     if (ti == tj) return w == (val[x] ^ val[y]);     w ^= val[x] ^ val[y];     fa[ti] = tj;     val[ti] = w;     return 1;   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     reverse(s + 1, s + n + 1);     pw2[0] = 1;     for (int i = 1; i <= n; i++) pw2[i] = (pw2[i - 1] + pw2[i - 1]) % mod;     int ans = 0;     for (int lena = n - 1; lena >= 1; lena--) {       for (int j = 1; j <= ((n << 1) + 1); j++) fa[j] = j, val[j] = 0;       if (!merge((n), ((n << 1) + 1), 0)) continue;       if (!merge((n + n), ((n << 1) + 1), 1)) continue;       bool fail = 0;       for (int j = 1; j <= n / 2; j++) {         if (!merge((j + n), (n + 1 - j + n), 0)) {           fail = 1;           break;         }       }       if (fail) continue;       for (int j = 1; j <= lena / 2; j++) {         if (!merge((j), (lena + 1 - j), 0)) {           fail = 1;           break;         }       }       if (fail) continue;       for (int j = lena + 1; j < n; j++) {         if (!merge((j), ((n << 1) + 1), 0)) {           fail = 1;           break;         }       }       if (!merge((lena), ((n << 1) + 1), 1)) fail = 1;       if (fail) continue;       for (int j = 1; j <= n; j++) {         if (s[j] ==  0 ) {           if (!merge((j), (j + n), 0)) {             fail = 1;             break;           }         } else if (s[j] ==  1 ) {           if (!merge((j), (j + n), 1)) {             fail = 1;             break;           }         }       }       if (fail) continue;       int cnt = 0;       for (int j = 1; j <= ((n << 1) + 1); j++)         if (getf(j) == j && getf(j) != getf(((n << 1) + 1))) cnt++;       ans = (ans + pw2[cnt]) % mod;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) {       int n;       cin >> n;       vector<long long int> a(n);       for (long long int i = 0; i < n; i++) cin >> a[i];       sort((a).begin(), (a).end());       int c = 0;       for (long long int i = 0; i < n; i++) {         int m = upper_bound((a).begin(), (a).end(), a[i] + 5) - a.begin() - i;         if (m > c) c = m;       }       cout << c;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 20;   int ans, a, m, n;   long long ps0[N], ps1[N], arr[N], inf = 1e10 + 100;   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n >> arr[0];     arr[n] = inf;     ps0[0] = 0;     for (int i = 1; i < n; i++) {       cin >> arr[i];       ps0[i] = ps0[i - 1] + arr[i] - arr[i - 1];     }     ps1[n - 1] = 0;     for (int i = n - 2; i >= 0; i--) {       ps1[i] = arr[i + 1] - arr[i] + ps1[i + 1];     }     cout << arr[1] - arr[0] <<     << ps1[0] << endl;     for (int i = 1; i < n; i++) {       cout << min(arr[i] - arr[i - 1], arr[i + 1] - arr[i]) <<                << max(ps0[i], ps1[i]) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (int)1e6 + 100;   const long long inf = (1ll << 60);   const int mod2 = (int)998244353;   const int mod = (int)1e9 + 7;   int n, m;   struct query {     int type;     int x1, y1, x2, y2;     long long v;   } Q[maxn];   struct fenwick {     long long a[1010][1010];     void clear() { memset(a, 0, sizeof a); }     long long get(int x, int y) {       long long res = 0;       for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {         for (int j = y; j >= 0; j = (j & (j + 1)) - 1) {           res ^= a[i][j];         }       }       return res;     }     void update(int x, int y, long long c) {       for (int i = x; i <= n; i |= i + 1) {         for (int j = y; j <= n; j |= j + 1) {           a[i][j] ^= c;         }       }     }     long long get(int x1, int y1, int x2, int y2) {       return get(x2, y2) ^ get(x1 - 1, y2) ^ get(x2, y1 - 1) ^              get(x1 - 1, y1 - 1);     }   } F[2][2];   long long get(int x1, int y1) { return F[x1 % 2][y1 % 2].get(x1, y1); }   long long get(int x1, int y1, int x2, int y2) {     return get(x2, y2) ^ get(x1 - 1, y2) ^ get(x2, y1 - 1) ^ get(x1 - 1, y1 - 1);   }   void update(int x1, int y1, long long c) {     F[x1 % 2][y1 % 2].update(x1, y1, c);   }   void updateRange(int x1, int y1, int x2, int y2, long long c) {     update(x1, y1, c);     update(x2 + 1, y1, c);     update(x1, y2 + 1, c);     update(x2 + 1, y2 + 1, c);   }   void solve() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       int type, x1, y1, x2, y2;       cin >> type >> x1 >> y1 >> x2 >> y2;       if (type == 2) {         long long v;         cin >> v;         updateRange(x1, y1, x2, y2, v);       } else {         cout << get(x1, y1, x2, y2) <<   n ;       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }