malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   const int N = 1e6 + 100;   pair<int, int> seg[4 * N];   int lazy[4 * N];   void shift(int nod) {     lazy[nod * 2] += lazy[nod];     lazy[nod * 2 + 1] += lazy[nod];     seg[nod * 2].first += lazy[nod];     seg[nod * 2 + 1].first += lazy[nod];     seg[nod * 2].second += lazy[nod];     seg[nod * 2 + 1].second += lazy[nod];     lazy[nod] = 0;   }   void upd(int nod, int l, int r, int L, int R, int val) {     if (l >= R || L >= r) {       return;     }     if (l >= L && r <= R) {       seg[nod].first += val;       seg[nod].second += val;       lazy[nod] += val;       return;     }     shift(nod);     int mid = (r + l) / 2;     upd(nod * 2, l, mid, L, R, val);     upd(nod * 2 + 1, mid, r, L, R, val);     seg[nod].first = max(seg[nod * 2].first, seg[nod * 2 + 1].first);     seg[nod].second = min(seg[nod * 2].second, seg[nod * 2 + 1].second);   }   int a[N];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int cnt = 1;     int to = 0, tc = 0;     for (int i = 0; i < n; i++) {       char c;       cin >> c;       if (c ==  ( ) {         if (a[cnt] == 1) {           if (to != tc || seg[1].second < 0) {             cout << -1 <<   n ;           } else {             cout << seg[1].first <<   n ;           }           continue;         }         if (a[cnt] == 2) {           upd(1, 1, N, cnt, N, +2);           tc--;         } else {           upd(1, 1, N, cnt, N, 1);         }         a[cnt] = 1;         to++;       }       if (c ==  ) ) {         if (a[cnt] == 2) {           if (to != tc || seg[1].second < 0) {             cout << -1 <<   n ;           } else {             cout << seg[1].first <<   n ;           }           continue;         }         if (a[cnt] == 1) {           upd(1, 1, N, cnt, N, -2);           to--;         } else {           upd(1, 1, N, cnt, N, -1);         }         tc++;         a[cnt] = 2;       }       if (c ==  R ) {         cnt++;       }       if (c ==  L ) {         cnt--;       }       if (c >=  a  && c <=  z ) {         if (a[cnt] == 1) {           a[cnt] = 0;           upd(1, 1, N, cnt, N, -1);           to--;         }         if (a[cnt] == 2) {           a[cnt] = 0;           upd(1, 1, N, cnt, N, +1);           tc--;         }       }       cnt = max(cnt, (int)1);       if (to != tc || seg[1].second < 0) {         cout << -1 <<   n ;       } else {         cout << seg[1].first <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a[1000001] = {0}, n;   int main() {     cin >> n;     long long sum = 0;     long s = 0, s1 = 0, s2 = 0, s3 = 0;     for (int k = 1; k <= n; ++k) {       cin >> a[k], sum += a[k];       if (a[k] == 1)         ++s;       else if (a[k] == 2)         ++s1;       else if (a[k] == 3)         ++s3;       else if (a[k] == 4)         s2++;     }     s3 += min(s, s1);     ;     if (sum == 1 || sum == 2 || sum == 5) {       cout << -1;       return 0;     }     sum = 0;     sum += min(s, s1);     s1 = s1 - s;     if (s1 < 0)       s = -s1, s1 = 0;     else       s = 0;     if (s > 0) {       sum += s - s / 3;       if (s == 1 && s3 == 0) ++sum;     }     if (s1 > 0) {       sum += s1 - s1 / 3;       if (s1 % 3 == 1 && s2 == 0) ++sum;     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long k;     cin >> n >> k;     k -= (long long)n * (n + 1) / 2;     if (k < 0) {       cout << -1 << endl;       return 0;     }     long long sum = (long long)n * (n + 1) / 2;     vector<int> ans;     for (int i = n - 1; i >= 0; i--) {       int add = max(0, n - 1 - (n - 1 - i) * 2);       if (k > add) {         ans.push_back(i);         ans[n - 1 - i] = i;         k -= add;         sum += add;       } else {         for (int j = 0; j < i; j++) {           ans.push_back(j);         }         ans.insert(ans.begin() + (n - 1 - i) + (add - k), i);         sum += k;         break;       }     }     cout << sum << endl;     for (int i = 0; i < n; i++) {       cout << i + 1;       if (i < n - 1) {         cout <<    ;       }     }     cout << endl;     for (int i = 0; i < n; i++) {       cout << ans[i] + 1;       if (i < n - 1) {         cout <<    ;       }     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 10;   int cnt[100 + 2][N + 2];   string s[100 + 2];   set<int> on[100 + 2], of[100 + 2];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> s[i];       s[i] =  #  + s[i] +  # ;       for (int j = 1; j <= m; j++) {         if (s[i][j] ==  . )           of[i].insert(j);         else           on[i].insert(j);       }       on[i].insert(0);       on[i].insert(m + 1);       of[i].insert(-1);       of[i].insert(m + 2);     }     long long ans = 0;     int a = 1, b = 1, d = 1;     while (true) {       if (clock() > CLOCKS_PER_SEC * 0.8) cout <<  Never n , exit(0);       if (a == n) break;       if (d) {         int cr = *on[a].lower_bound(b);         int nx = *of[a + 1].lower_bound(b);         if (nx < cr) {           ans += nx - b + 1;           a++;           b = nx;         } else {           ans += cr - b;           b = cr - 1;           d ^= 1;           if (s[a][cr] ==  + ) {             on[a].erase(cr);             s[a][cr] =  . ;             of[a].insert(cr);           }         }       } else {         auto it1 = on[a].upper_bound(b);         auto it2 = of[a + 1].upper_bound(b);         it1--, it2--;         int cr = *it1, nx = *it2;         if (nx > cr) {           ans += b - nx + 1;           a++;           b = nx;         } else {           ans += b - cr;           b = cr + 1;           d ^= 1;           if (s[a][cr] ==  + ) {             on[a].erase(cr);             s[a][cr] =  . ;             of[a].insert(cr);           }         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 998244353;   struct bucket {     long long size, minm;     vector<long long> off;     vector<long long> dps;     vector<long long> pre;     bucket(long long b) {       size = b;       off = vector<long long>(b);       pre = vector<long long>(b);       dps = vector<long long>(b);       minm = 0;     }     void updoff(long long p, long long l, long long r) {       assert(l >= 0 && l < size && r >= 0 && r < size && l <= r);       long long nmnm = INT_MAX;       for (long long j = l; j <= r; ++j) nmnm = min(nmnm, minm + off[j] + p);       for (long long j = 0; j < l; ++j) nmnm = min(nmnm, minm + off[j]);       for (long long j = r + 1; j < size; ++j) nmnm = min(nmnm, minm + off[j]);       for (long long j = 0; j < l; ++j) off[j] = off[j] + minm - nmnm;       for (long long j = l; j <= r; ++j) off[j] = off[j] + minm + p - nmnm;       for (long long j = r + 1; j < size; ++j) off[j] = off[j] + minm - nmnm;       minm = nmnm;       pre = vector<long long>(size);       for (long long j = 0; j < size; ++j)         pre[off[j]] = (pre[off[j]] + dps[j]) % mod;       for (long long j = 1; j < size; ++j) pre[j] = (pre[j] + pre[j - 1]) % mod;     }     void upddp(long long idx, long long newdp) {       dps[idx] = newdp;       pre = vector<long long>(size);       for (long long j = 0; j < size; ++j)         pre[off[j]] = (pre[off[j]] + dps[j]) % mod;       for (long long j = 1; j < size; ++j) pre[j] = (pre[j] + pre[j - 1]) % mod;     }   };   void update_offset(vector<bucket> &ds, long long n, long long l, long long r,                      long long p, long long b) {     assert(l <= r);     long long j = r / b;     ds[j].updoff(p, max(l, j * b) - j * b, r - j * b);     j--;     while (j * b > l) {       ds[j].minm += p;       j--;     }     if (l >= j * b && l < (j + 1) * b) ds[j].updoff(p, l - j * b, b - 1);   }   long long query(vector<bucket> &ds, long long n, long long r, long long b,                   long long k) {     long long j = r / b;     long long ret = 0;     while (j >= 0) {       long long idx = k - ds[j].minm;       if (idx >= 0) ret = (ret + ds[j].pre[min(idx, b - 1)]) % mod;       j--;     }     return ret;   }   int32_t main() {     long long n, k;     cin >> n >> k;     long long b = sqrt(n);     long long m = ceil((double)n / b);     vector<long long> a(n);     for (auto &x : a) cin >> x;     vector<bucket> ds;     for (long long i = 0; i < m; ++i) {       bucket B = bucket(b);       ds.push_back(B);     }     vector<long long> lo(n + 1, -1);     vector<long long> llo(n + 1, -1);     vector<long long> dp(n);     dp[0] = 1;     lo[a[0]] = 0;     ds[0].updoff(1, 0, 0);     ds[0].upddp(0, 1);     if ((1 / b) < m) ds[1 / b].upddp(1 - (1 / b) * b, 1);     for (long long i = 1; i < n; ++i) {       if (lo[a[i]] != -1) update_offset(ds, n, llo[a[i]] + 1, lo[a[i]], -1, b);       update_offset(ds, n, lo[a[i]] + 1, i, 1, b);       dp[i] = query(ds, n, i, b, k);       long long j = (i + 1) / b;       if (j < m) ds[j].upddp((i + 1) - j * b, dp[i]);       llo[a[i]] = lo[a[i]];       lo[a[i]] = i;     }     cout << dp[n - 1];   }
#include <bits/stdc++.h>   using namespace std;   char s[100005];   int main() {     int n;     cin >> n;     int k = min(n, 4);     for (int i = 0; i < k; i++)       for (int j = i; j < n; j += 4) s[j] = i +  a ;     s[n] =   0 ;     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, s = 0, o;     cin >> n;     char *a[n + 1], str[n + 1];     for (i = 0; i < n; i++) {       cin >> str;       a[i] = (char *)malloc(n + 1);       strcpy(a[i], str);     }     for (i = 0; i < n && s == 0; i++)       for (j = 0; j < n && s == 0; j++) {         o = 0;         if (j != 0 && a[i][j - 1] ==  o ) o++;         if ((j != n - 1) && a[i][j + 1] ==  o ) o++;         if (i != 0 && a[i - 1][j] ==  o ) o++;         if ((i != n - 1) && a[i + 1][j] ==  o ) o++;         if (o % 2 != 0) s = 1;       }     if (s)       cout <<  NO ;     else       cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int foot = n / 36;     float b = n % 36;     int kkk = b / 3;     double kk = kkk + 0.5;     float inch = b / 3;     if (inch >= kk)       inch = ceil(inch);     else if (inch < kk)       inch = floor(inch);     int sss = (float)(inch);     if (sss % 12 == 0) {       inch = 0;       foot += (sss / 12);     }     cout << foot <<     << inch;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a, b;   int f1[100005], f2[100005], res, p1, p2, k, dp2[100005];   int main() {     cin >> a >> b;     int n = a.length();     int m = b.length();     a =  #  + a;     b =  #  + b;     int p = 1;     for (int i = 1; i <= m; i++) {       if (p > n) break;       while (a[p] != b[i] && p <= n) p++;       if (p <= n) f1[i] = p;       p++;     }     p = n;     for (int i = 1; i <= max(m, n); i++) f2[i] = -1;     for (int i = m; i >= 1; i--) {       if (p < 1) break;       while (a[p] != b[i] && p >= 1) p--;       if (p >= 1) f2[i] = p;       p--;     }     for (int i = 1; i <= m; i++)       if (res < i && f1[i] > 0) {         res = i;         p1 = 1;         p2 = i;         k = 1;       }     for (int i = 1; i <= max(m, n); i++) dp2[i] = n + 1;     p = n;     for (int i = m; i >= 1; i--) {       if (p < 1) break;       while (a[p] != b[i] && p >= 1) p--;       if (p >= 1) dp2[i] = p;       p--;     }     for (int i = 1; i <= m; i++)       if (res < (m - i + 1) && dp2[i] < n + 1) {         res = (m - i + 1);         p1 = i;         p2 = m;         k = 1;       }     int z = 0;     int x = 0;     for (int i = 1; i <= m; i++) {       z = max(z, i + 1);       while (x <= n && a[x] != b[i]) x++;       if (x > n) break;       x++;       while (f2[z] < x) z++;       int ans = i + 1 + m - z;       if (res < ans) {         res = ans;         p1 = i;         p2 = z;         k = 2;       }     }     if (k == 1)       for (int i = p1; i <= p2; i++) cout << b[i];     else if (k == 2) {       for (int i = 1; i <= p1; i++) cout << b[i];       for (int i = p2; i <= m; i++) cout << b[i];     } else       cout <<  - ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename INT>   struct TripleDXY {     INT d, x, y;     TripleDXY(INT _d = 0, INT _x = 0, INT _y = 0) : d(_d), x(_x), y(_y) {}   };   template <typename INT>   TripleDXY<INT> egcd(INT a, INT b) {     bool neg_a = a < 0;     if (neg_a) a = -a;     bool neg_b = b < 0;     if (neg_b) b = -b;     INT x = 0, lastx = 1;     INT y = 1, lasty = 0;     while (b != 0) {       INT t = b;       INT q = a / b;       b = a % b;       a = t;       t = x;       x = lastx - q * x;       lastx = t;       t = y;       y = lasty - q * y;       lasty = t;     }     return TripleDXY<INT>(a, neg_a ? -lastx : lastx, neg_b ? -lasty : lasty);   }   long long ChooseMod(int n, int k, int M) {     long long res = 1;     for (int i = 1; i <= k; ++i, --n) {       TripleDXY<int> R = egcd(i, M);       assert(R.d == 1);       res = (res * n) % M;       res = (res * R.x) % M;       if (res < 0) res += M;     }     return res;   }   int N, K;   long long A[2004];   long long R[2004];   long long F[2004];   int main(int argc, char* argv[]) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> N >> K;     F[0] = 1;     for (int i = 1; i < N; ++i) {       F[i] = ChooseMod(K - 1 + i, i, 1000000007);     }     for (int i = 0; i < N; ++i) cin >> A[i];     R[0] = A[0] % 1000000007;     for (int i = 1; i < N; ++i) {       R[i] = 0;       for (int j = 0; j <= i; ++j) {         R[i] += (A[j] * F[i - j]);         R[i] %= 1000000007;       }     }     for (int i = 0; i < N; ++i) cout << R[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s1;     cin >> s1;     string s2;     cin >> s2;     string s3;     cin >> s3;     vector<pair<char, int> > cnt(26);     for (int i = int(0); i < int(int(s1.size())); i++) {       char c = s1[i];       int pos = tolower(c) -  a ;       cnt[pos].second += 0;       cnt[pos].first = c;     }     for (int i = int(0); i < int(int(s2.size())); i++) {       char c = s2[i];       int pos = tolower(c) -  a ;       cnt[pos].second += 0;       cnt[pos].first = c;     }     for (int i = int(0); i < int(int(s3.size())); i++) {       char c = s3[i];       int pos = tolower(c) -  a ;       cnt[pos].second += 1;       cnt[pos].first = c;     }     for (int i = int(0); i < int(int(s1.size())); i++) {       for (int j = int(0); j < int(26); j++) {         if (s1[i] == cnt[j].first) {           cnt[j].second -= 1;         }       }     }     for (int i = int(0); i < int(int(s2.size())); i++) {       for (int j = int(0); j < int(26); j++) {         if (s2[i] == cnt[j].first) {           cnt[j].second -= 1;         }       }     }     for (int i = int(0); i < int(26); i++) {       if (cnt[i].second < 0 || cnt[i].second > 0) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   long long ar[5000005];   int main() {     string s;     cin >> s;     long long sz = s.size();     long long cnt = 0;     for (int i = 0; i < sz; i++) {       long long l = 0, w = 0;       for (int j = i; j < sz; j++) {         if (s[j] ==  ( )           l++;         else if (s[j] ==  ) )           l--;         else           w++;         if (w > l && w != 0) {           w--;           l++;         }         if (l < 0) break;         if (w == l) cnt++;       }     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char* x) { cerr <<     << x <<    ; }   void __print(const string& x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V>& x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T& x) {     int f = 0;     cerr <<  { ;     for (auto& i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   template <class A>   void read(vector<A>& v);   template <class A, size_t S>   void read(array<A, S>& a);   template <class T>   void read(T& x) {     cin >> x;   }   void read(double& d) {     string t;     read(t);     d = stod(t);   }   void read(long double& d) {     string t;     read(t);     d = stold(t);   }   template <class H, class... T>   void read(H& h, T&... t) {     read(h);     read(t...);   }   template <class A>   void read(vector<A>& x) {     for (auto& a : x) read(a);   }   template <class A, size_t S>   void read(array<A, S>& x) {     for (auto& a : x) read(a);   }   const int MAXN = 2e5 + 5;   long long mod = 1e9 + 7;   vector<long long> gr[200005];   void solve() {     long long n;     cin >> n;     vector<long long> a(n);     read(a);     long long val = 0;     for (long long i = int(1); i < int(n); i++) {       if (a[i] < a[i - 1]) {         val += a[i - 1] - a[i];       }       if (val > a[0]) {         cout <<  NO               <<   n ;         return;       }     }     cout <<  YES           <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long test;     test = 1;     cin >> test;     while (test--) {       solve();     }   }
#include <bits/stdc++.h>   #define il inline   #define ll long long   const int N=2e5+5,B=316;      int n,q,b[N],c[N]; ll a[N],lz[N];      il int jump(int x){return x?std::max(a[x]-lz[x/B],0ll):-1;}      il void rebuild(int x,int v)   {    if (c[x]+v>B) return ; c[x]+=v; int i;    for (i=x*B; i<x*B+B; i++) b[i]=jump(i)<x*B?i:b[jump(i)];   }      il void add(int x,int y,int v)   {    int i; for (i=x/B*B; i<x; i++) a[i]+=v;    for (i=y+1; i<y/B*B+B; i++) a[i]+=v;    for (i=x/B; i<=y/B; i++) lz[i]+=v,rebuild(i,i!=x/B&&i!=y/B);   }      il int LCA(int x,int y)   {    for ( ; b[x]!=b[y]; x=jump(b[x])) if (jump(b[x])<jump(b[y])) std::swap(x,y);    for ( ; x!=y; x=jump(x)) if (x<y) std::swap(x,y); return x;   }      int main()   {    scanf( %d%d ,&n,&q),a[0]=-1; int i,x,y,k;    for (i=1; i<n; i++) scanf( %d ,a+i),a[i]--;        for (add(0,n-1,0); q; q--)     if (scanf( %d%d%d ,&i,&x,&y),i>1) printf( %d n ,LCA(x-1,y-1)+1);     else scanf( %d ,&k),add(x-1,y-1,k);        return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct pi {     bool dir;     int node;     int edge;   };   const int mxn = 200005;   int n;   vector<pi> graph[mxn];   int dp1[mxn];   vector<int> vv;   int ans = 1000000000;   void dfs1(int v, int p) {     for (int i = 0; i < graph[v].size(); i++) {       pi u = graph[v][i];       if (u.node == p) continue;       dfs1(u.node, v);       dp1[v] += dp1[u.node];       if (u.dir) dp1[v]++;     }   }   void dfs2(int v, int p, int l) {     int temp = l + dp1[v];     if (ans == (n - 1) - temp)       vv.push_back(v);     else if (ans > (n - 1) - temp) {       vv.clear();       vv.push_back(v);       ans = (n - 1) - temp;     }     for (int i = 0; i < graph[v].size(); i++) {       pi u = graph[v][i];       if (u.node == p) continue;       int something = temp - dp1[u.node];       if (u.dir)         something--;       else         something++;       dfs2(u.node, v, something);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       pi temp;       temp.dir = 1;       temp.node = y;       temp.edge = i;       graph[x].push_back(temp);       temp.dir = 0;       temp.node = x;       graph[y].push_back(temp);     }     dfs1(1, 1);     dfs2(1, 1, 0);     printf( %d n , ans);     sort(vv.begin(), vv.end());     printf( %d , vv[0]);     for (int i = 1; i < vv.size(); i++) printf(  %d , vv[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pi = pair<ll, ll>;   const ll inf = 0x3f3f3f3f3f3f3f3f;   const ll minf = 0xc0c0c0c0c0c0c0c0;   ll A[400400];   ll B[400400];   inline bool between(ll le, ll ri, ll first) {     return le <= first && first <= ri;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     ll n;     cin >> n;     for (ll i = 1; i <= n; i++) cin >> A[i];     ll res = 0;     for (ll bit = 0; bit <= 24; bit++) {       memcpy(B, A, sizeof(ll) * (n + 5));       ll mask = (1 << (bit + 1)) - 1;       for (ll i = 1; i <= n; i++) {         B[i] &= mask;       }       sort(B + 1, B + n + 1);       ll cnt = 0;       for (ll i = 1; i <= n; i++) {         cnt += (upper_bound(B + 1, B + n + 1, (1 << bit + 1) - 1 - B[i]) - B) -                (lower_bound(B + 1, B + n + 1, (1 << bit) - B[i]) - B);         if ((1 << bit) - B[i] <= B[i] && B[i] <= (1 << bit + 1) - 1 - B[i]) --cnt;         cnt +=             (upper_bound(B + 1, B + n + 1, (1 << bit + 2) - 2 - B[i]) - B) -             (lower_bound(B + 1, B + n + 1, (1 << bit) + (1 << bit + 1) - B[i]) -              B);         if (((1 << bit) + (1 << bit + 1)) - B[i] <= B[i] &&             B[i] <= (1 << bit + 2) - 2 - B[i])           --cnt;       }       assert(cnt % 2 == 0);       cnt /= 2;       if (cnt & 1) res |= (1 << bit);     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void work();   int main() {     work();     return 0;   }   char S[222222];   char T[222222];   int t[256][256];   void work() {     int n;     while (scanf( %d , &n) == 1) {       memset(t, 0, sizeof(t));       int ans = 0;       scanf( %s%s , S + 1, T + 1);       for (int i = (1), END = (n); i <= END; i++)         if (S[i] != T[i]) {           ans++;           t[S[i]][T[i]] = i;         }       bool two = false;       for (int i = ( a ), END = ( z ); i <= END; i++)         for (int j = (i + 1), END = ( z ); j <= END; j++)           if (t[i][j] && t[j][i]) {             two = true;             printf( %d n%d %d n , ans - 2, t[i][j], t[j][i]);             i = 256;             j = 256;           }       if (two) continue;       for (int i = ( A ), END = ( Z ); i <= END; i++)         for (int j = (i + 1), END = ( Z ); j <= END; j++)           if (t[i][j] && t[j][i]) {             two = true;             printf( %d n%d %d n , ans - 2, t[i][j], t[j][i]);             i = 256;             j = 256;           }       if (two) continue;       bool one = false;       for (int i = ( a ), END = ( z ); i <= END; i++) {         int pos = -1;         for (int j = ( a ), END = ( z ); j <= END; j++)           if (t[i][j]) pos = t[i][j];         if (pos == -1) continue;         for (int j = ( a ), END = ( z ); j <= END; j++)           if (t[j][i]) {             one = true;             printf( %d n%d %d n , ans - 1, pos, t[j][i]);             i = j = 256;           }       }       if (one) continue;       for (int i = ( A ), END = ( Z ); i <= END; i++) {         int pos = -1;         for (int j = ( A ), END = ( Z ); j <= END; j++)           if (t[i][j]) pos = t[i][j];         if (pos == -1) continue;         for (int j = ( A ), END = ( Z ); j <= END; j++)           if (t[j][i]) {             one = true;             printf( %d n%d %d n , ans - 1, pos, t[j][i]);             i = j = 256;           }       }       if (one) continue;       printf( %d n%d %d n , ans, -1, -1);     }   }