malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1003, INF = 2000000009;   struct ban {     int x, i;     ban() {}     ban(int x, int i) {       this->x = x;       this->i = i;     }   };   int n, m;   int s, f;   pair<pair<int, int>, int> b[N * 30];   vector<ban> a[N];   int hi;   bool c[N];   int pi[N], px[N];   bool dfs0(int x) {     c[x] = true;     if (x == f) return true;     for (int i = 0; i < a[x].size(); ++i) {       int h = a[x][i].x;       if (a[x][i].i == hi) continue;       if (!c[h]) {         pi[h] = a[x][i].i;         px[h] = x;         if (dfs0(h)) return true;       }     }     return false;   }   vector<int> path() {     for (int i = 1; i <= n; ++i) c[i] = false;     dfs0(s);     vector<int> v;     if (!c[f]) return v;     for (int i = f; i != s; i = px[i]) {       v.push_back(pi[i]);     }     reverse(v.begin(), v.end());     return v;   }   vector<int> vv;   int tin[N], ti, fup[N];   void dfs(int x, int pi) {     c[x] = true;     tin[x] = ti++;     fup[x] = tin[x];     for (int i = 0; i < a[x].size(); ++i) {       int h = a[x][i].x;       if (a[x][i].i == pi) continue;       if (a[x][i].i == hi) continue;       if (!c[h]) {         dfs(h, a[x][i].i);         fup[x] = min(fup[x], fup[h]);         if (fup[h] > tin[x]) vv.push_back(a[x][i].i);       } else {         fup[x] = min(fup[x], tin[h]);       }     }   }   vector<int> bridges() {     for (int i = 1; i <= n; ++i) c[i] = false;     vv.clear();     dfs(s, 0);     return vv;   }   int ans = INF;   int anss;   int ans1, ans2;   int main() {     cin >> n >> m;     cin >> s >> f;     for (int i = 1; i <= m; ++i) {       int x, y, z;       cin >> x >> y >> z;       a[x].push_back(ban(y, i));       a[y].push_back(ban(x, i));       b[i] = make_pair(make_pair(x, y), z);     }     if (s == f) {       cout <<  -1  << endl;       return 0;     }     vector<int> somepath = path();     if (somepath.empty()) {       cout << 0 << endl << 0 << endl;       return 0;     }     for (int i = 0; i < somepath.size(); ++i) {       hi = somepath[i];       vector<int> p = path();       if (p.empty()) {         if (b[somepath[i]].second < ans) {           ans = b[somepath[i]].second;           anss = 1;           ans1 = somepath[i];         }         continue;       }       set<int> s;       for (int j = 0; j < p.size(); ++j) s.insert(p[j]);       if (hi == 2) cerr <<   ;       vector<int> br = bridges();       for (int j = 0; j < br.size(); ++j) {         if (s.find(br[j]) != s.end()) {           if (b[somepath[i]].second + b[br[j]].second < ans) {             ans = b[somepath[i]].second + b[br[j]].second;             anss = 2;             ans1 = somepath[i];             ans2 = br[j];           }         }       }     }     if (ans == INF) {       cout <<  -1  << endl;       return 0;     }     cout << ans << endl;     cout << anss << endl;     if (anss == 1)       cout << ans1 << endl;     else       cout << ans1 <<     << ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   struct node {     int next[2];     int cnt;   };   node make_node() {     node nd;     nd.cnt = 0;     nd.next[0] = nd.next[1] = -1;     return nd;   }   node t[MAXN * 30];   int sz = 0;   int bs = 29;   void add(int tiv, int d) {     (0);     int v = 0;     for (int i = bs; i >= 0; i--) {       int bit = (tiv >> i) & 1;       t[v].cnt += d;       ;       (0);       if (t[v].next[bit] == -1) {         t[sz] = make_node();         t[v].next[bit] = sz++;       }       v = t[v].next[bit];     }     t[v].cnt += d;     (0);     (0);   }   int query(int p, int l) {     int res = 0;     int v = 0;     int val = 0;     for (int i = bs; i >= 0; i--) {       (0);       int pi = (p >> i) & 1;       int li = (l >> i) & 1;       if (li == 1) {         int nxt = t[v].next[pi];         if (nxt != -1)           res += t[nxt].cnt;         else           (0);         if (t[v].next[1 - pi] == -1)           return res;         else {           v = t[v].next[1 - pi];         }       } else {         if (t[v].next[pi] == -1) return res;         v = t[v].next[pi];       }     }     return res;   }   int main() {     t[0] = make_node();     sz = 1;     int q;     scanf( %d , &q);     int op, p, l;     for (int qq = 0; qq < q; qq++) {       scanf( %d%d , &op, &p);       if (op == 1) {         add(p, 1);       } else if (op == 2) {         add(p, -1);       } else {         scanf( %d , &l);         int res = query(p, l);         cout << res << endl;         ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int n, k, m, res = 0, sm = 0, edge = -1, nb = 1;   int a[200055], b[200050], nxt[200505], dp[200005] = {0}, ans[500005];   multiset<int> st, st1, st2;   set<int> stres;   string s, s1, s2, s3, s4;   vector<int> v[200050], vnode, vans, v3;   vector<pair<int, int> > vv, vv1, adj, v1, v2;   vector<pair<int, pair<int, int> > > vvv;   priority_queue<int> q;   map<int, int> mp;   multiset<int>::iterator it, it1, it2;   int voyel(char c) {     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u  || c ==  y )       return 1;     return 0;   }   int up[200005][20];   void solve() {     int i, j;     up[m + 1][0] = -1;     for (i = 1; i <= m; i++) {       int nxtt = nxt[b[i]];       int idx = lower_bound(v[nxtt].begin(), v[nxtt].end(), i) - v[nxtt].begin();       if (idx != v[nxtt].size()) {         int idxb = v[nxtt][idx];         up[i][0] = idxb;       } else         up[i][0] = -1;     }     for (int j = 1; j < 20; j++) {       for (i = 1; i <= m; i++)         if (up[i][j - 1] != -1) up[i][j] = up[up[i][j - 1]][j - 1];     }     for (i = 1; i <= m; i++) {       int bsup = i;       int x = n - 1;       for (j = 19; j >= 0; j--) {         if ((1 << j) <= x) {           x -= (1 << j);           if (bsup != -1) bsup = up[bsup][j];         }       }       if (bsup != -1) {         dp[i] = bsup;       }     }   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int i = 0, j = 0, x, y, z = 0, mx = 0, nb0 = 0, nb1 = 0, nbmax = 0, nbinf = 0,         mm = 5e9, idx = 0, ok = 0, l, r, negatif = 0, positif = 0, q, d, res1 = 0;     char c;     cin >> n >> m >> q;     for (i = 1; i <= n; i++) {       cin >> a[i];     }     for (i = 1; i <= n; i++) nxt[a[i]] = a[i + 1];     nxt[a[n]] = a[1];     for (i = 1; i <= m; i++) {       cin >> b[i];       v[b[i]].push_back(i);     }     for (i = 1; i <= n; i++) {       sort(v[i].begin(), v[i].end());     }     memset(up, -1, sizeof(up));     solve();     idx = m + 1;     mx = 5e9;     for (i = m; i >= 1; i--) {       if (dp[i]) mx = min(mx, dp[i]);       ans[i] = mx;     }     s =   ;     while (q--) {       cin >> x >> y;       res = (ans[x] <= y);       if (res != 0)         s +=  1 ;       else         s +=  0 ;     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1};   int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2};   using namespace std;   class PAIR {    public:     long long int first;     long long int second;     long long int third;   };   vector<long long int> V, V2, V3;   long long int ar[4500100];   map<long long int, long long int> m;   int main() {     long long int tcase = 1;     for (long long int test = 1; test <= tcase; test++) {       for (long long int i = 0; i <= 450010; i++) {         ar[i] = i;       }       long long int q, x, ans = 0;       scanf( %lld %lld , &q, &x);       long long int a;       for (long long int i = 0; i < q; i++) {         scanf( %lld , &a);         if (a == ans) {           ans++;           m[ar[a % x]] = 1;           while (m.count(ans) == 1) {             ans++;           }           ar[a % x] += x;           printf( %lld n , ans);           continue;         }         a %= x;         m[ar[a]] = 1;         if (ans == ar[a]) {           ans++;           while (m.count(ans) == 1) {             ans++;           }         }         ar[a] += x;         printf( %lld n , ans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 300 * 1000 + 5;   int n, k, arr[Maxn];   int main() {     scanf( %d%d , &n, &k);     int Min = INT_MAX, Max = 0;     for (int i = 0; i < n; i++)       scanf( %d , &arr[i]), Min = min(Min, arr[i]), Max = max(Max, arr[i]);     sort(arr, arr + n);     for (int i = Min; i > 0; i--) {       bool mark = false;       if (Max % i <= k) {         for (int j = 2; j * i <= Max; j++) {           int ind = lower_bound(arr, arr + n, i * j) - arr;           ind--;           if (ind >= 0) {             if (arr[ind] % i > k) mark = true;           }         }         if (!mark) {           printf( %d n , i);           return 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, cnt, t;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &a, &b);       cnt = 0;       while (a > 0 && b > 0) {         if (a > b) swap(a, b);         int tmp = b / a;         cnt += tmp;         b -= tmp * a;       }       printf( %d n , cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1005;   struct Edge {     int u, v, w, id;     Edge() {}     Edge(int a, int b, int c, int d) : u(a), v(b), w(c), id(d) {}     bool operator<(const Edge e) const { return w > e.w; }   } e[maxn * maxn];   int fa[maxn << 1];   int Find(int x) { return fa[x] == x ? fa[x] : (fa[x] = Find(fa[x])); }   void Merge(int a, int b) {     int x = Find(a);     int y = Find(b);     fa[x] = y;   }   int main() {     int n, m, q;     while (scanf( %d%d%d , &n, &m, &q) != EOF) {       int u, v, w;       for (int i = 0; i < m; i++) {         scanf( %d %d %d , &u, &v, &w);         e[i] = Edge(u, v, w, i + 1);       }       sort(e, e + m);       while (q--) {         int flag = 0;         for (int i = 1; i <= 2 * n; i++) fa[i] = i;         scanf( %d%d , &u, &v);         for (int i = 0; i < m; i++) {           if (e[i].id < u || e[i].id > v) continue;           if (Find(e[i].u) == Find(e[i].v)) {             printf( %d n , e[i].w);             flag = 1;             break;           } else {             Merge(e[i].u, e[i].v + n);             Merge(e[i].v, e[i].u + n);           }         }         if (!flag) printf( -1 n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long hell = 1000000007;   const long long INF = 1000000000;   void solve() {     long long n;     cin >> n;     map<long long, long long> mp;     long long a[n];     long long s = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       s += a[i];       mp[a[i]]++;     }     vector<long long> ans;     for (long long i = 0; i < n; i++) {       long long S = s - a[i];       if (S % 2) continue;       mp[a[i]]--;       S = S / 2;       if (mp[S]) ans.push_back(i);       mp[a[i]]++;     }     cout << ans.size() << endl;     for (long long j : ans) cout << j + 1 <<    ;     cout << endl;   }   int32_t main() {     long long t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200005], f[200005], t[2000006], mx, mxbr;   bool bio[2000006], p[2000006];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       p[a[i]] = 1;       mxbr = max(mxbr, a[i]);     }     for (int i = 2; i <= 2 * mxbr; i++) {       if (p[i - 1])         t[i] = i - 1;       else         t[i] = t[i - 1];     }     for (int i = 1; i <= n; i++) {       if (bio[a[i]]) continue;       int x = 2 * a[i];       for (int j = x; j <= 2 * mxbr; j += a[i])         if (t[j] > a[i]) mx = max(mx, t[j] % a[i]);       bio[a[i]] = 1;     }     cout << mx;   }
#include <bits/stdc++.h>   int a[100005];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     int flag = -1;     int sum = 0;     int sum1 = 0;     int ans = 1;     for (int i = 1; i < n; i++) {       if (a[i] == a[i - 1])         ans++;       else {         if (flag == -1) {           flag = 1;           sum = ans;           ans = 1;         } else {           if (ans != sum) {             printf( NO n );             return 0;           }           ans = 1;         }       }     }     if (flag == -1 || ans == sum)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   int main() {     int w1, h1, w2, h2, a, b, sum;     scanf( %d%d%d%d , &w1, &h1, &w2, &h2);     a = (h2 + h1 + 2) * 2;     b = w1 * 2;     sum = a + b;     printf( %d n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int MOD = 1000000007;   int N, a[169], c[169], K;   long long int M = -10000000000000LL;   int ned, prv[169], first[169];   long long int cap[20009], cost[20009], to[20009], nxt[20009], dist[169],       pot[169];   void init() {     memset(first, -1, sizeof first);     ned = 0;   }   void add(int u, int v, long long int f, long long int c) {     to[ned] = v, cap[ned] = f;     cost[ned] = c, nxt[ned] = first[u];     first[u] = ned++;     to[ned] = u, cap[ned] = 0;     cost[ned] = -c, nxt[ned] = first[v];     first[v] = ned++;   }   bool dijkstra(int s, int t) {     memset(prv, -1, sizeof prv);     for (int i = 0; i < N; i++) dist[i] = 1000000000000000000LL;     set<pair<long long int, int> > q;     q.insert(make_pair(0LL, s));     dist[s] = prv[s] = 0;     int u, v;     while (!q.empty()) {       u = q.begin()->second;       q.erase(q.begin());       for (int e = first[u]; e != -1; e = nxt[e]) {         if (cap[e] <= 0) continue;         v = to[e];         long long int new_dist = dist[u] + cost[e] + pot[u] - pot[v];         if (new_dist < dist[v]) {           q.erase(make_pair(dist[v], v));           dist[v] = new_dist;           prv[v] = e;           q.insert(make_pair(new_dist, v));         }       }     }     return prv[t] != -1;   }   inline long long int augment(int s, int t) {     for (int i = t; i != s; i = to[prv[i] ^ 1]) {       cap[prv[i]]--;       cap[prv[i] ^ 1]++;     }     --K;     long long int flowCost = dist[t] - pot[s] + pot[t];     for (int i = 0; i < N; i++)       if (prv[i] != -1) pot[i] += dist[i];     return flowCost;   }   long long int mincostmaxflow(int s, int t) {     long long int flowCost = 0;     memset(pot, 0, sizeof(pot));     while (K > 0 && dijkstra(s, t)) {       flowCost += augment(s, t);     }     return flowCost;   }   int main() {     set<int> v;     scanf( %d%d , &N, &K);     for (int i = 0; i < N; ++i) {       scanf( %d , &a[i]);       v.insert(a[i]);     }     for (int i = 1; i < N + 1; ++i) scanf( %d , &c[i]);     init();     K = min(K, (int)v.size());     for (int i = 0; i < N; ++i) {       add(0, 2 * i + 1, 1, c[a[i]]);       add(2 * i + 1, 2 * i + 2, 1, M);       add(2 * i + 2, 2 * N + 1, 1, 0);       for (int j = i + 1; j < N; ++j) {         if (a[i] != a[j])           add(2 * i + 2, 2 * j + 1, 1, c[a[j]]);         else           add(2 * i + 2, 2 * j + 1, 1, 0);       }     }     long long int n = N;     N = 2 * N + 2;     printf( %lld n , mincostmaxflow(0, N - 1) - M * n);   }
#include <bits/stdc++.h>   using namespace std;   char st[300010], opt[10];   int n, q;   int main() {     int i, j;     scanf( %d%d , &n, &q);     scanf( %s , st);     int cnt = 0, ans = 0;     for (i = 0; i < n; ++i) {       if (st[i] ==  . )         cnt++;       else {         ans += max(cnt - 1, 0);         cnt = 0;       }     }     ans += max(cnt - 1, 0);     char opt[4];     int pos;     while (q--) {       scanf( %d%s , &pos, opt);       pos--;       if (st[pos] ==  . ) {         if (pos + 1 < n && st[pos + 1] ==  . ) ans--;         if (pos - 1 >= 0 && st[pos - 1] ==  . ) ans--;       }       if (opt[0] ==  . ) {         if (pos + 1 < n && st[pos + 1] ==  . ) ans++;         if (pos - 1 >= 0 && st[pos - 1] ==  . ) ans++;       }       st[pos] = opt[0];       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void chmin(T &t, T f) {     if (t > f) t = f;   }   template <class T>   void chmax(T &t, T f) {     if (t < f) t = f;   }   int INF = (1 << 29);   int n, m;   int table[8][8];   void init() {}   void input() {     cin >> n >> m;     for (int i = (0); i < (n); i++)       for (int j = (0); j < (m); j++) cin >> table[i][j];   }   void solve() {     int mask = 1 << m;     int crt[1 << 8], nxt[1 << 8];     for (int i = (0); i < (mask); i++) crt[i] = INF;     crt[0] = 0;     for (int i = (0); i < (n); i++)       for (int j = (0); j < (m); j++) {         for (int k = (0); k < (mask); k++) nxt[k] = INF;         for (int k = (0); k < (mask); k++) {           if (k & 1) chmin(nxt[k >> 1], crt[k]);           if (!(k & 3) && j < m - 1) {             int add = (table[i][j] == table[i][j + 1] ? 0 : 1);             chmin(nxt[(k >> 1) | 1], crt[k] + add);           }           if (!(k & 1) && i < n - 1) {             int add = (table[i][j] == table[i + 1][j] ? 0 : 1);             chmin(nxt[(k >> 1) | (1 << (m - 1))], crt[k] + add);           }         }         swap(crt, nxt);       }     cout << crt[0] << endl;   }   int main() {     init();     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int res1 = max((3 * a) / 10, (a - (a / 250) * c));     int res2 = max((3 * b) / 10, (b - (b / 250) * d));     if (res1 > res2)       cout <<  Misha  << endl;     else if (res1 < res2)       cout <<  Vasya  << endl;     else       cout <<  Tie  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long func(long long a, long long b, long long c) {     if (a % 2 != b % 2) return (1ll << 60);     long long x = min(a + c, b + c);     return a + b + c - x;   }   int main(void) {     int i;     long long a, b, c;     cin >> a >> b >> c;     long long ans = (1ll << 60);     ans = min(ans, func(a, b, c));     ans = min(ans, func(b, c, a));     ans = min(ans, func(c, a, b));     if (ans == (1ll << 60)) return -1;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <class A>   istream& operator>>(istream& in, vector<A>& a) {     for (A& i : a) in >> i;     return in;   }   template <class A>   istream& operator>>(istream& in, vector<vector<A>>& a) {     for (auto& i : a)       for (auto& j : i) in >> j;     return in;   }   template <class A>   ostream& operator<<(ostream& in, vector<A>& a) {     for (A& i : a) in << i <<    ;     in << endl;     return in;   }   template <class A>   ostream& operator<<(ostream& in, vector<vector<A>>& a) {     for (auto& i : a) {       for (auto& j : i) in << j <<    ;       in << endl;     }     return in;   }   const long long mod = 1e9 + 7;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       y >>= 1;       x = (x * x) % mod;     }     return (res % mod);   }   void solve() {     int n, m;     cin >> n >> m;     vector<int> v(n), ans;     cin >> v;     map<int, bool> mp;     for (int i = 0; i < n; i++) {       mp[v[i]] = true;     }     for (int i = 1; 1; i++) {       if (mp[i] == 0 && m - i >= 0) {         ans.push_back(i);         m -= i;         mp[i] = true;       }       if (m < i) {         break;       }     }     cout << ans.size() <<   n  << ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long tc = 1;     for (long long t = 1; t <= tc; t++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int dx[4] = {-1, 0, 1, 0};   int dy[4] = {0, 1, 0, -1};   vector<string> museum;   vector<vector<int> > pictures;   vector<vector<bool> > used;   queue<pair<int, int> > line;   vector<pair<int, int> > req;   void BFS(int& i, int& j) {     line.push(make_pair(i, j));     used[i][j] = true;     int cnt = 0;     req.clear();     while (!line.empty()) {       int x = line.front().first;       int y = line.front().second;       line.pop();       req.push_back(make_pair(x, y));       for (int z = 0; z < 4; z++) {         int newI = x + dx[z];         int newJ = y + dy[z];         if (newI >= 0 && newI < n && newJ >= 0 && newJ < m &&             museum[newI][newJ] ==  * ) {           cnt++;         }       }       for (int z = 0; z < 4; z++) {         int newI = x + dx[z];         int newJ = y + dy[z];         if (newI >= 0 && newI < n && newJ >= 0 && newJ < m &&             museum[newI][newJ] ==  .  && !used[newI][newJ]) {           used[newI][newJ] = true;           line.push(make_pair(newI, newJ));         }       }     }     for (int z = 0; z < req.size(); z++) {       pictures[req[z].first][req[z].second] = cnt;     }   }   int main() {     cin >> n >> m >> k;     museum.resize(n);     used.resize(n, vector<bool>(m, false));     for (int i = 0; i < n; i++) {       cin >> museum[i];     }     pictures.resize(n, vector<int>(m, -1));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (museum[i][j] ==  .  && pictures[i][j] == -1) {           BFS(i, j);         }       }     }     for (int i = 0; i < k; i++) {       int x, y;       cin >> x >> y;       x--;       y--;       printf( %d n , pictures[x][y]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   long long mult(long long a, long long b, long long limit) {     long long x = 0, y = a;     while (b > 0) {       if (b % 2 == 1) {         x = (x + y);         if (x >= limit) return -1;       }       y = (y * 2);       b /= 2;       if (y >= limit && b > 0) return -1;     }     return x;   }   long long calc(long long teams) {     long long ret = 0;     while (teams % 2 == 0) {       long long hlf = teams / 2;       ret += hlf;       teams = hlf;       if (ret > n) return -1;     }     long long prt = mult(teams, teams - 1, 4 * n);     if (prt == -1) return -1;     prt /= 2;     ret += prt;     if (ret > n) return -1;     return ret;   }   int main() {     cin >> n;     vector<long long> sol;     for (long long pw2 = 1, cnt = 0; pw2 <= n * 4; pw2 *= 2, cnt++) {       long long lo = 0, hi = ceil(sqrt(4 * n));       long long found = -1;       while (lo <= hi) {         long long mid = (lo + hi) >> 1;         long long odd_part = 2 * mid + 1;         long long tot = mult(odd_part, pw2, 4 * n);         if (tot == -1) {           hi = mid - 1;           continue;         }         long long calc_runs = calc(tot);         if (calc_runs == -1) {           hi = mid - 1;           continue;         } else if (calc_runs == n) {           found = tot;           break;         } else if (calc_runs < n)           lo = mid + 1;         else           hi = mid - 1;       }       if (found != -1) sol.push_back(found);     }     if (sol.size() == 0) {       printf( -1 n );       return 0;     }     sort(sol.begin(), sol.end());     for (int i = 0; i < sol.size(); ++i) cout << sol[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int b[200010];   map<int, long long> S;   long long solve() {     S.clear();     long long df, ans = 0;     for (int i = 0; i < n; i++) {       df = b[i] - i;       S[df] += (long long)b[i];     }     map<int, long long>::iterator it;     for (it = S.begin(); it != S.end(); it++) ans = max(ans, it->second);     return ans;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> b[i];     cout << solve() << endl;   }