malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long inf = 27;   long long n, a[inf], b[inf], c[inf], ans = -1e9;   vector<long long> res;   map<pair<long long, long long>, pair<long long, vector<long long> > > mp;   vector<long long> mask;   void btadd(long long pos, long long sum1, long long sum2, long long sum3) {     if (pos == n / 2) {       long long id1 = sum2 - sum1, id2 = sum3 - sum1;       pair<long long, long long> id = make_pair(id1, id2);       if (mp.find(id) == mp.end())         mp[id] = make_pair(sum1, mask);       else         mp[id] = max(mp[id], make_pair(sum1, mask));       return;     }     mask.push_back(1);     btadd(pos + 1, sum1, sum2 + b[pos], sum3 + c[pos]);     mask.pop_back();     mask.push_back(2);     btadd(pos + 1, sum1 + a[pos], sum2, sum3 + c[pos]);     mask.pop_back();     mask.push_back(3);     btadd(pos + 1, sum1 + a[pos], sum2 + b[pos], sum3);     mask.pop_back();   }   vector<long long> merge(vector<long long> x, vector<long long> y) {     for (auto o : y) x.push_back(o);     return x;   }   void bt(long long pos, long long sum1, long long sum2, long long sum3) {     if (pos == n + 1) {       long long id1 = sum1 - sum2, id2 = sum1 - sum3;       pair<long long, long long> id = make_pair(id1, id2);       if (mp.find(id) == mp.end()) return;       if (mp[id].first + sum1 > ans)         ans = mp[id].first + sum1, res = merge(mp[id].second, mask);       return;     }     mask.push_back(1);     bt(pos + 1, sum1, sum2 + b[pos], sum3 + c[pos]);     mask.pop_back();     mask.push_back(2);     bt(pos + 1, sum1 + a[pos], sum2, sum3 + c[pos]);     mask.pop_back();     mask.push_back(3);     bt(pos + 1, sum1 + a[pos], sum2 + b[pos], sum3);     mask.pop_back();   }   int main() {     cin >> n;     for (long long i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];     if (n == 1) {       if ((a[1] == 0 && b[1] == 0)) cout <<  LM  << endl, exit(0);       if (a[1] == 0 && c[1] == 0) cout <<  LW  << endl, exit(0);       if (b[1] == 0 && c[1] == 0) cout <<  MW  << endl, exit(0);       cout <<  Impossible  << endl;       exit(0);     }     btadd(1, 0, 0, 0);     bt(n / 2, 0, 0, 0);     if (res.empty()) cout <<  Impossible  << endl, exit(0);     for (int i = 1; i <= n; i++)       if (res[i - 1] == 1)         cout <<  MW  << endl;       else if (res[i - 1] == 2)         cout <<  LW  << endl;       else         cout <<  LM  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int sl = s.length();     pair<int, int> a[26] = {};     for (int i = 0; i < 26; i++) a[i].second = i +  a ;     for (int i = 0; i < sl; i++) a[s[i] -  a ].first++;     sort(a, a + 26, greater<pair<int, int> >());     string ans(sl,  ? );     bool valid = false;     for (int i = 1; i < sl / 2; i++) ans[i] = a[0].second, a[0].first--;     for (int i = sl / 2; i < sl; i++) {       int sq = sqrt(i + 1);       bool ok = false;       for (int j = 2; j <= sq; j++) ok |= ((i + 1) % j == 0);       if (ok) ans[i] = a[0].second, a[0].first--;     }     if (a[0].first >= 0) {       string rem =   ;       for (int i = 0; i < 26; i++)         while (a[i].first--) rem.push_back(a[i].second);       for (int i = 0, j = 0; i < sl; i++)         if (ans[i] ==  ? ) {           ans[i] = rem[j];           j++;         }       valid = true;     }     if (valid == false)       cout <<  NO n ;     else       cout <<  YES n  << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ull = unsigned long long;   constexpr ll MAXN = 100000 + 5;   int n, m;   ll bot, inc, dam;   ll maxh[MAXN];   ll starth[MAXN];   ll regen[MAXN];   vector<pair<ll, ll>> up[MAXN];   unordered_map<ll, ll> mt;   unordered_set<ll> tpoints;   void gen(const int id) {     const ll mh = maxh[id];     const ll reg = regen[id];     auto &cup = up[id];     sort(cup.begin(), cup.end());     int in = 0;     ll prect = -1;     ll prech = -1;     int i = 0;     vector<pair<ll, ll>> cal;     while (i < cup.size() || cal.size()) {       if (cal.size()) {         ll prect = cal[0].first;         ll prech = cal[0].second;         cal.clear();         if (i >= cup.size() || prect < cup[i].first) {           if (prech <= dam) {             tpoints.insert(prect);             if (reg) {               prect++;               prech = min(prech + reg, mh);               cal.emplace_back(prect, prech);             }           } else {             mt[prect]--;             in = 0;           }         }         continue;       }       auto const p = cup[i];       const ll ct = p.first;       const ll ch = p.second;       if (ch < dam) {         if (in == 1) {         } else {           in = 1;           mt[ct]++;           tpoints.insert(ct);         }         if (reg) {           prect = ct + (dam - ch) / reg;           prech = ch + (prect - ct) * reg;           cal.emplace_back(prect, prech);         }       } else if (ch > dam) {         if (in == 1) {           tpoints.insert(ct - 1);           mt[ct]--;           in = 0;         }       } else if (ch == dam) {         if (in == 0) {           in = 1;           mt[ct]++;           tpoints.insert(ct);         } else {           tpoints.insert(ct);         }         if (reg) {           prect = ct + 1;           prech = min(mh, prech + reg);           cal.emplace_back(prect, prech);         }       }       i++;     }   }   int main() {     ios::sync_with_stdio(false);     int inf = 0;     cin >> n >> m;     cin >> bot >> inc >> dam;     ll base = 0;     for (int i = 1; i <= n; ++i) {       cin >> maxh[i] >> starth[i] >> regen[i];       if (maxh[i] <= dam) {         if (inc > 0) {           inf = 1;         } else           base++;       }       up[i].emplace_back(0, starth[i]);     }     for (int i = 0; i < m; ++i) {       int t, id, h;       cin >> t >> id >> h;       up[id].emplace_back(t, h);     }     if (inf) {       cout << -1;       return 0;     }     for (int i = 1; i <= n; ++i) {       if (maxh[i] > dam) gen(i);     }     for (auto const &p : mt) {       tpoints.insert(p.first);     }     ll ret = 0;     vector<pair<ll, ll>> vm(mt.begin(), mt.end());     sort(vm.begin(), vm.end());     auto mit = vm.begin();     vector<ll> tt(tpoints.begin(), tpoints.end());     sort(tt.begin(), tt.end());     for (auto t : tt) {       while (mit != vm.end() && mit->first <= t) {         base += mit->second;         ++mit;       }       ret = max(ret, base * (bot + inc * t));     }     ret = max(ret, base * (bot));     if (base > 0 && inc > 0) {       inf = 1;     }     if (inf) {       cout << -1;       return 0;     }     cout << ret;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000005;   const int P = 998244353;   long long n;   long long f[N], g[N];   long long a[N];   long long inv_9, inv_6, inv_1;   long long ans;   long long exp_3[N];   long long fac[N], c_n[N];   inline long long ksm(long long base, long long x) {     long long res = 1;     while (x) {       if (x & 1) res *= base, res %= P;       base *= base, base %= P;       x >>= 1;     }     return res;   }   void work() {     int type;     for (int i = 0; i < n; i++) {       if ((n - i) % 2 == 0)         type = 1;       else         type = P - 1;       ans +=           ((c_n[i]) *            (((type) *              ((P + ksm((exp_3[i] - 1 + P) % P, n) - ksm(exp_3[i], n)) % P) % P)) %            P),           ans %= P;     }     ans *= 3, ans %= P;     ans = P - ans, ans %= P;     for (int i = 1; i <= n; i++) {       if (i & 1)         type = 1;       else         type = P - 1;       ans +=           ((2) *            (((type) * (((c_n[i]) * (ksm(3, n * n - i * (n - 1))) % P)) % P)) % P),           ans %= P;     }   }   void init() {     scanf( %lld , &n);     a[2 * n] = ksm(3, 2 * n);     a[n] = ((P - 2) * ksm(3, n)) % P;     a[0] = 1;     exp_3[0] = 1;     for (int i = 1; i <= n; i++) exp_3[i] = ((3) * (exp_3[i - 1]) % P);     fac[0] = 1;     for (int i = 1; i <= n; i++) fac[i] = ((i) * (fac[i - 1]) % P);     for (int i = 0; i <= n; i++)       c_n[i] = ((fac[n]) *                 (((ksm(fac[i], P - 2)) * (ksm(fac[n - i], P - 2)) % P)) % P);     work();     printf( %lld n , ans);   }   int main(int argc, char** argv) {     init();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, u, d, l, r, i, h[10005];   string a;   int main() {     cin >> n >> a;     for (i = 0; i < n; i++) {       if (a[i] ==  0 ) d = r = l = 1;       if (a[i] ==  1  || a[i] ==  2  || a[i] ==  3 ) u = 1;       if (a[i] ==  1  || a[i] ==  4  || a[i] ==  7 ) l = 1;       if (a[i] ==  3  || a[i] ==  6  || a[i] ==  9 ) r = 1;       if (a[i] ==  7  || a[i] ==  9 ) d = 1;     }     if (u == 1 && d == 1 && r == 1 && l == 1)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int k;   int arr[N];   vector<int> v[N];   vector<int> gap[N];   int solve(int l, int r, int c) {     int m = (l + r) >> 1;     if (l == r) return v[c][l];     if (l >= r) return 0;     if (r == l + 1) {       if (gap[c][l] <= k)         return v[c][l] + v[c][r];       else         return 0;     }     int lt = m;     int rt = m;     int cost = 0;     int ans = v[c][m];     int maxi = max(solve(l, m, c), solve(m, r, c));     while (cost + gap[c][rt] <= k) {       cost += gap[c][rt];       ans += v[c][rt + 1];       rt++;       if (rt >= r) break;     }     maxi = max(ans, maxi);     while (rt >= m) {       if (lt == l) break;       while (cost + gap[c][lt - 1] <= k) {         cost += gap[c][lt - 1];         ans += v[c][lt - 1];         lt--;         if (lt == l) break;       }       if (maxi < ans) maxi = ans;       if (rt < l + 1) break;       ans -= v[c][rt];       cost -= gap[c][--rt];     }     return maxi;   }   signed main() {     int n, m;     cin >> n >> m >> k;     int count[n + 5];     count[n] = -1;     count[n + 1] = -1;     for (int i = 0; i < n; i++) {       cin >> arr[i];       count[i] = -1;     }     int ct = 1;     arr[n] = n + 2;     count[arr[0]] = 0;     for (int i = 1; i < n + 1; i++) {       if (arr[i] == arr[i - 1]) ct++;       if (arr[i] != arr[i - 1]) {         v[arr[i - 1]].push_back(ct);         if (count[arr[i]] != -1) {           gap[arr[i]].push_back(i - count[arr[i]] - 1);         }         count[arr[i - 1]] = i - 1;         ct = 1;       }     }     int maxi = -1;     for (int i = 1; i <= m; i++) {       maxi = max(solve(0, v[i].size() - 1, i), maxi);     }     cout << maxi << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e17;   struct edge {     int u, v;     edge() {}     edge(int _u, int _v) : u(_u), v(_v) {}   };   struct node {     vector<edge> edges;   };   struct tree {     vector<node> nodes;     int root, n;     tree(int _n, int _r = 0) : n(_n), root(_r) { nodes.resize(n); }     void add_edge(int u, int v) {       edge e1(u, v);       edge e2(v, u);       nodes[u].edges.push_back(e1);       nodes[v].edges.push_back(e2);     }     vector<pair<int, int>> findDiametersAndCenters() {       vector<pair<int, int>> ans;       vector<bool> vis1(n, 0), vis2(n, 0);       vector<int> parent(n, 0);       for (int i = 0; i < n; i++) {         if (vis1[i]) {           continue;         }         int diameter, d1, d2;         findDiameter(i, vis1, vis2, parent, diameter, d1, d2);         int c = findCenter(d2, diameter, parent);         ans.push_back({diameter, c});       }       return move(ans);     }     pair<int, int> bfs(int u, vector<bool> &visited, vector<int> &parent) {       queue<pair<int, int>> Q;       visited[u] = true;       int dist = 0;       Q.push({u, 0});       while (!Q.empty()) {         u = Q.front().first;         dist = Q.front().second;         Q.pop();         for (auto &e : nodes[u].edges) {           if (visited[e.v]) {             continue;           }           visited[e.v] = true;           Q.push({e.v, dist + 1});           parent[e.v] = u;         }       }       return {u, dist};     }     void findDiameter(int u, vector<bool> &vis1, vector<bool> &vis2,                       vector<int> &parent, int &diameter, int &d1, int &d2) {       d1 = bfs(u, vis1, parent).first;       auto p = bfs(d1, vis2, parent);       d2 = p.first;       diameter = p.second;     }     int findCenter(int u, int diameter, vector<int> &parent) {       diameter >>= 1;       while (diameter--) {         u = parent[u];       }       return u;     }   };   int main() {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int n, m;     cin >> n >> m;     tree t(n);     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       t.add_edge(u, v);     }     vector<pair<int, int>> DnC = t.findDiametersAndCenters();     sort(DnC.rbegin(), DnC.rend());     int res = DnC[0].first;     if (DnC.size() >= 2) {       res = max(res, (DnC[0].first + 1) / 2 + (DnC[1].first + 1) / 2 + 1);     }     if (DnC.size() >= 3) {       res = max(res, (DnC[1].first + 1) / 2 + (DnC[2].first + 1) / 2 + 2);     }     cout << res <<   n ;     for (int i = 1; i < DnC.size(); i++) {       cout << DnC[i].second + 1 <<     << DnC[0].second + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e4 + 100, M = 210;   int gi() {     int w = 0;     bool q = 1;     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) q = 0, c = getchar();     while (c >=  0  && c <=  9 ) w = w * 10 + c -  0 , c = getchar();     return q ? w : -w;   }   void go() {     puts( -1 );     exit(0);   }   int d[M][N], id[N];   int p[M][N], pre[N];   bool in[N];   int C;   int fa[N];   vector<int> e[N];   inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }   vector<pair<int, int> > sub[N];   inline void link(int a, int b) {     if (find(a) == find(b)) go();     fa[find(a)] = find(b);     e[a].push_back(b);     e[b].push_back(a);   }   inline void dfs(int k, int D, int fa) {     if (D != d[C][k]) go();     for (int t : e[k])       if (t != fa) dfs(t, D + 1, k);   }   int main() {     int n = gi(), m = gi(), i, j, k, last, ld, t, mx, to;     for (i = 1; i <= n; i++) fa[i] = i;     for (i = 1; i <= m; i++) {       for (j = 1; j <= n; j++)         if (!(d[i][j] = gi())) id[i] = j;       if (!id[i]) go();     }     p[1][0] = id[1];     in[id[1]] = true;     for (k = 2; k <= m; k++) {       for (i = 1; i <= n; i++)         if (d[1][i] + d[k][i] == d[1][id[k]]) p[k][d[1][i]] = i, in[i] = true;       for (i = d[1][id[k]]; i; i--) {         if (!p[k][i]) go();         pre[p[k][i]] = p[k][i - 1];       }     }     for (k = 1; k <= n; k++)       if (!in[k]) {         mx = -1;         for (i = 1; i <= m; i++) {           t = (d[1][id[i]] + d[1][k] - d[i][k]) / 2;           if (t > mx) mx = t, to = p[i][t];         }         sub[to].push_back(make_pair(d[1][k], k));       }     for (k = 1; k <= n; k++) {       sort(sub[k].begin(), sub[k].end());       for (i = 0, last = k, ld = d[1][k]; i < sub[k].size(); i++) {         if (i && sub[k][i].first != sub[k][i - 1].first)           ld = d[1][last = sub[k][i - 1].second];         if (sub[k][i].first != ld + 1) go();         pre[sub[k][i].second] = last;       }     }     for (i = 1; i <= n; i++)       if (pre[i])         link(pre[i], i);       else if (i != id[1])         go();     for (i = 1; i <= n; i++)       if (pre[i]) printf( %d %d n , pre[i], i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1001];   int main() {     int n;     scanf( %d , &n);     int m = n;     int pos = 0;     int k = 1;     while (true) {       if (a[pos] == 0) m--;       if (m == 0) {         printf( YES n );         return 0;       }       a[pos] = 1;       if (pos == (pos + k) % n) {         printf( NO n );         return 0;       }       pos = (pos + k) % n;       k++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 200010;   const long long MOD = 1e9 + 7;   const long long INF = 1e9;   const long long LINF = 1e18;   long long n, m, a[maxn], b[maxn];   map<long long, long long> M, N;   string s, ss;   set<long long> S;   long long l, r, h;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long ans = 0;     for (long long i = 0; i < n; i++)       ans += ((a[i] % 10007) * (a[n - i - 1] % 10007)) % 10007, ans %= 10007;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   char buffer[1000005];   char str[1000005];   vector<vector<int>> loop;   int n;   int op(int k, int d) {     int t = -1;     strcpy(buffer, str);     loop.clear();     vector<int> nxt(k);     vector<int> pre(k + 1);     vector<int> vis(k + 1);     vector<int> lpi(k + 1);     vector<int> lpj(k + 1);     for (int i = 0; i < d; ++i)       for (int j = 0;; ++j) {         if (j * d + i >= k) break;         pre[t + 1] = j * d + i;         nxt[j * d + i] = t++;       }     pre[k] = -1;     for (int i = 0; i < k; ++i)       if (!vis[i]) {         vector<int> temp;         loop.push_back(temp);         int tp = loop.size() - 1;         int p = i;         while (p <= k && !vis[p]) {           vis[p] = 1;           lpi[p] = tp;           lpj[p] = loop[tp].size();           loop[tp].push_back(p - 1);           p = pre[p] + 1;         }       }     for (int i = 0; i < n; ++i) {       if (i < k - 1) {         if (lpi[i + 1] == 0) {           t = min(lpj[i + 1], n - k + 1);           str[loop[0][lpj[i + 1] - t] + t] = buffer[i];         } else {           t = n - k + 1;           t = lpj[i + 1] - t;           int sz = loop[lpi[i + 1]].size();           t %= sz;           t += sz;           t %= sz;           str[loop[lpi[i + 1]][t] + n - k + 1] = buffer[i];         }       } else {         t = min(n - k + 1 - (i - k + 1), lpj[k]);         str[loop[0][lpj[k] - t] + t + (i - k + 1)] = buffer[i];       }     }     str[n] = 0;     return 0;   }   int main() {     scanf( %s , str);     n = strlen(str);     int m;     cin >> m;     int k, d;     for (int i = 0; i < m; ++i) {       scanf( %d%d , &k, &d);       op(k, d);       printf(str);       putchar(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, T, a, b, c;   int x[4], y[4];   long long cost[4];   string ans;   long long f(long long x, long long y) { return (x + y) * (abs(y - x) + 1) / 2; }   long long Cal(int X, int Y, int x, int y) {     if (X <= x && Y <= y) return f(0, x + y - X - Y) + f(0, n + n - x - y);     if (X >= x && Y >= y) return f(X + Y - x - y, n + n - x - y);     if (X <= x && Y >= y)       return f(x + Y - X - y, Y - y + 1) + f(Y - y, n + n - x - y);     return f(X + y - x - Y, X - x + 1) + f(X - x, n + n - x - y);   }   long long rm[4];   bool ok(int X, int Y) {     for (int i = 0; i < 4; ++i)       if ((rm[i] = T - cost[i] - Cal(X, Y, x[i], y[i])) < 0) return false;     if (X < a + c && Y < b + c)       return ((rm[1] >> 1) + (rm[2] >> 1)) >=              (long long)(a + c - max((int)a, X)) * (b + c - max((int)b, Y));     return true;   }   int main() {     cin >> n >> T >> a >> b >> c;     --c;     x[1] = x[0] = a, y[2] = y[0] = b;     x[2] = x[3] = a + c, y[1] = y[3] = b + c;     int X = 1, Y = 1;     for (int i = 0; i < 4; ++i)       if (Cal(X, Y, x[i], y[i]) - abs(x[i] - X) - abs(y[i] - Y) > T)         return puts( Impossible ), 0;     while (X != n || Y != n) {       if (X < n && ok(X + 1, Y))         ++X, ans +=  R ;       else         ++Y, ans +=  U ;       for (int i = 0; i < 4; ++i) cost[i] += abs(x[i] - X) + abs(y[i] - Y);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int s, f, t;     for (int i = 0; i < n; i++) {       cin >> s >> f >> t;       int flag = t / (m - 1);       int yushu = t % (m - 1);       int floor;       if (flag & 1) {         floor = m - yushu;       } else         floor = 1 + yushu;       int totaltime = 0;       if (s > floor) {         if (flag % 2 == 0)           totaltime = s - floor;         else           totaltime = floor - 1 + s - 1, flag = 0;         floor = s;       } else if (s < floor) {         if (flag % 2 == 0) {           totaltime = (m - floor) + (m - s);           flag = 1;         } else           totaltime = floor - s;         floor = s;       }       if (s == f) {         totaltime = t;       } else {         if (floor > f) {           if (flag % 2 == 0) {             totaltime += (m - floor + m - f);           } else             totaltime += floor - f;         } else if (floor < f) {           if (flag % 2 == 0)             totaltime += f - floor;           else             totaltime += floor - 1 + f - 1;         }         totaltime += t;       }       cout << totaltime << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 25;   long long a[MAX];   int main() {     ios_base::sync_with_stdio(false);     long long n, k, h;     cin >> n >> h >> k;     for (int i = 0; i < n; i++) cin >> a[i];     long long ans = 0;     long long in = a[0];     for (int i = 1; i < n; i++) {       if (in + a[i] <= h) {         in += a[i];       } else {         double x = (a[i] + in - h) * 1.0 / k;         long long x1 = floor(x);         long long x2 = ceil(x);         long long t1 = in, t2 = in;         t1 -= x1 * k;         if (t1 < 0) t1 = 0;         if (t1 + a[i] <= h) {           in -= x1 * k;           if (in < 0) in = 0;           in += a[i];           ans += x1;           continue;         }         t2 -= x2 * k;         if (t2 < 0) t2 = 0;         if (t2 + a[i] <= h) {           in -= x2 * k;           if (in < 0) in = 0;           in += a[i];           ans += x2;         }       }     }     if (in > 0) {       long long t1 = in / k;       long long t2 = in % k;       ans += t1;       if (t2) ans++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     long long n;     cin >> n;     vector<int> v(n);     for (int i = (0); i < (n); ++i) cin >> v[i];     sort(v.begin(), v.end());     vector<int> res = {v[0]};     for (int i = (0); i < (n); ++i)       for (int j = (0); j < (31); ++j) {         int lx = v[i] - (1 << j);         int rx = v[i] + (1 << j);         bool isl = binary_search(v.begin(), v.end(), lx);         bool isr = binary_search(v.begin(), v.end(), rx);         if (isl && isr && int(res.size()) < 3) {           res = {lx, v[i], rx};         }         if (isl && int((int)res.size()) < 2) {           res = {lx, v[i]};         }       }     cout << (int)res.size() << endl;     for (auto it : res) cout << it <<    ;   }