malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 501;   long long matrix[maxn][maxn];   long long sum_col[maxn];   long long sum_row[maxn];   long long sum_d1 = 0;   long long sum_d2 = 0;   int pos_col = 0;   int pos_row = 0;   int main() {     int n, sum = 0;     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         int tmp;         cin >> tmp;         if (tmp == 0) {           pos_col = j;           pos_row = i;         }         if (i == j) sum_d1 += tmp;         if (i == n - j - 1) sum_d2 += tmp;         sum_row[i] += tmp;         sum_col[j] += tmp;       }     }     if (n == 1) {       cout << 1;       return 0;     }     bool ans = true;     int cor = 0;     if (pos_col == cor) cor = 1;     long long num = sum_col[cor] - sum_col[pos_col];     if (num <= 0) ans = false;     sum_col[pos_col] += num;     sum_row[pos_row] += num;     if (pos_col == pos_row) sum_d1 += num;     if (pos_row == n - pos_col - 1) sum_d2 += num;     for (int i = 0; i < n; i++) {       if (sum_col[i] != sum_col[cor]) ans = false;       if (sum_row[i] != sum_col[cor]) ans = false;     }     if (sum_d1 != sum_col[cor]) ans = false;     if (sum_d2 != sum_col[cor]) ans = false;     if (ans)       cout << num;     else       cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   long long int n, remm[200010], actual_pos[200010];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     clock_t clk = clock();     int q;     cin >> n;     for (int i = 1; i <= n; i++) cin >> remm[i], actual_pos[i] = remm[i];     remm[n + 1] = 1e15;     cin >> q;     set<int> stations;     for (int i = 1; i <= n + 1; i++) stations.insert(i);     while (q--) {       int type;       cin >> type;       if (type == 1) {         int vess, pour;         cin >> vess >> pour;         while (pour != 0) {           int go_to = *(stations.lower_bound(vess));           if (remm[go_to] > pour) {             remm[go_to] -= pour;             pour = 0;           } else {             pour -= remm[go_to];             remm[go_to] = 0;             stations.erase(go_to);           }         }       } else {         int ves;         cin >> ves;         cout << actual_pos[ves] - remm[ves] << endl;       }     }     cerr << endl          << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> t[100000];   int n;   int h[100000];   int arr[100000];   double fac[100001];   bool cmp(int a, int b) { return h[a] < h[b]; }   void dfs(int cur, int he, int par = -1) {     h[cur] = he;     for (int i = 0; i < t[cur].size(); i++) {       if (t[cur][i] == par) continue;       dfs(t[cur][i], he + 1, cur);     }   }   int main() {     cin >> n;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       t[a - 1].push_back(b - 1);       t[b - 1].push_back(a - 1);     }     dfs(0, 1);     for (int i = 0; i < n; i++) arr[i] = i;     sort(arr, arr + n, cmp);     double ans = 1;     fac[0] = 1;     fac[1] = 1;     for (int i = 2; i <= n; i++) fac[i] = 1.0 / i;     for (int i = 1; i < n; i++) {       ans = (ans + 1) * fac[h[i]] + ans * (1 - fac[h[i]]);     }     printf( %.9lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void FAST_IO() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   template <class F, class S>   ostream& operator<<(ostream& os, pair<F, S>& p) {     os <<  (  << p.first <<  ,  << p.second <<  ) ;     return os;   }   template <class T, class S>   ostream& operator<<(ostream& os, map<T, S>& v) {     os <<  { ;     for (auto& i : v) cout <<  {  << i.first <<  ,  << i.second <<  } ;     os <<  } ;     return os;   }   template <class T>   ostream& operator<<(ostream& os, set<T>& v) {     os <<  { ;     for (auto& i : v) cout << i <<  , ;     os <<  } ;     return os;   }   template <class T>   ostream& operator<<(ostream& os, vector<T>& v) {     os <<  [ ;     if (v.size()) os << v[0];     for (int i = 1; i < v.size(); ++i) os <<  ,  << v[i];     os <<  ] ;     return os;   }   int main() {     int n;     vector<bool> in(1002);     while (cin >> n) {       in[n] = true;       getchar();     }     int first = true;     for (int i = 0; i < in.size(); ++i) {       if (!in[i]) continue;       int begin = i;       while (in[i]) i++;       if (!first) printf( , );       if (i - begin > 1)         printf( %d-%d , begin, i - 1);       else         printf( %d , i - 1);       first = false;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<long long> m(n);     for (int i = 0; i < n; i++) cin >> m[i];     long long sum = 0;     for (int i = 0; i < n; i++) sum += m[i];     sum += n;     vector<long long> a(n + 1);     for (int i = n - 1; i >= 0; i--) a[i] = max(a[i + 1] - 1, m[i] + 1);     for (int i = 1; i < n; i++) a[i] = max(a[i], a[i - 1]);     for (int i = 0; i < n; i++) sum -= a[i];     cout << -sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   int lca[400100][20];   int len[400100];   long long s[400100][20];   int w[400100];   int main() {     ios::sync_with_stdio(false);     int Q;     cin >> Q;     int cnt = 0;     int last = 0;     len[0] = 1;     for (long long q = 0; q < (long long)(Q); ++q) {       int t, x;       long long y;       cin >> t >> x >> y;       x ^= last;       --x;       y ^= last;       if (t == 1) {         ++cnt;         w[cnt] = y;         for (int i = 20 - 1; i >= 0; --i) {           if (w[lca[x][i]] < y) {             x = lca[x][i];           }         }         if (w[x] < y) {           x = lca[x][0];         }         if (w[x] < y) {           x = cnt;         }         lca[cnt][0] = x;         len[cnt] = len[x] + 1;         s[cnt][0] = y;         for (long long i = 0; i < (long long)(20 - 1); ++i) {           lca[cnt][i + 1] = lca[lca[cnt][i]][i];           s[cnt][i + 1] = s[cnt][i] + s[lca[cnt][i]][i];         }       } else {         last = 0;         int upp = len[x];         for (int i = 20 - 1; i >= 0; --i) {           if (s[x][i] <= y) {             y -= s[x][i];             x = lca[x][i];             last += 1 << i;           }         }         last = min(last, upp);         cout << last << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> val(100000 + 5);   struct Gaussian {     long long no_of_bits = 20;     vector<long long> v;     long long set, origsize = 0, redsize = 0;     void push(long long val) {       origsize++;       if (val) v.push_back(val);     }     void clear() {       v.clear();       set = 0, redsize = 0;     }     void eliminate() {       set = redsize = 0;       for (long long bit = 0; bit <= no_of_bits; bit++) {         bool check = false;         for (long long i = redsize; i < v.size(); i++) {           if ((v[i] >> bit) & 1) {             swap(v[i], v[redsize]);             check = true;             break;           }         }         if (check) {           for (long long i = redsize + 1; i < v.size(); i++) {             if ((v[i] >> bit) & 1) v[i] ^= v[redsize];           }           redsize++;         }       }       v.resize(redsize);       for (auto it : v) set |= it;     }     Gaussian& operator=(Gaussian& orig) {       v = orig.v;       set = orig.set;       redsize = orig.redsize;       origsize = orig.origsize;       return *this;     }   };   long long modexpo(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b % 2) res = (res * a) % 1000000007;       a = (a * a) % 1000000007;       b = b / 2;     }     return res;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, q;     cin >> n >> q;     Gaussian arr[n];     val.resize(n);     for (long long i = 0; i < n; i++) cin >> val[i];     arr[0].push(val[0]);     arr[0].eliminate();     for (long long i = 1; i < n; i++) {       arr[i] = arr[i - 1];       arr[i].push(val[i]);       arr[i].eliminate();     }     while (q--) {       long long l, x;       cin >> l >> x;       Gaussian temp = arr[--l];       temp.push(x);       temp.eliminate();       long long ans = 0;       if (temp.redsize == arr[l].redsize)         ans = modexpo(2, arr[l].origsize - arr[l].redsize);       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod1 = 19260817;   const long long mod2 = 19660813;   int n;   int m;   char s[200005];   char opt[5];   struct {     int tree[200005];     int lowbit(int x) { return x & -x; }     void ins(int pos, int val) {       for (; pos <= n; pos += lowbit(pos)) tree[pos] += val;     }     int query(int pos) {       int sum = 0;       for (; pos; pos -= lowbit(pos)) sum += tree[pos];       return sum;     }   } t[125];   int find(int x) {     int ret = 0;     for (int i = 20; i >= 0; --i) {       if (ret + (1 << i) > n) continue;       int sum = 0;       for (int j = 48; j < 125; ++j) sum += t[j].tree[ret + (1 << i)];       if (x >= sum) {         x -= sum;         ret += (1 << i);       }     }     return ret;   }   set<int> book[125];   set<int>::iterator it;   vector<int> memo;   bool check(int pos) {     if (pos == 1) {       if (t[s[pos]].query(pos)) return true;     } else {       if (t[s[pos]].query(pos) - t[s[pos]].query(pos - 1)) return true;     }     return false;   }   int main() {     scanf( %d %d , &n, &m);     scanf( %s , s + 1);     for (int i = 1; i <= n; ++i) {       t[s[i]].ins(i, 1);       book[s[i]].insert(i);     }     while (m--) {       int l;       int r;       scanf( %d %d %s , &l, &r, opt + 1);       int lcur = find(l - 1) + 1;       int rcur = find(r - 1) + 1;       it = book[opt[1]].lower_bound(lcur);       memo.clear();       while (it != book[opt[1]].end()) {         int pos = *it;         if (pos > rcur) break;         memo.push_back(pos);         ++it;       }       for (auto p : memo) book[opt[1]].erase(p);       for (auto p : memo) t[opt[1]].ins(p, -1);     }     for (int i = 1; i <= n; ++i) {       if (check(i)) printf( %c , s[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, k, m, maxa, minb, tem;   int main() {     cin >> a >> b >> k >> m;     for (int i = 0; i < a; i++) {       cin >> tem;       if (i == k - 1) maxa = tem;     }     for (int i = 0; i < b; i++) {       cin >> tem;       if (i == b - m) minb = tem;     }     cout << (maxa < minb ?  YES  :  NO ) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long w, h, u1, d1, u2, d2;     cin >> w >> h >> u1 >> d1 >> u2 >> d2;     for (int i = h; i >= 0; i--) {       w += i;       if (i == d1) w -= u1;       if (i == d2) w -= u2;       w = max(w, 0LL);     }     cout << w << endl;   }
#include <bits/stdc++.h>   using namespace std;   unordered_set<int> S;   int main() {     int n;     cin >> n;     int A[n], dp[n + 1];     dp[0] = 0;     S.clear();     for (int _n{n}, i{0}; i < _n; ++i) {       cin >> A[i];       dp[i + 1] = dp[i];       if (!S.count(A[i])) {         S.insert(A[i]);         dp[i + 1]++;       }     }     S.clear();     uint64_t ans = 0;     for (int _n{n + 1}, i{1}; i < _n; ++i) {       if (!S.count(A[n - i])) {         ans += dp[n - i];         S.insert(A[n - i]);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool comp(long long a, long long b) { return a > b; }   std::vector<long long> fac(500000);   void pre() {     fac[0] = 1;     for (int i = 1; i < 500000; i++) {       fac[i] = i * fac[i - 1];       fac[i] %= 998244353;     }   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long modInverse(long long n, long long p) { return power(n, p - 2, p); }   long long nCrModPFermat(long long n, long long r) {     if (n <= 0 || n < r) return 0;     if (r == 0) return 1;     long long a = (fac[n] * modInverse(fac[r], 998244353) % 998244353 *                    modInverse(fac[n - r], 998244353) % 998244353) %                   998244353;     return a;   }   void solve() {     long long k, x, y, n;     cin >> n >> k;     std::vector<pair<long long, long long>> ar;     long long ans = 0;     for (int i = 0; i < n; i++) {       long long l, r;       cin >> l >> r;       ar.push_back(make_pair(l, r));     }     if (k == 1) {       cout << n <<   n ;       return;     }     sort(ar.begin(), ar.end());     multiset<long long> q;     long long cnt;     for (int i = 0; i < n; i++) {       while (!q.empty() && *q.begin() < ar[i].first) {         q.erase(q.begin());       }       cnt = q.size();       ans += (nCrModPFermat(cnt, k - 1));       ans %= 998244353;       q.insert(ar[i].second);     }     cout << ans <<   n ;   }   int main() {     pre();     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mx = 2e3 + 1, Mod = 1e9 + 7;   long long int k, Pa, Pb;   int pw(long long int a, int b) {     long long int ans = 1;     while (b) {       if (b % 2) ans = (ans * a) % Mod;       a = (a * a) % Mod;       b /= 2;     }     return ans;   }   long long int dp[mx][mx];   long long int dpp(int i, int j) {     if (j >= k) return j;     return dp[i][j];   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> k >> Pa >> Pb;     long long int divm = pw(Pa + Pb, Mod - 2);     long long int divb = (Pa * pw(Pb, Mod - 2)) % Mod;     for (int i = k; i >= 0; i--)       for (int j = k - 1; j >= 0; j--) {         if (i == k) {           dp[i][j] = (i + j + divb) % Mod;           continue;         }         dp[i][j] =             (((Pa * dpp(i + 1, j) + Pb * dpp(i, i + j)) % Mod) * divm) % Mod;       }     return cout << dp[1][0], 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[2000 + 5][2000 + 5];   int v, res, n, m, k, cnt;   int main() {     scanf( %d%d%d , &n, &m, &k);     bool flag = 0;     if (k == 1) flag = 1;     for (int i = 1; i <= n; i++) scanf( %s , str[i]);     for (int i = 1; i <= n; i++) {       for (int j = 0; j < m; j++) {         if (str[i][j] ==  * ) {           if (v >= k) res += v - k + 1;           v = 0;         } else           v++, cnt++;       }       if (v >= k) res += v - k + 1;       v = 0;     }     if (flag == 1) {       printf( %d , cnt);       return 0;     }     for (int i = 0; i < m; i++) {       for (int j = 1; j <= n; j++) {         if (str[j][i] ==  * ) {           if (v >= k) res += v - k + 1;           v = 0;         } else           v++;       }       if (v >= k) res += v - k + 1;       v = 0;     }     printf( %d , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int arr[101], ans = 0, temp = 0;     int i, j, n;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %I64d , &arr[i]);     for (i = 0; i < n; i++) {       for (j = i; j < n; j++) {         temp = temp ^ arr[j];         ans = max(ans, temp);       }       temp = 0;     }     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2020;   int n, m, i, j, cnt[N];   char grid[N][N];   bool check(int s) {     for (int i = 0; i < m; ++i)       if (grid[s][i] ==  1  && cnt[i] <= 1) return 0;     return 1;   }   int main() {     cin >> n >> m;     for (i = 0; i < n; ++i) {       scanf( %s , grid + i);       for (j = 0; j < m; ++j) {         cnt[j] += (grid[i][j] ==  1 );       }     }     for (i = 0; i < n; ++i) {       if (check(i)) {         return cout <<  YES , 0;       }     }     cout <<  NO ;     return 0;   }
#include<string.h>   #include<bits/stdc++.h>   using namespace std;   int main()   {    int t;    cin>>t;    //string a,b;    while(t--)    {     string a,b;     cin>>a;     int n,m,g,maxx;     cin>>b;     string l,k;     int len=a.size(),len1=b.size();     for(int i=1;i<=len;i++)     {      int r=0;      for(int j=0;j<(len-i);)      {       if(a.substr(j,i)!=a.substr(j+i,i))       {        r=1;        break;       }       else j+=i;      }      if(!r)       {      l=a.substr(0,i);      break;     }    }     for(int i=1;i<=len1;i++)     {      int r=0;      for(int j=0;j<(len1-i);)      {       if(b.substr(j,i)!=b.substr(j+i,i))       {        r=1;        break;       }       else j+=i;      }      if(!r)      {        k=b.substr(0,i);        break;}     }     int s,s1;     s=l.size();     s1=k.size();     n=len/s,m=len1/s1;     maxx=min(n,m);     for(int i=maxx;i>=1;i--)     {      if(n%i==0&&m%i==0)      {       g=i;       break;      }     }     //cout<<l<<   <<k;     if(l==k)      {      for(int i=0;i<n*m/g;i++)  cout<<l;      cout<<endl;     }     else cout<< -1 <<endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 100 * 1000;   int ok[MaxN];   int bad[MaxN];   char TYPE[MaxN];   int QUERY[MaxN];   bool crime[MaxN];   int main() {     int n, m;     scanf( %d%d n , &n, &m);     int sumWrong = 0;     for (int i = 0; i < n; i++) {       char type;       int x;       scanf( %c%d , &type, &x);       if (i != n - 1) scanf(  n );       TYPE[i] = type;       QUERY[i] = x - 1;       if (type ==  + ) {         bad[x - 1]++;       } else {         ok[x - 1]++;         sumWrong++;       }     }     int sz = 0;     for (int i = 0; i < n; i++) {       int right = bad[i] + sumWrong - ok[i];       if (right == m) {         crime[i] = true;         sz++;       }     }     for (int i = 0; i < n; i++) {       if (TYPE[i] ==  - ) {         if (!crime[QUERY[i]]) printf( Truth n );         if (crime[QUERY[i]] && sz > 1) printf( Not defined n );         if (crime[QUERY[i]] && sz == 1) printf( Lie n );       } else {         if (!crime[QUERY[i]]) printf( Lie n );         if (crime[QUERY[i]] && sz > 1) printf( Not defined n );         if (crime[QUERY[i]] && sz == 1) printf( Truth n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     cin.sync_with_stdio(false);     long long k[3];     int t[3];     int n, i, j;     for (i = 0; i < 3; i++) cin >> k[i];     for (i = 0; i < 3; i++) cin >> t[i];     cin >> n;     vector<long long> a(n);     vector<long long> b(n);     for (i = 0; i < n; i++) {       cin >> a[i];       b[i] = a[i];     }     for (j = 0; j < 3; j++)       if (k[j] > n) k[j] = n;     for (j = 0; j < 3; j++) {       priority_queue<long long, vector<long long>, greater<long long> > Q;       for (i = 0; i < k[j]; i++) {         Q.push(0);       }       for (i = 0; i < n; i++) {         long long p = Q.top();         Q.pop();         if (p < b[i]) p = b[i];         b[i] = p + t[j];         Q.push(b[i]);       }     }     long long ans = 0;     for (i = 0; i < n; i++) {       if (b[i] - a[i] > ans) ans = b[i] - a[i];     }     cout << ans << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define pb push_back   #define reg register   #define int long long   #define For(i,a,b) for(reg int i=a;i<=b;++i)   #define Down(i,a,b) for(reg int i=a;i>=b;--i)    #define ull unsigned long long   #define rep(i,a,b) for(reg int i=a;i<=b;++i)   #define ll long long   inline int max(int x,int y){return x>y?x:y;}   inline int min(int x,int y){return x<y?x:y;}   inline void ckmin(int &x,int y){x=x<y?x:y; return ;}   inline void ckmax(int &x,int y){x=x>y?x:y; return ;}   inline int gcd(int n,int m){return m?gcd(m,n%m):n;}   inline int lcm(int x,int y){return x/gcd(x,y)*y;}   inline void swap(int &x,int &y){int t=x; x=y; y=t; return ;}   namespace yspm{    inline int read(){        int res=0,f=1; char k;        while(!isdigit(k=getchar())) if(k== - ) f=-1;        while(isdigit(k)) res=res*10+k- 0 ,k=getchar();        return res*f;       }       char out[100];       inline void print(int x){           if(!x) return putchar( 0 ),putchar(  n ),void();           if(x<0) putchar( - ),x=-x;            int cnt=0; while(x) out[++cnt]=x%10,x/=10;            Down(i,cnt,1) putchar(out[i]+ 0 ); putchar(  n ); return ;       }        const int N=1e5+10,bl=510;       vector<int>f[N<<2];       int n,a[N],p,v;       inline void push_up(int x){           int rpos=0,lsz=f[x<<1].size(),rsz=f[x<<1|1].size(); f[x].clear();           for(reg int i=0;i<lsz;){               if(rpos==rsz||(f[x<<1][i]<f[x<<1|1][rpos]-i)) f[x].push_back(f[x<<1][i++]);               else f[x].push_back(f[x<<1|1][rpos++]-i);           } for(reg int j=rpos;j<rsz;++j) f[x].push_back(f[x<<1|1][j]-lsz);           return ;       }       inline void build(int p,int l,int r){           if(l==r) return f[p].resize(1),f[p][0]=a[l],void(); int mid=(l+r)>>1;            build(p<<1,l,mid); build(p<<1|1,mid+1,r);            if(r-l+1<=bl) push_up(p); return ;       }       inline void modify(int x,int l,int r){           if(l==r) return f[x][0]=a[l],void(); int mid=(l+r)>>1;            if(p<=mid) modify(x<<1,l,mid); else modify(x<<1|1,mid+1,r);            if(r-l+1<=bl) push_up(x); return ;       }       inline void query(int x,int l,int r){           if(l>=p&&r-l+1<=bl) return v+=upper_bound(f[x].begin(),f[x].end(),v)-f[x].begin(),void(); int mid=(l+r)>>1;            if(mid>=p) query(x<<1,l,mid); return query(x<<1|1,mid+1,r);        }    signed main(){        n=read(); rep(i,1,n) a[i]=i-read(); build(1,1,n);         int Q=read(); while(Q--){            if(read()==1){                int x=read(),y=read();                 a[x]=x-y; p=x; modify(1,1,n);            }else{                p=read(); if(p==n) print(a[n]);                 else v=a[p],++p,query(1,1,n),print(v);            }        } return 0;       }   }signed main(){return yspm::main();}   //Use The Time To Enrich This Selfclosing Youth
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, n, m, q, p;     cin >> q;     while (q--) {       cin >> n;       string s;       cin >> s;       p = 0;       if (s.length() > 2) {         cout <<  YES n2 n ;         cout << s[0] <<    ;         for (i = 1; i < n; i++) cout << s[i];         cout << endl;       } else {         if (s[0] < s[1])           cout <<  YES n2 n  << s[0] <<     << s[1] << endl;         else           cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 4000;   long long p[MAXN + 10], v[MAXN + 10], d[MAXN + 10];   bool lft[MAXN + 10];   int n;   void print(int n) {     for (int i = 0; i < n; i++) cout << p[i] <<    ;     cout << endl;     for (int i = 0; i < n; i++) cout << lft[i] <<    ;     cout << endl;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> v[i] >> d[i] >> p[i];     int res = 0;     for (int i = 0; i < n; i++) {       if (lft[i]) continue;       res++;       long long f = 0, effect = 0;       for (int j = i + 1; j < n; j++) {         if (lft[j]) continue;         p[j] -= max(0ll, v[i] - f++);         p[j] -= effect;         if (p[j] < 0) {           lft[j] = true;           effect += d[j];         }       }     }     cout << res << endl;     for (int i = 0; i < n; i++)       if (!lft[i]) cout << i + 1 <<    ;     cout << endl;   }