malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, x;   bool vis[300010];   int a[300010];   int ans = 1;   int main() {     scanf( %d , &n);     x = n;     printf( %d  , ans);     for (int i = 1; i < n; i++) {       scanf( %d , &a[i]);       vis[a[i]] = 1;       bool p = 0;       bool v = 0;       while (vis[x]) {         ans--;         x--;       }       ans++;       printf( %d  , ans);     }     printf( %d  , 1);   }
#include <bits/stdc++.h>   using namespace std;   struct piece {     int x, y;     char p[20][20];     piece(int _x, int _y) : x(_x), y(_y) {}     bool operator<(const piece& rhs) const {       if ((x * y) != (rhs.x * rhs.y))         return (x * y) < (rhs.x * rhs.y);       else         return x < rhs.x;     }   };   struct Piece {     int x, y;     char p[20][20];     Piece() {}     bool operator==(const Piece& rhs) const {       bool eq = true;       for (int i = 0; i < x; i++)         for (int j = 0; j < y; j++)           if (p[i][j] != rhs.p[i][j]) {             eq = false;             goto n1;           }     n1:       if (eq) return true;       char tmp[20][20];       if (x == y) {         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++) tmp[i][j] = rhs.p[y - (j + 1)][i];         eq = true;         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++)             if (p[i][j] != tmp[i][j]) {               eq = false;               goto n2;             }       n2:         if (eq) return true;       }       for (int i = 0; i < x; i++)         for (int j = 0; j < y; j++) tmp[i][j] = rhs.p[x - (i + 1)][y - (j + 1)];       eq = true;       for (int i = 0; i < x; i++)         for (int j = 0; j < y; j++)           if (p[i][j] != tmp[i][j]) {             eq = false;             goto n3;           }     n3:       if (eq) return true;       if (x == y) {         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++) tmp[i][j] = rhs.p[j][x - (i + 1)];         eq = true;         for (int i = 0; i < x; i++)           for (int j = 0; j < y; j++)             if (p[i][j] != tmp[i][j]) {               eq = false;               goto n4;             }       n4:         if (eq) return true;       }       return false;     }   };   char p[20][20];   set<int> fa, fb;   set<piece> P;   int a, b;   int good(int x, int y) {     vector<Piece> ps;     int ih = a / x, jh = b / y;     for (int i = 1; i <= ih; i++)       for (int j = 1; j <= jh; j++) {         Piece tmp;         tmp.x = x;         tmp.y = y;         int kh = (i - 1) * x + x - 1, lh = (j - 1) * y + y - 1;         for (int k = (i - 1) * x, m = 0; k <= kh; k++, m++)           for (int l = (j - 1) * y, n = 0; l <= lh; l++, n++)             tmp.p[m][n] = p[k][l];         for (unsigned int k = 0; k < ps.size(); k++)           if (ps[k] == tmp) return false;         ps.push_back(tmp);       }     return true;   }   int main() {     cin >> a >> b;     for (int i = 0; i < a; i++)       for (int j = 0; j < b; j++) cin >> p[i][j];     for (int i = 1; i <= a; i++)       if (!(a % i)) fa.insert(i);     for (int i = 1; i <= b; i++)       if (!(b % i)) fb.insert(i);     for (set<int>::iterator ita = fa.begin(); ita != fa.end(); ita++)       for (set<int>::iterator itb = fb.begin(); itb != fb.end(); itb++) {         int x = *ita, y = *itb;         if (good(x, y)) P.insert(piece(x, y));       }     cout << P.size() << endl;     cout << (*(P.begin())).x <<     << (*(P.begin())).y << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t > 0) {       int a[3];       for (int i = 0; i < 3; i++) {         cin >> a[i];       }       sort(a, a + 3);       long c;       if (a[0] == a[1] && a[1] == a[2])         c = 0;       else if (a[0] == a[1] && a[2] - a[0] > 1) {         c = (a[2] - 1) * 2 - (a[0] + a[1] + 2);       } else if (a[0] == a[1] && a[2] - a[0] == 1) {         c = 0;       } else if (a[1] == a[2] && a[2] - a[0] > 1) {         c = (a[1] + a[2] - 2) - (a[0] + 1) * 2;       } else if (a[1] == a[2] && a[2] - a[0] == 1) {         c = 0;       } else {         c = a[1] - a[0] - 1 + a[2] - 1 - a[1] + a[2] - a[0] - 2;       }       cout << c <<   n ;       t--;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int l, r, i, j, d, tp;     cin >> l >> r;     bool f;     for (i = l; i <= r; i++) {       tp = i;       int arr[10];       for (j = 0; j < 10; j++) arr[j] = 0;       while (tp > 0) {         d = tp % 10;         tp = tp / 10;         arr[d]++;       }       f = true;       for (j = 0; j < 10; j++) {         if (arr[j] <= 1)           f = true;         else {           f = false;           break;         }       }       if (!f)         f = false;       else {         cout << i;         f = true;         break;       }     }     if (!f) cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using VI = vector<int>;   using VC = vector<char>;   using VS = vector<string>;   using VL = vector<long long>;   using VVI = vector<VI>;   using VVL = vector<VL>;   using MII = map<int, int>;   using MIVI = map<int, VI>;   using MSS = map<string, string>;   using MLL = map<LL, LL>;   int READ_INT() {     int temp;     cin >> temp;     return temp;   }   LL READ_LONG() {     LL temp;     cin >> temp;     return temp;   }   void mcs(VI &series, int &max_sum) {     int s = 0;     for (auto x : series) {       s += x;       max_sum = max(max_sum, s);       if (s < 0) s = 0;     }   }   template <typename T>   T MAX(T t) {     return t;   }   template <typename T, typename... Args>   T MAX(T t, Args... args) {     return max(t, MAX(args...));   }   const int MOD = int(1e9) + 7;   const int INF = 1e9 + 5;   const double PI = acos(-1.0);   const double EPS = 1e-9;   int n, m, k;   int matrix[105][105][105];   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 1; i < n + 1; ++i) {       for (int j = 1; j < m + 1; ++j) {         string s;         cin >> s;         for (int q = 0; q < k; ++q) {           matrix[i][j][q + 1] = s[q] -  0 ;         }       }     }     int count = 0;     int l = k;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         for (int k = 1; k <= l; ++k) {           if (matrix[i][j][k] == 0) continue;           int t = 0;           t += (matrix[i][j][k - 1] && matrix[i][j][k + 1]);           t += (matrix[i][j - 1][k] && matrix[i][j + 1][k]);           t += (matrix[i - 1][j][k] && matrix[i + 1][j][k]);           if ((matrix[i][j][k - 1] && matrix[i][j + 1][k]) &&               matrix[i][j + 1][k - 1] == 0)             t++;           if ((matrix[i][j - 1][k] && matrix[i][j][k + 1]) &&               matrix[i][j - 1][k + 1] == 0)             t++;           if ((matrix[i][j - 1][k] && matrix[i + 1][j][k]) &&               matrix[i + 1][j - 1][k] == 0)             t++;           if ((matrix[i - 1][j][k] && matrix[i][j + 1][k]) &&               matrix[i - 1][j + 1][k] == 0)             t++;           if ((matrix[i - 1][j][k] && matrix[i][j][k + 1]) &&               matrix[i - 1][j][k + 1] == 0)             t++;           if ((matrix[i][j][k - 1] && matrix[i + 1][j][k]) &&               matrix[i + 1][j][k - 1] == 0)             t++;           if (t) count++;         }       }     }     cout << count <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 15000001;   int64_t primes[N];   int64_t gcd(int64_t a, int64_t b) {     if (a == 0)       return b;     else       return gcd(b % a, a);   }   int64_t Power(int64_t base, int64_t e) {     if (e == 0) return 1;     int64_t ans = base;     e--;     while (e) {       if (e & 1) ans = (ans * base);       base = (base * base);       e >>= 1;     }     return (ans);   }   void sieve() {     for (int64_t i = 2; i <= N; i++) {       if (primes[i] == -1) {         for (int64_t j = i; j <= N; j += i) primes[j] = i;       }     }   }   int main() {     for (int64_t i = 0; i < N; i++) {       primes[i] = -1;     }     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     sieve();     map<int64_t, int64_t> mp;     int64_t n;     cin >> n;     int64_t a[n];     int64_t tmp;     for (int64_t i = 0; i < n; i++) cin >> a[i];     int64_t ggcd;     ggcd = a[0];     for (int64_t i = 0; i < n; i++) {       ggcd = gcd(ggcd, a[i]);     }     int64_t ggcd2 = 1;     for (int64_t i = 0; i < n; i++) {       a[i] = a[i] / ggcd;     }     for (int64_t i = 0; i < n; i++) {       tmp = a[i];       while (tmp > 1) {         int64_t y = primes[tmp];         while (tmp % y == 0) {           tmp = tmp / y;         }         mp[y]++;       }     }     int64_t freq = 0;     int64_t val = ggcd;     for (auto kk : mp) {       if (freq <= kk.second) {         val = kk.first;         freq = kk.second;       }     }     if (freq) {       cout << (n - freq) << endl;     } else       cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t, i, j, cnt, k, lo, hi, mid;     cin >> t;     while (t--) {       string s, t;       cin >> s >> t;       vector<long long int> v[26];       for (i = 0; s[i]; i++) {         v[s[i] -  a ].push_back(i);       }       bool flag = true;       cnt = 1;       j = -1;       for (i = 0; t[i]; i++) {         k = -1;         lo = 0;         hi = (int)v[t[i] -  a ].size() - 1;         while (lo <= hi) {           mid = (lo + hi) / 2LL;           if (v[t[i] -  a ][mid] > j) {             k = v[t[i] -  a ][mid];             hi = mid - 1;           } else {             lo = mid + 1;           }         }         if (j == -1 and k == -1) {           flag = false;           break;         } else if (k != -1) {           j = k;         } else {           j = -1;           i--;           cnt++;         }       }       if (!flag) cnt = -1;       cout << cnt <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (--t >= 0) {       long long a, b, c, d;       cin >> a >> b >> c >> d;       if (a <= b) {         cout << b << endl;         continue;       }       if (c <= d) {         cout << -1 << endl;         continue;       }       a -= b;       long long ans = b;       long long f;       if (a % (c - d) == 0)         f = a / (c - d);       else         f = a / (c - d) + 1;       ans += f * c;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a[10005];   int main() {     int n, x, k = 0;     cin >> n;     x = (sqrt(1.0 + 8 * n) + 1) / 2;     cout << x << endl;     for (int i = 1; i <= x; i++)       for (int j = i + 1; j <= x; j++) a[i].push_back(++k), a[j].push_back(k);     for (int i = 1; i <= x; i++, cout << endl)       for (int j = 0; j < a[i].size(); j++) cout << a[i][j] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[200010];   int n, k;   int sa[200010];   int ra[200010], tr[200010];   int lcp[200010];   int l[200010], r[200010];   stack<int> ls, rs;   set<long long> ss;   bool CmpSa(int a, int b) {     if (ra[a] != ra[b]) return ra[a] < ra[b];     int aa = a + k < n ? ra[a + k] : -1;     int bb = b + k < n ? ra[b + k] : -1;     return aa < bb;   }   void GaoSa() {     for (int i = 0; i <= n; ++i) {       sa[i] = i;       ra[i] = i < n ? s[i] : -1;     }     for (k = 1; k <= n; k <<= 1) {       sort(sa, sa + n + 1, CmpSa);       tr[sa[0]] = 0;       for (int i = 1; i <= n; ++i) {         tr[sa[i]] = tr[sa[i - 1]] + CmpSa(sa[i - 1], sa[i]);       }       memcpy(ra, tr, sizeof(int) * (n + 1));     }   }   void GaoLcp() {     int tmp = 0;     for (int i = 0; i < n; ++i) {       int rk = ra[i];       int j = sa[rk - 1];       if (tmp > 0) --tmp;       while (i + tmp < n && j + tmp < n && s[i + tmp] == s[j + tmp]) {         ++tmp;       }       lcp[rk - 1] = tmp;     }   }   inline long long Hash(int b, int c) { return b * 1000000ll + c; }   int main() {     scanf( %s , s);     n = strlen(s);     s[n] =  | ;     memcpy(s + n + 1, s, sizeof(char) * n);     n = 2 * n + 1;     GaoSa();     GaoLcp();     for (int i = 0; i <= n; ++i) {       while (!rs.empty() && lcp[rs.top()] > lcp[i]) {         r[rs.top()] = i;         rs.pop();       }       rs.push(i);     }     for (int i = n; i >= 0; --i) {       while (!ls.empty() && lcp[ls.top()] > lcp[i]) {         l[ls.top()] = i;         ls.pop();       }       ls.push(i);     }     long long ans = 0;     for (int i = 1; i < n - 1; ++i) {       if (lcp[i]) {         if (ss.find(Hash(lcp[i], l[i])) != ss.end()) continue;         long long tmp = (r[i] - l[i]) / 2;         tmp = tmp * (tmp + 1) / 2;         ans += tmp * (lcp[i] - max(lcp[l[i]], lcp[r[i]]));         ss.insert(Hash(lcp[i], l[i]));       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename G, typename H>   struct triple {     G first, second, T;     triple(G x, G y, G z) : first(x), second(y), T(z) {}     triple() : first(0), second(0), T(0) {}     bool operator<(const triple<G, H> other) const { return first > other.first; }   };   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     vector<int> v(m);     for (auto &i : v) cin >> i;     sort(v.begin(), v.end());     int g, r;     cin >> g >> r;     int oo = 2e9;     vector<vector<int>> dp(m, vector<int>(g + 1, oo));     dp[0][g] = 0;     deque<pair<int, int>> pq;     pq.push_back({0, g});     while (!pq.empty()) {       pair<int, int> t = pq.front();       pq.pop_front();       if (t.second == 0 && dp[t.first][g] > dp[t.first][t.second] + 1) {         dp[t.first][g] = dp[t.first][t.second] + 1;         pq.push_back({t.first, g});       }       if (t.second != 0) {         int i = t.first, j = t.second;         if (i > 0) {           int w = v[i] - v[i - 1];           if (w <= j && dp[i - 1][j - w] > dp[i][j]) {             dp[i - 1][j - w] = dp[i][j];             pq.push_front({i - 1, j - w});           }         }         if (i < m - 1) {           int w = v[i + 1] - v[i];           if (w <= j && dp[i + 1][j - w] > dp[i][j]) {             dp[i + 1][j - w] = dp[i][j];             pq.push_front({i + 1, j - w});           }         }       }     }     int ans = oo;     for (int i = 0; i <= g; i++)       if (dp[m - 1][i] != oo) ans = min(ans, dp[m - 1][i] * (r + g) + g - i);     if (ans == oo) ans = -1;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e2 + 10;   const int INF = 1 << 30;   char str[MAXN][MAXN];   int Pow(int a, int b) {     if (b == 0) return 1;     int res = 1;     while (b--) res *= a;     return res;   }   int main() {     int a, b, n;     while (scanf( %d%d%d , &a, &b, &n) != EOF) {       if (a == 0) {         if (b == 0)           printf( 1 n );         else           printf( No solution n );         continue;       }       if (b % a) {         printf( No solution n );         continue;       }       a = b / a;       int res = -INF;       if (a < 0) {         a = -a;         if (n % 2 == 0) {           printf( No solution n );           continue;         }         for (int i = 0; i <= 1000; i++) {           if (Pow(i, n) == a) {             res = i;             break;           }           if (Pow(i, n) > a) break;         }         res = -res;       } else {         for (int i = 0; i <= 1000; i++) {           if (Pow(i, n) == a) {             res = i;             break;           }           if (Pow(i, n) > a) break;         }       }       if (res == -INF) {         printf( No solution n );       } else {         printf( %d n , res);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   const int maxn = 2e5 + 10;   int a[maxn];   char s[maxn];   const char *t =  LR ;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     scanf( %s , s);     bool rev = s[0] ==  R ;     int cnt = 0;     for (int i = 1; i < n; i++) {       cnt += s[i] == s[i - 1];     }     printf( %d %c n , a[cnt], t[rev]);     int l = cnt, r = cnt;     for (int i = 1; i < n; i++) {       if (s[i] == s[i - 1])         l--, printf( %d %c n , a[l], t[((cnt - l) & 1) ^ rev]);       else         r++, printf( %d %c n , a[r], t[((r - cnt) & 1) ^ rev]);     }   }
#include <bits/stdc++.h>   using namespace std;   long long po(long long x, long long n) {     long long res = 1;     while (n > 0) {       if (n & 1) res = (res * x) % 998244353;       n = n / 2;       x = (x * x) % 998244353;     }     return res;   }   long long fac[500000 + 1] = {0};   long long ifac[500000 + 1] = {0};   void pre() {     fac[0] = ifac[0] = 1;     for (int i = 1; i <= 500000; i++) {       fac[i] = (i * fac[i - 1]) % 998244353;       ifac[i] = po(fac[i], 998244353 - 2);     }   }   long long nCr(long long n, long long r) {     if (r > n || r < 0 || n < 0) return 0;     return (((fac[n] * ifac[r]) % 998244353) * ifac[n - r]) % 998244353;   }   void func() {     long long n, k;     cin >> n >> k;     long long ans = 0;     pre();     for (int i = 1; i <= n; i++) {       ans = (ans + nCr(n / i - 1, k - 1)) % 998244353;     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) func();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m;     cin >> n >> m;     long long int a[n];     for (long long int i = 0; i < n; i++) {       a[i] = 0;     }     long long int x;     for (long long int i = 0; i < m; i++) {       cin >> x;       a[x - 1] += 1;     }     long long int min = (m > n) ? m : n;     for (long long int i = 0; i < n; i++) {       if (a[i] < min) min = a[i];     }     cout << min << endl;     return 0;   }
#include <bits/stdc++.h>   const int maxn = 11111;   struct dsu {     int f[555];     int c;     void init() {       int i;       c = 0;       for (i = 1; i <= 505; i++) f[i] = i;     }     int find(int a) { return f[a] == a ? a : f[a] = find(f[a]); }     void Union(int x, int y) {       x = find(x), y = find(y);       if (x != y) f[x] = y, c++;     }   } L[maxn], R[maxn];   int l[maxn], r[maxn];   int main() {     int n, m, i, j, k, a, b;     scanf( %d%d , &n, &m);     L[0].init(), R[m + 1].init();     for (i = 1; i <= m; i++) scanf( %d%d , &l[i], &r[i]);     for (i = 1; i <= m; i++) L[i] = L[i - 1], L[i].Union(l[i], r[i]);     for (i = m; i >= 1; i--) R[i] = R[i + 1], R[i].Union(l[i], r[i]);     scanf( %d , &k);     while (k--) {       scanf( %d%d , &a, &b);       dsu t = L[a - 1];       for (i = 1; i <= n; i++) t.Union(i, R[b + 1].f[i]);       printf( %d n , n - t.c);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000 + 2;   vector<int> G[MAXN];   double f[MAXN];   int siz[MAXN];   int pa[MAXN];   void dfs(int u) {     for (int i = 0; i < G[u].size(); ++i) {       int v = G[u][i];       f[v] = f[u] + 1.0 + (siz[u] - siz[v] - 1.0) / 2.0;       dfs(v);     }   }   void solve(int n) {     for (int i = n; i >= 1; --i) {       ++siz[i];       siz[pa[i]] += siz[i];     }     f[1] = 1;     dfs(1);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 2; i <= n; ++i) {       scanf( %d , pa + i);       G[pa[i]].push_back(i);     }     solve(n);     for (int i = 1; i <= n; ++i) printf( %.15f  , f[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   void sc(int &x) { scanf( %d , &x); }   void sc(int &x, int &y) { scanf( %d%d , &x, &y); }   void sc(int &x, int &y, int &z) { scanf( %d%d%d , &x, &y, &z); }   void sc(long long &x) { scanf( %lld , &x); }   void sc(long long &x, long long &y) { scanf( %lld%lld , &x, &y); }   void sc(long long &x, long long &y, long long &z) {     scanf( %lld%lld%lld , &x, &y, &z);   }   void sc(char *x) { scanf( %s , x); }   void sc(char *x, char *y) { scanf( %s%s , x, y); }   void sc(char *x, char *y, char *z) { scanf( %s%s%s , x, y, z); }   void out(int x) { printf( %d n , x); }   void out(long long x) { printf( %lld n , x); }   void out(int x, int y) { printf( %d %d n , x, y); }   void out(long long x, long long y) { printf( %lld %lld n , x, y); }   void out(int x, int y, int z) { printf( %d %d %d n , x, y, z); }   void out(long long x, long long y, long long z) {     printf( %lld %lld %lld n , x, y, z);   }   void ast(long long x, long long l, long long r) { assert(x >= l && x <= r); }   using namespace std;   const int N = 6e3 + 5, mod = 1e9 + 7;   int n, x[N], y[N];   int vis[2][2];   int gcd(int x, int y) { return !y ? x : gcd(y, x % y); }   int cal(int i, int j) {     int xx = abs(x[i] - x[j]), yy = abs(y[i] - y[j]);     xx = gcd(xx, yy);     return xx * 2;   }   void sol(int cas) {     sc(n);     for (int i = 1; i <= n; i++) sc(x[i], y[i]);     for (int i = 1; i <= n; i++) x[i] >>= 1, y[i] >>= 1, x[i] &= 1, y[i] &= 1;     long long ans = 0;     for (int i = 1; i <= n; i++) {       memset(vis, 0, sizeof(vis));       for (int j = n; j >= i + 1; j--) {         for (int h = 0; h <= 1; h++)           for (int k = 0; k <= 1; k++) {             int s = x[i] * y[j] + x[j] * y[i] + x[i] * k + h * y[i] + x[j] * k +                     h * y[j];             s &= 1;             if (s == 0) ans += vis[h][k];           }         vis[x[j]][y[j]]++;       }     }     out(ans);   }   void init() {}   int main() {     srand(time(0));     init();     int t = 1, cas = 0;     while (t--) {       sol(++cas);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 100009;   int arr[MX];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) scanf( %d , arr + i);     int add = 0;     for (int i = 0; i < m; ++i) {       int cmd;       scanf( %d , &cmd);       if (cmd == 1) {         int idx, val;         scanf( %d%d , &idx, &val);         --idx;         arr[idx] = val - add;       } else if (cmd == 2) {         int val;         scanf( %d , &val);         add += val;       } else {         int idx;         scanf( %d , &idx);         --idx;         printf( %d n , arr[idx] + add);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p = 1000000000;     cin >> n;     int k[n], i;     for (i = 0; i < n; i++) {       cin >> k[i];     }     i = 0;     int j = 0, sum = 0;     while (n--) {       sum = 0;       while (k[i]--) {         cin >> j;         sum = sum + j * 5 + 15;       }       i++;       if (sum < p) {         p = sum;       }     }     cout << p;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000007;   const double eps = 0.000001;   int q(int i, int j, vector<int> &ps) {     if (i > j) return 0;     if (i) return ps[j] - ps[i - 1];     return ps[j];   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     int n = s.size();     vector<int> ps(n + 1, 0);     int ans = 0;     for (int i = 0; i < n; i++) {       ps[i + 1] = ps[i] + (int)(s[i] ==  a );     }     for (int i = 0; i < n; i++) {       for (int j = i; j <= n; j++) {         int cr = i - q(0, i, ps) + (n - j) - q(j + 1, n, ps) + q(i + 1, j, ps);         ans = max(ans, n - cr);       }     }     cout << ans << endl;     return 0;   }