malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, k;   int arr[200005];   int brr[200005];   priority_queue<int, vector<int>, greater<int> > q;   stack<int> s;   int vis[200005];   int main() {     while (cin >> n >> k) {       while (!q.empty()) q.pop();       while (!s.empty()) s.pop();       memset(vis, 0, sizeof(vis));       int kmax = 0;       for (int i = 0; i < k; i++) {         scanf( %d , &arr[i]);         vis[arr[i]] = 1;         kmax = max(kmax, arr[i]);       }       for (int i = 1; i <= kmax; i++) {         if (vis[i] == 0) {           q.push(i);         }       }       int indexb = 0;       for (int i = 0; i < k; i++) {         if (s.empty()) {           s.push(arr[i]);         } else if (arr[i] > s.top()) {           while (!s.empty() && arr[i] > s.top()) {             brr[indexb++] = s.top();             s.pop();           }           s.push(arr[i]);         } else {           s.push(arr[i]);         }       }       bool flag = true;       for (int i = 0; i < indexb; i++) {         if (brr[i] != i + 1) flag = false;       }       if (flag == false) {         cout << -1 << endl;         continue;       }       stack<int> choosing;       for (int i = 0; i < k; i++) printf( %d%c , arr[i], i == k - 1 ?     :    );       int cnt = 0;       while (!s.empty()) {         while (!q.empty() && q.top() < s.top()) {           choosing.push(q.top());           q.pop();         }         s.pop();         while (!choosing.empty()) {           printf( %d , choosing.top());           cnt++;           if (cnt == kmax - k && kmax == n)             printf(  n );           else             printf(   );           choosing.pop();         }       }       for (int i = n; i >= kmax + 1; i--) {         printf( %d%c , i, i == kmax + 1 ?   n  :    );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char ans[444444], a[444444];   long long h1[444444], h2[444444], p[444444];   int d1, d2, n;   bool check(int i, int e) {     if (i > n) return e;     int s = e ?  a  : a[i];     for (char x = s; x <=  z ; ++x) {       h1[i] = h1[i - 1] * 241 + x;       h2[i] = h2[i - 1] + p[i] * x;       h1[i] %= 1000000007;       h2[i] %= 1000000007;       if (i >= d1) {         long long t = (h1[i] - h1[i - d1] * p[d1]) % 1000000007 * p[i + 1 - d1] %                       1000000007;         long long q = h2[i] - h2[i - d1];         if ((t - q) % 1000000007 == 0) continue;       }       if (i >= d1) {         long long t = (h1[i] - h1[i - d2] * p[d2]) % 1000000007 * p[i + 1 - d2] %                       1000000007;         long long q = h2[i] - h2[i - d2];         if ((t - q) % 1000000007 == 0) continue;       }       ans[i] = x;       if (check(i + 1, e || (x > a[i]))) return 1;     }     return 0;   }   int main() {     scanf( %d , &d1);     d2 = d1 + 1;     scanf( %s , a + 1);     n = strlen(a + 1);     p[0] = 1;     ans[n + 1] =   0 ;     for (int i = 1; i <= n; ++i) p[i] = p[i - 1] * 241 % 1000000007;     if (check(1, 0))       printf( %s n , ans + 1);     else       puts( Impossible );   }
#include <bits/stdc++.h>   using namespace std;   string s;   char zh[125], ch, sw;   int n, m;   int main() {     cin >> n >> m >> s;     for (int i = 97; i <= 122; i += 1) {       zh[i] = i;     }     for (int i = 1; i <= m; i += 1) {       cin >> ch >> sw;       for (int j = 97; j <= 122; j += 1) {         if (zh[j] == ch) {           zh[j] = sw;         } else {           if (zh[j] == sw) {             zh[j] = ch;           }         }       }     }     for (int i = 0; i <= n - 1; i += 1) {       cout << zh[s[i]];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, res, dpa[4005][4005], s[4005], c[4005][4005];   long long combo(long long x, long long y) {     if (c[x][y] != 0) return c[x][y];     if (y == 0 || x == y) return c[x][y] = 1;     if (x == 0 || x < y) return 0;     return c[x][y] = (combo(x - 1, y - 1) + combo(x - 1, y)) % 1000000007;   }   int main() {     cin >> n;     dpa[0][0] = s[0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         dpa[i][j] = dpa[i - 1][j - 1] + dpa[i - 1][j] * j;         dpa[i][j] %= 1000000007;         s[i] += dpa[i][j];         s[i] %= 1000000007;       }     }     for (int i = 0; i < n; i++) {       res += combo(n, n - i) * s[i];       res %= 1000000007;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<string, long long> > Name(1010);   long long n;   vector<vector<pair<string, long long> > > a(1010);   map<string, long long> already;   map<string, long long>::iterator ii;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     long long i, j;     for (i = 1; i <= n; i++) {       string w;       long long version;       cin >> w >> version;       if (i == 1) {         already[w] = version;       }       Name[i] = make_pair(w, version);       long long m;       cin >> m;       for (j = 0; j < m; j++) {         cin >> w >> version;         a[i].push_back(make_pair(w, version));       }     }     vector<pair<string, long long> > q;     map<string, long long> pretendent;     q.push_back(Name[1]);     while (q.size() > 0) {       long long qs = 0, qf = q.size();       vector<pair<string, long long> > temp;       temp.clear();       pretendent.clear();       while (qs < qf) {         long long cur;         for (i = 1; i <= n; i++) {           if (Name[i].first == q[qs].first && Name[i].second == q[qs].second)             cur = i;         }         for (i = 0; i < a[cur].size(); i++) {           string task = a[cur][i].first;           long long version = a[cur][i].second;           if (already[task] == 0)             pretendent[task] = max(pretendent[task], version);         }         qs++;       }       q.clear();       for (ii = pretendent.begin(); ii != pretendent.end(); ii++) {         string task = ii->first;         long long version = ii->second;         already[task] = version;         q.push_back(make_pair(task, version));       }     }     if (already[Name[1].first] == Name[1].second) already.erase(Name[1].first);     cout << already.size() << endl;     for (ii = already.begin(); ii != already.end(); ii++) {       cout << ii->first <<     << ii->second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int dat[100000 + 10];   int vis[100000 + 10];   int dfs(int x) {     vis[x] = 1;     if (vis[dat[x]] == 0) return dfs(dat[x]) + 1;     return 1;   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> dat[i + 1];     }     vector<long long> g;     for (int i = 1; i <= n; i++) {       if (vis[i] == 0) {         g.push_back(dfs(i));       }     }     sort(g.begin(), g.end());     reverse(g.begin(), g.end());     if (g.size() == 0) {       cout <<  0  << endl;     } else if (g.size() == 1) {       cout << g[0] * g[0] << endl;     } else {       long long total = (g[0] + g[1]) * (g[0] + g[1]);       for (int i = 2; i < g.size(); i++) {         total += g[i] * g[i];       }       cout << total << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxx = (int)1e7;   long long SOD(long long n) {     long long ans = 0;     while (n) {       ans += (n % 10);       n /= 10;     }     return ans;   }   int main() {     int T;     cin >> T;     while (T--) {       vector<int> num;       long long n, s, nnn;       cin >> n >> s;       nnn = n;       if (SOD(n) <= s) {         cout << 0 << endl;         continue;       }       while (n) {         num.push_back(n % 10);         n /= 10;       }       reverse(num.begin(), num.end());       int sum = 0;       int start = 0;       for (int i = 0; i < num.size(); i++) {         sum += num[i];         if (sum >= s) {           if (i != 0 && num[i - 1] != 9) {             num[i - 1]++;             start = i;             break;           }           if (i == 0) {             num.insert(num.begin(), 1);             start = 1;             break;           } else if (num[i - 1] == 9) {             while (i != 0 && num[i - 1] == 9) {               i--;             }             i--;           }         }       }       for (int i = start; i < num.size(); i++) {         num[i] = 0;       }       int p = num.size() - 1;       long long nn = 0;       for (int i = 0; i < num.size(); i++) {         nn += num[i] * round(pow(10, p));         p--;       }       cout << (nn - nnn) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 100100;   int n, m, k;   int a[mx];   int pos[mx];   int main() {     ios::sync_with_stdio(0);     cin >> n >> m >> k;     long long ans = 0;     for (int i = 1; i <= k; i++) {       cin >> a[i];       pos[a[i]] = i;     }     while (n--) {       for (int i = 0, x; i < m; i++) {         cin >> x;         ans += pos[x];         for (int j = pos[x]; j > 1; j--) {           swap(a[j], a[j - 1]);           pos[a[j]]++;         }         pos[x] = 1;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, t;     cin >> n >> t;     long long int i, a, c, ans, k = 0, f = 0;     for (i = 0; i < n; i++) {       cin >> a;       c = 86400 - a;       if (a == 0) {         c = 86400;       }       k += c;       if (k >= t && f == 0) {         ans = i + 1;         f = 100;       }     }     if (n == 1) {       cout << 1 << endl;       return 0;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1e6;   int st[MX * 4], la[MX * 4], tin[MX], tout[MX], t, n;   vector<int> chd[MX];   void dfs(int u) {     tin[u] = ++t;     for (auto c : chd[u]) {       dfs(c);     }     tout[u] = t;   }   void push(int v) {     st[v * 2] += la[v];     la[v * 2] += la[v];     st[v * 2 + 1] += la[v];     la[v * 2 + 1] += la[v];     la[v] = 0;   }   void upd(int a, int b, int val, int v = 1, int l = 1, int r = n) {     if (b < l || r < a) return;     if (a <= l && r <= b) {       st[v] += val;       la[v] += val;     } else {       push(v);       int m = (l + r) / 2;       upd(a, b, val, v * 2, l, m);       upd(a, b, val, v * 2 + 1, m + 1, r);       st[v] = max(st[v * 2], st[v * 2 + 1]);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int k;     cin >> n >> k;     vector<pair<int, int>> stk;     for (int i = 0; i < n; ++i) {       int a;       cin >> a;       while (!stk.empty() && stk.back().first < a) {         chd[i].push_back(stk.back().second);         stk.pop_back();       }       stk.emplace_back(a, i);     }     for (auto [a, i] : stk) {       dfs(i);     }     for (int i = 0; i < n; ++i) {       upd(tin[i], tout[i], 1);       if (i >= k - 1) {         if (i >= k) {           upd(tin[i - k], tout[i - k], -1);         }         cout << st[1] <<    ;       }     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int maxPrime[10000005];   long long cnt_prime[10000005];   int primes[10000005];   int cnt_p;   void init() {     for (int i = 2; i < 10000005; i += 2) maxPrime[i] = 2;     for (int i = 3; i * i < 10000005; i += 2) {       if (maxPrime[i] == i || maxPrime[i] == 0) {         maxPrime[i] = i;         for (int j = i * 2; j < 10000005; j += i) {           maxPrime[j] = i;         }       }     }     for (int i = 2; i < 10000005; i++) {       if (maxPrime[i] == 0) maxPrime[i] = i;       if (maxPrime[i] == i) {         primes[cnt_p++] = i;       }     }   }   bool good(long long x) {     for (int i = 0; i < cnt_p; i++) {       long long temp = x;       long long res = 0;       while (temp) {         temp /= primes[i];         res += temp;       }       if (res < cnt_prime[primes[i]]) return false;     }     return true;   }   int main() {     long long sum = 0;     int n;     int maxx = 0;     init();     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a;       scanf( %d , &a);       maxx = max(maxx, a);       sum += a;       cnt_prime[a]++;     }     for (int i = maxx; i >= 2; i--) {       cnt_prime[i] += cnt_prime[i + 1];     }     for (int i = maxx; i >= 2; i--) {       cnt_prime[i / maxPrime[i]] += cnt_prime[i];       if (maxPrime[i] != i) {         cnt_prime[maxPrime[i]] += cnt_prime[i];       }     }     long long left = maxx, right = sum;     while (left <= right) {       long long mid = (left + right) / 2;       if (good(mid)) {         right = mid - 1;       } else {         left = mid + 1;       }     }     cout << left << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long DP[1000000];   long long counter[1000000];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       counter[x]++;     }     DP[0] = 0;     DP[1] = counter[1];     for (int i = 0; i < 1000000; i++) {       DP[i] = max(DP[i - 1], DP[i - 2] + counter[i] * i);     }     cout << DP[1000000 - 1];   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);   }   const long long maxn = 100;   long long mas[maxn], mas2[maxn];   vector<pair<long long, long long> > cur;   vector<pair<long long, long long> > ans[maxn];   void split(long long n) {     cur.clear();     long long a, b;     a = 1, b = 1;     for (long long i = 2; i <= n; i++) {       if (mas[i] == mas[i - 1] + 1) {         b = i;       } else {         cur.push_back({a, b});         a = i, b = i;       }     }     cur.push_back({a, b});   }   signed main() {     fast();     long long n, i, j, p, k, a, b;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> mas[i];     }     long long x;     p = 0;     while (true) {       split(n);       long long sz = cur.size();       if (sz == 1) {         break;       }       p++;       x = mas[n];       if (x == n) {         x = mas[cur[sz - 2].second];         for (i = 1; i <= n; i++) {           if (mas[i] == x + 1) {             if (i != 1) {               ans[p].push_back({1, i - 1});             }             ans[p].push_back({i, cur[sz - 2].first - 1});             ans[p].push_back(cur[sz - 2]);             ans[p].push_back(cur[sz - 1]);             k = 1;             for (j = cur[sz - 1].first; j <= cur[sz - 1].second; j++) {               mas2[k] = mas[j];               k++;             }             for (j = cur[sz - 2].first; j <= cur[sz - 2].second; j++) {               mas2[k] = mas[j];               k++;             }             for (j = i; j <= cur[sz - 2].first - 1; j++) {               mas2[k] = mas[j];               k++;             }             if (i != 1) {               for (j = 1; j <= i - 1; j++) {                 mas2[k] = mas[j];                 k++;               }             }             for (k = 1; k <= n; k++) {               mas[k] = mas2[k];             }             break;           }         }       } else {         for (i = 1; i <= n; i++) {           if (mas[i] == x + 1) {             if (i != 1) {               ans[p].push_back({1, i - 1});             }             ans[p].push_back({i, cur[sz - 1].first - 1});             ans[p].push_back(cur[sz - 1]);             k = 1;             for (j = cur[sz - 1].first; j <= cur[sz - 1].second; j++) {               mas2[k] = mas[j];               k++;             }             for (j = i; j <= cur[sz - 1].first - 1; j++) {               mas2[k] = mas[j];               k++;             }             if (i != 1) {               for (j = 1; j <= i - 1; j++) {                 mas2[k] = mas[j];                 k++;               }             }             for (k = 1; k <= n; k++) {               mas[k] = mas2[k];             }             break;           }         }       }     }     cout << p << endl;     for (i = 1; i <= p; i++) {       cout << ans[i].size() <<    ;       for (j = 0; j < ans[i].size(); j++) {         cout << ans[i][j].second - ans[i][j].first + 1 <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void _fill_int(int* p, int val, int rep) {     int i;     for (i = 0; i < rep; i++) p[i] = val;   }   signed long long GETi() {     signed long long i;     scanf( %lld , &i);     return i;   }   int N, A[100001];   void solve() {     int f, i, j, k, l, x, y;     cin >> N;     for (i = 0; i < N; i++) cin >> A[i];     sort(A, A + N);     if (N == 1) return (void)printf( -1 n );     if (A[0] == A[N - 1]) return (void)printf( 1 n%d n , A[0]);     if (N == 2 && (A[1] - A[0]) % 2 == 0)       return (void)printf( 3 n%d %d %d n , A[0] - (A[1] - A[0]),                           A[0] + (A[1] - A[0]) / 2, A[1] + (A[1] - A[0]));     int mi = A[1] - A[0];     for (i = 0; i < N - 1; i++) mi = min(mi, A[i + 1] - A[i]);     x = -1;     for (i = 0; i < N - 1; i++) {       if (A[i + 1] - A[i] == mi)         continue;       else if (A[i + 1] - A[i] == 2 * mi && x == -1)         x = i;       else         return (void)printf( 0 n );     }     if (x == -1)       (void)printf( 2 n%d %d n , A[0] - mi, A[N - 1] + mi);     else       (void)printf( 1 n%d n , A[x] + mi);   }   int main(int argc, char** argv) {     string s;     if (argc == 1) ios::sync_with_stdio(false);     for (int i = 1; i < argc; i++) s += argv[i], s +=   n ;     for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> g;   vector<int> vis, d;   void dfs(int v, int c) {     d[v] = c;     vis[v] = true;     for (int u : g[v]) {       if (!vis[u]) dfs(u, c + 1);     }   }   void solve() {     int n, m;     cin >> n >> m;     g.resize(n + 1, vector<int>());     vis.resize(n + 1, false);     d.resize(n + 1, -1);     while (m--) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     dfs(1, 0);     int u = max_element(d.begin(), d.end()) - d.begin();     vis.clear();     vis.resize(n + 1, false);     dfs(u, 0);     cout << (*max_element(d.begin(), d.end())) <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     while (T--) {       solve();     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000 )   using namespace std;   int n, m;   pair<int, pair<int, int> > a[100010];   pair<int, int> g[100010];   int r[100010];   void solve() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> a[i].first >> a[i].second.first;       a[i].second.first *= -1;       a[i].second.second = i;     }     for (int i = 0; i < n; i++) r[i] = i + 1;     sort(a, a + m);     int cur = 0;     int lst = 0;     for (int i = 0; i < m; i++) {       if (a[i].second.first == -1) {         cur = 1;         lst++;         g[a[i].second.second] = pair<int, int>(0, lst);       } else {         while (cur < lst && r[cur] > lst) cur++;         if (cur >= lst) {           cout << -1;           return;         }         g[a[i].second.second] = pair<int, int>(cur, r[cur]);         r[cur]++;       }     }     for (int i = 0; i < m; i++) {       cout << g[i].first + 1 <<     << g[i].second + 1 << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     srand(88);     solve();     return 0;   }
#include <bits/stdc++.h>      #define endl   n    #define fi first   #define se second   #define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))   #define forn(i,n) for (int i = 0; i < int(n); i++)   #define forr(i,a,b) for (int i = a; i <= b; i++)   #define all(v) v.begin(), v.end()   #define pb push_back      using namespace std;      typedef long long ll;   typedef long double ld;   typedef pair<int, int> ii;   typedef vector<int> vi;   typedef vector<vi> vvi;   typedef vector<ii> vii;      const int MX = 405, mod = 998244353;   int n, c[26];   ll dp[2][MX][MX][2][2][2][2], res;      int main () {    ios_base::sync_with_stdio(0); cin.tie(0);        cin >> n;    forn (i, 26)     cin >> c[i];        int x = 0, y = 1 - x;        forn (a, 2) forn (b, 2) forn (c, 2) forn (d, 2)     dp[x][n + 1][n + 1][a][b][c][d] = 1;          for (int t = n - 1; t >= 0; t--) {     forn (i, n + 2) forn (j, n + 2) forn (a, 2) forn (b, 2) forn (c, 2) forn (d, 2) {      ll &res = dp[y][i][j][a][b][c][d];      res = (24 - (!a && !c && t >= 2)) * dp[x][i][j][b][0][d][0];            if (!a)       res += dp[x][i == n + 1 ? i : i + 1][j][b][1][d][0];            if (!c)       res += dp[x][i][j == n + 1 ? j : j + 1][b][0][d][1];            res %= mod;     }          swap(x, y);    }        res = dp[x][n + 1][n + 1][0][0][0][0];        forn (i, 26)     res -= dp[x][n - c[i]][n + 1][0][0][0][0];        forn (i, 26) forn (j, i)     res += dp[x][n - c[i]][n - c[j]][0][0][0][0];        cout << MOD(res, mod) << endl;         return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long l;   long long calc(long long a, long long b, long long c) {     long long sum = b + c;     long long t = max(a, sum);     long long ret = 0;     while (t - a + sum - (b + c) <= l) {       long long rem = l - (t - a + sum - (b + c));       ret += (rem + 1) * (sum - (b + c) + 1);       sum++;       t = max(a, sum);     }     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long a, b, c;     cin >> a >> b >> c >> l;     long long ans = 0;     for (int i = 0; i <= l; i++) ans += (i + 2) * 1ll * (i + 1) / 2;     ans -= calc(a, b, c);     ans -= calc(b, a, c);     ans -= calc(c, a, b);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     string s1;     cin >> s >> s1;     map<char, int> m;     m.insert(make_pair( a , 1));     m.insert(make_pair( b , 2));     m.insert(make_pair( c , 3));     m.insert(make_pair( d , 4));     m.insert(make_pair( e , 5));     m.insert(make_pair( f , 6));     m.insert(make_pair( g , 7));     m.insert(make_pair( h , 8));     m.insert(make_pair( i , 9));     m.insert(make_pair( j , 10));     m.insert(make_pair( k , 11));     m.insert(make_pair( l , 12));     m.insert(make_pair( m , 13));     m.insert(make_pair( n , 14));     m.insert(make_pair( o , 15));     m.insert(make_pair( p , 16));     m.insert(make_pair( q , 17));     m.insert(make_pair( r , 18));     m.insert(make_pair( s , 19));     m.insert(make_pair( t , 20));     m.insert(make_pair( u , 21));     m.insert(make_pair( v , 22));     m.insert(make_pair( w , 23));     m.insert(make_pair( x , 24));     m.insert(make_pair( y , 25));     m.insert(make_pair( z , 26));     int cnt1[27];     memset(cnt1, 0, sizeof(cnt1));     for (int i = 0; i < s.length(); i++) {       cnt1[m.find(s[i])->second]++;     }     int count1 = 0;     int cnt2[27];     memset(cnt2, 0, sizeof(cnt2));     for (int i = 0; i < s1.length(); i++) {       if (cnt1[m.find(s1[i])->second] == 0) {         cout << -1 << endl;         return 0;       }       cnt2[m.find(s1[i])->second]++;     }     for (int i = 1; i <= 26; i++) {       if (cnt2[i] > cnt1[i])         count1 += cnt1[i];       else if (cnt2[i] <= cnt1[i])         count1 += cnt2[i];     }     cout << count1 << endl;     return 0;   }