malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1005;   const int W = 1005;   const long long inf = 1e18;   struct dsu {     vector<int> pr;     vector<int> weights;     vector<long long> beauties;     set<int> roots;     dsu(int _n) {       pr.resize(_n + 5);       weights.resize(_n + 5);       beauties.resize(_n + 5);       iota((pr).begin(), (pr).end(), 0);       for (int u = (1); u <= ((_n)); u += (+1)) {         roots.insert(u);       }     }     int find(int u) { return pr[u] == u ? u : pr[u] = find(pr[u]); }     bool unite(int u, int v) {       u = find(u);       v = find(v);       if (u != v) {         pr[u] = v;         beauties[v] += beauties[u];         weights[v] += weights[u];         roots.erase(u);         return true;       }       return false;     }   };   set<int> who[W];   long long dp[W];   int weights[N];   long long beauties[N];   bool done[W];   int n, m, max_w;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);     cin >> n >> m >> max_w;     dsu dg(n);     for (int u = (1); u <= ((n)); u += (+1)) {       int w;       cin >> w;       dg.weights[u] = weights[u] = w;     }     for (int u = (1); u <= ((n)); u += (+1)) {       long long b;       cin >> b;       dg.beauties[u] = beauties[u] = b;     }     for (int i = (0); i <= ((m)-1); i += (+1)) {       int u, v;       cin >> u >> v;       dg.unite(u, v);     }     done[0] = true;     for (int u : dg.roots) {       for (int w = (max_w); w >= (0); w += (-1)) {         if (w - dg.weights[u] < 0) {           break;         }         int ru = dg.find(u);         if (dp[w - dg.weights[u]] + dg.beauties[u] > dp[w] &&             !who[w - dg.weights[ru]].count(ru) && done[w - dg.weights[u]]) {           done[w] = true;           dp[w] = dp[w - dg.weights[u]] + dg.beauties[u];           who[w] = who[w - dg.weights[u]];           who[w].insert(ru);         }       }     }     for (int u = (1); u <= ((n)); u += (+1)) {       for (int w = (max_w); w >= (0); w += (-1)) {         if (w - weights[u] < 0) {           break;         }         int ru = dg.find(u);         if (dp[w - weights[u]] + beauties[u] > dp[w] &&             !who[w - weights[u]].count(ru) && done[w - weights[u]]) {           done[w] = true;           dp[w] = dp[w - weights[u]] + beauties[u];           who[w] = who[w - weights[u]];           who[w].insert(ru);         }       }     }     cout << *max_element(dp, dp + max_w + 1) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 152;   const int maxp = 51123987;   static int A[maxn], len;   static int opt[maxn][52][52][52], n, Ne[maxn][4];   char s[maxn];   static int idx[maxn * 10];   int main() {     scanf( %d n , &n);     for (int i = 1; i <= n; i++) {       s[++len] = getchar();       if (s[len] == s[len - 1]) len--;     }     for (int i = len; i; i--) {       int kd = s[i] ==  a ;       if (s[i] ==  b ) kd = 2;       if (s[i] ==  c ) kd = 3;       Ne[i][1] = Ne[i + 1][1];       Ne[i][2] = Ne[i + 1][2];       Ne[i][3] = Ne[i + 1][3];       Ne[i][kd] = i;     }     int mxl = (n - 1) / 3 + 1;     opt[Ne[1][1]][1][0][0] = 1;     opt[Ne[1][2]][0][1][0] = 1;     opt[Ne[1][3]][0][0][1] = 1;     for (int i = 1; i <= len; i++)       for (int j = 0; j <= mxl; j++)         for (int k = 0; k <= mxl; k++)           for (int l = 0; l <= mxl; l++) {             opt[Ne[i][1]][j + 1][k][l] =                 opt[Ne[i][1]][j + 1][k][l] + opt[i][j][k][l];             if (opt[Ne[i][1]][j + 1][k][l] >= maxp)               opt[Ne[i][1]][j + 1][k][l] -= maxp;             opt[Ne[i][2]][j][k + 1][l] =                 opt[Ne[i][2]][j][k + 1][l] + opt[i][j][k][l];             if (opt[Ne[i][2]][j][k + 1][l] >= maxp)               opt[Ne[i][2]][j][k + 1][l] -= maxp;             opt[Ne[i][3]][j][k][l + 1] =                 opt[Ne[i][3]][j][k][l + 1] + opt[i][j][k][l];             if (opt[Ne[i][3]][j][k][l + 1] >= maxp)               opt[Ne[i][3]][j][k][l + 1] -= maxp;           }     int ans = 0;     for (int i = 1; i <= len; i++) {       if (n % 3 == 0) ans = (ans + opt[i][mxl][mxl][mxl]) % maxp;       if (n % 3 == 1)         ans = (ans + opt[i][mxl - 1][mxl - 1][mxl] +                opt[i][mxl - 1][mxl][mxl - 1] + opt[i][mxl][mxl - 1][mxl - 1]) %               maxp;       if (n % 3 == 2)         ans = (ans + opt[i][mxl][mxl - 1][mxl] + opt[i][mxl - 1][mxl][mxl] +                opt[i][mxl][mxl][mxl - 1]) %               maxp;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char c[600];   vector<int> check;   int n;   vector<int> cal;   int calculate() {     int num = 0;     cal.clear();     int minimum = INT_MAX;     for (int i = 1; i <= n; i++) {       if (c[i - 1] ==  ( ) {         num++;         minimum = min(minimum, num);         cal.push_back(num);       } else {         num--;         minimum = min(minimum, num);         cal.push_back(num);       }     }     int ret = 0;     for (int i = 1; i <= n; i++) {       if (minimum == cal[i - 1]) {         ret++;       }     }     return ret;   }   int main() {     scanf( %d , &n);     scanf( %s , c);     int ans_l = 1, ans_r = 1;     int beauty = INT_MIN;     int cnt = 0;     for (int i = 1; i <= n; i++) {       if (c[i - 1] ==  ( ) {         cnt++;       } else {         cnt--;       }     }     if (cnt != 0) {       printf( 0 n1 1 );       return 0;     }     for (int i = 1; i <= n; i++) {       for (int j = i; j <= n; j++) {         char temp = c[j - 1];         c[j - 1] = c[i - 1];         c[i - 1] = temp;         int now_beauty = calculate();         if (beauty < now_beauty) {           beauty = now_beauty;           ans_l = i;           ans_r = j;         }         temp = c[j - 1];         c[j - 1] = c[i - 1];         c[i - 1] = temp;       }     }     printf( %d n%d %d , beauty, ans_l, ans_r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const long long MOD = 1e9 + 7;   const int N = 1e6;   int T, n, r, A[1005];   void solve() {     cin >> n >> r;     for (int i = 1; i <= n; i++) {       cin >> A[i];     }     int ans = 0;     int z;     for (int i = 1; i <= n; i = z + r) {       bool can_warm = false;       z = -1;       int left = max(i - r + 1, 0), right = min(i + r, n + 1);       for (int j = left; j < right; j++) {         if (A[j]) {           can_warm = true;           z = j;         }       }       if (!can_warm) {         cout << -1;         return;       }       ans++;     }     cout << ans;   }   int(main)() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     T = 1;     while (T--) {       solve();     }   }
#include<iostream>   #include<bits/stdc++.h>   using namespace std;   #define boost ios_base::sync_with_stdio(false); cin.tie(NULL)   #define ll unsigned long long int   #define tinput int t; cin>>t; while(t--)   #define rep(i,n,s) for((i)=(s); (i)<(n); (i)++)      template <typename T>   T getmini(T x, T y) { return (x<y)?x:y; }   template <typename T>   T getmaxi(T x, T y) { return (x>y)?x:y; }      int main(){       #ifndef ONLINE_JUDGE       freopen( b_input.txt ,  r , stdin);  freopen( b_output.txt ,  w , stdout);       #endif       boost;              tinput {        int x, y;        cin>>x>>y;        int ans = x+y;        if(abs(x-y)>1) {         ans = ans + abs(x-y) - 1;        }        cout<<ans<<endl;       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int pa[maxn], a[maxn], b[maxn];   struct Edge {     int u, v, w;     friend bool operator<(const Edge& a, const Edge& b) { return a.w > b.w; }   } e[maxn];   void init(int n) {     for (int i = 1; i <= n; i++) pa[i] = i, b[i] = 1;   }   int find(int x) {     if (x == pa[x]) return x;     return pa[x] = find(pa[x]);   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     init(n);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &e[i].u, &e[i].v);       e[i].w = min(a[e[i].u], a[e[i].v]);     }     sort(e + 1, e + m + 1);     double sum = 0;     for (int i = 1; i <= m; i++) {       int fu = find(e[i].u);       int fv = find(e[i].v);       if (fu != fv) {         sum += 1.0 * e[i].w * b[fu] * b[fv];         pa[fv] = fu;         b[fu] += b[fv];         b[fv] = 1;       }     }     printf( %.6f n , sum * 2 / (1.0 * n * (n - 1)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long M = 1e9 + 7;   long long power(long long a, long long p) {     if (p == 0) return 1;     long long ans = power(a, p / 2);     ans = (ans * ans) % M;     if (p % 2) ans = (ans * a) % M;     return ans;   }   int nC2(int n) { return (n * (n - 1)) / 2; }   int fact(int n) {     if (n == 0 || n == 1) {       return 1;     } else {       return n * fact(n - 1);     }   }   int countOne(int n) { return __builtin_popcount(n); }   int checkParity(int n) { return __builtin_parity(n); }   int digitCount(int n) { return floor(log10(n)) + 1; }   int log2(int x) {     int res = 0;     while (x >>= 1) res++;     return res;   }   int isPowerof2(int x) { return (x && !(x & x - 1)); }   bool is_prime(int n) {     if (n == 1) {       return false;     }     int i = 2;     while (i * i <= n) {       if (n % i == 0) {         return false;       }       i += 1;     }     return true;   }   int main() {     int test, n, m, x, y, counter = 0, sum = 0, ans = 0, res = 0, rem = 0;     bool flag = true;     bool check = true;     string s;     cin >> n;     for (int i = 0; i < n; i++) {       if (i % 2 == 0 && flag == true) {         cout <<  a ;         check = true;       } else if (i % 2 != 0 && check == true) {         cout <<  b ;         flag = false;       } else if (i % 2 == 0 && flag == false) {         cout <<  b ;         check = false;       } else if (i % 2 != 0 && check == false) {         cout <<  a ;         flag = true;       }     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void test_case();   long long power(int n, int p);   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       test_case();     }     return 0;   }   void test_case() {     int n, x;     cin >> n >> x;     vector<int> arr(n);     for (int i = 0; i < n; i++) cin >> arr[i];     sort(arr.begin(), arr.end());     int teams = 0;     int cnt = 1;     for (int ptr = n - 1; ptr >= 0; ptr--) {       if (arr[ptr] * cnt >= x) {         teams++;         cnt = 1;       } else         cnt++;     }     cout << teams <<   n ;   }   long long power(int n, int p) {     long long ans = 1;     if (p == 0) return 1;     long long temp = power(n, p / 2);     if (p % 2 == 0)       ans = (temp * temp) % 1000000007;     else {       ans = (ans * n) % 1000000007;       ans *= (temp * temp) % 1000000007;     }     return ans;   }
#include <bits/stdc++.h>   using namespace std;   struct rec {     int l, r;   };   rec f[2222][2223];   bool can[2222][2223];   int n, m, k, x, y, xx, yy;   void del(int x, int y) {     can[x][y] = false;     for (int i = 1; i <= m; i++) {       f[x][i].l = f[x][i - 1].l;       if (can[x][i - 1]) f[x][i].l = i - 1;     }     for (int i = m; i >= 1; i--) {       f[x][i].r = f[x][i + 1].r;       if (can[x][i + 1]) f[x][i].r = i + 1;     }     return;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         f[i][j].l = j - 1;         f[i][j].r = j + 1;         can[i][j] = true;       }     for (int i = 1; i <= n; i++) {       f[i][m + 1].r = m + m;     }     while (k--) {       int ans = n + m + n + m;       scanf( %d%d , &x, &y);       for (int i = 1; i <= n; i++) {         int u = abs(i - x);         if (can[i][y]) {           if (ans > u) {             ans = u;             xx = i;             yy = y;           }         } else {           if (f[i][y].l > 0 && ans > u + abs(f[i][y].l - y)) {             ans = u + abs(f[i][y].l - y);             xx = i;             yy = f[i][y].l;           }           if (f[i][y].r < m + 1 && ans > u + abs(f[i][y].r - y)) {             ans = u + abs(f[i][y].r - y);             xx = i;             yy = f[i][y].r;           }         }         if (ans == 0) break;       }       printf( %d %d n , xx, yy);       del(xx, yy);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100007], b[100007], c[100007];   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 1; i < n + 1; i++) cin >> a[i];     for (int i = 1; i < n + 1; i++) {       if (a[i] > a[i - 1])         b[i] = b[i - 1] + 1;       else         b[i] = 1;     }     c[n] = 1;     a[n + 1] = INT_MAX;     for (int i = n - 1; i > 0; i--) {       if (a[i + 1] > a[i])         c[i] = c[i + 1] + 1;       else         c[i] = 1;     }     int mx = 0;     for (int i = 1; i < n + 1; i++) {       if (b[i] + 1 <= n)         mx = max(mx, b[i] + 1);       else         mx = max(mx, b[i]);       if (a[i - 1] + 1 < a[i + 1]) mx = max(mx, b[i - 1] + c[i + 1] + 1);     }     cout << mx << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       long long n, k, d1, d2;       cin >> n >> k >> d1 >> d2;       if (n % 3) {         cout <<  no n ;         continue;       }       int flag = 0;       long long x1, x2, x3;       if (2 * d1 + d2 + k <= n && (2 * d1 + d2 + k) % 3 == 0) {         x1 = (2 * d1 + d2 + k) / 3;         x3 = x1 - (d1 + d2);         x2 = x1 - d1;         if (x1 >= 0 && x2 >= 0 && x3 >= 0 && x1 <= n / 3 && x2 <= n / 3 &&             x3 <= n / 3)           flag = 1;       }       if (2 * d1 - d2 + k >= 0 && 2 * d1 - d2 + k <= n &&           (2 * d1 - d2 + k) % 3 == 0) {         x1 = (2 * d1 - d2 + k) / 3;         x3 = x1 - (d1 - d2);         x2 = x1 - d1;         if (x1 >= 0 && x2 >= 0 && x3 >= 0 && x1 <= n / 3 && x2 <= n / 3 &&             x3 <= n / 3)           flag = 1;       }       if (-2 * d1 + d2 + k >= 0 && -2 * d1 + d2 + k <= n &&           (-2 * d1 + d2 + k) % 3 == 0) {         x1 = (-2 * d1 + d2 + k) / 3;         x3 = x1 - (-1 * d1 + d2);         x2 = x1 + d1;         if (x1 >= 0 && x2 >= 0 && x3 >= 0 && x1 <= n / 3 && x2 <= n / 3 &&             x3 <= n / 3)           flag = 1;       }       if (-2 * d1 - d2 + k >= 0 && -2 * d1 - d2 + k <= n &&           (-2 * d1 - d2 + k) % 3 == 0) {         x1 = (-2 * d1 - d2 + k) / 3;         x3 = x1 - (-1 * d1 - d2);         x2 = x1 + d1;         if (x1 >= 0 && x2 >= 0 && x3 >= 0 && x1 <= n / 3 && x2 <= n / 3 &&             x3 <= n / 3)           flag = 1;       }       if (flag)         cout <<  yes n ;       else         cout <<  no n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int N = 132007;   int n, a, b;   int rev[N], fac[N], finv[N], f[N], g[N], h[N];   inline int qpow(int x, int k, int r = 1) {     for (; k; k >>= 1, x = 1ll * x * x % mod)       if (k & 1) r = 1ll * r * x % mod;     return r;   }   inline void ntt(int *a, int len, int opt) {     for (int i = 0; i < len; ++i)       if (i < rev[i]) swap(a[i], a[rev[i]]);     for (int i = 1; i < len; i <<= 1) {       int wn = qpow(3, (mod - 1) / (i << 1));       for (int j = 0; j < len; j += i << 1) {         int w = 1;         for (int k = 0; k < i; ++k, w = 1ll * w * wn % mod) {           int x = a[j + k], y = 1ll * a[j + k + i] * w % mod;           a[j + k] = (x + y) % mod;           a[j + k + i] = (x - y + mod) % mod;         }       }     }     if (~opt) return;     reverse(a + 1, a + len);     const int inv = qpow(len, mod - 2);     for (int i = 0; i < len; ++i) a[i] = 1ll * a[i] * inv % mod;   }   void solve(int n) {     if (!n) return g[1] = 1, void();     int t = n - 1 >> 1, mid = n + 1 >> 1, len = 1, bit = 0;     for (; len <= n + 2; len <<= 1, ++bit)       ;     solve(t);     for (int i = 0; i < len; ++i) rev[i] = rev[i >> 1] >> 1 | (i & 1) << bit - 1;     for (int i = f[0] = 1; i <= mid; ++i) f[i] = 1ll * f[i - 1] * mid % mod;     for (int i = 0; i <= mid; ++i)       f[i] = 1ll * f[i] * finv[i] % mod, h[i] = 1ll * g[i] * fac[i] % mod;     for (int i = mid + 1; i < len; ++i) f[i] = h[i] = 0;     reverse(f, f + mid + 2);     ntt(f, len, 1);     ntt(h, len, 1);     for (int i = 0; i < len; ++i) h[i] = 1ll * f[i] * h[i] % mod;     ntt(h, len, -1);     for (int i = 0; i <= mid; ++i) h[i] = 1ll * h[i + mid + 1] * finv[i] % mod;     for (int i = mid + 1; i < len; ++i) h[i] = 0;     ntt(g, len, 1);     ntt(h, len, 1);     for (int i = 0; i < len; ++i) g[i] = 1ll * g[i] * h[i] % mod;     ntt(g, len, -1);     if (n & 1) return;     for (int i = mid + mid + 1; i < len; ++i) g[i] = 0;     for (int i = len - 1; i; --i) g[i] = (g[i - 1] + 1ll * g[i] * n) % mod;   }   inline int C(int n, int m) {     return 1ll * fac[n] * finv[m] % mod * finv[n - m] % mod;   }   int main() {     scanf( %d%d%d , &n, &a, &b);     long long ans = 0;     if (a == b && a == 1) return printf( %d n , n == 1) & 0;     if (a + b > n + 1 || !a || !b) return printf( %d n , 0) & 0;     for (int i = fac[0] = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;     finv[n] = qpow(fac[n], mod - 2);     for (int i = n; i; --i) finv[i - 1] = 1ll * finv[i] * i % mod;     solve(n - 2);     return printf( %lld n , 1ll * g[a + b - 2] * C(a + b - 2, a - 1) % mod) & 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x;   vector<int> v;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &x);       int a = lower_bound(v.begin(), v.end(), x) - v.begin();       if (a == v.size())         v.push_back(x);       else         v[a] = x;     }     printf( %d n , v.size());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int b;     cin >> n >> b;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int mini[n];     mini[0] = a[0];     for (int i = 1; i < n; i++) {       mini[i] = min(mini[i - 1], a[i]);     }     int maxi = b;     for (int i = 1; i < n; i++) {       maxi = max(maxi, b % mini[i] + (b / mini[i]) * a[i]);     }     cout << maxi;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   int n, m, x, y, w, cnt, col[maxn], dis[maxn], vis[maxn], d[maxn], head[maxn];   struct node {     int nxt, to, val;   } e[maxn << 1];   void add(int x, int y, int w) {     e[++cnt].to = y;     e[cnt].nxt = head[x];     head[x] = cnt;     e[cnt].val = w;   }   queue<int> q;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       scanf( %d%d%d , &x, &y, &w);       add(y, x, w);     }     if (n == 1) {       cout <<  0  << endl <<  0 ;       return 0;     }     memset(col, -1, sizeof(col));     q.push(n);     vis[n] = 0;     while (q.size()) {       int x = q.front();       q.pop();       if (x == 1) {         break;       }       for (int i = head[x]; i; i = e[i].nxt) {         int v = e[i].to;         if (vis[v]) continue;         if (col[v] == -1 || col[v] == 1 - e[i].val) {           col[v] = 1 - e[i].val;         } else {           q.push(v);           d[v] = d[x] + 1;           vis[v] = 1;         }       }     }     if (d[1]) {       cout << d[1] << endl;     } else {       cout <<  -1  << endl;     }     for (int i = 1; i <= n; ++i) {       if (col[i] == -1) {         cout <<  0 ;       } else {         cout << col[i];       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int fpow(long long int n, long long int k,                      long long int p = 1000000007) {     long long int r = 1;     n = n % p;     while (k > 0) {       if (k & 1) {         r = (r * n) % p;       }       k = k >> 1;       n = (n * n) % p;     }     return r;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     if (n <= 9) {       cout << 1 <<   n ;       cout << n;     } else {       long long int ans = -1;       for (long long int i = 1; i <= 9; i++) {         if (n % i == 0) ans = i;       }       cout << n / ans <<   n ;       for (long long int i = 1; i <= n / ans; i++) cout << ans <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 51, MOD = 1e9 + 7;   struct Matrix {     int num[6][6];     Matrix() { memset(num, 0, sizeof(num)); }     inline int* operator[](const int& x) { return num[x]; }     inline const int* operator[](const int& x) const { return num[x]; }   };   Matrix mat, mat2, x, x2;   int f1, f2, f3, c, res;   long long int n;   inline long long int read() {     register long long int num = 0, neg = 1;     register char ch = getchar();     while (!isdigit(ch) && ch !=  - ) {       ch = getchar();     }     if (ch ==  - ) {       neg = -1;       ch = getchar();     }     while (isdigit(ch)) {       num = (num << 3) + (num << 1) + (ch -  0 );       ch = getchar();     }     return num * neg;   }   inline int qpow(int base, int exponent) {     int res = 1;     while (exponent) {       if (exponent & 1) {         res = (long long int)res * base % MOD;       }       base = (long long int)base * base % MOD, exponent >>= 1;     }     return res;   }   inline Matrix operator*(Matrix x, Matrix y) {     Matrix res;     for (register int i = 1; i <= 5; i++) {       for (register int j = 1; j <= 5; j++) {         for (register int k = 1; k <= 5; k++) {           res[i][j] = (res[i][j] + (long long int)x[i][k] * y[k][j] % (MOD - 1)) %                       (MOD - 1);         }       }     }     return res;   }   inline Matrix qpow(Matrix base, long long int exponent) {     Matrix res;     for (register int i = 1; i <= 5; i++) {       res[i][i] = 1;     }     while (exponent) {       if (exponent & 1) {         res = res * base;       }       base = base * base, exponent >>= 1;     }     return res;   }   int main() {     n = read(), f1 = read(), f2 = read(), f3 = read(), c = read(), res = 1;     mat[1][1] = mat[2][1] = mat[3][1] = mat[1][2] = mat[2][3] = mat[4][4] =         mat[5][4] = 1;     mat[5][5] = x[1][5] = mat2[1][1] = 1, mat[4][1] = 2, mat[5][1] = MOD - 5,     x[1][4] = 3;     mat2[2][1] = mat2[3][1] = mat2[1][2] = mat2[2][3] = x2[1][3] = 1;     res = qpow(c, (x * qpow(mat, n - 3))[1][1]);     res = (long long int)res * qpow(f1, (x2 * qpow(mat2, n - 3))[1][1]) % MOD,     x2[1][3] = 0, x2[1][2] = 1;     res = (long long int)res * qpow(f2, (x2 * qpow(mat2, n - 3))[1][1]) % MOD,     x2[1][2] = 0, x2[1][1] = 1;     res = (long long int)res * qpow(f3, (x2 * qpow(mat2, n - 3))[1][1]) % MOD,     printf( %d n , res);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t, i, n, ans = 0, k = 0, mx;     cin >> n;     long long int a[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     ans = a[0] / 3;     k = a[0] % 3;     for (i = 1; i < n; i++) {       mx = min(k, a[i] / 2);       ans += mx;       k -= mx;       a[i] -= 2 * mx;       ans += a[i] / 3;       k += a[i] % 3;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void data() {}   const int N = 1e6 + 100;   const long long mod = 998244353;   const long long mod2 = 1e9 + 7;   int main() {     data();     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long k;     cin >> k;     string second;     cin >> second;     vector<long long> pos;     long long ans = 0;     if (k == 0) {       long long ans = 0;       long long cur = 0;       for (long long i = 0; i < second.size(); i++) {         if (second[i] ==  0 ) {           cur++;         } else {           ans += cur * (cur + 1) / 2;           cur = 0;         }       }       ans += cur * (cur + 1) / 2;       cout << ans <<   n ;       return 0;     }     pos.push_back(0);     for (long long i = 0; i < second.size(); i++) {       if (second[i] ==  0 ) {         continue;       }       pos.push_back(i + 1);     }     pos.push_back(second.size() + 1);     long long cur = 0;     for (long long i = 0; i < second.size(); i++) {       if (second[i] ==  0 ) {         continue;       }       cur++;       if (cur >= k) {         ans += (pos[cur - k + 1] - pos[cur - k]) * (pos[cur + 1] - pos[cur]);       }     }     cout << ans;   }