malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void go(int parent, int node, int depth, int& odd_count, int& even_count,           vector<vector<int>>& tree) {     int count = 0;     for (int i = 0; i < tree[node].size(); i++) {       if (tree[node][i] != parent) {         count++;         go(node, tree[node][i], depth + 1, odd_count, even_count, tree);       }     }     if (count == 0) {       odd_count += depth % 2;       even_count += !(depth % 2);     }   }   int main() {     int n;     scanf( %d , &n);     vector<vector<int>> tree(n);     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d %d , &u, &v);       tree[u - 1].push_back(v - 1);       tree[v - 1].push_back(u - 1);     }     int root = -1;     for (int i = 0; i < tree.size(); i++) {       if (tree[i].size() > 1) {         root = i;         break;       }     }     int odd_count = 0, even_count = 0;     go(-1, root, 0, odd_count, even_count, tree);     int min_ans = 0, max_ans = n - 1;     if (!odd_count || !even_count) {       min_ans = 1;     } else {       min_ans = 3;     }     vector<int> parent_leaf_count(n, 0);     for (int i = 0; i < n; i++) {       if (tree[i].size() == 1) {         parent_leaf_count[tree[i][0]]++;       }     }     for (int i = 0; i < n; i++) {       if (parent_leaf_count[i]) {         max_ans -= (parent_leaf_count[i] - 1);       }     }     printf( %d %d n , min_ans, max_ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int main() {     cin >> s;     bool ms = false;     string a;     string b;     if (s[0] ==  - ) ms = true;     bool flag = false;     bool p = ms;     for (int i = 0; i < s.size(); i++) {       if (p) {         p = false;         continue;       }       if (s[i] ==  . ) {         flag = true;         continue;       }       if (!flag)         a.push_back(s[i]);       else         b.push_back(s[i]);     }     int l = a.size();     if (ms) cout <<  ( ;     cout <<  $ ;     for (int i = 0; i < l; i++) {       if ((l - i) % 3 == 0 && i != 0) cout <<  , ;       cout << a[i];     }     cout <<  . ;     if (b.size() >= 2)       cout << b[0] << b[1];     else if (b.size() == 1)       cout << b[0] <<  0 ;     else       cout <<  00 ;     if (ms) cout <<  ) ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       int a[n], b[n];       for (int i = 0; i < n; i++) cin >> a[i];       string s;       cin >> s;       vector<pair<long long, pair<long long, long long>>> c(n);       for (int i = 0; i < n; i++) {         c[i].second.first = a[i];         c[i].second.second = i;         c[i].first = (s[i] -  0 );       }       sort(c.begin(), c.end());       long long cnt = 1;       for (int i = 0; i < n; i++) {         b[c[i].second.second] = cnt;         cnt++;       }       for (int i = 0; i < n; i++) {         cout << b[i] <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long dp_cata[3021][5021];   int main() {     dp_cata[0][0] = 1;     for (long long j = 0; j <= 5001; j++)       for (long long i = 0; i <= 3001; i++) {         if (i == 0) {           if (j != 0) dp_cata[i][j] = dp_cata[i + 1][j - 1];         } else           dp_cata[i][j] =               (dp_cata[i + 1][j - 1] + dp_cata[i - 1][j - 1]) % 1000000007;       }     long long n, m;     string s;     cin >> n >> m >> s;     if (n % 2 != 0) {       cout << 0;       exit(0);     }     long long x = 0, y = 0;     long long lientiep = 0;     for (long long i = 0; i < s.size(); i++) {       if (s[i] ==  ( )         x++;       else         y++;       lientiep = max(lientiep, y - x);     }     if (x > n / 2 || y > n / 2) {       cout << 0;       exit(0);     }     long long X = n / 2 - x;     long long Y = n / 2 - y;     long long ans = 0;     for (int i = 0; i <= n - m; i++) {       for (int j = 0; j <= i; j++)         if (j + x >= i - j + y && j - (i - j) >= lientiep) {           if (j < i - j) continue;           ans =               (ans +                dp_cata[j - (i - j)][i] *                    dp_cata[2 * (n / 2 - (i - j + y)) - (n - m - i)][n - m - i]) %               1000000007;         }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ans;   int G[10][10];   int p[10];   bool vis[10][10];   void dfs(int cur) {     if (cur > n) {       memset(vis, 0, sizeof(vis));       int cnt = 0;       for (int i = 1; i <= n; i++) {         for (int j = i + 1; j <= n; j++) {           if (!G[i][j]) continue;           int u = p[i];           int v = p[j];           if (!vis[u][v]) {             vis[u][v] = vis[v][u] = true;             cnt++;           }         }       }       ans = max(ans, cnt);       return;     }     for (int i = 1; i <= 6; i++) {       p[cur] = i;       dfs(cur + 1);     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d%d , &u, &v);       G[u][v] = G[v][u] = 1;     }     dfs(1);     printf( %d n , ans);     return 0;   }
#include<bits/stdc++.h>   #define ll long long   #define ld long double   #define ff first   #define ss second   #define eb emplace_back   #define pb push_back   #define mp make_pair   #define all(x) begin(x), end(x)   #define endl   n    int dx[4] = {1, -1, 0, 0};   int dy[4] = {0, 0, -1, 1};   // ll dp[100005];   ll mod = 1e9 + 7;   bool vis[100000];   using namespace std;   bool isPrime(ll n) {     ll j;     for ( j = 2; j <= sqrt(n); j++) {       if (n % j == 0) {         break;       }     }     if (j > sqrt(n)) {       return 1;     }     else {       return 0;     }   }   ll modexpo(ll a, ll b) {     ll ans = 1;     a = a % mod;     while (b > 0) {       if ((b & 1) == 1) {         ans = ((ans % mod) * (a % mod)) % mod;       }       b = b >> 1;       a = ((a % mod) * (a % mod)) % mod;     }     return ans;   }   ll invmod(ll n) {     return modexpo(n, mod - 2);   }      ll comb(ll n, ll r) {     if (r == 0) {       return 1;     }     ll fact[n + 1];     fact[0] = 1;     for (ll i = 1; i <= n; i++) {       fact[i] = (fact[i - 1] * i) % mod;     }     return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) % mod;   }   ll gcd(ll a, ll b) {     if (a == 0) {       return b;     }     return gcd(b % a, a);   }   ll lcm(ll a, ll b) {     return (a * b) / gcd(a, b);   }   void dfs(ll i, vector<ll>adj[], bool visited[]) {     visited[i] = 1;     for (auto j : adj[i]) {       if (visited[j] == 0) {         dfs(j, adj, visited);       }     }   }   bool sortbysecdesc(const pair<ll, ll> &a, const pair<ll, ll> &b)   {     return a.second > b.second;   }   void solve(ll k) {     ll n;     cin >> n;     ll w[n + 1], ans = 0;     w[0] = 0;     vector<pair<ll, ll>>p;     for (ll i = 0; i < n; i++) {       cin >> w[i + 1];       p.pb(mp(i + 1, w[i + 1]));       ans += w[i + 1];     }     ll in[n + 1];   // memset(in, -1, sizeof(in));     for (ll i = 0; i <= n; i++) {       in[i] = -1;     }     for (ll i = 0; i < n - 1; i++) {       ll u, v;       cin >> u >> v;       in[u]++, in[v]++;     }     cout << ans <<    ;     sort(p.begin(), p.end(), sortbysecdesc);     for (ll i = 0; i < p.size(); i++) {       while (in[p[i].first] > 0) {         ans += p[i].second;         cout << ans <<    ;         in[p[i].first]--;       }     }     cout << endl;   }         int main() {   #ifndef ONLINE_JUDGE     // for getting input from input.txt     freopen( input.txt ,  r , stdin);     // for writing output to output.txt     freopen( output.txt ,  w , stdout);   #endif        ios_base::sync_with_stdio(false);     cin.tie(NULL);     ll t = 1;     cin >> t;     ll k = 1;     while (k <= t) {       solve(k);       k++;     }     return 0;   }   // f3=f2-f1,f4=-f1,f5=-f2,f6=f1-f2,f7=f1,f8=f2,f9=f2-f1,
#include <bits/stdc++.h>   using namespace std;   int main() {     map<pair<int, int>, int> dat;     vector<pair<int, int> > p;     int np;     cin >> np;     int res = 0;     while (np--) {       int x, y;       cin >> x >> y;       p.push_back(make_pair(x, y));       dat[make_pair(x, y)] = 1;     }     int sz = p.size();     for (int i = 0; i < sz; i++)       for (int j = i + 1; j < sz; j++) {         double x = p[i].first + p[j].first;         double y = p[i].second + p[j].second;         x /= 2.0;         y /= 2.0;         pair<int, int> tmp;         if (fabs(x - int(x)) < 1e-9 && fabs(y - int(y)) < 1e-9) {           tmp = make_pair(int(x), int(y));           if (dat.find(tmp) != dat.end()) res++;         }       }     cout << res << endl;   }
#include <iostream>   #include <cstdio>   #define mod 998244353   #define int long long   using namespace std;   int n,k,sa[200005],rk[200005];   int num;   inline int Qpow(register int a,register int p){    if (p==0)return 1;    register int t=Qpow(a,p/2);    t=t*t%mod;    if (p%2==1)t=t*a%mod;    return t;   }   inline int inv(register int x){    return Qpow(x,mod-2);   }   inline int C(register int n,register int m){    if (n<m||m<0)return 0;    register int ans=1;    for (register int i=1;i<=n;i++)ans=ans*i%mod;    for (register int i=1;i<=m;i++)ans=ans*inv(i)%mod;    for (register int i=1;i<=n-m;i++)ans=ans*inv(i)%mod;    return ans;   }   signed main(){    cin>>n>>k;    for (register int i=1;i<=n;i++){     scanf( %d ,&sa[i]);     sa[i]++;     rk[sa[i]]=i;    }    for (register int i=1;i<n;i++)     if (rk[sa[i]+1]>rk[sa[i+1]+1])k--;    cout<<C(n+k-1,k-1)<<endl;    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[7];   int main() {     int n, len;     string str;     scanf( %d n , &n);     for (int i = 0; i < n; i++) {       getline(cin, str);       for (int j = 0; j < 7; j++) {         arr[j] += (str[j] -  0 );       }     }     int mx = 0;     for (int i = 0; i < 7; i++) mx = max(arr[i], mx);     printf( %d n , mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct P {     double x, y;   } a[259];   long long f[259][259];   int n;   int read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   double cross(P a, P b, P c) {     P x = (P){b.x - a.x, b.y - a.y};     P y = (P){c.x - a.x, c.y - a.y};     return x.x * y.y - x.y * y.x;   }   bool jud() {     double ans = 0;     for (int i = 2; i <= n; i++) ans += cross(a[1], a[i - 1], a[i]);     if (ans > 0) return 1;     return 0;   }   void rever() {     for (int i = 1; i <= n / 2; i++) swap(a[i], a[n - i + 1]);   }   int main() {     n = read();     for (int i = 1; i <= n; i++) scanf( %lf%lf , &a[i].x, &a[i].y);     if (jud()) rever();     for (int i = 1; i <= n; i++) f[i][i + 1] = 1;     for (int l = 1; l <= n - 1; l++)       for (int i = 1; i + l <= n; i++)         for (int j = i + 1; j < i + l; j++)           f[i][i + l] =               (f[i][i + l] + f[i][j] % 1000000007 * f[j][i + l] % 1000000007 *                                  (cross(a[i], a[j], a[i + l]) < 0 ? 1 : 0)) %               1000000007;     printf( %lld n , f[1][n] % 1000000007);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, f, a, b;   vector<long long> V;   long long ans;   int main() {     scanf( %lld %lld , &n, &f);     for (int i = 1; i <= n; i++) {       scanf( %lld %lld , &a, &b);       if (a >= b) {         V.push_back(0);         ans += b;       } else {         if (a * 2 <= b) {           V.push_back(a);         } else {           V.push_back(b - a);         }         ans += a;       }     }     sort(V.begin(), V.end());     reverse(V.begin(), V.end());     for (int i = 0; i < f; i++) {       ans += V[i];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int customer[1000][1000];   int main() {     int n, m, k;     cin >> n >> m >> k;     deque<int> dq;     for (int i = 0; i < k; i++) {       int x;       cin >> x;       dq.push_back(x);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cin >> customer[i][j];     }     int t = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int cnt = 0;         for (deque<int>::iterator l = dq.begin(); l != dq.end(); l++) {           cnt++;           if (*l == customer[i][j]) {             int x = *l;             dq.erase(l);             dq.push_front(x);             t += cnt;             break;           }         }       }     }     cout << t;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     if (n == 1) {       cout << 1;       return 0;     }     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) {         while (n % i == 0) {           n /= i;         }         if (n == 1) {           cout << i;         } else {           cout << 1;         }         getchar();         getchar();         return 0;       }     }     cout << n;     getchar();     getchar();   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     string s = bitset<32>(n).to_string();     vector<int> v;     for (int i = 31; i >= 0; i--) {       if (s[i] ==  1 ) {         v.push_back(32 - i);       }     }     reverse(v.begin(), v.end());     for (int& a : v) {       cout << a <<    ;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t = 1, i = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 42;   long long dp[N][N];   int f[N], n;   string s;   long long Solve(int x) {     memset(dp, 0, sizeof dp);     dp[0][x] = 1;     for (int i = 0; i < n; i++) {       for (int j = 0; j < s.size(); j++) {         int m = j;         while (m && s[m] !=  0 ) m = f[m];         if (s[m] ==  0 ) m++;         dp[i + 1][m] += dp[i][j];         m = j;         while (m && s[m] !=  1 ) m = f[m];         if (s[m] ==  1 ) m++;         dp[i + 1][m] += dp[i][j];       }     }     return dp[n][x];   }   int main() {     cin >> n >> s;     for (int i = 2; i <= s.size(); i++) {       f[i] = f[i - 1];       while (f[i] && s[f[i]] != s[i - 1]) f[i] = f[f[i]];       if (s[f[i]] == s[i - 1]) f[i]++;     }     long long ans = 0;     for (int i = 0; i < s.size(); i++) ans += Solve(i);     cout << (1ll << n) - ans <<   n ;   }
#include <bits/stdc++.h>   const double Pi = 3.14159265;   const int N = 1e6 + 50;   const int M = 1e5 + 15;   const unsigned long long base = 163;   const int INF = 0x3f3f3f3f;   using namespace std;   int a[N];   int main() {     int n;     scanf( %d , &n);     int l = 0, r = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     int pre = 1;     int now = -1;     int flag = 0;     for (int i = 1; i <= n - 1; i++) {       if (a[i] == a[i + 1]) {         pre++;       } else {         flag = 1;         if (now == -1)           now = pre;         else {           if (pre != now) {             cout <<  NO  << endl;             return 0;           }         }         pre = 1;       }     }     if (pre != now && flag) return cout <<  NO n , 0;     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   const int MOD = 1e9 + 7;   const int MAXN = 1e6 + 3;   struct Rcompare {     bool operator()(pair<int, int> lhs, pair<int, int> rhs) {       return lhs.first > rhs.first;     }   };   struct compare {     bool operator()(pair<int, int> lhs, pair<int, int> rhs) {       return lhs.first < rhs.first;     }   };   int solve(int x) {     if (x < 4 || x == 5 || x == 7 || x == 11) {       return -1;     }     if (x % 4 == 0) {       return x / 4;     }     if (x % 4 == 2) {       return x / 4;     }     if (x % 4 == 1) {       return x / 4 - 1;     }     return x / 4 - 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     for (int i = 0; i < (n); ++i) {       int x;       cin >> x;       cout << solve(x) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int bin[31];   int cnt;   int ch[6000010][2];   void insert(int x) {     for (int i = 30; i >= 0; --i) {       bin[i] = x & 1;       x >>= 1;     }     int now = 0;     for (int i = 0; i <= 30; ++i) {       if (!ch[now][bin[i]]) {         ch[now][bin[i]] = ++cnt;       }       now = ch[now][bin[i]];     }   }   int getans(int l, int r, int k) {     if (k == 32) return 0;     int firmin = 1 << 30;     if (ch[l][0] && ch[r][0])       firmin = min(firmin, getans(ch[l][0], ch[r][0], k + 1));     if (ch[l][1] && ch[r][1])       firmin = min(firmin, getans(ch[l][1], ch[r][1], k + 1));     if (firmin != 1 << 30) return firmin;     int secmin = 1 << 30;     if (ch[l][1] && ch[r][0])       secmin = min(secmin, getans(ch[l][1], ch[r][0], k + 1)) + (1 << (31 - k));     if (ch[l][0] && ch[r][1])       secmin = min(secmin, getans(ch[l][0], ch[r][1], k + 1)) + (1 << (31 - k));     return secmin;   }   long long ans;   void dfs(int x, int k) {     if (ch[x][0] && ch[x][1]) {       ans += 1ll * (getans(ch[x][0], ch[x][1], k + 1) + (1 << (31 - k)));     }     if (ch[x][0]) dfs(ch[x][0], k + 1);     if (ch[x][1]) dfs(ch[x][1], k + 1);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       int x;       scanf( %d , &x);       insert(x);     }     dfs(0, 1);     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFL = 0x3f3f3f3f3f3f3f3fLL;   const long double eps = 1e-8;   const int MAXN = 100000 + 5;   pair<long double, long double> X[MAXN << 2];   inline pair<long double, long double> calc(const int& a, const int& b) {     long double x = (long double)(b - a) / (long double)a;     return make_pair(x, x);   }   inline void pushUp(const int& rt) {     X[rt].first = X[rt << 1].first * X[rt << 1 | 1].first;     X[rt].second = X[rt << 1].second + X[rt << 1 | 1].second * X[rt << 1].first;   }   void build(int l, int r, int rt) {     static int ax, bx;     if (l == r) {       scanf( %d %d , &ax, &bx);       X[rt] = calc(ax, bx);       return;     }     int mid = (l + r) >> 1;     build(l, mid, rt << 1);     build(mid + 1, r, rt << 1 | 1);     pushUp(rt);   }   void update(const int& p, const pair<long double, long double>& v, int l, int r,               int rt) {     if (l == r) {       X[rt] = v;       return;     }     int mid = (l + r) >> 1;     if (p <= mid)       update(p, v, l, mid, rt << 1);     else       update(p, v, mid + 1, r, rt << 1 | 1);     pushUp(rt);   }   pair<long double, long double> query(const int& L, const int& R, int l, int r,                                        int rt) {     static pair<long double, long double> z =         make_pair((long double)1.0, (long double)0.0);     if (L <= l && r <= R) return X[rt];     int mid = (l + r) >> 1;     pair<long double, long double> x = z, y = z, ret;     if (L <= mid) x = query(L, R, l, mid, rt << 1);     if (R > mid) y = query(L, R, mid + 1, r, rt << 1 | 1);     ret.first = x.first * y.first;     ret.second = x.second + y.second * x.first;     return ret;   }   int main() {     static int n, q, op, x, ax, bx, lx, rx;     while (~scanf( %d %d , &n, &q)) {       build(1, n, 1);       while (q--) {         scanf( %d , &op);         if (op == 1) {           scanf( %d %d %d , &x, &ax, &bx);           update(x, calc(ax, bx), 1, n, 1);         } else {           scanf( %d %d , &lx, &rx);           long double ans = query(lx, rx, 1, n, 1).second;           if (ans != ans || ans >= 1e20)             ans = 0.0;           else             ans = 1 / (1 + ans);           cout << fixed << setprecision(8) << ans <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read() {     T x = 0, f = 0;     char c = getchar();     while (!isdigit(c)) f = c ==  - , c = getchar();     while (isdigit(c)) x = x * 10 + c - 48, c = getchar();     return f ? -x : x;   }   namespace run {   const long long N = 2e5 + 9;   map<long long, long long> mp;   long long n, a[N], ans;   long long main() {     n = read<long long>();     for (long long i = 1; i <= n; i++) a[i] = read<long long>();     mp[0] = 1;     for (long long i = 1, sum = 0, las = 0; i <= n; i++) {       sum += a[i];       las = max(las, mp[sum]);       ans += i - las;       mp[sum] = i + 1;     }     printf( %lld n , ans);     return 0;   }   }  // namespace run   int main() { return run::main(); }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int id, a, b;   } node[111111], zhan[111111];   bool cmp1(Node a, Node b) { return a.a > b.a || (a.a == b.a && a.b > b.b); }   bool cmp2(Node a, Node b) { return a.b > b.b || (a.b == b.b && a.a < b.a); }   int main() {     int n, p, k;     scanf( %d%d%d , &n, &p, &k);     for (int i = 0; i < n; i++)       scanf( %d%d , &node[i].a, &node[i].b), node[i].id = i + 1;     sort(node, node + n, cmp2);     sort(node, node + n - p + k, cmp1);     int flag = 1 << 30, flag1 = -1;     for (int i = 0; i < k; i++) {       zhan[i] = node[i];       if (flag >= zhan[i].b) {         if (flag == zhan[i].b)           flag1 = max(zhan[i].a, flag1);         else           flag1 = zhan[i].a;         flag = zhan[i].b;       }     }     sort(node + k, node + n, cmp2);     int cnt = k;     for (int i = k; cnt < p; i++) {       if (node[i].b < flag || (node[i].b == flag && node[i].a >= flag1))         zhan[cnt++] = node[i];     }     for (int i = 0; i < p; i++) printf( %d  , zhan[i].id);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   struct ent {     int val, pos;     inline bool operator<(const ent &cpr) const { return val < cpr.val; }   };   set<ent> pq;   int n;   int val[300005];   long long sum[300005];   long long ret;   int a, b;   int del[300005];   int dcnt;   int main() {     ret = -1000000000000ll;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &val[i]);     for (int i = 1; i <= n; i++) {       sum[i] = sum[i - 1] + max(val[i], 0);       ent nw;       nw.pos = i;       nw.val = val[i];       set<ent>::iterator it;       it = pq.find(nw);       if (it == pq.end())         pq.insert(nw);       else {         if (ret < 2 * val[i] + sum[i - 1] - sum[(*it).pos]) {           ret = 2 * val[i] + sum[i - 1] - sum[(*it).pos];           a = (*it).pos;           b = i;         }       }     }     cout << ret;     for (int i = 1; i < a; i++) del[++dcnt] = i;     for (int i = a + 1; i < b; i++)       if (val[i] < 0) del[++dcnt] = i;     for (int i = b + 1; i <= n; i++) del[++dcnt] = i;     printf(  %d n , dcnt);     for (int i = 1; i <= dcnt; i++) printf( %d  , del[i]);   }