malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> eg[400005];   long long dep[400005];   int dfn[400005], sz[400005];   int a[400005];   int p[400005], w[400005];   int dfcnt = 0;   int fa[400005][20];   void dfs(int a) {     sz[a] = 1, dfn[a] = ++dfcnt;     for (auto v : eg[a]) {       if (v == p[a]) continue;       fa[v][0] = a;       for (int i = 1; i < 20; i++) fa[v][i] = fa[fa[v][i - 1]][i - 1];       dep[v] = dep[a] + w[v];       dfs(v);       sz[a] += sz[v];     }   }   long long ud[400005];   vector<int> qs[400005];   int d[400005];   int lb(int x) { return x & -x; }   void upd(int pl, int x) {     while (pl < 400005) d[pl] += x, pl += lb(pl);   }   int q(int pl) {     int ans = 0;     while (pl) ans += d[pl], pl -= lb(pl);     return ans;   }   int ans[400005];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 2; i <= n; i++) {       scanf( %d%d , &p[i], &w[i]);       eg[p[i]].push_back(i);     }     dfs(1);     dep[0] = -1e18;     for (int i = 1; i <= n; i++) {       int v = i;       for (int j = 19; j >= 0; j--) {         int t = fa[v][j];         if (dep[t] >= dep[i] - a[i]) v = t;       }       if (p[v]) upd(dfn[p[v]], -1);       upd(dfn[i], 1);     }     for (int i = 1; i <= n; i++) ans[i] = q(dfn[i] + sz[i] - 1) - q(dfn[i] - 1);     for (int i = 1; i <= n; i++) printf( %d  , ans[i] - 1);     return 0;   }
#include <bits/stdc++.h>   int n, k, a, b;   int ask(int x, int y) {     if (x == n) return 1;     fflush(stdout);     printf( 1 %d %d n , x, y);     fflush(stdout);     char s[5];     scanf( %s , s);     fflush(stdout);     return s[0] ==  T ;   }   int xxx(int l, int r) {     int mid, res = 0;     while (l <= r) {       mid = (l + r) >> 1;       if (ask(mid, mid + 1))         res = mid, r = mid - 1;       else         l = mid + 1;     }     return res;   }   int main() {     scanf( %d%d , &n, &k);     fflush(stdout);     a = xxx(1, n);     b = xxx(1, a - 1);     if (!b) b = xxx(a + 1, n);     fflush(stdout);     printf( 2 %d %d , a, b);     fflush(stdout);   }
#include <bits/stdc++.h>   int main() {     int n;     int x, y;     int k;     int l;     scanf( %d , &n);     for (x = 4; 2 * x < n; x++) {       y = n - x;       k = 0;       l = 0;       for (int i = 2; i < x; i++) {         if (x % i == 0) k = 1;       }       for (int j = 2; j < y; j++) {         if (y % j == 0) l = 1;       }       if (k && l) {         printf( %d %d , x, y);         break;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   using ii = pair<int, int>;   using ll = long long;   const int N = 2005;   const int mod = 1e9 + 7;   ll a[2005], b[2005];   ll lena[2005], lenb[2005];   int n, m;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) cin >> b[i];     ll x;     cin >> x;     fill(lena, lena + n + 1, 1e9);     fill(lenb, lenb + m + 1, 1e9);     for (int i = 0; i < n; i++) {       ll cur = 0;       for (int j = i; j < n; j++) {         cur += a[j];         lena[j - i + 1] = min(lena[j - i + 1], cur);       }     }     for (int i = 0; i < m; i++) {       ll cur = 0;       for (int j = i; j < m; j++) {         cur += b[j];         lenb[j - i + 1] = min(lenb[j - i + 1], cur);       }     }     int out = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (lena[i] * lenb[j] <= x) out = max(out, i * j);     cout << out <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   const int nax = 1e6 + 10;   long long fac[nax], ifac[nax], inv[nax];   long long ncr(int n, int k) {     if (n < 0 || k < 0 || k > n) return 0;     return fac[n] * ifac[k] % mod * ifac[n - k] % mod;   }   int main() {     fac[0] = ifac[0] = 1;     for (int i = 1; i < nax; i++) {       inv[i] = i == 1 ? 1 : mod - mod / i * inv[mod % i] % mod;       fac[i] = fac[i - 1] * i % mod;       ifac[i] = ifac[i - 1] * inv[i] % mod;       assert(fac[i] * ifac[i] % mod == 1);     }     ios::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     int n = s.size();     int lp = 0, rp = count(s.begin(), s.end(),  ) );     int lq = 0, rq = count(s.begin(), s.end(),  ? );     long long ans = 0;     for (int i = 0; i < n; i++) {       (ans += ncr(lq + rq, rq - lp + rp) * lp +               ncr(lq + rq - 1, rq - 1 - lp + rp) * lq) %= mod;       if (s[i] ==  ( )         lp++;       else if (s[i] ==  ) )         rp--;       else if (s[i] ==  ? )         lq++, rq--;       else         assert(0);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long T, i, j, n;     char c[2], ca[4] = { v ,  < ,  ^ ,  > }, a, b;     cin >> a >> b;     map<char, long long> m;     m[ca[0]] = 1;     m[ca[1]] = 2;     m[ca[2]] = 3;     m[ca[3]] = 4;     cin >> n;     n = n % 4;     if (n == 0)       cout <<  undefined  << endl;     else if (m[a] <= m[b]) {       if (m[b] - m[a] == 2)         cout <<  undefined  << endl;       else if (m[b] - m[a] == n)         cout <<  cw  << endl;       else if (4 - m[b] + m[a] == n)         cout <<  ccw  << endl;       else         cout <<  undefined  << endl;     } else {       if (m[a] - m[b] == 2)         cout <<  undefined  << endl;       else if (4 - m[a] + m[b] == n)         cout <<  cw  << endl;       else if (m[a] - m[b] == n)         cout <<  ccw  << endl;       else         cout <<  undefined  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const double PI = acos(-1);   const int oo = 1e9, bpr = 1e9 + 7, N = 0;   long long f[110];   int a[110];   long long d[110][4][4];   int n;   inline long long calc(int ps, int v1, int v2) {     if (ps == n) return v1 == 0 && v2 == 0;     if (d[ps][v1][v2] != -1) return d[ps][v1][v2];     long long res = 0;     for (int i = 0; i < 2; ++i) {       int x = min(v1, v2 + i);       for (int j = 0; j <= x; ++j) {         if (v1 - j == a[ps]) {           res += calc(ps + 1, v2 + i - j, j);         }       }     }     return d[ps][v1][v2] = res;   }   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     f[0] = f[1] = 1;     for (n = 2; f[n - 1] <= 1e18; ++n) f[n] = f[n - 1] + f[n - 2];     --n;     int t;     cin >> t;     while (t--) {       long long x;       cin >> x;       int cnt = 0;       for (int i = n; i >= 1; --i) {         a[i] = (f[i] <= x);         if (a[i]) x -= f[i];       }       memset(d, -1, sizeof(d));       cout << calc(0, 0, 0) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int level[26];     for (int i = 0; i < 26; i++) cin >> level[i];     string s;     cin >> s;     long long ans = 0;     for (char ch =  a ; ch <=  z ; ch++) {       map<long long, long long> m;       long long sum = 0;       for (int i = 0; i < s.length(); i++) {         sum += level[s[i] -  a ];         if (s[i] == ch) ans += m[sum - level[ch -  a ]], m[sum]++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   void stderr_printf(const char *fmt, ...) {     va_list ap;     va_start(ap, fmt);     vfprintf(stderr, fmt, ap);     va_end(ap);   }   using namespace std;   struct flist {     int val;     int pos;   };   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int i, j, k;     int n;     cin >> n;     ;     int stage = 0;     bool ans = true;     cin >> j;     ;     for (i = 0; i < n - 1; i++) {       int cur;       cin >> cur;       ;       if (stage == 0) {         if (cur == j) {           stage = 1;         } else if (cur < j) {           stage = 2;         } else if (cur > j) {           stage = 0;         }       } else if (stage == 1) {         if (cur == j) {           stage = 1;         } else if (cur < j) {           stage = 2;         } else if (cur > j) {           ans = false;         }       } else {         if (cur >= j) {           ans = false;         }       }       j = cur;     }     if (ans) {       printf( YES n );     } else {       printf( NO n );     }   }
#include <bits/stdc++.h>   using namespace std;   struct lex_compare {     bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) const {       return lhs.second > rhs.second;     }   };   void solve() {     int n;     cin >> n;     vector<long long> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     sort(v.begin(), v.end());     if (n >= 60) {       long long ans = 0;       for (int i = 0; i < n; i++) {         ans += abs(v[i] - 1ll);       }       cout << ans <<   n ;     } else {       int k = 1;       while (true) {         if ((long long)pow(k, n - 1) > v[n - 1]) {           break;         }         k += 1;       }       long long ans1 = 0, ans2 = 0;       for (int i = 0; i < n; i++) {         ans1 += abs(v[i] - (long long)pow(k, i));         ans2 += abs(v[i] - (long long)pow(k - 1, i));       }       cout << min(ans1, ans2) <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n = 1;     for (int i = 0; i < n; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int main() {     ios::sync_with_stdio(false);     int n;     long long m, x;     set<long long> v1;     set<long long> v2;     v1.insert(0);     v2.insert(0);     cin >> n >> m;     long long ans = 0;     for (int i = 0; i < n / 2; i++) {       cin >> x;       set<long long> tmp;       for (auto it : v1) tmp.insert((it + x) % m), ans = max(ans, it);       for (auto it : tmp) v1.insert(it), ans = max(ans, it);     }     for (int i = n / 2; i < n; i++) {       cin >> x;       set<long long> tmp;       for (auto it : v2) tmp.insert((it + x) % m), ans = max(ans, it);       for (auto it : tmp) v2.insert(it), ans = max(ans, it);     }     for (auto it : v1) {       int precisa = (m - 1) - it;       auto ok = v2.lower_bound(precisa);       if (ok == v2.end()) ok--;       while (ok != v2.begin() and it + *ok >= m) ok--;       ans = max(ans, (it + *ok) % m);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   vector<vector<int> > v;   bool transponer;   void escribe() {     if (transponer) {       vector<vector<int> > nextv(m + 2, vector<int>(n + 2, 0));       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) nextv[j][i] = v[i][j];       swap(n, m);       v = nextv;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++)         if (v[i][j])           cout <<  * ;         else           cout <<  . ;       cout << endl;     }   }   int valor(int i, int j) {     if (i == 1) return 0;     if (j == 1) return 1;     if (j == m) return 3;     return 4;   }   void genera() {     int act = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (act + valor(i, j) > k) {           int resta = k - act;           if (resta == 1) {             if (m > j)               v[i][m] = 1;             else               v[i + 1][1] = 1;           } else if (resta == 2) {             if (m - j + 1 >= 3)               v[i][m - 1] = 1;             else if (m - j + 1 == 2)               v[i][m] = v[i + 1][m] = v[i + 1][m - 1] = 1;             else               v[i + 1][2] = 1;           } else {             if (m - j + 1 >= 4)               v[i][m] = v[i][m - 2] = 1;             else if (j == 2) {               if (i < n)                 v[i][m] = v[i + 1][m] = v[i + 1][m - 1] = v[i + 1][1] =                     v[i + 1][2] = 1;               else {                 v[i][1] = 0;                 v[i][2] = v[i][4] = 1;               }             } else               v[i][m] = v[i + 1][m] = v[i + 1][m - 1] = v[i + 1][1] = 1;           }           escribe();           return;         }         v[i][j] = 1;         act += valor(i, j);         if (act == k) {           escribe();           return;         }       }     }   }   int main() {     ios::sync_with_stdio(false);     int casos;     cin >> casos;     for (int cas = 0; cas < casos; cas++) {       if (cas > 0) cout << endl;       cin >> n >> m >> k;       transponer = false;       if (n > m) {         swap(n, m);         transponer = true;       }       v = vector<vector<int> >(n + 2, vector<int>(m + 2, 0));       int total = (n - 1) + (n - 1) * (m - 2) * 4 + (n - 1) * 3;       if (k > total or k == total - 1 or k == total - 2 or k == total - 4 or           k == total - 5) {         cout << -1 << endl;         continue;       }       if (k == total - 8) {         if (n > 3) {           cout << -1 << endl;           continue;         }         for (int i = 1; i <= n; i++)           for (int j = 1; j <= m - 1; j++) v[i][j] = 1;         escribe();         continue;       }       if (m == 3 and k == 7) {         for (int i = 1; i <= 3; i++)           for (int j = 1; j <= 3; j++) v[i][j] = 1;         v[1][1] = v[3][1] = v[1][3] = 0;         escribe();         continue;       }       genera();     }   }
#include <bits/stdc++.h>   int main() {     int a, i;     char b, c, x;     scanf( %d  , &a);     scanf( %c , &b);     for (i = 1; i <= a - 2; i++) scanf( %c , &x);     scanf( %c , &c);     if (b ==  S  && c ==  F )       printf( YES );     else       printf( NO );   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int f = 1, x = 0;     char c = getchar();     while (c <  0  ||  9  < c) {       if (c ==  - ) f = -1;       c = getchar();     }     while ( 0  <= c && c <=  9 )       x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();     return f * x;   }   const int MAXN = 100000;   const int INF = 0x3f3f3f3f;   int ans;   void Query(int L, int R, int l1, int r1, int l2, int r2) {     if (l1 > r1 || l2 > r2) return;     int le = max(l1, l2), ri = min(r1, r2);     ans = max(ans, ri - le + 1);     if ((l1 <= l2 && r2 <= r1) || (l2 <= l1 && r1 <= r2)) return;     int Mid = (L + R) >> 1;     Query(L, Mid - 1, l1, min(r1, Mid - 1), l2, min(r2, Mid - 1));     Query(L, Mid - 1, l1, min(r1, Mid - 1), max(l2, Mid + 1) - Mid, r2 - Mid);     Query(L, Mid - 1, max(l1, Mid + 1) - Mid, r1 - Mid, l2, min(r2, Mid - 1));     Query(L, Mid - 1, max(l1, Mid + 1) - Mid, r1 - Mid, max(l2, Mid + 1) - Mid,           r2 - Mid);     return;   }   int main() {     int l1 = read(), r1 = read(), l2 = read(), r2 = read();     Query(1, 1073741823, l1, r1, l2, r2);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static int N, K, M, G, U[500003], V[500003], W[500003], fa[500003], sup[500003],       dep[500003];   static bool spe[500003];   static vector<pair<bool, int>> edge[500003];   static long long ans;   int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }   void dfs(int u, int f) {     dep[u] = dep[sup[u] = f] + 1;     for (auto v : edge[u])       if (v.second != f) {         spe[v.second] = v.first;         dfs(v.second, u);       }   }   int main() {     scanf( %d%d%d , &N, &K, &M);     for (int i = 1; i <= N; i++) fa[i] = i;     for (int i = 0, x, y; i < K; i++) {       scanf( %d%d , &x, &y);       edge[x].push_back(make_pair(true, y));       edge[y].push_back(make_pair(true, x));       fa[find(x)] = find(y);     }     for (int i = 0; i < M; i++) {       scanf( %d%d%d , &U[G], &V[G], &W[G]);       int u = find(U[G]), v = find(V[G]);       if (u != v) {         edge[U[G]].push_back(make_pair(false, V[G]));         edge[V[G]].push_back(make_pair(false, U[G]));         fa[u] = v;       } else         G++;     }     dfs(1, 0);     for (int i = 1; i <= N; i++) fa[i] = i;     for (int i = 0; i < G; i++) {       int u = find(U[i]), v = find(V[i]);       while (u != v) {         if (dep[u] < dep[v]) swap(u, v);         ans += spe[u] ? W[i] : 0;         u = fa[u] = find(sup[u]);       }     }     for (int i = 1; i <= N; i++)       for (auto v : edge[i])         if (v.first && find(v.second) != find(i)) return puts( -1 ), 0;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     int k, a, b, v;     int sections;     scanf( %d%d%d%d , &k, &a, &b, &v);     sections = a / v;     sections += ((a % v) != 0);     int box = 0;     k--;     while (b > 0) {       box++;       if (b >= k) {         b -= k;         sections -= (k + 1);       } else {         sections -= (b + 1);         b = 0;       }       if (sections <= 0) break;     }     if (sections > 0) box += sections;     printf( %d n , box);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<vector<char> > v;     v.resize(n, vector<char>(m));     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> v[i][j];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if ((i + j) % 2 == 0 && v[i][j] ==  . ) {           cout <<  B ;           if (j == m - 1) cout <<   n ;         } else if ((i + j) % 2 == 1 && v[i][j] ==  . ) {           cout <<  W ;           if (j == m - 1) cout <<   n ;         } else {           cout <<  - ;           if (j == m - 1) cout <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 5;   struct bing {     int fa[N];     void init() {       for (int i = (1); i < (N); i++) fa[i] = i;     }     int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }     void unite(int x, int y) { fa[find(x)] = find(y); }     bool same(int x, int y) { return find(x) == find(y); }   } bi[2];   int n, m1, m2;   int main() {     for (int i = (0); i < (2); i++) bi[i].init();     cin >> n >> m1 >> m2;     int op = m1 > m2 ? 0 : 1;     for (int i = (1); i < (m1 + 1); i++) {       int u, v;       scanf( %d%d , &u, &v);       bi[op].unite(u, v);     }     for (int i = (1); i < (m2 + 1); i++) {       int u, v;       scanf( %d%d , &u, &v);       bi[1 - op].unite(u, v);     }     printf( %d n , min(n - 1 - m1, n - 1 - m2));     for (int i = (1); i < (n + 1); i++)       if (!bi[0].same(1, i) && !bi[1].same(1, i)) {         bi[0].unite(1, i), bi[1].unite(1, i);         printf( %d %d n , 1, i);       }     for (int a = 2, b = 2; a <= n; a++) {       if (bi[0].same(1, a)) continue;       while (b <= n && bi[1].same(1, b)) b++;       if (b <= n) {         bi[0].unite(a, b), bi[1].unite(a, b);         printf( %d %d n , a, b);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, k, m, n, rez = 0;     int a[300];     bool b[300] = {0};     bool c;     cin >> n >> k;     for (i = 1; i <= 2 * n + 1; i++) cin >> a[i];     for (j = 0; j < k; j++) {       c = true;       i = 2;       while (c) {         if (!b[i] && a[i] > a[i - 1] + 1 && a[i] > a[i + 1] + 1) {           a[i]--;           b[i] = true;           c = false;         }         i += 2;       }     }     for (i = 1; i <= 2 * n + 1; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10;   const int MAXM = 1e6 + 10;   const int MAXLOG = 20;   struct Edge {     int x, y, w;     int id;   } edge[MAXM];   int T, n, m, i;   int val;   vector<pair<int, int> > e[MAXN];   int fa[MAXN], anc[MAXN][MAXLOG], dep[MAXN];   int ans[MAXM];   int mx[MAXN][MAXLOG];   bool on_mst[MAXM];   inline bool cmp(Edge a, Edge b) { return a.w < b.w; }   inline int get_root(int x) {     if (fa[x] == x) return x;     return fa[x] = get_root(fa[x]);   }   inline void kruskal() {     int i, x, y, sx, sy;     int w;     for (i = 1; i <= n; i++) fa[i] = i;     sort(edge + 1, edge + m + 1, cmp);     for (i = 1; i <= m; i++) {       x = edge[i].x;       y = edge[i].y;       w = edge[i].w;       sx = get_root(x);       sy = get_root(y);       if (sx != sy) {         fa[sx] = sy;         on_mst[edge[i].id] = 1;         e[x].push_back(make_pair(y, w));         e[y].push_back(make_pair(x, w));       }     }   }   inline void build(int u) {     int i, v;     for (i = 1; i < MAXLOG; i++) {       anc[u][i] = anc[anc[u][i - 1]][i - 1];       mx[u][i] = max(mx[u][i - 1], mx[anc[u][i - 1]][i - 1]);     }     for (i = 0; i < e[u].size(); i++) {       v = e[u][i].first;       if (anc[u][0] != v) {         dep[v] = dep[u] + 1;         anc[v][0] = u;         mx[v][0] = e[u][i].second;         build(v);       }     }   }   inline int get(int x, int y) {     int i, t;     int ans = 0;     if (dep[x] > dep[y]) swap(x, y);     t = dep[y] - dep[x];     for (i = 0; i < MAXLOG; i++) {       if (t & (1 << i)) {         ans = max(ans, mx[y][i]);         y = anc[y][i];       }     }     if (x == y) return ans;     for (i = MAXLOG - 1; i >= 0; i--) {       if (anc[x][i] != anc[y][i]) {         ans = max(ans, max(mx[x][i], mx[y][i]));         x = anc[x][i];         y = anc[y][i];       }     }     return max(ans, max(mx[x][0], mx[y][0]));   }   int main() {     scanf( %d%d , &n, &m);     if (m == n - 1) return 0;     for (i = 1; i <= m; i++) {       scanf( %d%d%d , &edge[i].x, &edge[i].y, &edge[i].w);       edge[i].id = i;     }     kruskal();     build(1);     for (int i = 1; i <= m; ++i) {       if (!on_mst[edge[i].id]) ans[edge[i].id] = get(edge[i].x, edge[i].y);     }     for (int i = 1; i <= m; ++i)       if (!on_mst[i]) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int l = s.length();     vector<vector<int>> dp(5000, vector<int>(5000, 0));     vector<int> kk(s.size() + 1, 0);     for (int length = 1; length <= l; length++) {       for (int right = 0; right < s.size(); right++) {         int r = right + length - 1;         if (r >= s.size()) break;         if (s[right] != s[r]) continue;         if (right == r) {           dp[r][r] = 1;         } else if (length == 2) {           dp[right][r] = 2;         } else if (dp[right + 1][r - 1] > 0) {           int haf = length / 2;           int ml = right + haf - 1;           int mr = r - haf + 1;           dp[right][r] = 1 + min(dp[right][ml], dp[mr][r]);         }         kk[dp[right][r]]++;       }     }     for (int i = l; i >= 1; i--) {       kk[i - 1] = kk[i] + kk[i - 1];     }     for (int i = 1; i <= l; i++) {       string pt = to_string(kk[i]) +    ;       cout << pt;     }   }
#include <bits/stdc++.h>   using namespace std;   const int Z = (int)3e3 + 111;   const int N = (int)1e6 + 111;   const int INF = (int)1e9 + 111;   const int MOD = (int)1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string t, ans;     cin >> t;     int k;     if (t.size() % 2)       k = 1;     else       k = 0;     int po1(0), po2(t.size() - 1);     while (ans.size() != t.size()) {       if (k) {         ans = t[po1] + ans;         po1++;       } else {         ans = t[po2] + ans;         po2--;       }       k = !k;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, first, second, third, fourth;     cin >> a >> b >> c;     first = a + b + c;     second = 2 * (a + b);     third = 2 * (b + c);     fourth = 2 * (a + c);     cout << min(first, min(second, min(third, fourth)));   }