malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 50;   signed main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     long long n;     cin >> n;     vector<long long> a(n);     for (long long i = 0; i < n; i++) cin >> a[i];     long long ans = 0;     sort(a.begin(), a.end());     for (long long i = 0, j = n - 1; i < j; i++, j--) {       ans += (a[i] + a[j]) * (a[i] + a[j]);     }     cout << ans;   }
#include <bits/stdc++.h>   const int maxn = 1000010;   const int P = 1000000007;   int k, w;   int f[maxn], g[maxn];   int pow(int x, int y) {     int e = 1;     while (y) {       if (y & 1) e = (long long)e * x % P;       x = (long long)x * x % P;       y >>= 1;     }     return e;   }   int main() {     int i, d, t, s = 0;     scanf( %d%d , &k, &w);     for (f[0] = g[0] = 1, i = 1; i <= k; ++i)       f[i] = (long long)f[i - 1] * i % P, g[i] = pow(f[i], P - 2);     for (t = 1; t <= k; ++t) {       d = (long long)f[k] * g[k - t] % P * g[k - t] % P;       if (t <= w - 1)         s = ((long long)d * t % P * f[k] % P * pow(k, w - t - 1) + s) % P;       else         s = ((long long)d * w % P * f[k - t + w - 1] + s) % P;     }     for (t = 1; t < k; ++t) {       d = (long long)f[k] * g[k - t] % P * g[k - t - 1] % P;       if (t + 1 <= w - 1)         s = ((long long)d * t % P * f[k] % P * pow(k, w - t - 2) + s) % P;       else         s = ((long long)d * (w - 1) % P * f[k - t + w - 2] + s) % P;     }     printf( %d , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void bruteforce() {}   long long power(long long x, long long y) {     long long res = 1;     x = x % 1000000007;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % 1000000007;       y = y >> 1;       x = (x * x) % 1000000007;     }     return res;   }   long long modInverse(long long n) { return power(n, 1000000007 - 2); }   long long primes[1000100];   int main() {     ios::sync_with_stdio(0);     long long tc = 1;     cin >> tc;     for (long long i = 2; i < 1000100; i++) {       if (!primes[i]) {         for (long long j = i * i; j < 1000100; j += i) primes[j] = i;       }     }     for (int tci = 1; tci < tc + 1; tci++) {       long long x, p, k;       cin >> x >> p >> k;       if (p == 1) {         cout << x + k << endl;         continue;       }       set<long long> s;       long long pp = primes[p];       while (primes[p]) {         s.insert(pp);         p /= pp;         pp = primes[p];       }       s.insert(p);       vector<long long> v;       for (auto ss : s) v.push_back(ss);       long long d = v.size();       long long l = x + 1, r = 1e8;       long long ans = 0;       while (l <= r) {         long long mid = (l + r) / 2;         long long u = mid - x;         for (int i = 1; i < (1ll << d); i++) {           long long num = 1;           for (int j = 0; j < d; j++) {             if (i & (1ll << j)) {               num *= v[j];             }           }           long long o = __builtin_popcount(i);           if (o % 2 == 0)             u += (mid / num) - (x / num);           else             u -= (mid / num) - (x / num);         }         if (u >= k)           r = mid - 1;         else if (u < k)           l = mid + 1;         if (u == k) ans = mid;       }       if (ans == 0) cout << x <<  00  << p <<  00  << k << endl;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, i, l, k;     cin >> t;     while (t--) {       cin >> n >> k >> l;       int s = 0, f = 2 * k - 1, dep, flg = 1;       for (i = 1; i <= n; i++) {         cin >> dep;         if (!flg) continue;         if (l < dep) {           cout <<  NO  << endl;           flg = 0;         }         if (!flg) continue;         int s1 = k - 1 - (l - dep), f1 = k - 1 + (l - dep);         if (s1 < 0) s1 = 0;         if (f1 > 2 * k - 1) f1 = 2 * k - 1;         if (s1 == 0 && f1 == 2 * k - 1) {           s = 0;           f = 2 * k - 1;           continue;         }         if (s == 0 && f == 2 * k - 1) {           s = s1;           f = f1;           continue;         }         s = max(s + 1, s1);         f = f1;         if (s > f) {           cout <<  NO  << endl;           flg = 0;         }       }       if (flg) cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, i, cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0, cnt6 = 0;     char x[10];     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %s , x);       if (x[0] ==  p ) {         cnt1++;       } else if (x[0] ==  g ) {         cnt2++;       } else if (x[0] ==  b ) {         cnt3++;       } else if (x[0] ==  o ) {         cnt4++;       } else if (x[0] ==  r ) {         cnt5++;       } else if (x[0] ==  y ) {         cnt6++;       }     }     printf( %d n , 6 - n);     if (cnt1 == 0) {       printf( Power n );     }     if (cnt2 == 0) {       printf( Time n );     }     if (cnt3 == 0) {       printf( Space n );     }     if (cnt4 == 0) {       printf( Soul n );     }     if (cnt5 == 0) {       printf( Reality n );     }     if (cnt6 == 0) {       printf( Mind n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using pii = pair<long long, long long>;   using vi = vector<long long>;   using vvi = vector<vi>;   const signed INF_ = 1001001001;   const long long INF = 1001001001001001001LL;   const long long DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0},                   DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 0};   template <class T>   ostream &operator<<(ostream &os, const vector<T> &v) {     for (auto i = begin(v); i != end(v); i++)       os << *i << (i == end(v) - 1 ?    :    );     return os;   }   template <class T>   istream &operator>>(istream &is, vector<T> &v) {     for (auto i = begin(v); i != end(v); i++) is >> *i;     return is;   }   template <class T, class U>   istream &operator>>(istream &is, pair<T, U> &p) {     is >> p.first >> p.second;     return is;   }   template <class T, class U>   bool chmax(T &a, const U &b) {     return a < b ? a = b, 1 : 0;   }   template <class T, class U>   bool chmin(T &a, const U &b) {     return a > b ? a = b, 1 : 0;   }   template <class T>   void psum(T &c) {     partial_sum(begin(c), end(c), begin(c));   }   template <class T>   using heap = priority_queue<T, deque<T>, greater<T>>;   struct before_main_function {     before_main_function() {       cin.tie(nullptr);       ios::sync_with_stdio(false);       cout << setprecision(15) << fixed;     }   } before_main_function;   signed main() {     vi a(6);     cin >> a;     long long n;     cin >> n;     vi b(n);     cin >> b;     vector<pii> c;     c.reserve(n * 6);     for (long long i = 0, ilen = (long long)(n); i < ilen; ++i) {       for (long long j = 0, jlen = (long long)(6); j < jlen; ++j) {         c.emplace_back(b[i] - a[j], i);       }     }     sort(begin(c), end(c));     map<long long, long long> cnt;     long long l = 0;     long long ans = INF;     for (long long r = 0, rlen = (long long)(((long long)c.size())); r < rlen;          ++r) {       cnt[c[r].second] += 1;       while (((long long)cnt.size()) == n) {         chmin(ans, c[r].first - c[l].first);         if (cnt[c[l].second] == 1) {           cnt.erase(c[l].second);         } else {           cnt[c[l].second] -= 1;         }         l += 1;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   void getmax(int &a, const int b) {     if (b > a) a = b;   }   struct Segment {     int l, r;     Segment() {}     Segment(const int _l, const int _r) : l(_l), r(_r) {}     bool operator<(const Segment &s) const {       return l != s.l ? l < s.l : r > s.r;     }   };   vector<Segment> SEG[100][100];   int N;   void RemoveCovering(vector<Segment> &s) {     sort(s.begin(), s.end());     vector<Segment> ans;     for (int i = 0, j; i < (int)s.size();) {       ans.push_back(s[i]);       for (j = i + 1; j < (int)s.size() && s[j].r <= s[i].r; j++)         ;       i = j;     }     s.clear(), ans.swap(s);   }   void Insert(vector<Segment> &ans, const vector<Segment> &ls,               const vector<Segment> &rs) {     for (const Segment &s : ls) ans.push_back(s);     for (const Segment &s : rs) ans.push_back(s);     if (ls.empty() || rs.empty()) return;     for (int i = 0, j = 0; i < (int)ls.size(); i++) {       while (j + 1 < (int)rs.size() && rs[j + 1].l <= ls[i].r) j++;       if (rs[j].l <= ls[i].r && rs[j].r >= ls[i].l)         ans.push_back(Segment(ls[i].l, rs[j].r));     }   }   int M;   int DP[101][301];   vector<int> VALS;   int Id(const int v) {     return lower_bound(VALS.begin(), VALS.end(), v) - VALS.begin();   }   int main() {     while (scanf( %d , &N) == 1) {       if (true) {         vector<Segment> tmp;         for (int i = 0; i < N; i++) {           static Segment s;           scanf( %d%d , &s.l, &s.r);           tmp.push_back(s);         }         sort(tmp.begin(), tmp.end());         for (int i = 0; i < N; i++)           for (int j = i; j < N; j++) SEG[i][j].clear();         VALS.clear();         for (int i = 0; i < N; i++) {           const int a = tmp[i].l, l = tmp[i].r;           SEG[i][i].push_back(Segment(a - l, a));           SEG[i][i].push_back(Segment(a, a + l));           VALS.push_back(a - l), VALS.push_back(a), VALS.push_back(a + l);         }         tmp.clear(), vector<Segment>().swap(tmp);       }       if (true) {         auto &s = VALS;         sort(s.begin(), s.end()),             s.resize(unique(s.begin(), s.end()) - s.begin());         M = s.size();       }       for (int gap = 1; gap < N; gap++) {         for (int i = 0; i + gap < N; i++) {           const int j = i + gap;           for (int k = i; k < j; k++) {             Insert(SEG[i][j], SEG[i][k], SEG[k + 1][j]);             Insert(SEG[i][j], SEG[k + 1][j], SEG[i][k]);           }           RemoveCovering(SEG[i][j]);         }       }       for (int i = 0; i <= M; i++) DP[0][i] = 0;       for (int i = 1; i <= N; i++) {         for (int j = 0; j <= M; j++) DP[i][j] = DP[i - 1][j];         for (int j = 1; j <= i; j++)           for (const auto &s : SEG[j - 1][i - 1]) {             const int l = Id(s.l) + 1;             for (int k = Id(s.r) + 1; k <= M; k++)               getmax(DP[i][k], DP[j - 1][l - 1] + (s.r - s.l));           }       }       const int ans = DP[N][M];       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 55;   int n, m;   int f[N][N], g[N][N], h[N][N], F[N][N], inv[N];   inline long long qpow(long long a, long long b) {     long long res = 1;     for (; b; b >>= 1, a = a * a % mod)       if (b & 1) res = res * a % mod;     return res;   }   inline void add(int &x, int y) {     x += y;     if (x >= mod) x -= mod;   }   inline void dec(int &x, int y) {     x -= y;     if (x < 0) x += mod;   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n + 1; i++) inv[i] = qpow(i, mod - 2);     f[0][1] = 1;     h[0][0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = n + 1; j >= 1; j--)         F[i - 1][j] = (F[i - 1][j + 1] + f[i - 1][j]) % mod;       for (int j = n + 1; j >= 1; j--)         for (int k = 0; k < i; k++)           add(g[i][j], 1ll * F[k][j] * F[i - k - 1][j] % mod);       for (int j = 1; j <= n + 1; j++) dec(g[i][j], g[i][j + 1]);       for (int j = 1; j <= n + 1; j++)         for (int x = n; x >= 0; x--)           for (int y = n + 1; y >= 0; y--) {             int res = 0, c = 1;             for (int k = 0; k * i <= x && k * j <= y; k++) {               add(res, 1ll * h[x - k * i][y - k * j] * c % mod);               c = 1ll * c * (g[i][j] + k) % mod * inv[k + 1] % mod;             }             h[x][y] = res;           }       for (int j = 1; j <= n + 1; j++) f[i][j] = h[i][j - 1];     }     printf( %d , f[n][m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long n, i, a;     unsigned long long s1 = 0, s2 = 0, s3 = 0;     cin >> n;     for (i = 0; i < n; i++) {       cin >> a;       s1 += (unsigned long long)a;     }     for (i = 0; i < n - 1; i++) {       cin >> a;       s2 += (unsigned long long)a;     }     for (i = 0; i < n - 2; i++) {       cin >> a;       s3 += (unsigned long long)a;     }     cout << s1 - s2 <<   n  << s2 - s3;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   long long a[N], b[N];   void add(int l, int r, int val) {     if (l > r) return;     b[l] += val;     b[r + 1] -= val;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) cin >> a[i];     for (int i = 1; i < m; i++)       if (a[i - 1] != a[i]) {         int x1 = min(a[i - 1], a[i]);         int x2 = max(a[i - 1], a[i]);         add(1, x1 - 1, x2 - x1);         add(x1, x1, x2 - 1);         add(x1 + 1, x2 - 1, x2 - x1 - 1);         add(x2, x2, x1);         add(x2 + 1, n, x2 - x1);       }     for (int i = 1; i <= n; i++) b[i] += b[i - 1];     for (int i = 1; i <= n; i++) {       if (i > 1) cout <<    ;       cout << b[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200000 + 10;   struct node {     int next, to;   } e[maxn * 2];   int head[maxn * 2];   int a[maxn];   set<int> G[maxn];   int ans[maxn];   int cnt;   int gcd(int a, int b) {     if (!b) return a;     return gcd(b, a % b);   }   void init() {     memset(head, 0, sizeof(head));     cnt = 0;   }   void add(int u, int t) {     e[++cnt].next = head[u];     e[cnt].to = t;     head[u] = cnt;   }   void dfs(int u, int fa) {     for (int i = head[u]; i != 0; i = e[i].next) {       int v = e[i].to;       if (v == fa) continue;       ans[v] = gcd(ans[u], a[v]);       G[v].insert(ans[u]);       for (set<int>::iterator it = G[u].begin(); it != G[u].end(); it++) {         G[v].insert(gcd(*it, a[v]));       }       dfs(v, u);     }   }   int main() {     int n;     init();     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       add(u, v);       add(v, u);     }     ans[1] = a[1];     G[1].insert(0);     dfs(1, 0);     for (int i = 1; i <= n; i++) {       set<int>::iterator it = G[i].end();       it--;       ans[i] = max(ans[i], *it);     }     for (int i = 1; i <= n; i++) {       if (i == 1)         printf( %d , ans[i]);       else         printf(  %d , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   int powmod(long long a, int b, int c) {     long long r = 1 % c;     while (b) {       if (b & 0x1) r = r * a % c;       a = a * a % c;       b >>= 1;     }     return r;   }   int phi(int n) {     int ret = n, i;     for (i = 2; i * i <= n; ++i)       if (n % i == 0) {         ret -= ret / i;         while (n % i == 0) n /= i;       }     if (n != 1) ret -= ret / n;     return ret;   }   int eval(char s[]) {     int i, r = 0;     for (i = 0; s[i]; ++i) r = r * 10 + s[i] -  0 ;     return r;   }   char B[1000005], N[1000005];   int C;   void gao() {     long long b = 0, c;     int i;     for (i = 0; B[i]; ++i) b = b * 10 + B[i] -  0 , b %= C;     if (strlen(N) == 1 && N[0] ==  1 ) {       --b;       if (b < 0) b += C;       if (b == 0) b = C;       cout << b << endl;       return;     }     if (strlen(N) <= 9) {       c = eval(N);       --c;     } else {       c = phi(C);       long long t = 0;       for (i = 0; N[i]; ++i) t = t * 10 + N[i] -  0 , t %= c;       --t;       if (t < 0) t += c;       c += t;     }     long long ret = powmod(b, c, C);     ret = ret * (b - 1) % C;     if (ret < 0) ret += C;     if (ret == 0) ret = C;     cout << ret << endl;   }   int main() {     while (3 == scanf( %s%s%d , B, N, &C)) gao();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (!(n & 1))       cout << -1 << endl;     else {       for (int i = 0; i < n; i++) cout << i <<    ;       cout << endl;       for (int i = 0; i < n; i++) cout << i <<    ;       cout << endl;       for (int i = 0; i < n; i++) cout << 2 * i % n <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const double EPS = 1e-8;   const int mod = 1e9 + 7;   const int N = 1e6 + 10;   const long long INF = 1e18;   long long power(long long x, long long y) {     long long t = 1;     while (y > 0) {       if (y % 2)         y -= 1, t = t * x % mod;       else         y /= 2, x = x * x % mod;     }     return t;   }   vector<vector<pair<int, long long>>> G;   set<pair<long long, int>> s;   vector<long long> dis;   vector<int> par;   void dijkstra(int x) {     int n = G.size();     dis.resize(n);     par.resize(n);     for (int i = 0; i < n; ++i) {       dis[i] = INF;       par[i] = -1;     }     dis[x] = 0;     for (int i = 0; i < n; ++i) s.insert(make_pair(dis[i], i));     while (!s.empty()) {       auto curr = s.begin();       int v = curr->second, val = curr->first;       s.erase(s.begin());       for (auto u : G[v]) {         if (dis[u.first] > dis[v] + u.second) {           s.erase(make_pair(dis[u.first], u.first));           dis[u.first] = dis[v] + u.second;           par[u.first] = v;           s.insert(make_pair(dis[u.first], u.first));         }       }     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     G.resize(n);     for (int i = 0; i < m; ++i) {       int x, y;       long long z;       scanf( %d%d%lld , &x, &y, &z);       x--, y--;       G[x].push_back(make_pair(y, z));       G[y].push_back(make_pair(x, z));     }     dijkstra(0);     if (dis[n - 1] == INF)       printf( -1 n );     else {       stack<int> ans;       ans.push(n - 1);       int curr = n - 1;       while (curr != 0) {         curr = par[curr];         ans.push(curr);       }       while (!ans.empty()) {         int x = ans.top() + 1;         ans.pop();         printf( %d  , x);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double bili = acos(-1.0) / 4;   const double pi = acos(-1.0);   bool IN() {     char ch = getchar();     while (ch <  0  || ch >  9 ) ch = getchar();     return bool(ch -  0 );   }   int n, ptot, yuan;   bool a[2005][2005], vis[2005][2005];   int sum[2005][2005];   pair<int, int> Q[4000005];   int l, r, ans1;   int dx[4] = {-1, 1, 0, 0};   int dy[4] = {0, 0, -1, 1};   double C[100005];   bool edge(int x, int y) {     for (int i = 0; i < 4; i++) {       int zx = x + dx[i], zy = y + dy[i];       if (zx <= 0 || zx > n || zy <= 0 || zy > n || a[zx][zy] == 0) return 1;     }     return 0;   }   void bfs(int x, int y) {     Q[l = r = 1] = make_pair(x, y);     int bian = 0;     for (; l <= r; l++) {       pair<int, int> u = Q[l];       if (edge(u.first, u.second)) bian++;       for (int j = 0; j < 4; j++) {         pair<int, int> v = make_pair(u.first + dx[j], u.second + dy[j]);         if (v.first > 0 && v.first <= n && v.second > 0 && v.second <= n &&             !vis[v.first][v.second]) {           if (a[v.first][v.second] == 0) continue;           Q[++r] = v;           vis[v.first][v.second] = 1;         }       }     }     int mxy = -211, mxx = 0, miy = 21100, mix = 0, d = 0;     for (int i = (int)1; i <= (int)r; i++) {       if (Q[i].second > mxy) {         mxx = Q[i].first;         mxy = Q[i].second;       }       if (Q[i].second < miy) {         mix = Q[i].first;         miy = Q[i].second;       }     }     if (r > 101) {       sort(Q + 1, Q + r + 1);       for (int i = 1; i <= 8; i++)         for (int j = r - 7; j <= r; j++) {           d = max(d, ((Q[i].first - Q[j].first) * (Q[i].first - Q[j].first) +                       (Q[i].second - Q[j].second) * (Q[i].second - Q[j].second)));         }       ++ans1;       double z = 1.0 * d / r;       if (z < 1.55) yuan++;     }   }   int main() {     scanf( %d , &n);     for (int i = (int)1; i <= (int)n; i++)       for (int j = (int)1; j <= (int)n; j++) a[i][j] = IN();     for (int i = (int)1; i <= (int)n; i++)       for (int j = (int)1; j <= (int)n; j++)         sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];     for (int i = (int)1; i <= (int)n; i++) {       for (int j = (int)1; j <= (int)n; j++) {         int u = ((((i) < (j) ? (i) : (j))) <                          (((n - i + 1) < (n - j + 1) ? (n - i + 1) : (n - j + 1)))                      ? (((i) < (j) ? (i) : (j)))                      : (((n - i + 1) < (n - j + 1) ? (n - i + 1) : (n - j + 1))));         u = ((u) < (4) ? (u) : (4));         int sm = sum[i + u - 1][j + u - 1] - sum[i - u + 1 - 1][j + u - 1] -                  sum[i + u - 1][j - u + 1 - 1] +                  sum[i - u + 1 - 1][j - u + 1 - 1],             total = (2 * u) * (2 * u);         double lv = 1. * sm / total;         if (lv > 0.5)           a[i][j] = 1;         else           a[i][j] = 0;       }     }     for (int i = (int)1; i <= (int)n; i++)       for (int j = (int)1; j <= (int)n; j++) {         if (vis[i][j]) continue;         bfs(i, j);       }     sort(C + 1, C + ans1 + 1);     printf( %d %d n , yuan, ans1 - yuan);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[100009];   int dp[100009];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i];     int ans = 1;     dp[0] = 1;     for (int i = 0; i < n; i++) {       dp[i] = 1;       if (arr[i] >= arr[i - 1]) dp[i] = dp[i - 1] + 1;       ans = max(ans, dp[i]);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int T;   double pi = acos(-1.0);   vector<long long> v;   long long factorial(long long x) {     long long total = 1;     for (int i = 2; i <= x; i++) total *= i;     return total;   }   bool isprime(long long x) {     vector<bool> prime(x + 1, 1);     prime[0] = prime[1] = 0;     for (long long i = 2; i * i <= x; i++)       if (prime[i])         for (long long j = i * i; j <= x; j += i) prime[j] = 0;     return prime[x];   }   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long temp = 1;   long long fastpow(long long base, long long exponent) {     if (exponent == 0) return 1;     if (exponent == 1) return (temp * base);     if (exponent % 2 == 0)       return fastpow(base * base, exponent / 2);     else {       temp *= base;       fastpow(base * base, exponent / 2);     }   }   void fill(long long f) {     v.clear();     long long x;     for (long long i = 0; i < f; i++) {       cin >> x;       v.push_back(x);     }   }   void printv() {     int size = v.size() - 1;     for (int i = 0; i <= size; i++) {       cout << v[i] <<    ;     }     cout << endl;   }   bool is = 0;   long long f(long long n) {     long long num = n;     long long Max = 0, Min = 9;     while (n) {       long long dig = n % 10;       if (dig == 0) {         is = 1;         return num;       }       Max = max(Max, dig);       Min = min(Min, dig);       n /= 10;     }     return Max * Min + num;   }   void solve() {     int n, m;     cin >> n >> m;     int cn = 0;     for (int a = 0; a <= 1000; a++)       for (int b = 0; b <= 1000; b++)         if (a * a + b == n && b * b + a == m) {           cn++;         }     cout << cn << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     { solve(); }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( -O2 )   const int lim = 2e5 + 5;   long long n, k, x, y, t, ans, p[lim];   map<long long, long long> f;   long long inv(long long x) { return (~x) & ((1LL << k) - 1); }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     f[0] += 1;     ans += n * (n + 1);     for (int i = 1; i <= n; i++) {       cin >> x;       p[i] = p[i - 1] ^ x;       f[p[i]]++;     }     for (auto u : f) {       if (f.find(inv(u.first)) == f.end()) {         t = f[u.first] / 2;         y = f[u.first] - t;         ans -= t * (t - 1) + y * (y - 1);       } else {         t = (f[u.first] + f[inv(u.first)]) / 2;         y = f[u.first] + f[inv(u.first)] - t;         ans -= t * (t - 1) / 2 + y * (y - 1) / 2;       }     }     ans /= 2;     cout << ans << endl;     return 0;   }