malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     map<string, int> mapp;     int mina = 10000000, minb = 10000000, minc = 10000000, minab = 10000000,         minac = 10000000, minbc = 10000000, min3 = 10000000;     int x;     string na;     for (int i = 0; i < n; i++) {       cin >> x >> na;       sort(na.begin(), na.end());       if (na.length() == 3) {         min3 = min(x, min3);       } else if (na ==  A ) {         mina = min(x, mina);       } else if (na ==  B ) {         minb = min(x, minb);       } else if (na ==  C ) {         minc = min(x, minc);       } else if (na ==  AB ) {         minab = min(x, minab);       } else if (na ==  AC ) {         minac = min(x, minac);       } else if (na ==  BC ) {         minbc = min(x, minbc);       }     }     min3 = min(min3, minab + minc);     min3 = min(min3, minac + minb);     min3 = min(min3, minbc + mina);     min3 = min(min3, mina + minb + minc);     min3 = min(min3, minab + minbc);     min3 = min(min3, minab + minac);     min3 = min(min3, minac + minbc);     if (min3 > 1000000) {       cout <<  -1  << endl;     } else {       cout << min3 << endl;     }     return 0;   }
#include <bits/stdc++.h>   bool visited[200010] = {0};   int first[200010], second[200010], thrid[200010], count = 0;   std::set<long long int> happened;   long long int f(int one, int two) {     return (1LL * 1e6 * std::min(one, two) + std::max(one, two));   }   int dfs(int current, std::vector<std::vector<int> > &g, int parent = -1) {     if (visited[current]) return current;     visited[current] = 1;     std::vector<int> s;     for (int i = 0; i < g[current].size(); ++i) {       if (g[current][i] != parent) {         int value = dfs(g[current][i], g, current);         if (value != -1 &&             happened.find(f(g[current][i], current)) == happened.end()) {           s.push_back(value);         }       }     }     int ffirst = 0, ssecond = 1;     while (ssecond < s.size()) {       happened.insert(f(s[ffirst], current));       happened.insert(f(s[ssecond], current));       first[count] = s[ffirst];       second[count] = current;       thrid[count] = s[ssecond];       ++count;       ffirst += 2;       ssecond += 2;     }     if (ffirst == s.size()) return current;     if (parent != -1) {       first[count] = s[ffirst];       second[count] = current;       thrid[count] = parent;       ++count;       happened.insert(f(s[ffirst], current));       happened.insert(f(current, parent));     }     return -1;   }   int main() {     int n, m;     std::cin >> n >> m;     std::vector<std::vector<int> > g(n);     for (int i = 0; i < m; ++i) {       int x, y;       std::cin >> x >> y;       --x;       --y;       g[x].push_back(y);       g[y].push_back(x);     }     for (int i = 0; i < n; ++i) {       if (!visited[i]) {         dfs(i, g);       }     }     std::cout << count <<   n ;     for (int i = 0; i < count; ++i) {       std::cout << first[i] + 1 <<     << second[i] + 1 <<     << thrid[i] + 1                 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> s;   vector<pair<int, int> > v;   vector<vector<int> > g;   vector<bool> used;   map<int, int> mp;   int c[1005];   int cl[1005];   int cr[1005];   int main() {     ios_base::sync_with_stdio(0);     int n, m, k;     cin >> n >> m >> k;     g.resize(n);     for (int i = 0; i < k; i++) {       int x;       cin >> x;       x--;       s.push_back(x);     }     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       v.push_back({a, b});       g[a].push_back(b);       g[b].push_back(a);     }     int ck = 0;     queue<int> q;     used.resize(n + 5, 0);     mp[0] = n;     for (int i = 0; i < k; i++) {       q.push(s[i]);       ck++;       while (!q.empty()) {         int vc = q.front();         c[vc] = ck;         used[vc] = 1;         for (int i = 0; i < g[vc].size(); i++) {           if (!used[g[vc][i]]) q.push(g[vc][i]);         }         q.pop();       }     }     for (int i = 0; i < n; i++) {       cl[c[i]]++;     }     for (int i = 0; i < m; i++) {       int x = v[i].first;       cr[c[x]]++;     }     long long mx = 0;     int num = -1;     for (int i = 1; i <= ck; i++) {       long long cur = (cl[i] + cl[0]) * (cl[i] + cl[0] - 1) - cr[i] - cr[0];       if (cur > mx) {         mx = cur;         num = i;       }     }     cl[num] += cl[0];     cr[num] += cr[0];     long long ans = 0;     for (int i = 1; i <= ck; i++) {       ans += cl[i] * (cl[i] - 1) / 2 - cr[i];     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   int gcd(int a, int b, int &counter) {     if (b == 0) return a;     counter += a / b;     return gcd(b, a % b, counter);   }   int main() {     int n;     int minn = 1000000;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int tempCounter = 0;       if (gcd(n, i, tempCounter) == 1 && tempCounter < minn) minn = tempCounter;     }     if (n == 1)       minn = 0;     else       minn--;     printf( %d n , minn);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10, inf = 15e8;   int A[maxn], B[maxn], C[maxn], ANSA, ANSB, n, l, r;   vector<int> ed;   vector<pair<int, int> > v[maxn];   int SZ[maxn], MX;   bool mark[maxn];   pair<int, int> val[2 * maxn];   void dfsS(int u, int par = -1) {     SZ[u] = 1;     for (pair<int, int> p : v[u]) {       if (p.first != par && !mark[p.first])         dfsS(p.first, u), SZ[u] += SZ[p.first];     }   }   int dfsC(int u, int ss, int par = -1) {     for (pair<int, int> p : v[u]) {       if (p.first != par && !mark[p.first] && SZ[p.first] >= ss)         return dfsC(p.first, ss, u);     }     return u;   }   void prep() {     for (int i = 0; i < 2 * MX; i++) {       val[i] = {-inf, -inf};     }   }   pair<int, int> ask(int f, int s) {     s = min(s, MX - 1);     f += MX;     s += MX;     pair<int, int> ans = {-inf, -inf};     while (f < s) {       if (f & 1) ans = max(ans, val[f++]);       if (s & 1) ans = max(ans, val[--s]);       f >>= 1;       s >>= 1;     }     return ans;   }   void add(int pos, pair<int, int> p) {     pos += MX;     while (pos > 0) {       val[pos] = max(val[pos], p);       pos >>= 1;     }   }   void dfsadd(int u, int ln, int sm, int par) {     add(ln, {sm, u});     for (pair<int, int> p : v[u]) {       if (p.first != par && !mark[p.first])         dfsadd(p.first, ln + 1, sm + p.second, u);     }   }   void dfsask(int u, int ln, int sm, int par) {     pair<int, int> X = ask(max(0, l - ln), max(0, r - ln + 1));     if (X.first + sm >= 0) ANSA = X.second, ANSB = u;     for (pair<int, int> p : v[u]) {       if (p.first != par && !mark[p.first])         dfsask(p.first, ln + 1, sm + p.second, u);     }   }   void solve(int u) {     dfsS(u);     MX = SZ[u] + 5;     prep();     u = dfsC(u, SZ[u] / 2);     add(0, {0, u});     mark[u] = 1;     for (pair<int, int> p : v[u]) {       if (!mark[p.first])         dfsask(p.first, 1, p.second, u), dfsadd(p.first, 1, p.second, u);     }     for (pair<int, int> p : v[u]) {       if (!mark[p.first]) solve(p.first);     }   }   bool okay(int num) {     memset(mark, 0, sizeof mark);     for (int i = 1; i <= n; i++) {       v[i].clear();     }     for (int i = 0; i < n - 1; i++) {       v[A[i]].push_back({B[i], C[i] >= ed[num] ? 1 : -1});       v[B[i]].push_back({A[i], C[i] >= ed[num] ? 1 : -1});     }     ANSA = ANSB = -1;     solve(1);     return ANSA != -1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> l >> r;     for (int i = 0; i < n - 1; i++) {       cin >> A[i] >> B[i] >> C[i];       ed.push_back(C[i]);     }     sort(ed.begin(), ed.end());     int l = 0, r = n - 2, ansa = -1, ansb = -1;     while (l <= r) {       int mid = (l + r) / 2;       if (okay(mid))         ansa = ANSA, ansb = ANSB, l = mid + 1;       else         r = mid - 1;     }     cout << ansa <<     << ansb << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000007;   int main() {     int a, b;     cin >> a >> b;     long long S = 0;     for (int e = 1; e < b; e++) {       long long s1 = ((long long)a * (a + 1) / 2) % INF;       long long s2 = (s1 * b) % INF;       s2 = (s2 + a) % INF;       S = (S + ((s2 * e) % INF)) % INF;     }     cout << S;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   int main(){       int t;       cin>>t;       while(t--){           int n;           cin>>n;           int a[n];           int mini;           int c=0;           for(int i=0;i<n;i++){               cin>>a[i];           }           // for(int i=0;i<n;i++){           //     if(a[i]<mini){           //         mini=a[i];           //     }          mini=*min_element(a,a+n);                      for(int i=0;i<n;i++){               if(a[i]!=mini ){                   c++;               }           }           cout << c << endl;       }         }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 20222, mod = 998244353;   int n, k, q, A[max_n], a[max_n];   int dp[max_n];   int solve() {     int q1 = 0, q2 = 1;     memset(dp, 0, sizeof(dp));     dp[0] = 1;     for (int i = 0; i < n; ++i) {       for (int j = min(i + 1, k); j >= max(1, k - (n - i - 1)); --j) {         dp[j] = (dp[j] + 1LL * dp[j - 1] * a[i]) % mod;       }     }     return dp[k];   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       scanf( %d , &A[i]);     }     scanf( %d , &q);     while (q--) {       copy(A, A + n, a);       int tp, x;       scanf( %d%d , &tp, &x);       if (tp == 1) {         int pos, d;         scanf( %d%d , &pos, &d);         --pos;         a[pos] = d;       } else {         int l, r, d;         scanf( %d%d%d , &l, &r, &d);         --l;         for (int i = l; i < r; ++i) {           a[i] += d;         }       }       for (int i = 0; i < n; ++i) {         a[i] = ((x - a[i]) % mod + mod) % mod;       }       printf( %d n , solve());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct TP {};   int ar[5][5];   int ans = 0;   int nums[5];   bool used[10];   void cal(int pos) {     if (pos == 5) {       int tmp = 0;       for (int x = 0; x < 5; x++) {         for (int y = x; y < 4; y += 2) {           tmp += ar[nums[y]][nums[y + 1]];           tmp += ar[nums[y + 1]][nums[y]];         }       }       ans = max(ans, tmp);       return;     }     for (int i = 0; i < 5; i++) {       if (!used[i]) {         nums[pos] = i;         used[i] = 1;         cal(pos + 1);         used[i] = 0;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     for (int i = 0; i < 5; i++)       for (int j = 0; j < 5; j++) scanf( %d , &ar[i][j]);     cal(0);     printf( %d , ans);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int x1, y1, x2, y2, res = 0;     scanf( %d%d%d%d , &x1, &y1, &x2, &y2);     int n;     scanf( %d , &n);     for (int i = 0; i < (int)(n); ++i) {       long long a, b, c;       scanf( %lld%lld%lld , &a, &b, &c);       long long t1 = a * x1 + b * y1 + c;       long long t2 = a * x2 + b * y2 + c;       t1 = t1 > 0, t2 = t2 > 0;       res += t1 != t2;     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int rup(int x) {     if ((x % 7) == 0) {       return x / 7;     }     return (x / 7) + 1;   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i += 1) {       int x;       cin >> x;       cout << rup(x) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, d;     cin >> n >> d;     int a[n], sum = 0;     for (int i = 0; i < n; i++) cin >> a[i], sum += a[i];     if (sum + 10 * (n - 1) <= d)       cout << (d - sum) / 5;     else       cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1 << 28;   const long long LINF = 1ll << 61;   inline long long getnum() {     register long long r = 0;     register bool ng = 0;     register char c;     c = getchar();     while (c !=  -  && (c <  0  || c >  9 )) c = getchar();     if (c ==  - ) ng = 1, c = getchar();     while (c !=     && c !=   n ) r = r * 10 + c -  0 , c = getchar();     if (ng) r = -r;     return r;   }   template <class T>   inline void putnum(T x) {     if (x < 0) putchar( - ), x = -x;     register short a[20] = {}, sz = 0;     while (x > 0) a[sz++] = x % 10, x /= 10;     if (sz == 0) putchar( 0 );     for (int i = sz - 1; i >= 0; i--) putchar( 0  + a[i]);   }   inline void putsp() { putchar(   ); }   inline void putendl() { putchar(  n ); }   inline char mygetchar() {     register char c = getchar();     while (c ==     || c ==   n ) c = getchar();     return c;   }   int n, k;   int a[511];   bool dp[511][511];   vector<int> v;   int main() {     n = getnum(), k = getnum();     for (int i = 1; i <= n; i++) a[i] = getnum();     dp[0][0] = 1;     for (int i = 1; i <= n; i++) {       for (int t1 = 500; t1 >= 0; t1--) {         for (int t2 = 500; t2 >= 0; t2--) {           if (t1 + a[i] <= 500) dp[t1 + a[i]][t2] |= dp[t1][t2];           if (t2 + a[i] <= 500) dp[t1][t2 + a[i]] |= dp[t1][t2];         }       }     }     for (int i = 0; i <= k; i++)       if (dp[i][k - i]) v.push_back(i);     putnum(v.size()), putendl();     for (int i = 0; i < v.size(); i++) putnum(v[i]), putsp();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int u = 1, i = 0, q1, q2, a[100001], s[200002], d[100000], f[100001];   void k(int w) {     q2 = w / 2;     while (a[s[q2]] > a[q1]) {       s[w] = s[q2];       w = q2;       q2 /= 2;     }     s[w] = q1;   }   void l() {     if (i) {       i--;       k(d[i]);     } else {       k(u);       u++;     }   }   void m() {     q1 = 1;     q2 = 2;     while ((s[q2]) || (s[q2 + 1]))       if ((s[q2]) && ((!s[q2 + 1]) || (a[s[q2]] < a[s[q2 + 1]]))) {         s[q1] = s[q2];         q1 = q2;         q2 = q1 * 2;       } else {         s[q1] = s[q2 + 1];         q1 = q2 + 1;         q2 = q1 * 2;       }     s[q1] = 0;     d[i] = q1;     i++;   }   int main() {     int q, w, e, r, t, c, v, y;     a[0] = -1;     for (w = 0; w < 200002; w++) s[w] = 0;     cin >> q >> w;     e = t = 0;     r = 1;     while ((e) || (r <= q)) {       while ((e < w) && (r <= q)) {         cin >> c >> a[r];         if (t < c) t = c;         q1 = r;         l();         r++;         e++;       }       y = 0;       while (e) {         c = a[s[1]];         t += c - y;         v = 0;         while (a[s[1]] == c) {           f[s[1]] = t;           m();           e--;           v++;         }         t += 1 + v / 2;         y = c;       }       t += y;     }     for (e = 1; e <= q; e++) cout << f[e] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     long long res = 0;     cin >> n >> m;     int v[n];     for (int i = 0; i < n; i++) {       cin >> v[i];     }     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       res += min(v[x - 1], v[y - 1]);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> a(n), b(n);     pair<int, int> p;     vector<pair<int, int> > v;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     iota(b.begin(), b.end(), 0);     sort(b.begin(), b.end(), [&](int x, int y) {       if (a[x] != a[y]) {         return a[x] < a[y];       }       return x < y;     });     for (int i = n - 1; i >= 0; i--) {       int it = 0;       for (auto j = b.begin(); j != b.end(); j++) {         if (*j == i) {           b.erase(j);           break;         }         it++;       }       for (int j = it; j < b.size(); j++) {         p.first = b[j];         p.second = i;         v.emplace_back(p);       }     }     cout << v.size() <<   n ;     for (auto i : v) {       cout << i.first + 1 <<     << i.second + 1 <<   n ;     }   }   int main() {     solve();     return 0;   }
#include  bits/stdc++.h    using namespace std;      #define ll long long   #define Rip_classic_loki_for_glorious_purpose ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)      #pragma GCC target ( avx2 )   #pragma GCC optimization ( O3 )   #pragma GCC optimization ( unroll-loops )      // need for speed      int main()   {       Rip_classic_loki_for_glorious_purpose;         int t;       cin >> t;          while(t--){           int n,k,check;        cin >> n >> k;        int w = 0;     for(int i = 0;i < n;i++){      cout << (i ^ w) << endl;      cin >> check;      if(check == 1){       break;      }      w = i;     }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool compare(vector<long long> &A, vector<long long> &B) {     if (A[0] - A[1] > B[0] - B[1]) return true;     return false;   }   int main() {     long long(n), (a), (b);     scanf( %lld%lld%lld , &(n), &(a), &(b));     ;     vector<vector<long long>> A, B;     long long sum = 0;     for (long long i = 0; i < (n); i++) {       long long(a), (b);       scanf( %lld%lld , &(a), &(b));       ;       if (a > b)         B.push_back(vector<long long>{a, b});       else         A.push_back(vector<long long>{a, b});       sum += b;     }     if (b == 0) {       printf( %lld n , sum);       return 0;     }     long long val = 1;     while (a--) val *= 2;     sort((B).begin(), (B).end(), compare);     while (B.size() > b) {       A.push_back(B[B.size() - 1]);       B.pop_back();     }     long long store = 0;     for (long long i = 0; i < (B.size()); i++) {       sum += B[i][0] - B[i][1];       if (B.size() == b && i == b - 1) store = B[i][1] - B[i][0];     }     long long ans = sum;     for (long long i = 0; i < (B.size()); i++) {       long long temp = sum;       temp -= B[i][0];       temp += B[i][0] * val;       ans = max(ans, temp);     }     for (long long i = 0; i < (A.size()); i++) {       long long temp = sum + store;       temp -= A[i][1];       temp += A[i][0] * val;       ans = max(ans, temp);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using std::list;   const int N = 128;   struct car {     int coord, length, req;   };   list<car> cars;   int InsertCar(int length, int req, int b, int f) {     list<car>::iterator i = cars.begin(), j = ++cars.begin();     int from, to;     while (j != cars.end()) {       from = i->coord + i->length + b;       to = j->coord - f;       if (to - from >= length) {         cars.insert(j, (car){from, length, req});         return from;       }       ++i, ++j;     }     return -1;   }   void DeleteCar(int req) {     list<car>::iterator i = cars.begin();     while (i != cars.end()) {       if (i->req == req) {         cars.erase(i);         break;       }       ++i;     }   }   int main() {     int l, b, f, n;     scanf( %d%d%d%d , &l, &b, &f, &n);     cars.push_back((car){-b, 0, -1});     cars.push_back((car){l + f, 0, -1});     int type, req;     for (int i = 0; i < n; ++i) {       scanf( %d%d , &type, &req);       if (type == 1)         printf( %d n , InsertCar(req, i, b, f));       else         DeleteCar(req - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 5;   const int INF = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   int n, k;   int a[MAXN];   stack<pair<int, int> > s;   int l[MAXN], r[MAXN];   long long cal(int l, int r) {     if (l > r || r - l + 1 - k < 0) return 0;     int m = (r - l + 1 - (k - 1)) / (k - 1);     long long res = 1LL * (m + 1) * (r - l - k + 2) % mod -                     1LL * (1 + m) * m / 2 % mod * (k - 1) % mod;     return res;   }   int main(int argc, char* argv[]) {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) {       if (i == 1)         s.push(make_pair(a[i], l[i] = 1));       else {         l[i] = i;         while (!s.empty() && s.top().first < a[i]) {           l[i] = s.top().second;           s.pop();         }         s.push(make_pair(a[i], l[i]));       }     }     while (!s.empty()) s.pop();     for (int i = n; i >= 1; i--) {       if (i == n)         s.push(make_pair(a[i], r[i] = n));       else {         r[i] = i;         while (!s.empty() && s.top().first <= a[i]) {           r[i] = s.top().second;           s.pop();         }         s.push(make_pair(a[i], r[i]));       }     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       long long res = cal(l[i], r[i]) - cal(l[i], i - 1) - cal(i + 1, r[i]);       res = res % mod * a[i] % mod;       ans = (ans + res) % mod;     }     if (ans < 0) ans += mod;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200000 + 10;   int n;   long long x[N], y[N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld%lld , &x[i], &y[i]);     }     while (1) {       vector<int> r;       for (int i = 1; i <= n; i++) {         if ((x[i] + y[i]) % 2 == 0) r.push_back(i);       }       if (r.size() == 0 || r.size() == n) {         for (int i = 1; i <= n; i++) {           long long tx = x[i];           long long ty = y[i];           x[i] = tx - ty;           y[i] = tx + ty;         }         if (x[1] % 2 != 0) {           for (int i = 1; i <= n; i++) {             x[i]++, y[i]++;             x[i] /= 2, y[i] /= 2;           }         }         while (1) {           bool ok = 1;           for (int i = 1; i <= n; i++) {             if (x[i] % 2 || y[i] % 2) ok = 0;           }           if (ok) {             for (int i = 1; i <= n; i++) {               x[i] /= 2, y[i] /= 2;             }           } else {             break;           }         }         continue;       }       printf( %d n , r.size());       for (auto x : r) {         printf( %d  , x);       }       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   long long inf = 2147483647;   const long long ll = 9223372036854775807, ninf = 1000000000;   const double eps = 1e-6;   const long long nll = 1000000000000000000;   class CircleOrder {    public:     string firstOrder(string s) {}   };   long long C[1005][1005] = {};   long long dp[1005] = {};   const int MOD = 998244353;   int main() {     for (int i = 0; i < 1005; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; j++) {         C[i][j] = C[i - 1][j] + C[i - 1][j - 1];         C[i][j] %= MOD;       }     }     int a;     while (cin >> a) {       int A[1005] = {};       for (int i = 0; i < a; i++) cin >> A[i];       dp[a] = 1;       for (int i = a - 1; i >= 0; i--) {         if (A[i] <= 0) continue;         for (int j = i + A[i] + 1; j <= a; j++) {           dp[i] += (dp[j]) * (C[j - i - 1][A[i]]);           dp[i] %= MOD;         }       }       long long ans = 0;       for (int i = 0; i < a; i++) {         ans += dp[i];         ans %= MOD;       }       cout << ans <<   n ;     }     return 0;   }