malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long powr(long long exp) {     if (exp == 1) return 2;     if (exp % 2 == 0) {       long long ret = (powr(exp / 2)) % 1000000007;       ret = (ret * ret) % 1000000007;       return ret;     }     long long ret = powr(exp / 2) % 1000000007;     ret = (ret * ret * 2) % 1000000007;     return ret;   }   int main() {     string s;     cin >> s;     long long mul = 1;     string s1 =   ;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  a  || s[i] ==  b ) s1 += s[i];     }     s1 +=  b ;     long long st = 1;     for (int i = 0; i < s1.size(); i++) {       if (s1[i] ==  b ) {         mul = ((mul) * (st % 1000000007)) % 1000000007;         st = 1;       } else if (s1[i] ==  a ) {         st++;       }     }     mul = (mul - 1);     if (mul < 0) mul += 1000000007;     cout << mul;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 101;   const int BITS = 60;   struct node {     int son[2];     bool all;     bool have;   } f[N * 200 * 4];   int na, nb;   int tot;   vector<pair<int, int> > d[BITS + 1];   void ins(long long l, int bits, int s, long long ll, long long rr) {     if (l + (1ll << bits) - 1 < ll || rr < l) return;     if (f[s].all) return;     if (l >= ll && l + (1ll << bits) - 1 <= rr) {       f[s].all = 1;       f[s].have = 1;       return;     }     f[s].have = 1;     if (!f[s].son[0]) f[s].son[0] = ++tot;     if (!f[s].son[1]) f[s].son[1] = ++tot;     ins(l, bits - 1, f[s].son[0], ll, rr);     ins(l + (1ll << (bits - 1)), bits - 1, f[s].son[1], ll, rr);     f[s].all = (f[f[s].son[0]].all && f[f[s].son[1]].all);   }   const int mod = 998244353;   int add(int x, int y) {     x += y;     return x >= mod ? x - mod : x;   }   int sub(int x, int y) {     x -= y;     return x < 0 ? x + mod : x;   }   int mul(int x, int y) { return 1ll * x * y % mod; }   int calc(int x, int y) {     int z = 1;     while (y) {       if (y & 1) z = mul(z, x);       x = mul(x, x), y >>= 1;     }     return z;   }   int ni2 = calc(2, mod - 2);   int calc(long long x) { return mul(mul((x - 1) % mod, x % mod), ni2); }   int work(int prefix, int bits) {     if (!d[bits].size()) return 0;     for (auto u : d[bits]) {       if (f[u.first].all || f[u.second].all) {         return add(mul(prefix, (1ll << bits) % mod), calc(1ll << bits));       }     }     int v = 0;     for (int x = 0; x < 2; x++) {       d[bits - 1].clear();       for (int i = 0; i < 2; i++)         for (auto u : d[bits])           if (f[f[u.first].son[i]].have && f[f[u.second].son[i ^ x]].have)             d[bits - 1].push_back({f[u.first].son[i], f[u.second].son[i ^ x]});       v = add(work(add(prefix, (((long long)x) << (bits - 1)) % mod), bits - 1),               v);     }     return v;   }   int main() {     tot = 3;     scanf( %d , &na);     while (na--) {       long long l, r;       scanf( %lld %lld , &l, &r);       ins(0, BITS, 1, l, r);     }     scanf( %d , &nb);     while (nb--) {       long long l, r;       scanf( %lld %lld , &l, &r);       ins(0, BITS, 2, l, r);     }     d[BITS].push_back({1, 2});     printf( %d n , work(0, BITS));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isv(char x) {     if (x ==  a  || x ==  e  || x ==  i  || x ==  o  || x ==  u ) return true;     return false;   }   int main() {     ios::sync_with_stdio(0);     long long c, a, b, act;     cin >> c;     cin >> a >> b;     act = max(a, b);     --c;     while (c--) {       cin >> a >> b;       if (a <= act && b <= act)         act = max(a, b);       else if (a <= act)         act = a;       else if (b <= act)         act = b;       else {         cout <<  NO  <<   n ;         return 0;       }     }     cout <<  YES  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXn = 2e5 + 3;   const long long INF = 1e15 + 1;   long long t[4 * MAXn], sum[MAXn], lazy[4 * MAXn];   int id[MAXn];   void Build(int v, int l, int r) {     lazy[v] = 0;     if (l == r) {       t[v] = sum[l];       return;     }     int mid = (r + l) / 2;     Build(v * 2, l, mid);     Build(v * 2 + 1, mid + 1, r);     t[v] = min(t[v * 2], t[v * 2 + 1]);     return;   }   void Down(int v) {     t[v * 2] += lazy[v];     lazy[v * 2] += lazy[v];     t[v * 2 + 1] += lazy[v];     lazy[v * 2 + 1] += lazy[v];     lazy[v] = 0;   }   void Update(int v, int l, int r, int L, int R, long long x) {     if (r < L || R < l) return;     if (L <= l && r <= R) {       lazy[v] += x;       t[v] += x;       return;     }     int mid = (r + l) / 2;     Down(v);     Update(v * 2, l, mid, L, R, x);     Update(v * 2 + 1, mid + 1, r, L, R, x);     t[v] = min(t[v * 2], t[v * 2 + 1]);     return;   }   long long get(int v, int l, int r, int L, int R) {     if (r < L || R < l) return INF;     if (L <= l && R >= r) return t[v];     int mid = (l + r) / 2;     Down(v);     return min(get(v * 2, l, mid, L, R), get(v * 2 + 1, mid + 1, r, L, R));   }   int main() {     int n;     cin >> n;     int val;     for (int i = 1; i <= n; i++) {       cin >> val;       id[val] = i;     }     sum[0] = 0;     long long p;     for (int i = 1; i <= n; i++) {       cin >> p;       sum[i] = sum[i - 1] + p;     }     Build(1, 1, n - 1);     long long ans = get(1, 1, n - 1, 1, n - 1);     for (int val = 1; val <= n; val++) {       if (id[val] > 1)         Update(1, 1, n - 1, 1, id[val] - 1, sum[id[val]] - sum[id[val] - 1]);       if (id[val] < n) {         Update(1, 1, n - 1, id[val], n - 1, -sum[id[val]] + sum[id[val] - 1]);         ans = min(ans, get(1, 1, n - 1, id[val], n - 1));       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, tmp1, tmp2, q;   string s, t;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> q;     for (int rr = 0; rr < q; rr++) {       cin >> n >> s;       tmp1 = 0, t =   ;       while (s[tmp1] ==  0  && tmp1 < n) {         cout << 0;         tmp1++;       }       tmp2 = s.length() - 1;       while (s[tmp2] ==  1  && tmp2 >= 0) {         t +=  1 ;         tmp2--;       }       if (tmp1 < tmp2) {         cout << 0;       }       cout << t <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   using Int = long long;   int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false),               cout << fixed << setprecision(9), 0);   vector<int> state;   void makemove(vector<int>& A) {     if (A.empty()) {       cout << 0 << endl;       exit(0);     } else {       cout << A.size() <<    ;       for (auto a : A) {         state[a] = 1;         cout << a + 1 <<    ;       }       cout << endl;     }     int input;     cin >> input;     if (input == 0 || input == -1) {       exit(0);     }     for (int i = 0; i < A.size(); i++) {       state[(input - 1 + i) % state.size()] = 0;     }   }   int main() {     int N;     cin >> N;     state.resize(N);     int K = 0, R = 0;     for (int i = 1; i <= N; i++) {       int p = N / i;       int r = N % i;       int RR = (p - 1) * (i - r) + p * r - (r == 0 ? p - 1 : p);       if (RR > R) {         K = i;         R = RR;       }     }     vector<int> optimum;     if (R == 0) {       optimum.resize(N);     } else {       int p = N / K;       int r = N % K;       for (int i = 0; i < K - r; i++) {         for (int j = 0; j < p; j++) {           optimum.push_back(!!j);         }       }       for (int i = 0; i < r; i++) {         for (int j = 0; j < p + 1; j++) {           optimum.push_back(!!j);         }       }       assert(optimum.size() == N);     }     vector<int> move;     for (;;) {       move.clear();       int cnt = 0;       for (int i = 0; i < N; i++) {         if (optimum[i] != state[i]) {           move.push_back(i);         }         cnt += state[i];       }       if (cnt >= R) {         move.clear();       }       makemove(move);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       int k;       cin >> k;       bool ok = true;       int pa = 0, pb = 0;       for (int j = 0; j < k; ++j) {         int a, b;         cin >> a >> b;         if (a < pa || b < pb) ok = false;         if (a == pa && b != pb) ok = false;         if (a > pa && (a - pa) < (b - pb)) ok = false;         pa = a;         pb = b;       }       cout << (ok ?  YES  :  NO ) << endl;     }   }
#include <bits/stdc++.h>   const int int_reme = 2147483647;   const int log21e9_reme = 30;   const int maxn = 2e5 + 10;   const long long mod = 1e9 + 7;   const int INF = 0x3f3f3f3f;   using namespace std;   char DATA[maxn], duizhao[maxn];   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       DATA[0] = 2;       DATA[n + 1] = 2;       getchar();       for (int i = 1; i <= n; i++) {         scanf( %c , &DATA[i]);       }       getchar();       for (int i = 1; i <= n; i++) {         scanf( %c , &duizhao[i]);       }       int ans = 0;       for (int i = 1; i <= n; i++) {         if (duizhao[i] ==  1 ) {           if (DATA[i] ==  0 )             ans++;           else {             if (DATA[i - 1] ==  1 ) {               DATA[i - 1] =  2 ;               ans++;             } else if (DATA[i + 1] ==  1 ) {               DATA[i + 1] =  2 ;               ans++;             }           }         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long mod1 = 1000000007;   const unsigned long long mod2 = 1073676287;   const unsigned long long base1 = 1000000033;   const unsigned long long base2 = 1190494759;   vector<unsigned long long> base_pow(1000009);   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     string str;     cin >> str;     int arr[str.size() + 1], temp = 0;     arr[str.size()] = 0;     for (int i = 0; i < str.size(); i++) {       if (str[i] ==  + ) {         temp++;       } else         temp--;       arr[i] = temp;     }     cout << *max_element(arr, arr + str.size() + 1) -                 *min_element(arr, arr + str.size() + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-7;   const double PI = acos(-1.0);   const long long mod = 1e18;   const int MAXN = 100000 + 5;   const int INF = 0x3f3f3f3f;   const int N = 100 + 10;   int main() {     ios::sync_with_stdio(false);     int n, f[26], num = 0, ans = 0;     char opr;     bool flag = false;     string s;     cin >> n;     memset(f, 0, sizeof f);     for (int i = 0; i < n; i++) {       cin >> opr >> s;       if (opr ==  ! ) {         if (flag) {           ans++;         }         int tmp[26];         memset(tmp, 0, sizeof tmp);         for (int k = 0; k < s.length(); k++) {           tmp[s[k] -  a ] = 1;         }         for (int k = 0; k < 26; k++) {           if (tmp[k] == 0) f[k] = -1;         }       } else if (opr ==  . ) {         for (int k = 0; k < s.length(); k++) {           f[s[k] -  a ] = -1;         }       } else {         if (flag && f[s[0] -  a ] == -1) ans++;         f[s[0] -  a ] = -1;       }       num = 0;       for (int k = 0; k < 26; k++) {         if (f[k] != -1) num++;       }       if (num == 1) flag = true;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int fh = 1, x = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) fh = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       x = (x << 3) + (x << 1) + ch -  0 ;       ch = getchar();     }     return fh * x;   }   inline void write(const int x) {     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   inline int _abs(const int x) { return x >= 0 ? x : -x; }   inline int _max(const int x, const int y) { return x >= y ? x : y; }   inline int _min(const int x, const int y) { return x <= y ? x : y; }   inline int _gcd(const int x, const int y) { return y ? _gcd(y, x % y) : x; }   inline int _lcm(const int x, const int y) { return x * y / _gcd(x, y); }   char a[100005], b[100005], ans[100005];   int lena, lenb;   signed main() {     scanf( %s %s , a, b);     ans[0] = a[0];     int i;     for (i = 1; i < strlen(a); i++)       if (a[i] < b[0])         ans[i] = a[i];       else         break;     ans[i] = b[0];     printf( %s n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int word[4];     for (int i = 0; i < 4; i++) {       cin >> word[i];     }     int number = 0;     sort(word, word + 4);     for (int i = 0; i < 3; i++) {       for (int j = i + 1; j < 4; j++) {         if (word[i] == word[j]) {           number++;           i = j - 1;         } else {           i = j - 1;           break;         }       }     }     cout << number;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[101], res;   int b[101];   int main() {     int n, i, k, t;     cin >> n >> k;     for (i = 0; i < n; i++) {       cin >> t;       a[t]++;     }     while (1) {       for (i = 1; i <= k; i++) b[i] = 0;       t = 0;       for (i = 1; i < k; i++)         if (a[i] > 0) {           a[i]--;           b[i + 1]++;           t = 1;         }       res++;       for (i = 1; i <= k; i++) a[i] += b[i];       if (!t) break;     }     cout << res - 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     while (~scanf( %d , &t)) {       while (t--) {         int n;         scanf( %d , &n);         char a[n + 1];         scanf(  %s , a);         int ans = 0;         for (int i = 0; i < n; i++) {           if (a[i] ==  >  || a[n - i - 1] ==  < ) {             break;           } else {             ans++;           }         }         printf( %d n , ans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int64_t INF = (1 << 30) - 1;   const long long oo = (1ll << 62) - 1;   const long double PI = 3.1415926535898;   const int64_t N = 100000 + 5;   int64_t n;   vector<int64_t> a[N];   int64_t d[5][N];   int64_t mau[N];   int64_t c[5][5];   int64_t dfs(int64_t u, int64_t p, int64_t col, int64_t vt) {     col %= 3;     col += 1;     int64_t ans = d[c[vt][col]][u];     for (int64_t v : a[u]) {       if (v == p) continue;       ans += dfs(v, u, col, vt);     }     return ans;   }   void dfs2(int64_t u, int64_t p, int64_t col, int64_t vt) {     col %= 3;     col += 1;     mau[u] = c[vt][col];     for (int64_t v : a[u]) {       if (v == p) continue;       dfs2(v, u, col, vt);     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int64_t i = 1; i <= n; i++) cin >> d[1][i];     for (int64_t i = 1; i <= n; i++) cin >> d[2][i];     for (int64_t i = 1; i <= n; i++) cin >> d[3][i];     for (int64_t i = 1; i < n; i++) {       int64_t u, v;       cin >> u >> v;       a[u].push_back(v);       a[v].push_back(u);     }     for (int64_t i = 1; i <= n; i++) {       if (a[i].size() >= 3) {         cout << -1;         return 0;       }     }     c[1][1] = 1;     c[1][2] = 2;     c[1][3] = 3;     c[2][1] = 1;     c[2][2] = 3;     c[2][3] = 2;     int64_t s = 1;     while (a[s].size() == 2) s++;     int64_t res = oo, col, vt;     for (int64_t i = 1; i <= 2; i++) {       for (int64_t j = 1; j <= 3; j++) {         int64_t ans = dfs(s, s, j - 1, i);         if (ans < res) {           res = ans;           col = j;           vt = i;         }       }     }     dfs2(s, s, col - 1, vt);     cout << res <<   n ;     for (int64_t i = 1; i <= n; i++) cout << mau[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long b, long long m) {     a %= m;     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a % m;       a = a * a % m;       b >>= 1;     }     return res;   }   int binomial(int n, int k) {     if (k == 0 || k == n) return 1;     return binomial(n - 1, k - 1) + binomial(n - 1, k);   }   bool prime[10000];   void Sieve(long long int n) {     memset(prime, true, sizeof(prime));     for (int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (int i = p * p; i <= n; i += p) prime[i] = false;       }     }   }   vector<int> f;   int print(int n) {     for (int i = 2; i <= sqrt(n); i++) {       if (n % i == 0) {         if (n / i == i)           f.push_back(i);         else {           f.push_back(i);           f.push_back(n / i);         }       }     }     return f.size();   }   pair<int, int> fib(int n) {     if (n == 0) return {0, 1};     auto p = fib(n >> 1);     int c = p.first * (2 * p.second - p.first);     int d = p.first * p.first + p.second * p.second;     if (n & 1)       return {d, c + d};     else       return {c, d};   }   int main() {     int n;     cin >> n;     int k = 0;     vector<int> v;     Sieve(n);     for (int i = 2; i <= n; i++) {       if (prime[i]) {         int q = 1;         while (q <= (n / i)) {           q *= i;           v.push_back(q);         }       }     }     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n;   pair<int, int> a[2][100010];   bool used[100010];   int fat[100010];   int main() {     int i, j, c, v;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d %d , &c, &v);       a[c][++a[c][0].first] = make_pair(v, i);     }     sort(a[0] + 1, a[0] + a[0][0].first + 1);     sort(a[1] + 1, a[1] + a[1][0].first + 1);     i = j = 1;     for (int t = 1; t < n; t++) {       int tmp = min(a[0][i].first, a[1][j].first);       printf( %d %d %d n , a[0][i].second, a[1][j].second, tmp);       a[0][i].first -= tmp, a[1][j].first -= tmp;       if (a[0][i].first)         j++;       else if (a[1][j].first)         i++;       else if (i < a[0][0].first)         i++;       else         j++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   long long modexp(long long a, long long n) {     if (a == 0) return 0;     if (n == 0) return 1;     long long p = modexp(a, n / 2);     p = p * p % MOD;     if (n & 1) p = p * a % MOD;     return p;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, m, l, r;     cin >> n >> m >> l >> r;     long long k = r + 1 - l;     long long e = n * m % (MOD - 1);     long long ans = modexp((k % MOD + MOD) % MOD, e);     if (n % 2 == 0 || m % 2 == 0) {       long long k0 = 0, k1 = 0;       if (l % 2 == 0 && r % 2 == 0) ++k0;       if (l % 2 == 1 && r % 2 == 1) ++k1;       ans = (ans + modexp((k0 + MOD - k1) % MOD, e)) % MOD;       ans = (ans * modexp(2, MOD - 2)) % MOD;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cout << *i <<    ;     cout << endl;   }   template <class T>   void chmin(T &t, T f) {     if (t > f) t = f;   }   template <class T>   void chmax(T &t, T f) {     if (t < f) t = f;   }   int in() {     int x;     scanf( %d , &x);     return x;   }   const int R = 3;   const int S = R * R / 2;   int uf[4000010];   int root(int x) { return (uf[x] < 0) ? x : (uf[x] = root(uf[x])); }   bool conn(int x, int y) {     x = root(x);     y = root(y);     if (x == y) return 0;     if (uf[x] > uf[y]) swap(x, y);     uf[x] += uf[y];     uf[y] = x;     return 1;   }   int N;   inline int _(int x, int y) { return x * N + y; }   int A[2010][2010];   int B[2010][2010];   int C[2010][2010];   vector<pair<int, int> > ps[4000010];   int main() {     int x, y;     int r;     for (; ~scanf( %d , &N);) {       for (x = 0; x < N; ++x)         for (y = 0; y < N; ++y) {           A[x][y] = in();         }       for (x = 0; x < N; ++x)         for (y = 0; y < N; ++y) {           B[x + 1][y + 1] = B[x + 1][y] + B[x][y + 1] - B[x][y] + A[x][y];         }       for (x = 0; x + R <= N; ++x)         for (y = 0; y + R <= N; ++y) {           C[x][y] = B[x + R][y + R] - B[x + R][y] - B[x][y + R] + B[x][y];         }       memset(uf, ~0, sizeof(uf));       for (x = 0; x + R <= N; ++x)         for (y = 0; y + R <= N; ++y)           if (C[x][y] > S) {             if (x)               if (C[x - 1][y] > S) conn(_(x - 1, y), _(x, y));             if (y)               if (C[x][y - 1] > S) conn(_(x, y - 1), _(x, y));           }       for (r = 0; r < N * N; ++r) {         ps[r].clear();       }       for (x = 0; x + R <= N; ++x)         for (y = 0; y + R <= N; ++y)           if (C[x][y] > S) {             r = root(_(x, y));             ps[r].push_back(make_pair(x, y));           }       int ansC = 0, ansS = 0;       for (r = 0; r < N * N; ++r)         if (!ps[r].empty()) {           int sz = ps[r].size(), i, j;           if (sz < 30) continue;           double ox = 0, oy = 0;           for (i = 0; i < sz; ++i) {             x = ps[r][i].first;             y = ps[r][i].second;             ox += x;             oy += y;           }           ox /= sz;           oy /= sz;           double rads[10] = {};           for (i = 0; i < sz; ++i) {             x = ps[r][i].first;             y = ps[r][i].second;             double tmp = (x - ox) * (x - ox) + (y - oy) * (y - oy);             for (j = 0; j < 10; ++j) {               if (rads[j] < tmp) {                 swap(rads[j], tmp);               }             }           }           double rad = rads[0];           double ratio = sz / rad;           (ratio > 2.7) ? ++ansC : ++ansS;         }       printf( %d %d n , ansC, ansS);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 30005;   const int Maxk = 205;   const int Inf = 1000000000;   int n, k;   int a[Maxn];   int dp[Maxn][Maxk][2];   int res = -Inf;   int Add(int val, int sgn) { return sgn == 0 ? -val : val; }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i <= n; i++)       for (int j = 0; j <= k; j++) dp[i][j][0] = dp[i][j][1] = -Inf;     for (int i = n - 1; i >= 0; i--) {       for (int l = 0; l < 2; l++) {         int sum = 0;         for (int z = i; z < n; z++) {           sum += Add(a[z], l);           dp[i][1][l] = max(dp[i][1][l], sum);         }       }       for (int j = k; j >= 0; j--)         for (int l = 0; l < 2; l++) {           dp[i][j][l] = max(dp[i][j][l], dp[i + 1][j][l]);           if (j > 0) {             dp[i][j][l] = max(dp[i][j][l], dp[i + 1][j - 1][l]);             int sum = 0;             for (int z = i; z < n; z++) {               sum += Add(a[z], l);               dp[i][j][l] = max(dp[i][j][l], dp[z + 1][j - 1][1 - l] + 2 * sum);             }           }         }     }     for (int i = 0; i < n; i++)       for (int l = 0; l < 2; l++) {         int sum = 0;         for (int z = i; z < n; z++) {           sum += Add(a[z], l);           res = max(res, sum + dp[z + 1][k - 1][1 - l]);         }       }     printf( %d n , res);     return 0;   }