malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int a = 1023, b = 0, n, e;     char op;     cin >> n;     while (n--) {       cin >> op >> e;       if (op ==  | ) {         a |= e;         b |= e;       } else if (op ==  & ) {         a &= e;         b &= e;       } else if (op ==  ^ ) {         a ^= e;         b ^= e;       }     }     int ouxor = 0;     int ou = 0;     int exor = 0;     e = 0;     for (int i = 0; i < 10; i++) {       int num = 1 << i;       if ((a & num) && (b & num))         ou |= num;       else if ((b & num))         exor |= num;       else if (!(a & num) && !(b & num))         ouxor |= num;     }     int count = 0;     count += ouxor ? 2 : 0;     count += ou ? 1 : 0;     count += exor ? 1 : 0;     cout << count << endl;     if (ou) cout <<  |   << ou << endl;     if (ouxor) {       cout <<  |   << ouxor << endl;       cout <<  ^   << ouxor << endl;     }     if (exor) cout <<  ^   << exor << endl;   }
#include <bits/stdc++.h>   int main() {     int t;     scanf( %d , &t);     int a, b, c, d, k, x, y;     while (t--) {       scanf( %d %d %d %d %d , &a, &b, &c, &d, &k);       if (a % c == 0) {         x = a / c;       } else {         x = a / c + 1;       }       if (b % d == 0) {         y = b / d;       } else {         y = b / d + 1;       }       if (x + y > k) {         printf( -1 n );       } else         printf( %d %d n , k - y, y);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)1e15 + 696969;   long long n, k;   long long a[1LL << 20], b[1LL << 20];   long long opt[20][1LL << 20];   signed main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     memset(opt, -1, sizeof opt);     cin >> n;     for (long long i = 1; i < n; i <<= 1) k++;     long long ok = false;     for (long long i = 0; i < n; i++) {       long long x;       cin >> x;       if (x == -1)         ok = true;       else if (!ok)         a[i] = 0;       else         a[i - 1] = x;     }     n--;     reverse(a, a + n);     for (long long i = k - 1, j = 0; i > 0; i--) {       j += 1 << i;       b[i] = j;     }     for (long long i = 0; i < n; i++) {       opt[0][i] = a[i];     }     for (long long i = 1; i < k; i++) {       long long mn = INF;       for (long long j = n - 1; j >= 0; j--) {         if (j > b[i])           opt[i][j] = INF;         else {           opt[i][j] = mn + a[j];           mn = min(mn, opt[i - 1][j]);         }       }     }     cout << opt[k - 1][0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long x1, y1, z1;       long long x2, y2, z2;       cin >> x1 >> y1 >> z1;       cin >> x2 >> y2 >> z2;       long long sum = 0;       if (z2 > x1) {         z2 -= x1;         if (z2 > z1) {           z2 -= z1;           sum -= (2 * z2);         } else {           z1 -= z2;           sum += 2 * min(z1, y2);         }       } else {         sum += 2 * min(z1, y2);       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const int N = 1510;   int DP[27][N][N];   int ans[27][N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     string s;     cin >> s;     memset(DP, 0, sizeof(DP));     memset(ans, 0, sizeof(ans));     DP[s[0] -  a ][0][0] = 1;     for (int i = (int)1; i < (int)N; i++) DP[s[0] -  a ][0][i] = 1;     for (char ch =  a ; ch <=  z ; ch++) {       if (s[0] == ch) continue;       for (int i = (int)1; i < (int)N; i++) DP[ch -  a ][0][i] = 1;     }     for (int i = (int)1; i < (int)(int)(s.size()); i++) {       for (char ch =  a ; ch <=  z ; ch++) {         if (s[i] == ch) {           int len = 0;           for (int k = i; k >= 0; k--) {             if (s[k] != ch) break;             len++;           }           DP[ch -  a ][i][0] = len;         }         for (int j = (int)1; j < (int)N; j++) {           if (ch == s[i])             DP[ch -  a ][i][j] = 1 + DP[ch -  a ][i - 1][j];           else             DP[ch -  a ][i][j] = 1 + DP[ch -  a ][i - 1][j - 1];         }       }     }     for (char ch =  a ; ch <=  z ; ch++) {       for (int j = 0; j < N; j++) {         for (int i = (int)0; i < (int)(int)(s.size()); i++)           ans[ch -  a ][j] = max(ans[ch -  a ][j], DP[ch -  a ][i][j]);       }     }     int q;     cin >> q;     for (int i = (int)0; i < (int)q; i++) {       int m;       char ch;       cin >> m >> ch;       cout << ans[ch -  a ][m] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const long long INFL = LLONG_MAX;   int N, ans, P[100100], ord[100100];   int comp(int a, int b) { return P[a] > P[b]; }   int main() {     ios_base::sync_with_stdio(0);     cout.precision(15);     cin >> N;     for (int(i) = 1; (i) <= (N); (i)++) {       cin >> P[i];       ord[i] = i;     }     sort(ord + 1, ord + 1 + N, comp);     cout << ord[1] <<     << P[ord[2]] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int inv = 0;     for (int i = 1; i < n; i++) {       for (int j = 0; j < i; j++) {         if (a[i] < a[j]) {           inv++;         }       }     }     inv %= 2;     int m;     cin >> m;     for (int i = 0; i < m; i++) {       int l, r;       cin >> l >> r;       int len = r - l + 1;       int di = (len * (len - 1)) / 2;       inv += di;       inv %= 2;       if (inv == 1) {         cout <<  odd  << endl;       } else {         cout <<  even  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int MAXN = 23;   int parseInt() {     int d;     scanf( %d , &d);     ;     return d;   }   int n;   int a[MAXN], b[MAXN];   vector<pair<int, int> > v;   map<int, int> rang;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       a[i] = parseInt();       v.push_back(make_pair(a[i], i));     }     sort(v.begin(), v.end());     for (int i = 0; i < n; ++i) {       rang[v[i].first] = i;       b[i] = v[i].first;     }     int rng;     for (int i = 0; i < n; ++i) {       rng = rang[a[i]];       rng = (rng + 1) % n;       cout << b[rng] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7, INF = 0x3f3f3f3f;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long qpow(long long a, long long n) {     long long r = 1 % P;     for (a %= P; n; a = a * a % P, n >>= 1)       if (n & 1) r = r * a % P;     return r;   }   long long inv(long long first) {     return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;   }   inline int rd() {     int first = 0;     char p = getchar();     while (p <  0  || p >  9 ) p = getchar();     while (p >=  0  && p <=  9 ) first = first * 10 + p -  0 , p = getchar();     return first;   }   const int N = 1e6 + 10;   int n, a, b;   struct _ {     long long a, b, c;     void pr() { printf( a=%lld,b=%lld n , a, b); }     bool operator<(const _& rhs) const { return c > rhs.c; }   } e[N];   long long ans;   int vis[N];   int main() {     scanf( %d%d%d , &n, &a, &b);     for (int i = 1; i <= n; ++i) {       scanf( %lld%lld , &e[i].a, &e[i].b);       e[i].c = e[i].a - e[i].b;     }     for (int i = 1; i <= n; ++i) ans += e[i].b;     if (!b) return printf( %lld n , ans), 0;     if (b == 1) {       long long t = 0;       for (int i = 1; i <= n; ++i) t = max(t, (e[i].a << a) - e[i].b);       return printf( %lld n , ans + t), 0;     }     sort(e + 1, e + 1 + n);     for (int i = 1; i <= n; ++i)       if (e[i].a > e[i].b) vis[i] = 1;     int cnt = 0;     for (int i = 1; i <= b; ++i)       if (vis[i]) ans += e[i].a - e[i].b, ++cnt;     long long t = 0;     for (int i = 1; i <= b; ++i) {       if (vis[i])         t = max(t, (e[i].a << a) - e[i].a);       else         t = max(t, (e[i].a << a) - e[i].b);     }     long long ret = ans + t;     t = 0;     for (int i = b + 1; i <= n; ++i) t = max(t, (e[i].a << a) - e[i].b);     if (cnt < b)       ret = max(ret, ans + t);     else       ret = max(ret, ans + t - e[b].a + e[b].b);     printf( %lld n , ret);   }
#include <bits/stdc++.h>   using namespace std;   int Length[1001], n, x, a[1001], Concern, Pos, Ppl;   vector<int> Queues, adj[1001], Ans;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> x;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       if (a[i]) adj[a[i]].push_back(i);     }     for (int i = 1; i <= n; ++i) {       if (a[i] == 0) {         Ppl = i;         int len = 0;         while (Ppl) {           ++len;           if (Ppl == x) Concern = i, Pos = len;           if (adj[Ppl].size())             Ppl = adj[Ppl][0];           else             Ppl = 0;         }         if (Concern != i) Queues.push_back(len);       }     }     for (int i = Queues.size() - 1; i >= 0; --i) {       vector<int> Add;       for (int j = 0; j < Ans.size(); ++j) {         if (!Length[Ans[j] + Queues[i]])           Add.push_back(Ans[j] + Queues[i]), Length[Ans[j] + Queues[i]] = 1;       }       for (int j = 0; j < Add.size(); ++j) Ans.push_back(Add[j]);       if (!Length[Queues[i]]) Ans.push_back(Queues[i]), Length[Queues[i]] = 1;     }     cout << Pos <<   n ;     sort(Ans.begin(), Ans.end());     for (int i = 0; i < Ans.size(); ++i) cout << Pos + Ans[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Min = -10000000;   int Max = -Min;   int A[8] = {1, 1, 0, 0, 1, 1, 1, 1};   int B[8] = {0, 0, 1, 1, 1, 1, -1, -1};   int C[8];   struct Nodes {     int x, y;   } p[100010];   bool operator<(Nodes &p1, Nodes p2) {     if (p1.x == p2.x) return p1.y < p2.y;     return p1.x < p2.x;   }   long long cross(long long x1, long long y1, long long x2, long long y2) {     return x1 * y2 - y1 * x2;   }   int main() {     int i, j, k;     int n;     long long a, b, c, res;     while (scanf( %d , &n) != EOF) {       for (i = 0; i < 8; i++) {         if (i & 1) {           C[i] = Max;         } else           C[i] = Min;       }       for (i = 1; i <= n; i++) {         scanf( %d%d , &p[i].x, &p[i].y);         C[0] = max(C[0], p[i].x);         C[1] = min(C[1], p[i].x);         C[2] = max(C[2], p[i].y);         C[3] = min(C[3], p[i].y);         C[4] = max(C[4], p[i].x + p[i].y);         C[5] = min(C[5], p[i].x + p[i].y);         C[6] = max(C[6], p[i].x - p[i].y);         C[7] = min(C[7], p[i].x - p[i].y);       }       res = 0;       for (i = 0; i < 8; i++) {         Nodes p1, p2;         p1.x = p1.y = Min;         p2.x = p2.y = Max;         for (j = 0; j < 8; j += 2) {           Nodes tmp[2];           for (k = j; k < j + 2; k++) {             c = cross(A[i], B[i], A[k], B[k]);             a = cross(A[i], C[i], A[k], C[k]);             b = cross(C[i], B[i], C[k], B[k]);             if (c == 0) break;             if (b % c || a % c) break;             tmp[k - j].x = b / c;             tmp[k - j].y = a / c;           }           if (k < j + 2) continue;           if (tmp[1] < tmp[0]) swap(tmp[0], tmp[1]);           if (p1 < tmp[0]) p1 = tmp[0];           if (tmp[1] < p2) p2 = tmp[1];         }         res += max(abs(p2.x - p1.x), abs(p2.y - p1.y));       }       cout << res + 4 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (scanf( %d , &n) == 1) {       string s;       cin >> s;       s =  #  + s;       bool used[n + 1];       memset(used, 0, sizeof used);       int d[n + 1];       for (int i = 1; i <= n; i++) {         scanf( %d , d + i);       }       int pos = 1;       bool ok = false;       while (!used[pos]) {         used[pos] = true;         if (s[pos] ==  < ) {           pos -= d[pos];         } else {           pos += d[pos];         }         if (pos <= 0 || pos > n) {           ok = true;           break;         }       }       if (ok) {         puts( FINITE );       } else {         puts( INFINITE );       }     }   }
#include <bits/stdc++.h>   using namespace std;   char _;   int num_rectangles;   pair<pair<int, int>, pair<int, int> > rectangles[135000], pre[135000],       suff[135000];   pair<pair<int, int>, pair<int, int> > intersection(       pair<pair<int, int>, pair<int, int> > first,       pair<pair<int, int>, pair<int, int> > second) {     if (first.first.first == INT_MIN || second.first.first == INT_MIN)       return {{INT_MIN, INT_MIN}, {INT_MIN, INT_MIN}};     int tx = max(first.first.first, second.first.first),         bx = min(first.second.first, second.second.first);     int ty = max(first.first.second, second.first.second),         by = min(first.second.second, second.second.second);     if (bx < tx || by < ty) return {{INT_MIN, INT_MIN}, {INT_MIN, INT_MIN}};     return {{tx, ty}, {bx, by}};   }   int main() {     scanf( %d , &num_rectangles);     for (int i = 0; i < num_rectangles; i++)       scanf(  %d %d %d %d , &rectangles[i].first.first,             &rectangles[i].first.second, &rectangles[i].second.first,             &rectangles[i].second.second);     sort(rectangles, rectangles + num_rectangles);     pre[0] = rectangles[0];     suff[num_rectangles - 1] = rectangles[num_rectangles - 1];     for (int i = 1; i < num_rectangles; i++) {       pre[i] = intersection(pre[i - 1], rectangles[i]);       suff[num_rectangles - i - 1] = intersection(           suff[num_rectangles - i], rectangles[num_rectangles - i - 1]);     }     for (int i = 0; i < num_rectangles; i++) {       if (i == 0) {         if (suff[1].first.first != INT_MIN) {           printf( %d %d n , suff[1].first.first, suff[1].first.second);           return 0;         }       } else if (i == num_rectangles - 1) {         if (pre[num_rectangles - 2].first.first != INT_MIN) {           printf( %d %d n , pre[num_rectangles - 2].first.first,                  pre[num_rectangles - 2].first.second);           return 0;         }       } else {         pair<pair<int, int>, pair<int, int> > first = pre[i - 1],                                               second = suff[i + 1],                                               intersect =                                                   intersection(first, second);         if (intersect.first.first != INT_MIN) {           printf( %d %d n , intersect.first.first, intersect.first.second);           return 0;         }       }     }     if (pre[num_rectangles - 1].first.first != INT_MIN) {       printf( %d %d n , pre[num_rectangles - 1].first.first,              pre[num_rectangles - 1].first.second);       return 0;     }     printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6, maxm = 1e6;   unsigned int degree[maxn + 10], blk[maxn + 10];   namespace find {   unsigned int fa[maxn + 10], siz[maxn + 10];   inline void Init(const unsigned int n) {     iota(fa, fa + n + 1, 0);     fill(siz, siz + n + 1, 1);   }   unsigned int GetFather(const unsigned int x) {     return fa[x] == x ? x : fa[x] = GetFather(fa[x]);   }   inline void Merge(const unsigned int x, const unsigned int y) {     unsigned int fx = GetFather(x), fy = GetFather(y);     if (fx == fy) return;     if (siz[fx] < siz[fy]) swap(fx, fy);     fa[fy] = fx;     siz[fx] += siz[fy];   }   }  // namespace find   int main() {     ios_base::sync_with_stdio(false);     unsigned int n, m;     cin >> n >> m;     find::Init(n);     for (unsigned int i = 0; i < m; ++i) {       unsigned int a, b;       cin >> a >> b;       find::Merge(a, b);       ++degree[a];       ++degree[b];     }     unsigned long long ans = 0;     const unsigned int r = find::GetFather(1);     bool fl = true;     for (unsigned int i = 1; i <= n; ++i) {       if (degree[i] & 0x01) ++blk[find::GetFather(i)];       if (degree[i] && find::GetFather(i) != r) fl = false;     }     if (fl && !blk[r]) {       cout <<  0  << endl;       return 0;     }     for (unsigned int i = 1; i <= n; ++i)       if (find::GetFather(i) == i) {         ans += blk[i] / 2;         if (degree[i] && !blk[i]) ++ans;       }     if (!degree[1] && find::siz[1] == 1 && find::GetFather(1) == 1) ++ans;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     int count = 0, count1 = 0;     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] >= 97 && s[i] <= 122)         count++;       else         count1++;     }     if (count >= count1) {       for (int i = 0; i < s.size(); i++) {         if (isupper(s[i])) s[i] = s[i] + 32;       }     } else {       for (int i = 0; i < s.size(); i++) {         if (islower(s[i])) s[i] = s[i] - 32;       }     }     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   int dirx[] = {-1, -1, -1, 0, 0, 1, 1, 1};   int diry[] = {-1, 0, 1, -1, 1, -1, 0, 1};   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }   void debug_out(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) int idx,                  __attribute__((unused)) int LINE_NUM) {     cerr << endl;   }   template <typename Head, typename... Tail>   void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {     if (idx > 0)       cerr <<  ,  ;     else       cerr <<  Line(  << LINE_NUM <<  )  ;     stringstream ss;     ss << H;     cerr << args[idx] <<   =   << ss.str();     debug_out(args, idx + 1, LINE_NUM, T...);   }   int const lmt = 2e5 + 5;   int a[lmt];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       long long n;       cin >> n;       for (long long i = 0; i < n; i++) cin >> a[i];       if (a[0] + a[1] <= a[n - 1]) {         cout << 1 <<    ;         cout << 2 <<    ;         cout << n <<   n ;       } else {         cout << -1 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a[300005], p[300005], out[300005];   long long f[300005];   bool v[300005];   int n, m, cnt;   void work(int p) {     int t = min(a[p], a[p + 1]);     if (t) out[++m] = p;     a[p] -= t;     a[p + 1] -= t;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       long long O = f[max(i - 2, 0)] + a[i];       long long E = f[max(i - 3, 0)] + max(a[i], a[i - 1]);       f[i] = min(O, E);       v[i] = (f[i] != O);     }     long long ans = min(f[n - 1], f[n]);     for (int i = n - (ans == f[n - 1]); i > 0; i -= 2 + v[i]) p[++cnt] = i;     reverse(p + 1, p + cnt + 1);     for (int i = 1; i <= cnt; i++) {       int pre = p[i - 1], now = p[i];       if (v) work(now - 1);       work(pre + 1);       work(now);     }     printf( %d n , m);     for (int i = 1; i <= m; i++) printf( %d n , out[i]);   }
#include <bits/stdc++.h>   using namespace std;   int a[4] = {1, 2, 3, 5};   int main(void) {     int n, k;     scanf( %d%d , &n, &k);     printf( %d n , (5 + 6 * (n - 1)) * k);     for (int i = 0; i < n; i++) {       printf( %d %d %d %d n , (a[0] + 6 * i) * k, (a[1] + 6 * i) * k,              (a[2] + 6 * i) * k, (a[3] + 6 * i) * k);     }   }
#include <bits/stdc++.h>   int main() {     int n, mxpos = 0, mx = 0, temp, i;     scanf( %d , &n);     int p[n];     for (i = 0; i < n; i++) {       scanf( %d , &p[i]);       if (mx < p[i]) {         mx = p[i];         mxpos = i;       }     }     int loopno = 0, j;     int notsorted = 1;     while (notsorted) {       notsorted = 0;       for (j = 0; j < n - loopno - 1; j++) {         if (p[j] > p[j + 1]) {           temp = p[j];           p[j] = p[j + 1];           p[j + 1] = temp;           notsorted = 1;         }       }       loopno++;     }     printf( %d %d , mxpos + 1, p[n - 2]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 32000;   const int mod = 1000000007;   const int inf = 2 * mod;   int dp[5001][5001];   pair<long long, long long> hashVal[5001];   pair<long long, long long> powVal[5001];   const long long base1 = 37;   const long long base2 = 2017;   const long long mod1 = 1e9 + 7;   const long long mod2 = 1e9 + 297;   int ans[50001];   string s;   inline int ceil(int p, int q) { return (p + q - 1) / q; }   int call(int l, int r) {     if (l > r) return 0;     if (l == r) return 1;     if (l == r - 1) return (s[l] == s[r] ? 2 : 0);     if (dp[l][r] != -1) return dp[l][r];     int ret;     if (s[l] != s[r] || call(l + 1, r - 1) == 0)       ret = 0;     else       ret = 1 + call(l, ceil(l + r, 2) - 1);     return dp[l][r] = ret;   }   int main() {     cin >> s;     int len = s.length();     memset(dp, -1, sizeof(dp));     for (int i = 0; i < len; i++) {       for (int j = 0; j < len; j++) {         ans[call(i, j)]++;       }     }     for (int i = len - 1; i >= 1; i--) ans[i] += ans[i + 1];     for (int i = 1; i <= len; i++) {       cout << ans[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = LLONG_MAX;   const long long mod = 1e9 + 7;   inline long long power(long long n, long long k, long long mod = INF) {     long long ans = 1;     while (k > 0) {       if (k & 1) ans = (ans * n) % mod;       n = (n * n) % mod;       k >>= 1;     }     return ans;   }   void sum() {     string s;     cin >> s;     long long n = (long long)s.size();     long long pre[n + 1];     long long suf[n + 2];     pre[1] = s[0] -  0 ;     suf[n] = s[n - 1] -  0 ;     suf[n + 1] = 0;     suf[0] = 0;     pre[0] = 0;     long long st = pre[1];     long long en = suf[n];     long long t = 1;     long long ans = 0;     for (long long i = 1; i < n; ++i) {       t = (t * 10) % mod;       st = (st * 10 + s[i] -  0 ) % mod;       pre[i + 1] = (pre[i] % mod + st) % mod;       en = (en + t * (s[n - i - 1] -  0 )) % mod;       suf[n - i] = en;     }     for (long long i = 2; i <= n + 1; ++i) {       long long temp = i - 1;       temp %= mod;       ans += (((pre[i - 2] * t) % mod) + (((temp)*suf[i]) % mod)) % mod;       ans %= mod;       t = ((t % mod) * power(10, mod - 2, mod)) % mod;     }     cout << (ans) % mod <<   n ;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     sum();     return 0;   }
#include <bits/stdc++.h>   int a[100005], s[100005];   int main() {     int l, r, q1, q2, i, N, S;     scanf( %d%d%d%d%d , &N, &l, &r, &q1, &q2);     s[0] = 0;     for (i = 1; i <= N; i++) {       scanf( %d , &a[i]);       s[i] = s[i - 1] + a[i];     }     int mx = s[N] * l + q1 * (N - 1);     for (i = 0; i <= N; i++) {       int t = s[i] * l + (s[N] - s[i]) * r;       int p = N - 2 * i;       if (p < 0) p = -p;       if (p) p--;       if (l > r)         t += p * q2;       else         t += p * q1;       if (t < mx) mx = t;     }     printf( %d n , mx);   }
#include <bits/stdc++.h>   using namespace std;   int arr[1000] = {0};   int main() {     int n, m, i, j, k;     cin >> n;     for (i = 0; i < n; i++) cin >> arr[i];     if (n % 2 == 0) {       cout <<  No  << endl;       return 0;     } else {       if (arr[0] % 2 == 1 && arr[n - 1] % 2 == 1) {         cout <<  Yes  << endl;       } else         cout <<  No  << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int pages, readPages[7];     scanf( %d , &pages);     for (int i = 0; i < 7; i++) scanf( %d , &readPages[i]);     int day = 1, i = 0;     while (pages > 0) {       if (day == 8) day = 1;       if (i == 7) i = 0;       pages -= readPages[i];       day++, i++;     }     printf( %d n , day - 1);     return 0;   }