malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   double a[maxn], st[maxn];   int len[maxn];   int main() {     int n, x;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &x);       a[i] = x;     }     int p = 0;     for (int i = 1; i <= n; i++) {       st[++p] = a[i];       len[p] = 1;       while (p > 1 && st[p] < st[p - 1]) {         st[p - 1] =             (st[p - 1] * len[p - 1] + st[p] * len[p]) / (len[p - 1] + len[p]);         len[p - 1] += len[p];         p--;       }     }     for (int i = 1; i <= p; i++) {       for (int j = 1; j <= len[i]; j++) {         printf( %.10f n , st[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T SQR(T x) {     return x * x;   }   template <class T>   inline string TOSTR(const T &x) {     stringstream ss;     ss << x;     return ss.str();   }   template <class T>   void UPDATE_MIN(T &x, T y) {     if (y < x) {       x = y;     }   }   template <class T>   void UPDATE_MAX(T &x, T y) {     if (x < y) {       x = y;     }   }   int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }   long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }   long long powmod(long long a, long long p, long long m) {     long long r = 1;     while (p) {       if (p & 1) r = r * a % m;       p >>= 1;       a = a * a % m;     }     return r;   }   template <typename K, typename V>   V GetWithDef(const std::unordered_map<K, V> &m, const K &key, const V &defval) {     auto it = m.find(key);     if (it == m.end()) {       return defval;     } else {       return it->second;     }   }   template <typename K, typename V>   void SetDef(std::unordered_map<K, V> &m, const K &key, const V &defval) {     auto it = m.find(key);     if (it == m.end()) m[key] = defval;   }   const int MOD = 1000 * 1000 * 1000 + 7;   const double PI = 3.1415926535897932384626433832795l;   struct Event {     int id;     long long x;     char type;     bool operator<(const Event &other) const {       if (x < other.x) return true;       if (x > other.x) return false;       return type < other.type;     }   };   Event events[2 * 200123];   int saved_max[200123];   int evtop = 0;   int N;   int main() {     ios_base::sync_with_stdio(0);     cin >> N;     for (int(i) = 0; (i) < (int)(N); (i)++) {       int x, w;       cin >> x >> w;       events[evtop++] = {i, x - w, 1};       events[evtop++] = {i, x + w, 0};     }     sort(events, events + evtop);     int max_cur_closed = 0;     for (int(i) = 0; (i) < (int)(evtop); (i)++) {       Event &e = events[i];       if (e.type == 1) {         saved_max[e.id] = max_cur_closed;       } else if (e.type == 0) {         UPDATE_MAX(max_cur_closed, saved_max[e.id] + 1);       } else         assert(0);     }     cout << max_cur_closed << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define f first   #define s second   #define ll long long   #define ld long double   #define pii pair <int,int>   #define pll pair <ll,ll>   #define pil pair <int,ll>   #define pli pair <ll,int>   #define pss pair <short,short>   #define ull unsigned long long   #define pdd pair <ld,ld>    #define pb push_back   #define mp make_pair   #define puu pair<ull,ull>   #define pvv pair<vector<int>, vector<int> >   #define _bp __builtin_popcount   #define ptt pair <pnode,pnode>   #define all(v) v.begin(),v.end()   #define en   n    void file()   {       freopen( input.txt , r ,stdin);       freopen( f.txt , w ,stdout);   }   void boos()   {    ios_base :: sync_with_stdio(0);    cin.tie(0);    cout.tie(0);   }   //const long double pi = acos(-1);   const ll INF = (ll)1e9 + 7ll;   const ll INF1 = 998244353;   const ll INF2 = (ll)1e9 + 9ll;   const ll LLINF = (ll)1e18;   const ll INTmx = (ll)1e9;   const ld EPS = (ld)1e-15;   const int N = 3e5 + 100;   string a[N];   ll st[N],dp[N],dp1[N],dp2[N];   int main()   {    boos();    //file();    int n,m;    cin >> n >> m;    int k = 0;    for(int i = 1;i <= n;i++)    {     cin >> a[i];     a[i] =  0  + a[i];     for(int j = 1;j <= m;j++)     {      if(a[i][j] ==  o )k++;     }    }    st[0] = 1;    dp1[0] = 1;    for(int i = 1;i <= k;i++)    {     st[i] = (st[i - 1] * 2ll) % INF1;    }    dp2[2] = 1;    dp1[2] = 1;    for(ll i = 3;i <= max(n,m);i++)    {     dp[i] = (dp[i - 2] + (st[i - 3] * (i - 2)) % INF1) % INF1;     if(i % 2 == 0)dp1[i] = (dp1[i - 1] * 2ll + 1ll) % INF1;     else dp1[i] = (dp1[i - 1] * 2ll) % INF1;     dp2[i] = dp[i];     dp2[i] = (dp2[i] + dp1[i]) % INF1;    }    //cout << dp2[3] <<     << k <<     << st[k - 2] << en;    ll ans = 0;    for(int i = 1;i <= n;i++)    {     int L = 1;     for(int j = 1;j <= m;j++)     {      if(a[i][j] ==  * )      {       if(L != j)       {        ans += (dp2[j - L] * st[k - (j - L)]) % INF1;        //ans += (st[j - L - 2] * st[k - (j - L)]) % INF1;        //cout << j - L <<    ;        ans %= INF1;       }       L = j + 1;      }     }     if(L != m + 1)     {      ans += (dp2[m - L + 1] * st[k - (m - L + 1)]) % INF1;      //ans += (st[m - L - 1] * st[k - (m - L + 1)]) % INF1;      //cout << m - L + 1 <<    ;      ans %= INF1;     }    }    //cout << dp[4] << en;    for(int j = 1;j <= m;j++)    {     int L = 1;     for(int i = 1;i <= n;i++)     {      if(a[i][j] ==  * )      {       if(L != i)       {        ans += (dp2[i - L] * st[k - (i - L)]) % INF1;        //ans += (st[i - L - 2] * st[k - (i - L)]) % INF1;        //cout << i - L <<    ;        ans %= INF1;       }       L = i + 1;      }     }     if(L != n + 1)     {      ans += (dp2[n - L + 1] * st[k - (n - L + 1)]) % INF1;      //ans += (st[n - L - 1] * st[k - (n - L + 1)]) % INF1;      //cout << n- L + 1 <<    ;      ans %= INF1;     }    }    cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 300005;   long long n, m, k;   struct node {     int id;     long long pos;     long long dir;   } no[MX];   int now[MX];   int ans[MX];   bool cmp(node a, node b) {     if (a.pos < b.pos) return true;     return false;   }   int main() {     char ss[5];     scanf( %I64d%I64d%I64d , &n, &m, &k);     long long p = 0;     for (int i = 0; i < n; i++) {       scanf( %I64d%s , &no[i].pos, ss);       --no[i].pos;       no[i].id = i;       no[i].dir = 1;       if (ss[0] ==  L ) no[i].dir = -1;       if (ss[0] ==  R )         p += (k + no[i].pos) / m;       else         p -= (k + m - 1 - no[i].pos) / m;       now[i] = ((no[i].pos + no[i].dir * k) % m + m) % m;     }     p = p % n;     sort(no, no + n, cmp);     sort(now, now + n);     for (int i = 0; i < n; i++) {       ans[no[((i - p) % n + n) % n].id] = now[i] + 1;     }     for (int i = 0; i < n; i++) {       printf( %d%c , ans[i], i == n - 1 ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   const int MAXN = 200010;   int B[MAXN], C[MAXN], a[MAXN];   long long b[MAXN], c[MAXN];   struct Node {     int b, c, id;     bool operator<(const Node ano) const { return b + c < ano.b + ano.c; }   } opt[MAXN];   int cnt[MAXN];   bool check(int x) {     int now = x;     for (int i = 1; i <= n; i++) {       a[opt[i].id] = now;       now += ((opt[i + 1].b + opt[i + 1].c - opt[i].b - opt[i].c) / n);     }     memset(cnt, 0, sizeof cnt);     memset(b, 0, sizeof b);     memset(c, 0, sizeof c);     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 30; j++) {         if ((a[i] >> j) & 1) cnt[j]++;       }     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 30; j++) {         if ((a[i] >> j) & 1) {           b[i] += 1LL * cnt[j] * (1 << j);           c[i] += 1LL * n * (1 << j);         } else {           c[i] += 1LL * cnt[j] * (1 << j);         }       }     }     return b[1] + c[1] >= B[1] + C[1];   }   bool check2(int x) {     int now = x;     for (int i = 1; i <= n; i++) {       a[opt[i].id] = now;       now += ((opt[i + 1].b + opt[i + 1].c - opt[i].b - opt[i].c) / n);     }     memset(cnt, 0, sizeof cnt);     memset(b, 0, sizeof b);     memset(c, 0, sizeof c);     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 30; j++) {         if ((a[i] >> j) & 1) cnt[j]++;       }     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 30; j++) {         if ((a[i] >> j) & 1) {           b[i] += 1LL * cnt[j] * (1 << j);           c[i] += 1LL * n * (1 << j);         } else {           c[i] += 1LL * cnt[j] * (1 << j);         }       }     }     for (int i = 1; i <= n; i++) {       if ((b[i] != B[i]) || (c[i] != C[i])) return 0;     }     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       scanf( %d , &opt[i].b), B[i] = opt[i].b, opt[i].id = i;     for (int i = 1; i <= n; i++) scanf( %d , &opt[i].c), C[i] = opt[i].c;     sort(opt + 1, opt + n + 1);     for (int i = 2; i <= n; i++) {       if ((opt[i].b + opt[i].c - opt[i - 1].b - opt[i - 1].c) % n != 0) {         puts( -1 );         return 0;       }     }     int l = 0, r = 1000000000;     while (l < r) {       int mid = (l + r) >> 1;       if (check(mid))         r = mid;       else         l = mid + 1;     }     if (check2(l)) {       for (int i = 1; i <= n; i++) printf( %d%c , a[i], (i == n ? 10 :    ));     } else       puts( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const int N = (1 << 18);   const double PI = acos(-1.0);   char s[N];   int lA, lB;   int a[N], b[N];   int inB[110][N];   int S, B;   struct cpx {     double x, y;     cpx(double p = 0, double q = 0) : x(p), y(q) {}     cpx operator+(cpx &o) { return cpx(x + o.x, y + o.y); }     cpx operator-(cpx &o) { return cpx(x - o.x, y - o.y); }     cpx operator*(cpx &o) { return cpx(x * o.x - y * o.y, x * o.y + y * o.x); }   } u[N], v[N];   void fft(cpx *a, int n, int f) {     int i, j, k;     for (i = j = 0; i < n; ++i) {       if (i > j) swap(a[i], a[j]);       for (k = n >> 1; (j ^= k) < k; k >>= 1)         ;     }     for (i = 1; i < n; i <<= 1) {       cpx wn(cos(PI / i), f * sin(PI / i));       for (j = 0; j < n; j += i << 1) {         cpx w(1, 0);         for (k = 0; k < i; ++k, w = w * wn) {           cpx x = a[j + k], y = w * a[i + j + k];           a[j + k] = x + y;           a[i + j + k] = x - y;         }       }     }     if (f == -1)       for (i = 0; i < n; ++i) a[i].x /= n, a[i].y /= n;   }   void work(int *a, int A, int id) {     int n = 1;     while (n <= A + lB) n <<= 1;     for (int i = 0; i < A; ++i) u[i] = cpx(a[i], 0);     for (int i = A; i < n; ++i) u[i] = cpx(0, 0);     for (int i = 0; i < A - 1 - i; ++i) swap(u[i], u[A - 1 - i]);     for (int i = 0; i < lB; ++i) v[i] = cpx(b[i], 0);     for (int i = lB; i < n; ++i) v[i] = cpx(0, 0);     fft(u, n, 1), fft(v, n, 1);     for (int i = 0; i < n; ++i) u[i] = u[i] * v[i];     fft(u, n, -1);     for (int i = 0; i < lB; ++i) inB[id][i] = (A - round(u[i].x)) / 2;   }   int main() {     scanf( %s , s);     lA = strlen(s);     for (int i = 0; i < lA; ++i) a[i] = (s[i] ==  1  ? 1 : -1);     scanf( %s , s);     lB = strlen(s);     for (int i = 0; i < lB; ++i) b[i] = (s[i] ==  1  ? 1 : -1);     S = sqrt(lA * log2(lA));     B = ceil(1. * lA / S);     for (int i = 0; i < B; ++i) {       int l = i * S, r = min(lA, l + S);       work(a + l, r - l, i);     }     int q;     scanf( %d , &q);     while (q--) {       int l, r, len, res = 0;       scanf( %d %d %d , &l, &r, &len);       int p = l / S, q = (l + len - 1) / S;       if (p == q) {         for (int i = l; i < l + len; ++i) res += (a[i] != b[i - l + r]);       } else {         for (int i = l; i < (p + 1) * S; ++i) res += (a[i] != b[i - l + r]);         for (int i = p + 1; i < q; ++i) res += (inB[i][(i + 1) * S - 1 - l + r]);         for (int i = q * S; i < l + len; ++i) res += (a[i] != b[i - l + r]);       }       printf( %d n , res);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, a, b;     cin >> n >> k >> a >> b;     bool impossible = false;     string s;     int curGroup = (a > b) ? 0 : 1;     int groupSize = 0;     for (int i = 0; i < n; ++i) {       if (curGroup) {         if (!b--) {           impossible = true;           break;         }         s.push_back( B );       } else {         if (!a--) {           impossible = true;           break;         }         s.push_back( G );       }       if (++groupSize == k || ((curGroup && a > b) || (!curGroup && b > a))) {         curGroup = 1 - curGroup;         groupSize = 0;       }     }     cout << (impossible ?  NO  : s) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[3 * 100001];   int main() {     int n;     long long s = 0;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> v[i];     }     sort(v + 1, v + n + 1);     for (int i = 1; i <= n / 2; ++i) {       s += (v[i] + v[n - i + 1]) * (v[i] + v[n - i + 1]);     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( sse4,avx )   struct Solution {     int n;     std::vector<std::vector<int>> graph;     std::vector<std::vector<int>> matrix;     int counter;     std::vector<int> dirtyFlags;     std::vector<double> maxProbs;     double checkFirst(int a) {       double res = 0;       for (int dist = 0; dist < n; dist++) {         std::vector<int> group;         for (int i = 0; i < n; i++) {           if (matrix[a][i] == dist) {             group.push_back(i);           }         }         if (group.size() == 0) continue;         double caseProb = group.size() / (double)n;         double c = 1.0 / group.size();         double ans = c;         std::vector<double> t(n);         for (int v : group) {           for (int nv : graph[v]) {             t[nv] += c / graph[v].size();           }         }         std::vector<int> groupT;         std::vector<double> groupTD;         for (int i = 0; i < n; i++) {           if (t[i] > 1e-20) {             groupT.push_back(i);             groupTD.push_back(t[i]);           }         }         for (int b = 0; b < n; b++) {           counter++;           double cur = 0;           for (size_t i = 0; i < groupT.size(); i++) {             int v = groupT[i];             double tv = groupTD[i];             int d = matrix[b][v];             if (dirtyFlags[d] == counter) {               if (tv > maxProbs[d]) {                 cur += tv - maxProbs[d];                 maxProbs[d] = tv;               }             } else {               dirtyFlags[d] = counter;               maxProbs[d] = tv;               cur += tv;             }           }           ans = std::max(ans, cur);         }         res += caseProb * ans;       }       return res;     }     void run(std::istream& in, std::ostream& out) {       int m;       in >> n >> m;       graph.clear();       graph.resize(n);       matrix.clear();       matrix.resize(n, std::vector<int>(n, 1000000));       for (int i = 0; i < n; i++) {         matrix[i][i] = 0;       }       for (int i = 0; i < m; i++) {         int a, b;         in >> a >> b;         a--;         b--;         graph[a].push_back(b);         graph[b].push_back(a);         matrix[a][b] = 1;         matrix[b][a] = 1;       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           for (int k = 0; k < n; k++) {             matrix[j][k] = std::min(matrix[j][k], matrix[j][i] + matrix[i][k]);           }         }       }       counter = 0;       dirtyFlags.resize(n);       maxProbs.resize(n);       double ans = 0;       for (int a = 0; a < n; a++) {         ans = std::max(ans, checkFirst(a));       }       out.precision(12);       out << ans << std::endl;     }   };   int main() {     std::cin.sync_with_stdio(false);     std::cin.tie(nullptr);     Solution().run(std::cin, std::cout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<string> f;   int main() {     int n;     cin >> n;     int ans = 0;     for (int i = 0; i < n; ++i) {       string s =   ;       while (1) {         char c;         cin >> c;         if (isdigit(c)) s += c;         if (((int)(s).size()) == 4) break;       }       swap(s[2], s[3]);       string t = s;       for (int i = 0; i < 4; ++i) {         char c = s[0];         for (int j = 0; j < 3; ++j) s[j] = s[j + 1];         s[3] = c;         if (s < t) t = s;       }       if (!f.count(t)) ++ans;       f.insert(t);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 ,  unroll-all-loops )   #pragma GCC target( sse4.2 )   using namespace std;   const long long kk = 1000;   const long long ml = kk * kk;   const long long mod = ml * kk + 7;   const long long inf = ml * ml * ml + 7;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   long long n;   bool viv = false;   string a, b;   int in[20], out[20];   vector<vector<int>> comp;   void DFS(int v, vector<bool> &used) {     used[v] = true;     comp.back().push_back(v);     for (int s = 0; s < 20; s++)       if ((out[v] & (1 << s)) || (in[v] & (1 << s)))         if (!used[s]) DFS(s, used);   }   void get_comp() {     vector<bool> used(20, false);     for (int i = 0; i < 20; i++)       if (!used[i]) {         comp.push_back({});         DFS(i, used);       }   }   int cnt(int val) {     int res = 0;     while (val) res += (val & 1), val >>= 1;     return res;   }   void solve() {     cin >> n;     cin >> a >> b;     comp.clear();     for (int i = 0; i < 20; i++) in[i] = out[i] = 0;     for (int i = 0; i < n; i++)       if (a[i] != b[i]) {         out[a[i] -  a ] |= (1 << (b[i] -  a ));         in[b[i] -  a ] |= (1 << (a[i] -  a ));       }     bool dag[1 << 20];     for (int i = 0; i < (1 << 20); i++) dag[i] = false;     dag[0] = true;     for (int mask = 0; mask < (1 << 20); mask++) {       for (int i = 0; i < 20; i++)         if ((mask >> i) & 1) {           if (((mask ^ (1 << i)) & (in[i])) == 0)             dag[mask] |= dag[mask ^ (1 << i)];         }     }     get_comp();     int ans = 0;     for (auto c : comp) {       if (viv) {         for (auto i : c) cout << i <<    ;         cout << endl;       }       int sz = c.size();       int mx_dag = 0;       for (int smask = 0; smask < (1 << sz); smask++) {         int mask = 0;         for (int i = 0; i < sz; i++)           if ((smask >> i) & 1) mask ^= (1 << c[i]);         if (dag[mask]) mx_dag = max(mx_dag, cnt(mask));       }       ans += 2 * sz - mx_dag - 1;     }     cout << ans <<   n ;     if (viv) cout <<   t____ t____ t  << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, m, k, w;   vector<vector<vector<char>>> mp;   struct dsu {     vector<long long int> p, sz;     dsu(long long int n) {       p.resize(n);       sz.resize(n, 1);       for (long long int i = 0; i < n; i++) p[i] = i;     }     long long int getRoot(long long int v) {       if (p[v] == v)         return v;       else         return p[v] = getRoot(p[v]);     }     void unite(long long int a, long long int b) {       a = getRoot(a);       b = getRoot(b);       if (a != b) {         if (sz[a] < sz[b]) swap(a, b);         p[b] = a;         sz[a] += sz[b];       }     }     bool inOne(long long int a, long long int b) {       a = getRoot(a);       b = getRoot(b);       return a == b;     }   };   long long int getR(long long int a, long long int b) {     long long int ans = 0;     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < m; j++) {         ans += (mp[a][i][j] != mp[b][i][j]);       }     }     return ans;   }   struct edge {     long long int a, b, w;     edge(long long int a = 0, long long int b = 0, long long int w = 0) {       this->a = a;       this->b = b;       this->w = w;     }   };   bool cmp(const edge& a, const edge& b) { return a.w < b.w; }   vector<vector<long long int>> g;   vector<pair<long long int, long long int>> path;   void dfs(long long int v = 0, long long int p = -1) {     if (p > -1) path.push_back({v, p});     for (auto to : g[v]) {       if (to == p) continue;       dfs(to, v);     }   }   signed main() {     cin >> n >> m >> k >> w;     mp.resize(k + 1, vector<vector<char>>(n, vector<char>(m)));     g.resize(k + 1);     for (long long int i = 1; i <= k; i++) {       for (long long int j = 0; j < n; j++) {         for (long long int w = 0; w < m; w++) cin >> mp[i][j][w];       }     }     vector<edge> ed;     for (long long int i = 1; i <= k; i++) ed.push_back(edge(0, i, n * m));     for (long long int i = 1; i <= k; i++) {       for (long long int j = i + 1; j <= k; j++)         ed.push_back(edge(i, j, getR(i, j) * w));     }     sort(ed.begin(), ed.end(), cmp);     dsu s(k + 1);     long long int ans = 0;     for (auto e : ed) {       long long int a = e.a, b = e.b, w = e.w;       if (s.inOne(a, b)) continue;       ans += w;       s.unite(a, b);       g[a].push_back(b);       g[b].push_back(a);     }     dfs();     cout << ans <<   n ;     for (auto i : path) cout << i.first <<     << i.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5000 + 10, MOD = 1000000007;   vector<pair<int, int> > lis[MAXN * 2];   pair<int, int> p[MAXN];   int n, f[MAXN], cnt;   bool b[MAXN];   int dis(const pair<int, int> &a, const pair<int, int> &b) {     return abs(a.first - b.first) + abs(a.second - b.second);   }   int getf(int first) {     if (first == f[first]) return first;     int fx = f[first];     f[first] = getf(f[first]);     b[first] ^= b[fx];     return f[first];   }   bool Merge(int first, int second) {     int fx = getf(first), fy = getf(second);     if (fx == fy) return b[first] ^ b[second];     f[fx] = fy;     b[fx] = b[first] ^ b[second] ^ 1;     --cnt;     return true;   }   int Pow(int a, int b) {     int d = 1;     for (; b; d = (b & 1) ? (long long)d * a % MOD : d,               a = (long long)a * a % MOD, b /= 2)       ;     return d;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d%d , &p[i].first, &p[i].second);     for (int i = 1; i <= n; ++i)       for (int j = i + 1; j <= n; ++j)         lis[dis(p[i], p[j])].push_back(make_pair(i, j));     cnt = n;     for (int i = 1; i <= n; ++i) f[i] = i, b[i] = 0;     for (int i = MAXN * 2 - 1; i >= 1; --i) {       bool flag = true;       int sum = cnt;       for (vector<pair<int, int> >::iterator it = lis[i].begin();            it != lis[i].end(); ++it)         if (!Merge(it->first, it->second)) {           flag = false;           break;         }       if (!flag) {         cout << i << endl;         cout << Pow(2, sum) << endl;         exit(0);       }     }     cout << 0 << endl << 2 << endl;     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:102400000,102400000 )   const int N = 1e5 + 10, M = 1024;   int a[N], cnt[N], n, k, x;   int main() {     scanf( %d %d %d , &n, &k, &x);     int ai;     for (int i = 1; i <= n; i++) {       scanf( %d , &ai);       a[ai]++;     }     for (int ca = 1; ca <= k; ca++) {       int tot = 0, y;       for (int i = 0; i <= M; i++) {         if (tot & 1)           cnt[i] = a[i] >> 1;         else           cnt[i] = (a[i] + 1) >> 1;         tot += a[i];       }       for (int i = 0; i <= M; i++) a[i] -= cnt[i], a[i ^ x] += cnt[i];     }     for (int i = M; i >= 0; i--)       if (a[i]) {         printf( %d  , i);         break;       }     for (int i = 0; i <= M; i++)       if (a[i]) {         printf( %d n , i);         break;       }     return 0;   }