malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   const int mod = 1e9 + 7;   int sub[N][N][N];   int pref[N][N];   int suff[N][N];   int ans[N];   int pw[N];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, X;     cin >> n >> X;     string s;     cin >> s;     s =  &  + s;     for (int i = 1; i <= n; i++) {       if (s[i] ==  0 )         sub[0][i][i] = 1;       else         sub[1][i][i] = 1;     }     if (s[1] ==  0 )       pref[0][1] = 1;     else       pref[1][1] = 1;     if (s[n] ==  0 )       suff[0][n] = 1;     else       suff[1][n] = 1;     pw[0] = pw[1] = 2;     if (s ==  &0 ) ans[0] = 1;     if (s ==  &1 ) ans[1] = 1;     for (int i = 2; i <= X; i++) {       pw[i] = 1ll * pw[i - 1] * pw[i - 2] % mod;       for (int l = 1; l <= n; l++) {         for (int r = l; r <= n; r++) {           sub[i][l][r] = (sub[i - 1][l][r] + sub[i - 2][l][r]) % mod;           for (int m = l; m < r; m++) {             sub[i][l][r] += 1ll * sub[i - 1][l][m] * sub[i - 2][m + 1][r] % mod;             sub[i][l][r] %= mod;           }         }       }       for (int l = 1; l <= n; l++) {         pref[i][l] = pref[i - 1][l];         pref[i][l] += 1ll * pref[i - 2][l] * pw[i - 1] % mod;         pref[i][l] %= mod;         for (int x = 1; x < l; x++) {           pref[i][l] += 1ll * pref[i - 1][x] * sub[i - 2][x + 1][l] % mod;           pref[i][l] %= mod;         }       }       for (int r = 1; r <= n; r++) {         suff[i][r] = suff[i - 2][r];         suff[i][r] += 1ll * suff[i - 1][r] * pw[i - 2] % mod;         suff[i][r] %= mod;         for (int x = r; x < n; x++) {           suff[i][r] += 1ll * suff[i - 2][x + 1] * sub[i - 1][r][x] % mod;           suff[i][r] %= mod;         }       }       for (int m = 1; m < n; m++) {         ans[i] += 1ll * pref[i - 1][m] * suff[i - 2][m + 1] % mod;         ans[i] %= mod;       }       ans[i] += 1ll * ans[i - 1] * pw[i - 2] % mod;       ans[i] %= mod;       ans[i] += 1ll * ans[i - 2] * pw[i - 1] % mod;       ans[i] %= mod;     }     cout << ans[X] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int memo[2700][2700];   string S;   int N;   int doit(int lo, int hi) {     if (lo == hi) {       return 1;     }     if (lo > hi) {       return 0;     }     int &ret = memo[lo][hi];     if (ret != -1) return ret;     ret = 0;     if (S[lo] == S[hi]) {       ret = max(ret, doit(lo + 1, hi - 1) + 2);     }     ret = max(ret, doit(lo + 1, hi));     ret = max(ret, doit(lo, hi - 1));     return ret;   }   string prefixStr, suffixStr, middleStr;   void doitG(int lo, int hi) {     if (lo == hi) {       middleStr += S[lo];       return;     }     if (lo > hi) return;     if (S[lo] == S[hi]) {       prefixStr += S[lo];       suffixStr += S[lo];       doitG(lo + 1, hi - 1);     } else {       if (doit(lo + 1, hi) > doit(lo, hi - 1)) {         doitG(lo + 1, hi);       } else {         doitG(lo, hi - 1);       }     }   }   int main() {     cin >> S;     N = S.size();     if (N > 2600) {       for (char c =  a ; c <=  z ; c++) {         int cnt = 0;         for (int i = 0; i < S.size(); i++) {           if (S[i] == c) {             cnt++;           }         }         if (cnt >= 100) {           for (int i = 0; i < 100; i++) cout << c;           cout << endl;           return 0;         }       }       assert(0);     } else {       memset(memo, -1, sizeof(memo));       int ret = doit(0, N - 1);       prefixStr = suffixStr = middleStr =   ;       doitG(0, N - 1);       reverse(suffixStr.begin(), suffixStr.end());       string res =   ;       for (int i = 0; i < prefixStr.size(); i++) res += prefixStr[i];       for (int i = 0; i < middleStr.size(); i++) res += middleStr[i];       for (int i = 0; i < suffixStr.size(); i++) res += suffixStr[i];       if (res.size() < 100) {         int n = res.size();         cout << res << endl;       } else {         if (res.size() == 100) {           cout << res << endl;         } else {           int n = res.size();           for (int i = 0; i < 50; i++) cout << res[i];           for (int j = n - 50; j < n; j++) cout << res[j];           cout << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<pair<int, int> > sort_positions;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       sort_positions.push_back(make_pair(a[i], i));     }     sort(a, a + n);     sort(sort_positions.begin(), sort_positions.end());     set<vector<int> > subsets;     for (int i = 0; i < n; i++) {       bool isempty = true;       vector<int> next_subset;       for (int j = 0; j < i; j++)         if (a[j] > i) {           next_subset.push_back(1);           isempty = false;         } else           next_subset.push_back(0);       int next_num = min(a[i], i + 1);       set<vector<int> > next_subsets;       if (isempty) {         next_subset.push_back(1);         next_subsets.insert(next_subset);         next_num--;         for (set<vector<int> >::iterator it = subsets.begin();              it != subsets.end(); it++) {           vector<int> subset(*it);           if (next_num > 0)             subset.push_back(1);           else             subset.push_back(0);           next_subsets.insert(subset);           next_num--;         }       } else {         for (set<vector<int> >::iterator it = subsets.begin();              it != subsets.end(); it++) {           vector<int> subset(*it);           if (next_num > 0)             subset.push_back(1);           else             subset.push_back(0);           next_subsets.insert(subset);           next_num--;         }         next_subset.push_back(0);         next_subsets.insert(next_subset);         if (next_num == 1) {           vector<int> subset(i, 0);           subset.push_back(1);           next_subsets.insert(subset);         }       }       subsets = next_subsets;     }     vector<int> ox[n];     for (int i = 0; i < sort_positions.size(); i++) {       int idx = sort_positions[i].second;       ox[idx].resize(0);       for (set<vector<int> >::iterator it = subsets.begin(); it != subsets.end();            it++)         ox[idx].push_back((*it)[i]);     }     cout << subsets.size() << endl;     for (int i = 0; i < subsets.size(); i++) {       for (int j = 0; j < n; j++) cout << ox[j][i];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, 1, 0, -1};   const int dy[] = {1, 0, -1, 0};   int n, m;   char a[1010][1010];   int d1[1010][1010], d2[1010][1010], d3[1010][1010];   vector<pair<int, int> > s1, s2, s3;   int ans = 0x3f3f3f3f;   int ax, ay;   void bfs(int d[1010][1010], char id) {     queue<pair<int, int> > qq;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (a[i][j] == id) d[i][j] = 0, qq.push(make_pair(i, j));     while (!qq.empty()) {       pair<int, int> from = qq.front();       int x = from.first, y = from.second;       qq.pop();       for (int i = 0; i < 4; i++) {         int tx = x + dx[i], ty = y + dy[i];         int dis = d[x][y] + (a[tx][ty] ==  . );         if ((d[tx][ty] != 0x3f3f3f3f && d[tx][ty] <= dis) || a[tx][ty] ==  # )           continue;         d[tx][ty] = dis;         qq.push(make_pair(tx, ty));       }     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> a[i][j];     for (int i = 0; i <= n + 1; i++) a[i][0] = a[i][m + 1] =  # ;     for (int j = 1; j <= m; j++) a[0][j] = a[n + 1][j] =  # ;     memset(d1, 0x3f, sizeof(d1));     memset(d2, 0x3f, sizeof(d2));     memset(d3, 0x3f, sizeof(d3));     bfs(d1,  1 );     bfs(d2,  2 );     bfs(d3,  3 );     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (d1[i][j] != 0x3f3f3f3f && d2[i][j] != 0x3f3f3f3f &&             d3[i][j] != 0x3f3f3f3f) {           int calc;           if (a[i][j] ==  . ) {             calc = d1[i][j] + d2[i][j] + d3[i][j] - 2;             if (ans > calc) ans = calc, ax = i, ay = j;           } else if (isdigit(a[i][j])) {             calc = d1[i][j] + d2[i][j] + d3[i][j];             if (ans > calc) ans = calc, ax = i, ay = j;           }         }     cout << (ans == 0x3f3f3f3f ? -1 : ans) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int N = 1000010;   int n, cnt[N], ans, val[N];   long long a[N];   template <typename T>   void gi(T &x) {     x = 0;     register char c = getchar(), pre = 0;     for (; c <  0  || c >  9 ; pre = c, c = getchar())       ;     for (; c >=  0  && c <=  9 ; c = getchar()) x = x * 10ll + (c ^ 48);     if (pre ==  - ) x = -x;   }   int main() {     gi(n);     for (int i = (1); i <= (n); i++) {       gi(a[i]);       long long t = a[i];       int w = 0;       for (; t % 2 == 0; t /= 2, ++w)         ;       ++cnt[w], val[i] = w;     }     for (int i = (1); i <= (70); i++)       if (cnt[i] > cnt[ans]) ans = i;     printf( %d n , n - cnt[ans]);     for (int i = (1); i <= (n); i++)       if (val[i] != ans) printf( %lld  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 7, mod = 1e9 + 7, inf = 1e9 + 7;   const long long linf = (long long)1e18 + 7;   const long double eps = 1e-15, pi = 3.141592;   const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1},             dy[] = {0, 1, 0, -1, 1, -1, 1, -1};   int n, sz;   long long ans;   long long a[N], suff[N];   int t[N * 20][2];   inline void add(long long x) {     int v = 0;     for (int i = 40; i >= 0; --i) {       int type = ((x & (1LL << i)) > 0);       if (!t[v][type]) t[v][type] = ++sz;       v = t[v][type];     }   }   inline long long get(long long x) {     int v = 0;     long long res = 0;     for (int i = 40; i >= 0; --i) {       int type = 1 - ((x & (1LL << i)) > 0);       if (t[v][type])         res += 1LL << i, v = t[v][type];       else         v = t[v][1 - type];     }     return res;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %I64d , &a[i]);     for (int i = n; i >= 1; --i) suff[i] = suff[i + 1] ^ a[i];     long long pref = 0;     add(0);     for (int i = 1; i <= n + 1; ++i) {       ans = max(ans, get(suff[i]));       add(pref ^= a[i]);     }     cout << ans;     exit(0);   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, sum, t;   int main() {     scanf( %I64d%I64d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %I64d , &t);       sum += t;       if (t && sum >= m) {         printf( %I64d  , sum / m);         sum %= m;       } else         printf( 0  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int s[maxn];   priority_queue<int, vector<int>, greater<int> > que;   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &s[i]);       que.push(s[i]);     }     sort(s, s + n);     int ans = 0;     for (int i = 0; i < n; i++) {       while (!que.empty() && que.top() <= s[i]) {         que.pop();       }       if (que.empty()) break;       if (que.top() > s[i]) {         ans++;         que.pop();       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, bool> childL, childR;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     ;     int n, a;     cin >> n;     cin >> a;     multiset<int> mulset;     mulset.insert(a);     for (int i = 1; i < n; i++) {       cin >> a;       auto ite = mulset.lower_bound(a);       if (childL[*ite] || ite == mulset.end()) {         ite--;         childR[*ite] = 1;       } else         childL[*ite] = 1;       if (i > 1) cout <<    ;       cout << *ite;       mulset.insert(a);     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int p = 1000000007;   int pow3[10];   int main() {     pow3[0] = 1;     pow3[1] = 3;     pow3[2] = pow3[1] * 3;     pow3[3] = pow3[2] * 3;     pow3[4] = pow3[3] * 3;     pow3[5] = pow3[4] * 3;     pow3[6] = pow3[5] * 3;     map<char, int> myMap;     char c;     long long n, k = 0, cnt = 0, res = 1;     for (int i = 48; i <= 57; i++) {       c = i;       myMap.insert(make_pair(c, k));       k++;     }     for (int i = 65; i <= 90; i++) {       c = i;       myMap.insert(make_pair(c, k));       k++;     }     for (int i = 97; i <= 122; i++) {       c = i;       myMap.insert(make_pair(c, k));       k++;     }     myMap.insert(make_pair( - , 62));     k++;     myMap.insert(make_pair( _ , 63));     k++;     while (cin >> c) {       n = myMap[c];       cnt = 0;       for (int i = 0; i < 6; i++) {         if (n % 2 == 0) cnt++;         n /= 2;       }       res = ((res % p) * pow3[cnt]) % p;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxm = 1e6 + 5;   int a[maxm];   int n;   struct BIT {     int c[maxm];     int lowbit(int i) { return i & -i; }     void add(int i, int t) {       while (i < maxm) {         c[i] += t, i += lowbit(i);       }     }     int ask(int i) {       int ans = 0;       while (i) {         ans += c[i], i -= lowbit(i);       }       return ans;     }   } T;   signed main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       ans += i - T.ask(a[i]);       T.add(a[i], 1);     }     if (ans % 2 == 0) {       puts( Petr );     } else {       puts( Um_nik );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string str;     cin >> str;     int L = 0;     for (int l = n / 2; l >= 1; l--) {       if (str.substr(0, l) == str.substr(l, l)) {         L = l;         break;       }     }     if (L == 0)       cout << n;     else       cout << n - L + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string s;       cin >> s;       bool flag = false;       for (int i = 1; i <= n; i++) {         if (s[i - 1] ==  0 ) {           if (i <= n / 2) {             cout << i <<     << n <<     << i + 1 <<     << n << endl;             flag = true;             break;           } else {             cout << 1 <<     << i <<     << 1 <<     << i - 1 << endl;             flag = true;             break;           }         }       }       int sz = n / 2;       if (!flag)         cout << 1 <<     << 1 + sz - 1 <<     << n - sz + 1 <<     << n << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int S = 320;   int a[N];   int dp[S + 1][N];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     int q, p, k;     cin >> q;     for (int j = 1; j <= S; j++) {       for (int i = n; i >= 1; i--) {         if (i + a[i] + j > n)           dp[j][i] = 1;         else           dp[j][i] = dp[j][i + a[i] + j] + 1;       }     }     for (int i = 0; i < q; i++) {       cin >> p >> k;       int cnt = 0;       if (k <= S)         cout << dp[k][p] << endl;       else {         while (p <= n) {           cnt++;           p += a[p] + k;         }         cout << cnt << endl;       }     }     return 0;   }
#define DEBUG 0      #include <bits/stdc++.h>   using namespace std;      #if DEBUG   // basic debugging macros   int __i__,__j__;   #define printLine(l) for(__i__=0;__i__<l;__i__++){cout<< - ;}cout<<endl   #define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl   #define printVar(n) cout<<#n<< :  <<n<<endl   #define printArr(a,l) cout<<#a<< :  ;for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<   ;}cout<<endl   #define print2dArr(a,r,c) cout<<#a<< : n ;for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<   ;}cout<<endl;}   #define print2dArr2(a,r,c,l) cout<<#a<< : n ;for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(   )<<a[__i__][__j__]<<   ;}cout<<endl;}      // advanced debugging class   // debug 1,2, A , test ;   class _Debug {       public:           template<typename T>           _Debug& operator,(T val) {               cout << val << endl;               return *this;           }   };   #define debug _Debug(),   #else   #define printLine(l)   #define printLine2(l,c)   #define printVar(n)   #define printArr(a,l)   #define print2dArr(a,r,c)   #define print2dArr2(a,r,c,l)   #define debug   #endif      // define   #define MAX_VAL 999999999   #define MAX_VAL_2 999999999999999999LL   #define EPS 1e-6   #define mp make_pair   #define pb push_back      // typedef   typedef unsigned int UI;   typedef long long int LLI;   typedef unsigned long long int ULLI;   typedef unsigned short int US;   typedef pair<int,int> pii;   typedef pair<LLI,LLI> plli;   typedef vector<int> vi;   typedef vector<LLI> vlli;   typedef vector<pii> vpii;   typedef vector<plli> vplli;      // ---------- END OF TEMPLATE ----------      int p[200001],k[200001],b[200001],w[200001];   int seed = 0,base = 0;   int rnd() {       int ret = seed;       seed = ((LLI) seed*base + 233) % 1000000007;       return ret;   }   int a[5000000],o[5000000],t[5000000];   int main() {       int i,j;       int n,m;       scanf( %d %d ,&n,&m);       for (i = 1; i <= m; i++) {           scanf( %d %d %d %d ,&p[i],&k[i],&b[i],&w[i]);           seed = b[i],base = w[i];           for (j = p[i-1]; j < p[i]; j++) {               t[j] = (rnd() % 2) + 1;               o[j] = a[j] = (rnd() % k[i]) + 1;           }       }          LLI s1 = 0,s2 = 0;       for (i = 0; i < n; i++) {           if (t[i] == 1) s1 += a[i];           else s2 += a[i];       }       if (s1 <= s2) {           for (i = 0; i < n; i++) t[i] ^= 3;       }       if (t[0] == 1) a[0]--;       LLI s = 0;       for (i = 0; i < n; i++) {           if (t[i] == 2) s += a[i],a[i] = 0;           else {               LLI x = min((LLI) a[i],s);               a[i] -= x,s -= x;           }       }       for (i = 0; i < n; i++) {           if (t[i] == 2) s += a[i],a[i] = 0;           else {               LLI x = min((LLI) a[i],s);               a[i] -= x,s -= x;           }       }       LLI ans = 1;       for (i = 0; i < n; i++) {           ans *= (((o[i]-a[i])^((LLI) (i+1)*(i+1)))+1) % 1000000007;           ans %= 1000000007;       }       printf( %I64d n ,ans);          return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   const long long xx = 2e5 + 10;   vector<long long> pos[xx];   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n, m, k;     cin >> n >> m >> k;     vector<long long> v(n);     vector<pair<long long, long long>> pi;     for (long long i = 0; i < n; i++) {       cin >> v[i];       pi.emplace_back(v[i], i);     }     sort(pi.rbegin(), pi.rend());     vector<pair<long long, long long>> vp;     long long sum = 0;     for (long long i = 0; i < m * k; i++) {       sum += pi[i].first;       vp.emplace_back(pi[i].second, pi[i].first);     }     sort(vp.begin(), vp.end());     cout << sum <<   n ;     for (long long i = m - 1; i < vp.size() - m; i += m) {       long long x = vp[i].first;       cout << x + 1 <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100010], mx1 = -100010, mx2 = -100010 - 10, ans = 1, cnt[100010];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) {       if (a[i] > mx1) {         mx2 = mx1;         mx1 = a[i];         cnt[a[i]]--;       } else if (a[i] > mx2) {         mx2 = a[i];         cnt[mx1]++;       }     }     for (int i = 1; i <= n; i++)       if (cnt[i] > cnt[ans]) ans = i;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool visited[10000];   int main() {     ios::sync_with_stdio(false);     ios_base::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);     string input;     int counter;     while (cin >> input) {       counter = 0;       for (int i = 0; i < input.size() - 1; i++)         if (input[i] ==  V  && input[i + 1] ==  K )           counter++, visited[i] = visited[i + 1] = 1, i++;       for (int i = 0; i < input.size() - 1; i++)         if (!visited[i] && !visited[i + 1])           if ((input[i] ==  V  && input[i + 1] ==  V ) ||               ((input[i] ==  K  && input[i + 1] ==  K ))) {             counter++;             break;           }     }     cout << counter << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   template <class T>   inline T SQR(T a) {     return a * a;   }   int C[100001][3];   bool can(int *A, int n, int k) {     int pos = k;     for (int i = (0), ei = (k); i < ei; i++) C[i][0] = A[i];     int cnt = 0;     while (pos < n && cnt < k) {       if (A[pos] < C[cnt][0]) C[cnt++][1] = A[pos];       pos++;     }     if (cnt != k) return false;     cnt = 0;     while (pos < n && cnt < k) {       if (A[pos] < C[cnt][1]) C[cnt++][2] = A[pos];       pos++;     }     return cnt == k;   }   int main() {     int n;     int A[100001];     cin >> n;     for (int i = (0), ei = (n); i < ei; i++) scanf( %d , A + i);     sort(A, A + n, greater<int>());     int l = 0, r = n / 3;     int ans = 0;     while (l <= r) {       int c = (l + r) >> 1;       if (can(A, n, c)) {         l = c + 1;         ans = c;       } else         r = c - 1;     }     can(A, n, ans);     printf( %d n , ans);     for (int i = (0), ei = (ans); i < ei; i++)       printf( %d %d %d n , C[i][0], C[i][1], C[i][2]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX_N = 4e3 + 10;   const long long MAX_M = 65 + 10;   const long long mod = 1e9 + 7;   const int INF = 1e9;   inline long long bpow(long long t, long long n) {     long long ans = 1;     while (n > 0) {       if (n & 1) ans = (ans * t) % mod;       t = (t * t) % mod, n >>= 1;     }     return ans;   }   int dp[MAX_N][MAX_M][MAX_M][2];   int a[MAX_N];   int cdp(int l, int r, int k, int x) {     if ((r - l + 1) < k) return 0;     if (dp[l][r - l][k][x] != -1) return dp[l][r - l][k][x];     int& ans = dp[l][r - l][k][x];     if (x == 0)       ans = max(cdp(l + k, r, k, 1) + a[l + k - 1] - a[l - 1],                 (r - l >= k) ? (a[l + k] - a[l - 1] + cdp(l + k + 1, r, k + 1, 1))                              : (-INF));     else       ans = min(a[r - k] - a[r] + cdp(l, r - k, k, 0),                 (r - l >= k) ? (a[r - k - 1] - a[r] + cdp(l, r - k - 1, k + 1, 0))                              : INF);     return ans;   }   int main() {     memset(dp, -1, sizeof dp);     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cout << fixed << setprecision(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) a[i] += a[i - 1];     cout << cdp(1, n, 1, 0);   }