malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 212345, OFFSET = 3;   struct BITree {     long long a[MAXN];     void clear() { memset(a, 0, sizeof(a)); }     int lowbit(int i) { return (i & -i); }     long long sum(int i) {       long long ret = 0;       for (i += OFFSET; i > 0; i -= lowbit(i)) ret += a[i];       return ret;     }     void add(int i, long long d) {       for (i += OFFSET; i < MAXN; i += lowbit(i)) a[i] += d;     }   } cnt, sum;   int h[MAXN];   vector<pair<int, long long> > qq;   vector<int> H;   int find(int h) { return lower_bound(H.begin(), H.end(), h) - H.begin(); }   int main() {     int n, q;     scanf( %d%d , &n, &q);     for (int i = 0; i < int(n); i++) scanf( %d , h + i);     qq.resize(q);     H = vector<int>(h, h + n);     for (int i = 0; i < int(q); i++) {       int t;       scanf( %d , &t);       if (t == 1) {         int p, x;         scanf( %d%d , &p, &x);         qq[i].first = p - 1;         qq[i].second = x;         H.push_back(x);       } else {         long long v;         scanf( %I64d , &v);         qq[i].first = -1;         qq[i].second = v;       }     }     sort(H.begin(), H.end());     H.resize(unique(H.begin(), H.end()) - H.begin());     cnt.clear();     sum.clear();     for (int i = 0; i < int(n); i++) {       h[i] = find(h[i]);       cnt.add(h[i], 1);       sum.add(h[i], H[h[i]]);     }     for (int i = 0; i < int(q); i++) {       if (~qq[i].first) {         int j = qq[i].first;         cnt.add(h[j], -1);         sum.add(h[j], -H[h[j]]);         h[j] = find(qq[i].second);         cnt.add(h[j], 1);         sum.add(h[j], H[h[j]]);       } else {         long long v = qq[i].second;         int l = 0, r = H.size() - 1;         while (l < r) {           int m = (l + r + 1) / 2;           int tot = cnt.sum(m);           long long vol = sum.sum(m);           if (H[m] * (long long)tot - vol < v)             l = m;           else             r = m - 1;         }         int tot = cnt.sum(l);         long long vol = sum.sum(l);         printf( %.10f n ,                H[l] + (v - (H[l] * (long long)tot - vol)) / (double)tot);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     vector<long long> a(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     sort(a.begin(), a.end());     long long sum = 0;     for (long long i = 0; i < m; i++) {       if (a[i] <= 0) sum += a[i];     }     if (sum <= 0) {       cout << abs(sum);     } else {       cout <<  0 ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000;   bool g[MAXN][MAXN];   bool mh[MAXN], mv[MAXN];   bool use[MAXN];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       g[a][b] = true;       mv[a] = true;       mh[b] = true;     }     int ans = 0;     for (int i = 1; i < n - 1; i++) ans += !mh[i] + !mv[i];     if (n % 2 && !mh[n / 2] && !mv[n / 2]) ans--;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<long long int> > v, dp;   long long int ans, k;   void dfs(long long int u, long long int par) {     long long int i;     dp[u][0] = 1;     for (auto it : v[u]) {       if (it == par) continue;       dfs(it, u);       for (i = 1; i <= k; i++) ans += dp[it][i - 1] * dp[u][k - i];       for (i = 1; i <= k; i++) dp[u][i] += dp[it][i - 1];     }     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t = 1;     while (t--) {       long long int n, i, x, y;       cin >> n >> k;       v.resize(n + 1);       dp.resize(n + 1, vector<long long int>(k + 1));       ans = 0;       for (i = 1; i < n; i++) {         cin >> x >> y;         v[x].push_back(y);         v[y].push_back(x);       }       dfs(1, 0);       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e4 + 1;   int n, m, x[N], y[N], freq[N], q[N], vis[N], match[N], T, ans[N];   vector<int> g[N];   bool get(int u) {     vis[u] = T;     for (auto i : g[u]) {       if (match[i] != -1 && vis[match[i]] == T) continue;       if (match[i] == -1 || get(match[i])) {         match[i] = u;         return 1;       }     }     return false;   }   int main() {     scanf( %d%d , &n, &m);     if (!m) return puts( 0 ), 0;     memset(match, -1, sizeof match);     for (int i = 0; i < m; i++)       scanf( %d %d , x + i, y + i), x[i], y[i], freq[x[i]]++, freq[y[i]]++;     int id = n + 1;     for (int i = 0; i < m; i++) {       g[x[i]].push_back(id);       g[y[i]].push_back(id++);     }     int can = 0;     queue<int> q;     for (int i = 1; i <= n; i++) q.push(i);     while (q.size()) {       int x = q.front();       q.pop();       if (freq[x]) {         freq[x]--;         T++;         if (get(x)) q.push(x), ans[x]++;       }     }     for (int i = 1; i <= n; i++) can = max(can, ans[i]);     printf( %d n , can);     for (int i = 0; i < m; i++)       if (match[i + n + 1] == y[i])         printf( %d %d n , y[i], x[i]);       else         printf( %d %d n , x[i], y[i]);   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int kMod = 998244353;   int inv(int b) {     int e = kMod - 2;     int r = 1;     while (e) {       if (e % 2) r = 1LL * r * b % kMod;       b = 1LL * b * b % kMod;       e /= 2;     }     return r;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, k, c;     cin >> n >> k >> c;     vector<int> a(n), mx(n, 0);     int all = 0;     for (int i = 0; i < n; ++i) {       cin >> a[i];       for (int j = 0; j <= k; ++j) {         mx[i] = max(mx[i], (a[i] ^ (a[i] - j)));       }       all ^= a[i];     }     vector<int> order(n);     iota(order.begin(), order.end(), 0);     sort(order.begin(), order.end(), [&](int a, int b) { return mx[a] < mx[b]; });     vector<vector<int>> comb(2 * k + 1, vector<int>(2 * k + 1, 0));     for (int i = 0; i <= 2 * k; ++i) {       comb[i][0] = comb[i][i] = 1;       for (int j = 1; j < i; ++j) {         comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % kMod;       }     }     vector<vector<long long>> dp(k + 1, vector<long long>(1 << c, 0));     dp[0][0] = 1;     int lim = 1;     for (auto it : order) {       for (int j = k; j >= 0; --j) {         for (int i = 1; i + j <= k; ++i) {           int val = (a[it] ^ (a[it] - i)) / 2;           for (int x = 0; x < lim; ++x)             dp[i + j][x ^ val] += comb[i + j][j] * dp[j][x];         }       }       for (int j = 0; j <= k; ++j) {         int val = (a[it] ^ (a[it] - j)) / 2;         while (lim <= val) lim *= 2;       }       for (int j = 0; j <= k; ++j)         for (int x = 0; x < lim; ++x) dp[j][x] %= kMod;     }     int sub = 1, invn = inv(n);     for (int i = 0; i < k; ++i) sub = 1LL * sub * invn % kMod;     for (int i = 0; i < (1 << c); ++i) {       int par = (k + all + i) % 2;       if (par)         cout << 0 <<    ;       else         cout << (dp[k][(i ^ all) / 2] * sub) % kMod <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int arr[n], odd = 0, even = 0;     for (int i = 0; i < n; i++) {       scanf( %d , arr + i);       if (arr[i] % 2)         odd++;       else         even++;     }     sort(arr, arr + n);     reverse(arr, arr + n);     long long ans = 0;     bool b = odd % 2;     for (int i = 0; i < n; i++) {       if (!b) {         ans += arr[i];       } else {         if (arr[i] % 2 && odd > 1) {           ans += arr[i];           odd--;         } else if (arr[i] % 2 == 0) {           ans += arr[i];         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(NULL);     int m, n;     cin >> m >> n;     set<int> v[m];     for (int i = 0; i < m; i++) {       int s;       cin >> s;       for (int j = 0; j < s; j++) {         int x;         cin >> x;         v[i].insert(x);       }     }     for (int i = 0; i < m; i++) {       for (int j = i + 1; j < m; j++) {         int cnt = 0;         for (auto it : v[i]) {           if (v[j].find(it) != v[j].end()) {             cnt = 1;             break;           }         }         if (cnt == 0) {           cout <<  impossible ;           exit(0);         }       }     }     cout <<  possible ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     long long x, y;     Point() {}     Point(long long x0, long long y0) : x(x0), y(y0) {}     void in() { scanf( %I64d %I64d , &x, &y); }     long long operator*(Point pt) { return x * pt.y - y * pt.x; }     Point operator-(Point pt) { return Point(x - pt.x, y - pt.y); }     Point operator+(Point pt) { return Point(x + pt.x, y + pt.y); }   } p[1000010];   int n;   long long solve(Point o) {     long long ans = 0;     int i, j;     i = j = 1;     while (i <= n) {       while (i == j || (p[j + 1] - p[i]) * (o - p[i]) >= 0) j++;       ans += (long long)(j - i) * (j - i - 1) / 2;       i++;     }     return ans;   }   bool In_Polygon(Point o) {     for (int i = 1; i <= n; i++)       if ((p[i + 1] - p[i]) * (o - p[i]) <= 0) return false;     return true;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) p[i].in();     for (int i = n + 1; i <= n + n; i++) p[i] = p[i - n];     reverse(p + 1, p + n + n + 1);     int cas;     scanf( %d , &cas);     for (int cc = 1; cc <= cas; cc++) {       Point o;       o.in();       if (!In_Polygon(o))         cout << 0 << endl;       else         cout << (long long)n * (n - 1) * (n - 2) / 6 - solve(o) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> L[200005], W[200005];   vector<pair<long long, int> > path;   int a[200005], add[200005], rmv[200005];   int res[200005];   void DFS(int u, long long dis) {     int v, w, rem1 = 0, rem2 = 0;     path.push_back(make_pair(dis, u));     for (int i = 0; i < L[u].size(); i++) {       v = L[u][i];       w = W[u][i];       DFS(v, dis + W[u][i]);       rem1 += add[v];       rem2 += rmv[v];     }     int pos = lower_bound(path.begin(), path.end(), make_pair(dis - a[u], -1)) -               path.begin();     if (pos != path.size() && path[pos].first >= dis - a[u]) {       v = path[pos].second;       rmv[v]--;       add[u]++;     }     path.pop_back();     res[u] = rem1 + rem2;     add[u] += rem1;     rmv[u] += rem2;   }   int main() {     int n, u, v, w;     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n - 1; i++) {       u = i;       scanf( %d%d , &v, &w);       v--;       L[v].push_back(u);       W[v].push_back(w);     }     DFS(0, 0);     for (int i = 0; i < n; i++) {       if (i) printf(   );       printf( %d , res[i]);     }     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   long long getint() {     long long summ = 0, f = 1;     char ch;     for (ch = getchar(); !isdigit(ch) && ch !=  - ; ch = getchar())       ;     if (ch ==  - ) {       f = -1;       ch = getchar();     }     for (; isdigit(ch); ch = getchar())       summ = (summ << 3) + (summ << 1) + ch - 48;     return summ * f;   }   long long n, m, a[200005], ans, k, s[200004];   priority_queue<long long> q;   signed main() {     cin >> n >> m;     for (long long i = 1; i <= n; i++) cin >> a[i];     for (long long i = n; i; i--) {       if (a[i] < 0)         q.push(a[i]);       else {         while (!q.empty() && a[i] >= 0) {           a[i] += q.top();           q.pop();         }         if (a[i] < 0) q.push(a[i]);       }     }     long long tot = 0;     while (!q.empty()) {       s[++tot] = q.top();       q.pop();     }     for (long long i = 1; i <= tot; i++) {       s[i] = -s[i] + s[i - 1];     }     for (long long i = 1, x; i <= m; i++) {       x = getint();       cout << tot + 1 - (upper_bound(s + 1, s + 1 + tot, x) - s) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   struct edge {     long long to;     long long cost;   };   vector<edge> mp[maxn];   long long dis[maxn];   long long vis[maxn];   long long dis1[maxn];   long long a[maxn];   long long b[maxn];   long long N, M, k;   long long cot[maxn];   bool SPFA(long long s, long long N) {     memset(vis, 0, sizeof(vis));     memset(cot, 0, sizeof(cot));     for (int i = 0; i <= N; i++) {       dis[i] = 1000000000000000000;       ;     }     priority_queue<long long> q;     dis[s] = 0;     q.push(s);     while (!q.empty()) {       int u = q.top();       q.pop();       vis[u] = 0;       for (int v = 0; v < mp[u].size(); v++) {         int to = mp[u][v].to;         if (dis[u] + mp[u][v].cost < dis[to]) {           dis[to] = dis[u] + mp[u][v].cost;           if (!vis[to]) {             vis[to] = 1;             q.push(to);           }         } else if (dis[to] == dis[u] + mp[u][v].cost) {           cot[to]++;         }       }     }     return true;   }   int main() {     long long u, v, cost;     scanf( %lld %lld %lld , &N, &M, &k);     memset(mp, 0, sizeof(mp));     for (int i = 0; i < M; i++) {       scanf( %lld%lld%lld , &u, &v, &cost);       edge te;       te.to = v;       te.cost = cost;       mp[u].push_back(te);       te.to = u;       te.cost = cost;       mp[v].push_back(te);     }     long long sum = 0;     for (int i = 0; i < k; i++) {       scanf( %lld %lld , &a[i], &b[i]);       edge te;       te.to = a[i];       te.cost = b[i];       mp[1].push_back(te);       te.to = 1;       te.cost = b[i];       mp[a[i]].push_back(te);     }     SPFA(1, N);     for (int i = 0; i < k; i++) {       if (dis[a[i]] < b[i]) {         sum++;       } else if ((dis[a[i]] == b[i])) {         if (cot[a[i]] >= 1) {           sum++;           cot[a[i]]--;         }       }     }     printf( %lld n , sum);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const long long LINF = LLONG_MAX;   int main() {     std::ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     vector<int> a(n, 0);     int ind = 0, length = n + 1;     for (int i = 0; i < m; i++) {       int l, r;       cin >> l >> r;       if (length > r - l + 1) {         length = r - l + 1;         ind = l - 1;       }     }     for (int i = ind, j = 0; i < n; i++, j++) {       a[i] = j % length;     }     for (int i = ind - 1, j = length - 1; i >= 0;          i--, j = (j - 1 + length) % length)       a[i] = j;     cout << length << endl;     for (auto k : a) cout << k <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, z = 0;     cin >> n;     char *colours = new char[50];     for (int x = 0; x < n; x++) {       cin >> colours[x];     }     for (int i = 0; i < n - 1; i++) {       if (colours[i] == colours[i + 1]) {         z++;       }     }     delete[] colours;     cout << z;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000100;   const int INF = (1 << 29);   const double EPS = 0.000000001;   const double Pi = acos(-1.0);   int n;   long long x[maxn];   int main() {     while (cin >> n) {       for (int i = 1; i <= n; i++) scanf( %I64d , &x[i]);       sort(x + 1, x + n + 1);       long long ans = 1e12;       for (int i = 1; i + n / 2 <= n; i++) {         long long a = x[i], b = x[i + n / 2];         ans = min(ans, b - a);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 0.000000000000001;   int n, k;   double P[21];   bool eq(long double a, long double b) {     if (abs(a - b) < 0.000000000000001) return true;     return false;   }   bool memo[1 << 21];   long double dp[1 << 21];   long double doit(int msk) {     if (msk == 0) return 1;     if (memo[msk] == true) {       return dp[msk];     }     int i, j;     long double ret = 0, sm = 0;     for (i = 0; i < n; i++) {       if (msk & (1 << i)) {         sm += P[i];       }     }     for (i = 0; i < n; i++) {       if (msk & (1 << i)) {         ret += P[i] * doit(msk ^ ((1 << i))) / (1 - (sm - P[i]));       }     }     memo[msk] = true;     return dp[msk] = ret;   }   long double ans[21];   int main() {     scanf( %d%d , &n, &k);     int i, j, nz = 0;     for (i = 0; i < n; i++) {       scanf( %lf , &P[i]);       if (!eq(P[i], 0)) nz++;       ans[i] = 0;     }     for (i = 0; i < (1 << n); i++) {       if (__builtin_popcount(i) == min(k, nz)) {         int f = 1;         for (j = 0; j < n; j++) {           if (i & (1 << j))             if (eq(0, P[j])) {               f = 0;               break;             }         }         if (!f) continue;         long double x = doit(i);         for (j = 0; j < n; j++) {           if (i & (1 << j)) {             ans[j] += x;           }         }       }     }     for (i = 0; i < n; i++) {       printf( %.15lf  , (double)ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, const U &b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, const U &b) {     if (a < b) a = b;   }   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T1, class T2>   inline void gn(T1 &x1, T2 &x2) {     gn(x1), gn(x2);   }   template <class T1, class T2, class T3>   inline void gn(T1 &x1, T2 &x2, T3 &x3) {     gn(x1, x2), gn(x3);   }   template <class T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   template <class T>   inline void println(T first) {     print(first);     putchar(  n );   }   template <class T>   inline void printsp(T first) {     print(first);     putchar(   );   }   template <class T1, class T2>   inline void print(T1 x1, T2 x2) {     printsp(x1), println(x2);   }   template <class T1, class T2, class T3>   inline void print(T1 x1, T2 x2, T3 x3) {     printsp(x1), printsp(x2), println(x3);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = (long long)a * a % m)       if (b & 1) ans = (long long)ans * a % m;     return ans;   }   pair<pair<int, int>, int> p[200010];   int first[200010], t[200010], nn;   vector<int> pos[200010], B[200010];   void update(int id, int u, int v) {     for (; u < B[id].size(); u += u & -u) B[id][u] += v;   }   int calc(int id, int u, int ans = 0) {     for (; u; u -= u & -u) ans += B[id][u];     return ans;   }   int main() {     int n;     gn(n);     for (int i = 0; i < n; i++) {       gn(p[i].first.first, p[i].first.second, p[i].second);       first[i] = p[i].second;       t[i] = p[i].first.second;     }     sort(t, t + n);     sort(first, first + n);     nn = unique(first, first + n) - first;     for (int i = 0; i < n; i++) {       p[i].first.second = upper_bound(t, t + n, p[i].first.second) - t;       p[i].second = lower_bound(first, first + nn, p[i].second) - first;       pos[p[i].second].push_back(p[i].first.second);     }     for (int i = 0; i < nn; i++) {       sort(pos[i].begin(), pos[i].end());       B[i].resize(pos[i].size() + 1);     }     for (int i = 0; i < n; i++) {       int a = p[i].first.first, u = p[i].second;       int t = upper_bound(pos[u].begin(), pos[u].end(), p[i].first.second) -               pos[u].begin();       if (a == 1)         update(u, t, 1);       else if (a == 2)         update(u, t, -1);       else         println(calc(u, t));     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cout.precision(10);     int n;     cin >> n;     set<string> st;     while (n--) {       string s, ss;       cin >> s;       for (int i = s.size() - 1; i >= 0; i--) {         if (s[i] ==  u ) {           ss +=  oo ;         } else if (s[i] ==  h ) {           ss +=  h ;           while (i > 0 && s[i - 1] ==  k ) {             i--;           }         } else {           ss += s[i];         }       }       reverse(ss.begin(), ss.end());       st.insert(ss);     }     cout << st.size() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cnt, ans, i, j, temp, flag;   string s, heavy =  heavy , metal =  metal ;   int main() {     cin >> s;     for (i = 0; i < s.length(); i++) {       temp = i;       flag = 0;       for (j = 0; j < 5; j++) {         if (s[temp] == heavy[j])           ++temp;         else           break;       }       if (j == 5) flag = 1, ++cnt;       if (flag) {         i = temp - 2;         continue;       }       temp = i;       for (j = 0; j < 5; j++) {         if (s[temp] == metal[j])           ++temp;         else           break;       }       if (j == 5) flag = 1, ans += cnt;       if (flag) {         i = temp - 2;         continue;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   map<long long int, map<long long int, bool> > my;   int main() {     long long int n;     cin >> n;     my[1][n] = 1;     if (n % 2 == 0) {       cout <<  white  << endl;       cout << 1 <<     << 2 << endl;     } else       cout <<  black  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9 + 7;   const int N = 5e2 + 10;   int a[N][N];   int b[N][N];   int c[N][N];   int minv[N];   int main() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     memset((minv), (0x3f), sizeof(minv));     for (int i = 1; i <= n; i++) {       scanf( %*s );       for (int j = 1; j <= m; j++) {         cin >> a[i][j] >> b[i][j] >> c[i][j];       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         vector<int> v;         for (int o = 1; o <= m; o++) {           for (int t = 0; t < c[i][o]; t++)             v.push_back(max(0, b[j][o] - a[i][o]));         }         sort(v.rbegin(), v.rend());         int sum = 0;         for (int o = 0; o < k && o < v.size(); o++) sum += v[o];         ans = max(ans, sum);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int INF = 1e9 + 1;   const int MOD = 1e9 + 7;   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i += 1) cin >> a[i];     ;     sort(a.begin(), a.end());     vector<int> ans;     for (int i = 0; i < n; i += 1) {       for (int j = 0; j < 31; j += 1) {         int pv = a[i] - (1 << j);         int nx = a[i] + (1 << j);         bool pv_find = binary_search(a.begin(), a.end(), pv);         bool nx_find = binary_search(a.begin(), a.end(), nx);         if (pv_find && nx_find) {           ans = {pv, a[i], nx};           break;         } else if (pv_find)           ans = {pv, a[i]};         else if (nx_find)           ans = {a[i], nx};       }       if ((int)ans.size() == 3) break;     }     if (ans.empty()) ans.push_back(a[0]);     cout << (int)ans.size() <<   n ;     for (int i = 0; i < (int)ans.size(); i += 1) cout << ans[i] <<    ;     ;     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }