malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, x1, y1, x2, y2, left, right;     cin >> a >> b >> x1 >> y1 >> x2 >> y2;     int r1 = (x2 - y2) / (2 * b);     int r2 = (x1 - y1) / (2 * b);     int r3 = (x2 + y2) / (2 * a);     int r4 = (x1 + y1) / (2 * a);     left = ((x2 - y2) / (2 * b) - (x1 - y1) / (2 * b));     right = ((x2 + y2) / (2 * a) - (x1 + y1) / (2 * a));     if (x2 - y2 < 0) left -= 1;     if (x1 - y1 < 0) left += 1;     if (x2 + y2 < 0) right -= 1;     if (x1 + y1 < 0) right += 1;     cout << max(abs(left), abs(right));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n_keys, n_chests;   int odd_keys, even_keys, odd_chests, even_chests;   int main() {     cin >> n_keys >> n_chests;     for (int i = 0; i < n_keys; i++) {       int x;       cin >> x;       if (x % 2 == 0)         even_keys++;       else         odd_keys++;     }     for (int i = 0; i < n_chests; i++) {       int x;       cin >> x;       if (x % 2 == 0)         even_chests++;       else         odd_chests++;     }     cout << min(even_chests, odd_keys) + min(odd_chests, even_keys) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> v;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       v.push_back(x);     }     sort(v.begin(), v.end());     if (v[0] == v[n / 2]) {       cout <<  Bob  << endl;     } else {       cout <<  Alice  << endl;     }   }
#include <bits/stdc++.h>   int main() {     int n, a[102], sum1 = 0, sum2 = 0;     int s, t;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     scanf( %d %d , &s, &t);     if (s == t) {       printf( 0 n );     } else {       int i;       if (s > t) {         s ^= t;         t ^= s;         s ^= t;       }       for (i = s - 1; i < t - 1; i++) sum1 += a[i];       for (i = t - 1; i < n; i++) sum2 += a[i];       for (i = 0; i < s - 1; i++) sum2 += a[i];       int ans;       sum1 > sum2 ? (ans = sum2) : (ans = sum1);       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 3e6 + 10, Maxk = 1e6 + 10;   int a[Maxn], l[Maxn], r[Maxn], s[Maxn], n, k;   vector<int> v[Maxk];   long long ans;   int ask(int k, int l, int r) {     int x = upper_bound(v[k].begin(), v[k].end(), r) - v[k].begin() - 1,         y = lower_bound(v[k].begin(), v[k].end(), l) - v[k].begin() - 1;     return x - y;   }   int main() {     ios::sync_with_stdio(0);     int i, j;     cin >> n >> k;     for (i = 1; i <= n; i++) cin >> a[i], s[i] = (s[i - 1] + a[i]) % k;     for (i = 0; i <= n; i++) v[s[i]].push_back(i);     for (i = 1; i <= n; i++)       for (l[i] = i - 1; l[i] >= 1 && a[l[i]] < a[i]; l[i] = l[l[i]])         ;     for (i = n; i >= 1; i--)       for (r[i] = i + 1; r[i] <= n && a[r[i]] <= a[i]; r[i] = r[r[i]])         ;     for (i = 1; i <= n; i++)       if (i - l[i] < r[i] - i) {         for (j = l[i] + 1; j <= i; j++)           ans += ask((a[i] + s[j - 1]) % k, i, r[i] - 1);       } else {         for (j = i; j <= r[i] - 1; j++)           ans += ask(((s[j] - a[i]) % k + k) % k, l[i], i - 1);       }     cout << ans - n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     scanf( %d , &T);     while (T--) {       int n, ans = 0;       scanf( %d , &n);       map<string, int> book;       vector<string> aa, temp;       for (int i = 1; i <= n; i++) {         string s;         cin >> s;         book[s] = 1;         temp.push_back(s);       }       for (vector<string>::iterator it = temp.begin(); it < temp.end(); it++) {         string s;         s = *it;         if (book[s] == 1) {           book[s]++;           aa.push_back(s);         } else {           for (int i = 0; i <= 9; i++) {             s[3] = i +  0 ;             if (!book.count(s)) {               book[s] = 1;               aa.push_back(s);               break;             }           }           ans++;         }       }       printf( %d n , ans);       for (vector<string>::iterator it = aa.begin(); it < aa.end(); it++)         cout << *it << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t = 1;     while (t--) {       long long l, r, i, sum = 0;       deque<long long> a;       a.push_back(4);       a.push_back(7);       cin >> l >> r;       for (i = l; i <= r;) {         if (i <= a.front()) {           sum += a.front();           i++;         } else {           a.push_back(a.front() * 10 + 4);           a.push_back(a.front() * 10 + 7);           a.pop_front();         }       }       cout << sum <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int typetest;   inline void fastIOfileinput() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     typetest = 1;   }   const int N = 1e2 + 2;   long long n;   void Enter() { cin >> n; }   long long cnt() {     return (long long)((long long)sqrt((long double)(24 * n + 1)) - 7) / 6;   }   void solve() {     long long ans = 0, x;     while (n > 1) {       ++ans;       x = cnt();       n -= (x + 1) * (3 * x + 4) / 2;     }     cout << ans <<   n ;   }   int main() {     fastIOfileinput();     if (typetest) {       int t;       cin >> t;       while (t--) {         Enter();         solve();       }     } else {       Enter();       solve();     }   }
#include <bits/stdc++.h>   int main() {     float a, b, x, y, v, g, k = 10000.000;     int i, n;     scanf( %f %f %d , &a, &b, &n);     for (i = 0; i < n; i++) {       scanf( %f %f %f , &x, &y, &v);       g = (x - a) * (x - a) + (y - b) * (y - b);       g = sqrt(g);       g = g / v;       if (g < k) {         k = g;       }     }     printf( %f n , k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma )   #pragma GCC optimize( unroll-loops )   const long long int mod = 1e9 + 7;   const long long int mod1 = 998244353;   const long long int inf = 1e18;   const long long int MX = 1e6 + 1;   const double PI = 3.141592653589793238;   template <typename T>   ostream& operator<<(ostream& out, const vector<T>& v) {     out <<  [ ;     for (auto i = v.begin(); i != v.end(); i++)       out << (i != v.begin() ?  ,  :   ) << (*i);     return (out <<  ] );   }   template <typename T>   ostream& operator<<(ostream& out, const set<T>& s) {     out <<  [ ;     for (auto i = s.begin(); i != s.end(); i++)       out << (i != s.begin() ?  ,  :   ) << (*i);     return (out <<  ] );   }   template <typename T>   ostream& operator<<(ostream& out, const unordered_set<T>& s) {     out <<   n  <<  [ ;     for (auto i = s.begin(); i != s.end(); i++)       out << (i != s.begin() ?  ,  :   ) << (*i);     return (out <<  ] );   }   template <typename T1, typename T2>   ostream& operator<<(ostream& out, const pair<T1, T2>& p) {     return (out <<  (  << p.first <<  ,  << p.second <<  ) );   }   template <typename T1, typename T2>   ostream& operator<<(ostream& out, const map<T1, T2>& m) {     out <<  {  <<   n ;     for (auto x : m) out <<      << x.first <<   ->   << x.second <<   n ;     return (out <<  } );   }   template <typename T1, typename T2>   ostream& operator<<(ostream& out, const unordered_map<T1, T2>& m) {     out <<  {  <<   n ;     for (auto x : m) out <<      << x.first <<   ->   << x.second <<   n ;     return (out <<  } );   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t;     cin.ignore();     while (t--) {       long long int n, m;       cin >> n >> m;       map<long long int, long long int> mp;       for (long long int i = 0; i < m; i++) {         long long int x, y, z;         cin >> x >> y >> z;         mp[y]++;       }       long long int p1 = 0;       for (long long int i = 0; i < n; i++) {         if (mp.find(i + 1) == mp.end()) {           p1 = i + 1;           break;         }       }       for (long long int i = 0; i < n; i++) {         if (i + 1 == p1) {           continue;         }         cout << p1 <<     << i + 1 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void Solve() {     int n;     string a, b;     cin >> n >> a >> b;     a =  -  + a +  - ;     b =  -  + b +  - ;     int val = 0;     for (int i = 1; i <= n; i++) {       if (a[i] != b[i])         val += 2;       else if (a[i] ==  0 ) {         val++;         if (a[i - 1] ==  1  && b[i - 1] ==  1 )           val++;         else if (a[i + 1] ==  1  && b[i + 1] ==  1 ) {           val++;           a[i + 1] = b[i + 1] =  - ;         }       }     }     cout << val << endl;   }   int main() {     int t;     cin >> t;     while (t--) Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   struct rge {     T b, e;   };   template <class T>   rge<T> range(T i, T j) {     return rge<T>{i, j};   };   template <class A, class B>   ostream &operator<<(ostream &os, pair<A, B> p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <class T>   ostream &operator<<(ostream &os, rge<T> d) {     os <<  [ ;     for (auto it = d.b; it != d.e; it++) os << (it == d.b ?    :  ,  ) << *it;     return os <<  ] ;   }   const int N = 1e5 + 5;   const long long inf = 1e18;   long long stones[N], frogs[N];   int n, jump;   bool can(long long x) {     for (int i = (1); i <= ((n)); i += (+1)) {       frogs[i] = 0;     }     frogs[0] = x;     int l = 0, r = 1;     while (l < n) {       while (frogs[l] > 0) {         while (r <= n && stones[r] - frogs[r] <= 0) {           r++;         }         if (l + jump < r) {           return false;         }         long long add = min(frogs[l], stones[r] - frogs[r]);         frogs[r] += add;         frogs[l] -= add;       }       l++;       r = max(l + 1, r);     }     return true;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);     cin >> n >> jump;     for (int i = (1); i <= ((n - 1)); i += (+1)) {       cin >> stones[i];     }     stones[n] = inf;     long long lo = 0, hi = inf;     while (lo + 1 < hi) {       long long mid = (lo + hi) / 2;       if (can(mid)) {         lo = mid;       } else {         hi = mid;       }     }     while (can(lo + 1)) {       lo++;     }     cout << lo <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   std::vector<int> v[100005];   int dist[100005];   void dfs(int s, int par) {     if (par != -1) dist[s] = dist[par] + 1;     for (int i = 0; i < v[s].size(); i++) {       if (par != v[s][i]) dfs(v[s][i], s);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1, xx, x = 0, y = 0, cc, m, k, n;     cin >> t;     while (t--) {       int a, b, da, db;       cin >> n >> a >> b >> da >> db;       for (int i = 1; i < n; i++) {         cin >> x >> y;         v[x].push_back(y);         v[y].push_back(x);         dist[i] = 0;       }       dist[n] = 0;       dfs(a, -1);       int ab = dist[b];       int farest, mx = -1;       for (int i = 1; i < n + 1; i++) {         if (mx < dist[i]) {           mx = dist[i];           farest = i;         }       }       for (int i = 1; i < n + 1; i++) dist[i] = 0;       dfs(farest, -1);       int diameter = -1;       for (int i = 1; i < n + 1; i++) diameter = max(diameter, dist[i]);       if (ab <= da || 2 * da >= diameter || 2 * da >= db)         cout <<  Alice  << endl;       else         cout <<  Bob  << endl;       for (int i = 1; i < n + 1; i++) v[i].clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename F, typename S>   ostream &operator<<(ostream &os, const pair<F, S> &p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  { ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  } ;   }   template <typename T>   ostream &operator<<(ostream &os, const set<T> &v) {     os <<  [ ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  ] ;   }   template <typename T>   ostream &operator<<(ostream &os, const multiset<T> &v) {     os <<  [ ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  ] ;   }   template <typename F, typename S>   ostream &operator<<(ostream &os, const map<F, S> &v) {     os <<  [ ;     for (auto it = v.begin(); it != v.end(); ++it) {       if (it != v.begin()) os <<  ,  ;       os << it->first <<   =   << it->second;     }     return os <<  ] ;   }   void faltu() { cerr << endl; }   template <typename T>   void faltu(T a[], int n) {     for (int i = 0; i < n; ++i) cerr << a[i] <<    ;     cerr << endl;   }   template <typename T, typename... hello>   void faltu(T arg, const hello &...rest) {     cerr << arg <<    ;     faltu(rest...);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t;     cin >> t;     while (t--) {       int n, s;       cin >> n;       s = sqrt(n);       if (n == 1) {         cout << 0 << endl;         continue;       } else {         if (s * s == n) {           cout << 2 * s - 2 << endl;         } else if ((s + 1) * s >= n) {           cout << 2 * s - 1 << endl;         } else if ((s + 1) * (s + 1) >= n) {           cout << 2 * s << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, a[maxn], b[maxn], t[maxn];   bool check(int num, int pos) {     t[pos] = num;     if (pos == n) return true;     for (int i = 0; i <= 3; i++) {       if ((num | i) == a[pos] && (num & i) == b[pos]) return check(i, pos + 1);     }     return false;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i < n; i++) {       scanf( %d , &b[i]);     }     for (int i = 0; i <= 3; i++) {       if (check(i, 1)) {         printf( YES n );         for (int j = 1; j <= n; j++) {           printf( %d  , t[j]);         }         return 0;       }     }     printf( NO );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200000 + 10;   const int M = 5 * N;   const int OO = 1000000000;   int ans = 0;   int anum = 0;   int i;   int n;   int result;   int sum[N];   int tree[M];   string s;   int lowbit(int x) { return x & (-x); }   int min(int a, int b) { return a < b ? a : b; }   int ask(int x) {     int i = x;     int result = OO;     while (i > 0) {       result = min(result, tree[i]);       i -= lowbit(i);     }     return result;   }   void update(int x, int y) {     int i = x;     while (i < M) {       tree[i] = min(tree[i], y);       i += lowbit(i);     }   }   int main() {     getline(cin, s);     n = s.size();     for (i = 0; i < n; i++)       if (s[i] >=  a  && s[i] <=  z ) s[i] = s[i] -  a  +  A ;     for (i = 0; i < n; i++) {       sum[i + 1] = sum[i];       if (s[i] ==  A  || s[i] ==  E  || s[i] ==  I  || s[i] ==  O  || s[i] ==  U )         sum[i + 1]--;       else         sum[i + 1] += 2;     }     for (i = 0; i <= n; i++) sum[i] += 2 * n;     for (i = 0; i < M; i++) tree[i] = OO;     update(sum[0], 0);     for (i = 1; i <= n; i++) {       result = ask(sum[i]);       if (i - result > ans) {         ans = i - result;         anum = 0;       }       if (i - result == ans) anum++;       update(sum[i], i);     }     if (ans > 0)       cout << ans <<     << anum <<   n ;     else       cout <<  No solution n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int MAX_N = 1e5 + 50;   int w[MAX_N];   void solve() {     int n, m;     cin >> n >> m;     long long ret = ((long long)w[n] + (long long)w[m] - 1LL) * 2LL;     cout << ret % MOD <<   n ;   }   void precal() {     w[0] = 0;     w[1] = 1;     w[2] = 2;     for (int i = (3); i < (MAX_N); ++i) {       w[i] = w[i - 1] + w[i - 2];       w[i] %= MOD;     }   }   signed main(void) {     ios_base::sync_with_stdio(false);     cin.tie(0);     precal();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 2e5;   int p[MAXN + 10], rub[MAXN + 10];   bool mark[MAXN + 10];   bool palin(int x) {     stringstream sst;     sst << x;     string s;     sst >> s;     for (int i = 0; i < s.length(); i++)       if (s[i] != s[s.length() - i - 1]) return false;     return true;   }   int main() {     ios::sync_with_stdio(false);     rub[1] = 1;     cerr << palin(121) << endl;     long double a, b;     cin >> a >> b;     for (int i = 2; i <= MAXN; i++) {       if (palin(i)) {         rub[i] = rub[i - 1] + 1;       } else         rub[i] = rub[i - 1];       if (!mark[i]) {         p[i] = p[i - 1] + 1;         for (int j = i + i; j <= MAXN; j += i) mark[j] = true;       } else         p[i] = p[i - 1];     }     long double x = a / b;     int Max = 0;     for (int i = 1; i <= MAXN; i++)       if ((long double)p[i] / (long double)rub[i] <= x) Max = i;     cout << Max << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int SZ = 200005;   vector<int> graph[SZ];   int par[SZ];   int dst[SZ];   int tot;   void dfs(int x, int crt) {     par[x] = crt;     tot++;     for (int nxt : graph[x]) {       if (par[nxt]) continue;       dfs(nxt, crt);     }   }   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (int i = 1; i <= n; i++) {         graph[i].clear();         par[i] = 0;         dst[i] = 0;       }       for (int i = 1; i <= n; i++) {         int x;         cin >> x;         graph[i].push_back(x);       }       int pp = 0;       for (int i = 1; i <= n; i++) {         if (par[i]) continue;         tot = 0;         dfs(i, ++pp);         dst[pp] = tot;       }       for (int i = 1; i <= n; i++) cout << dst[par[i]] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   const int maxn = 1e6 + 100;   const double EPS = 1e-12;   struct point {     double x, y;   };   string a[11] = { zero ,  one ,    two ,    three ,  four ,  five ,                    six ,   seven ,  eight ,  nine ,   ten };   string b[11] = {  ,      ,     twen ,   thir ,  for ,                    fif ,  six ,  seven ,  eigh ,  nine };   string c[11] = {  ,      ,      ,       thir ,  four ,                    fif ,  six ,  seven ,  eigh ,  nine };   int n;   int main() {     cin >> n;     if (n <= 10) {       cout << a[n] << endl;       return 0;     }     if (n < 20) {       if (n == 11)         cout <<  eleven  << endl;       else if (n == 12)         cout <<  twelve  << endl;       else         cout << c[n % 10] <<  teen  << endl;       return 0;     }     if (n % 10 == 0) {       cout << b[n / 10] <<  ty  << endl;       return 0;     }     cout << b[n / 10] <<  ty-  << a[n % 10] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     char board[n][n];     bool even = true;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) cin >> board[i][j];     for (int i = 0; i < n; i++) {       int c = 0;       for (int j = 0; j < n; j++) {         if (i - 1 >= 0 and board[i - 1][j] ==  o ) c++;         if (i + 1 < n and board[i + 1][j] ==  o ) c++;         if (j - 1 >= 0 and board[i][j - 1] ==  o ) c++;         if (j + 1 < n and board[i][j + 1] ==  o ) c++;         if (c % 2 == 1) even = false;       }     }     if (even)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int MAX = 1e7 + 7;   const long long int MOD = 1000000007;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);   }   int main() {     fast();     long long int TEST_CASES = 1;     while (TEST_CASES--) {       int n;       cin >> n;       vector<pair<string, int>> v(n);       map<string, long long int> mp, now;       for (long long int(i) = 0; (i) < n; (i)++) {         cin >> v[i].first >> v[i].second;         mp[v[i].first] += v[i].second;       }       string mxs;       long long int mx = INT_MIN;       for (auto i : mp) {         if (mx < i.second) {           mx = i.second;           mxs = i.first;         }       }       string str;       for (int i = 0; i < n; i++) {         now[v[i].first] += v[i].second;         if (mp[v[i].first] == mx && now[v[i].first] >= mx) {           str = v[i].first;           break;         }       }       cout << str <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef struct {     int freq;     char l;   } db;   int comp(const void *a, const void *b) {     db *x = (db *)a;     db *y = (db *)b;     return x->freq - y->freq;   }   int main() {     db aa[30];     db e;     string str;     int let[30], sz, i, cnt, k, d, j;     while (cin >> str) {       cin >> d;       memset(let, 0, sizeof(let));       sz = str.length();       for (i = 0; i < sz; i++) {         let[str[i] -  a ]++;       }       cnt = 0;       k = 0;       for (i = 0; i < 26; i++) {         if (let[i]) {           cnt++;           aa[k].l = i +  a ;           aa[k].freq = let[i];           k++;         }       }       qsort(aa, k, sizeof(db), comp);       sz = str.size();       for (i = 0; i < k; i++) {         if (d == 0) break;         for (j = 0; j < str.size() && d > 0; j++) {           if (str[j] == aa[i].l) {             str.erase(j, 1);             j--;             let[aa[i].l -  a ]--;             d--;           }         }       }       cnt = 0;       for (i = 0; i < 26; i++) {         if (let[i]) cnt++;       }       cout << cnt << endl;       cout << str << endl;     }     return 0;   }
#include <bits/stdc++.h>   char c[10005];   int main() {     int i, j, k, n, m;     int x0 = 0, x = 0, y0 = 0, y = 0;     scanf( %d%s , &n, c + 1);     for (i = 1; i <= n; i++) {       if (!x0 && c[i] ==  R ) x0 = i;       if (c[i] ==  R ) x = i;       if (!y0 && c[i] ==  L ) y0 = i;       if (c[i] ==  L ) y = i;     }     if (!x0)       printf( %d %d n , y, y0 - 1);     else if (!y0)       printf( %d %d n , x0, x + 1);     else       printf( %d %d n , x0, x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int blk_size;   struct node {     int l, r, id;     long long int ans = 0;   };   bool compare(node a, node b) {     if (a.l / blk_size != b.l / blk_size)       return (a.l) / blk_size < (b.l) / blk_size;     return a.r < b.r;   }   bool compare2(node a, node b) { return a.id < b.id; }   long long int freq[3000001];   int main() {     ios_base::sync_with_stdio(false);     ;     int n, m, k;     cin >> n >> m >> k;     std::vector<int> a(n), pxor(n + 1);     for (int i = 0; i < n; i++) cin >> a[i];     pxor[0] = 0;     for (int i = 1; i <= n; i++) pxor[i] = pxor[i - 1] ^ a[i - 1];     blk_size = sqrt(n + 1);     std::vector<node> q(m);     for (int i = 0; i < m; i++) {       cin >> q[i].l >> q[i].r;       q[i].id = i;     }     sort(q.begin(), q.end(), compare);     int start = 0, end = 0;     long long int ans = 0;     freq[0] = 1;     for (int i = 0; i < m; i++) {       int l = q[i].l - 1, r = q[i].r;       while (start > l) {         start--;         ans += freq[pxor[start] ^ k];         freq[pxor[start]]++;       }       while (start < l) {         freq[pxor[start]]--;         ans -= freq[pxor[start] ^ k];         start++;       }       while (end > r) {         freq[pxor[end]]--;         ans -= freq[pxor[end] ^ k];         end--;       }       while (end < r) {         end++;         ans += freq[pxor[end] ^ k];         freq[pxor[end]]++;       }       q[i].ans = ans;     }     sort(q.begin(), q.end(), compare2);     for (int i = 0; i < m; i++) printf( %lld n , q[i].ans);     return 0;   }