malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int maxnnn = (int)1e6 + 10;   int aaaa[maxnnn];   int bbbb[maxnnn];   int l[maxnnn];   int r[maxnnn];   int nnnnn;   vector<int> gggg[maxnnn];   vector<int> tttt[4 * maxnnn];   int cnttttt;   void build(int v, int tl, int tr) {     if (tl == tr)       tttt[v] = vector<int>(1, aaaa[tl]);     else {       int tm = (tl + tr) / 2;       build(v * 2, tl, tm);       build(v * 2 + 1, tm + 1, tr);       merge(tttt[v * 2].begin(), tttt[v * 2].end(), tttt[v * 2 + 1].begin(),             tttt[v * 2 + 1].end(), back_inserter(tttt[v]));     }   }   void query(int v, int tl, int tr, int l, int r, int x) {     if (l > r) return;     if (l == tl && tr == r) {       int i = (int)tttt[v].size() - 1;       while (i >= 0 && tttt[v][i] > x && cnttttt < nnnnn) {         cnttttt++;         gggg[bbbb[x]].push_back(bbbb[tttt[v][i]]);         gggg[bbbb[tttt[v][i]]].push_back(bbbb[x]);         i--;       }       return;     }     int tm = (tl + tr) / 2;     query(v * 2, tl, tm, l, min(r, tm), x);     query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);   }   int used[maxnnn];   void dfs(int v) {     cnttttt++;     used[v] = 1;     for (int u : gggg[v]) {       if (!used[u]) {         dfs(u);       }     }   }   void solution() {     cin >> nnnnn;     for (int i = 1; i <= nnnnn; i++) {       cin >> l[i] >> r[i];       aaaa[l[i]] = r[i];       aaaa[r[i]] = -1;       bbbb[r[i]] = bbbb[l[i]] = i;     }     build(1, 1, 2 * nnnnn);     for (int i = 1; i <= nnnnn; i++) {       query(1, 1, 2 * nnnnn, l[i], r[i], r[i]);     }     if (cnttttt != nnnnn - 1) {       cout <<  NO  << endl;       return;     }     cnttttt = 0;     dfs(1);     if (cnttttt == nnnnn) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solution();   }
#include <bits/stdc++.h>   using namespace std;   const long long linf = 1e18 + 5;   const int mod = (int)1e9 + 7;   const int logN = 17;   const int inf = 1e9;   const int N = 1e6 + 5;   int way[N][2], size[N], all[N][30][2], n, m, a[N], S = 1;   void insert(int x) {     int node = 1;     for (int i = 29; i >= 0; i--) {       int t = (x >> i) & 1;       if (!way[node][t]) way[node][t] = ++S;       node = way[node][t];       size[node]++;       for (int j = 0; j <= 29; j++) all[node][j][((x & (1 << j)) != 0)]++;     }   }   int hm(int x, int big) {     int node = 1;     int ans = 0;     for (int i = 29; i >= 0; i--) {       if (!node) break;       int t = 0;       if ((x & (1 << i)) ^ (big & (1 << i))) t = 1;       if (big & (1 << i))         ;       else         ans += size[way[node][!t]];       node = way[node][t];     }     ans += size[node];     return ans;   }   int molla(int node, int x) {     long long ans = 0;     for (int i = 0; i <= 29; i++) {       ans += (long long)all[node][i][!(x & (1 << i))] * (1 << i) % mod;       ans %= mod;     }     return ans;   }   long long sum(int x, int big) {     int node = 1;     long long ans = 0;     for (int i = 29; i >= 0; i--) {       if (!node) break;       int t = 0;       if ((x & (1 << i)) ^ (big & (1 << i))) t = 1;       if (big & (1 << i))         ;       else {         ans += molla(way[node][!t], x);         ans %= mod;       }       node = way[node][t];     }     ans += (long long)size[node] * big % mod;     ans %= mod;     return ans;   }   int get(int x) {     long long cur = 0;     for (int i = 1; i <= n; i++) cur += hm(a[i], x);     return cur / 2;   }   long long sum(int x) {     long long cur = 0;     for (int i = 1; i <= n; i++) cur = (cur + sum(a[i], x)) % mod;     if (cur & 1) cur += mod;     return cur / 2LL;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       insert(a[i]);     }     int bas = 0, son = (1 << 30) - 1;     if (!m) {       cout << 0 <<   n ;       return 0;     }     while (bas < son) {       int orta = bas + son >> 1;       if (bas == orta) orta++;       if (get(orta) >= m)         bas = orta;       else         son = orta - 1;     }     long long ans =         (sum(bas + 1) + (m - get(bas + 1)) * (long long)bas % mod) % mod;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e5 + 7;   int m, k;   long long n, x, s, a[MAX], b[MAX], c[MAX], d[MAX];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> k >> x >> s;     for (int i = 1; i <= m; ++i) {       cin >> a[i];     }     for (int i = 1; i <= m; ++i) {       cin >> b[i];     }     for (int i = 1; i <= k; ++i) {       cin >> c[i];     }     for (int i = 1; i <= k; ++i) {       cin >> d[i];     }     long long res = x * n;     for (int i = 1; i <= m; ++i) {       int l = 1, r = k;       while (l <= r) {         int mid = (l + r) / 2;         if (b[i] + d[mid] <= s) {           l = mid + 1;         } else {           r = mid - 1;         }       }       long long numPrep = c[r];       if (numPrep == n) {         res = 0;         break;       }       long long prepTime = x * n;       if (b[i] <= s) {         prepTime = a[i] * (n - numPrep);       }       res = min(prepTime, res);     }     long long mxNumPrep = -1;     for (int i = 1; i <= k; ++i) {       if (d[i] <= s) {         mxNumPrep = max(mxNumPrep, c[i]);       } else {         break;       }     }     res = min(x * (n - mxNumPrep), res);     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     char c = getchar(), f = 0;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = 1;     for (; c >=  0  && c <=  9 ; c = getchar())       x = (x << 1) + (x << 3) + (c ^ 48);     if (f) x = -x;   }   int vl, wh, n, nx[1005], a[1005], m;   char st[1005], dp[1005];   int main() {     read(n), read(wh);     for (int i = 1, x; i <= n; i++) read(x), x ? nx[x] = i, st[i] = 1 : 0;     for (int i = 1, c, x; i <= n; i++)       if (!st[i]) {         char tag = (c = 0) * (x = i);         while (x) c++, (x == wh ? tag = 1, vl = c : 0), x = nx[x];         if (!tag) a[++m] = c;       }     dp[0] = 1;     for (int i = 1; i <= m; i++)       for (int j = n; j >= a[i]; j--) dp[j] |= dp[j - a[i]];     for (int i = 0; i <= n; i++)       if (dp[i]) printf( %d n , i + vl);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     long long n;     cin >> n;     string s;     cin >> s;     vector<long long> pref(n + 1);     pref[0] = 0;     char c;     for (long long i = 1; i <= n; ++i) {       c = (int)s[i - 1] - 48;       pref[i] = pref[i - 1] + c;     }     long long q = n - 1;     while (s[q] ==  0 ) q--;     q++;     if (pref[n] == 0) {       cout <<  YES ;       return 0;     }     for (long long i = 1; i < pref[n]; ++i) {       long long ind = 0;       long long j = 1;       while (ind < q) {         while (j <= n && pref[j] - pref[ind] != i) j++;         if (j == n + 1) break;         ind = j;         j++;       }       if (ind == q) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   template <class T>   T gcd(T a, T b) {     T r;     while (b != 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   template <class T>   T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   template <class T>   T sqr(T x) {     return x * x;   }   template <class T>   T cube(T x) {     return x * x * x;   }   using namespace std;   string s;   bool check[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long int i, j, k, n, m, p = 0, q = 1e7;     string s;     char c;     c =  0 ;     cin >> s;     for (i = 0; i < s.size(); i++) {       if (s[i] == c) {         if (p == 0) {           cout << s[i];           p = 2;         }       } else {         if (p != 0) p--;         cout << s[i];       }       c = s[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const int MAXN = 3 * int(1e5) + 10;   int pos[MAXN];   int a[MAXN];   int n, q;   int deleted = -1;   int fenw[MAXN];   void upd(int x, int d) {     for (int i = x; i < n; i = (i | (i + 1))) fenw[i] += d;   }   int sum(int r) {     int res = 0;     for (int i = r; i >= 0; i = (i & (i + 1)) - 1) res += fenw[i];     return res;   }   int sum(int l, int r) { return sum(r) - sum(l - 1); }   bool isBeg(int i) { return sum(i, i) == 1; }   void build() {     memset(fenw, 0, sizeof fenw);     upd(0, 1);     for (int i = 1; i < n; i++)       if (pos[i - 1] > pos[i]) upd(i, 1);   }   void del(int val) {     if (val < n - 1 && pos[val] < pos[val + 1] && deleted != val + 1)       upd(val + 1, 1);     if (isBeg(val)) upd(val, -1);   }   void add(int val) {     if (val < n - 1 && pos[val] < pos[val + 1] && deleted != val + 1)       upd(val + 1, -1);     if (0 == val || pos[val - 1] > pos[val] || deleted == val - 1) upd(val, 1);   }   void goSwap(int x, int y) {     deleted = -1;     del(a[x]);     deleted = a[x];     del(a[y]);     swap(a[x], a[y]);     pos[a[x]] = x;     pos[a[y]] = y;     add(a[x]);     add(a[y]);   }   int calc(int x, int y) {     if (isBeg(x))       return sum(x, y);     else       return sum(x, y) + 1;   }   void output() {     for (int i = 0; i < int(n); i++) printf( %d  , sum(i, i));     puts(  );   }   int main() {     scanf( %d , &n);     for (int i = 0; i < int(n); i++) {       scanf( %d , a + i);       a[i]--;       pos[a[i]] = i;     }     build();     scanf( %d , &q);     for (int i = 0; i < int(q); i++) {       int p, x, y;       scanf( %d %d %d , &p, &x, &y);       x--;       y--;       if (p == 1)         printf( %d n , calc(x, y));       else         goSwap(x, y);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long t = 1;     while (t--) {       long long n, m;       cin >> n >> m;       long long len = n, l, r;       for (long long i = 0; i < m; i++) {         cin >> l >> r;         len = min(len, r - l + 1);       }       cout << len << endl;       for (long long i = 0; i < n; i++) {         cout << (i % len) <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ans;   int num[1000010], flag[1000010];   int fa[1000010], vis[1000010];   int Find(int x) { return fa[x] = x == fa[x] ? x : Find(fa[x]); }   void Union(int x, int y) {     int fx = Find(x);     int fy = Find(y);     if (fx != fy) fa[fy] = fx;   }   int main() {     int t, C = 1;     while (scanf( %d%d , &n, &m) != EOF) {       memset(num, 0, sizeof(num));       memset(flag, 0, sizeof(flag));       memset(vis, 0, sizeof(vis));       for (int i = 1; i <= n; i++) fa[i] = i;       int u, v;       vis[1] = 1;       for (int i = 0; i < m; i++) {         scanf( %d%d , &u, &v);         if (u != v) {           num[u]++;           num[v]++;           vis[u]++;           vis[v]++;           Union(u, v);         } else           vis[u]++;       }       int ans = 0, k = 0, tong = 0;       for (int i = 1; i <= n; i++)         if (num[i] & 1) flag[Find(i)]++;       for (int i = 1; i <= n; i++)         if (vis[i] && Find(i) == i) {           if (flag[i])             ans += flag[i];           else             tong++;           k++;         }       if (k == 1)         printf( %d n , ans / 2);       else         printf( %d n , ans / 2 + tong);     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN(1e5 + 5);   inline int read() {     char ch(getchar());     int x(0);     int flag(1);     while (!isdigit(ch)) {       if (ch ==  - ) {         flag = -1;       }       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return flag * x;   }   int sum[MAXN];   int a[MAXN];   int dp[MAXN];   int main() {     int n(read());     for (int i = 1; i <= n; i++) {       a[i] = read();     }     for (int i = n; i >= 1; i--) {       sum[i] = sum[i + 1] + a[i];       dp[i] = std::max(dp[i + 1], sum[i + 1] - dp[i + 1] + a[i]);     }     std::printf( %d %d n , sum[1] - dp[1], dp[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   const T& max(const T& a, const T& b, const T& c) {     return max(a, max(b, c));   }   template <class T>   const T& min(const T& a, const T& b, const T& c) {     return min(a, min(b, c));   }   void sc(int& a) { scanf( %d , &a); }   void sc(long long& a) { scanf( %lld , &a); }   void sc(int& a, int& b) {     sc(a);     sc(b);   }   void sc(long long& a, long long& b) {     sc(a);     sc(b);   }   void sc(int& a, int& b, int& c) {     sc(a, b);     sc(c);   }   void sc(long long& a, long long& b, long long& c) {     sc(a, b);     sc(c);   }   void prl(int a) { printf( %d n , a); }   void prl(long long a) { printf( %lld n , a); }   void prl() { printf(  n ); }   void prs(int a) { printf( %d  , a); }   void prs(long long a) { printf( %lld  , a); }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long poww(long long a, long long b) {     if (b == 0) return 1;     long long tmp = poww(a, b / 2);     return (b & 1 ? a * tmp * tmp : tmp * tmp);   }   long long sumOfDigs(string s) {     long long sum = 0;     for (int i = 0; i < s.length(); i++) sum += s[i] -  0 ;     return sum;   }   long long sumOfDigs(long long n) {     return (n < 10 ? n : n % 10 + sumOfDigs(n / 10));   }   string itos(long long i) {     string s =   ;     while (i) {       s += char(i % 10 +  0 );       i /= 10;     }     reverse(s.begin(), s.end());     return s;   }   long long stoi(string& s) {     long long tot = 0;     for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) {       tot += j * (s[i] +  0 );     }     return tot;   }   int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   using namespace std;   void tt() { freopen( test.txt ,  r , stdin); }   long long mod = 1000000000000000003;   long long modpower(long long x, long long y, long long p) {     x %= mod;     if (!y) return 1;     long long res = 1;     if (y & 1) {       res *= x;       res %= p;     }     long long z = modpower(x, y / 2, p);     z %= p;     z *= z;     z %= mod;     res *= z;     res %= p;     return res;   }   double ans = 1e60;   long long a = -1, b = -1;   int main() {     long long t1, t2, x1, x2, t0;     cin >> t1 >> t2 >> x1 >> x2 >> t0;     if (t1 == t0 && t2 == t0) {       return cout << x1 <<     << x2 << endl, 0;     } else if (t1 == t0) {       return cout << x1 <<     << 0 << endl, 0;     }     for (long long y2 = 1; y2 <= x2; y2++) {       long long y1 = (t2 * y2 - t0 * y2) / (t0 - t1);       if (y1 > x1) {         y1 = x1;       }       double t = (long double)(1.0 * y1 * t1 + 1.0 * y2 * t2) / (y1 + y2);       if (t < t0) continue;       if (t < ans || t == ans && a + b < y1 + y2) {         ans = t;         a = y1;         b = y2;       }     }     cout << a <<     << b << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, sz[maxn], ans[maxn];   long long sum;   vector<int> adj[maxn], vec;   void dfs(int u, int par) {     sz[u] = 1;     for (auto v : adj[u])       if (v != par) {         dfs(v, u);         sz[u] += sz[v];       }   }   void DFSend(int u, int par) {     vec.push_back(u);     for (auto v : adj[u])       if (v != par) DFSend(v, u);   }   int centroid(int u, int par) {     for (auto v : adj[u])       if (v != par && sz[v] * 2 > n) return centroid(v, u);     return u;   }   void read_input() {     cin >> n;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }   }   void solve() {     dfs(1, 0);     for (int i = 1; i <= n; i++) sum += min(sz[i], n - sz[i]);     sum *= 2;     DFSend(centroid(1, 0), -1);     for (int i = 0; i < n; i++) ans[vec[i]] = vec[(i + n / 2) % n];     cout << sum <<   n ;     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;   }   int main() {     read_input(), solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, mx;   int a[4000400], q[4000400], dis[2005];   bool vis[2005];   int head[2005], edgenum;   struct Edge {     int to, nxt;   } edge[4000400];   inline void add(int u, int v) {     edge[++edgenum].to = v;     edge[edgenum].nxt = head[u];     head[u] = edgenum;   }   inline void read(int &x) {     x = 0;     char c = getchar();     int f = 1;     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = 10 * x + c -  0 ;       c = getchar();     }     x *= f;   }   bitset<2004> dp[2];   inline int solve() {     int t = 1;     dp[0][1000] = 1;     for (int i = 1; i <= 1000; i++) {       dp[t].reset();       for (int j = 1; j <= k; j++)         if (a[j] > 0)           dp[t] |= dp[t ^ 1] << a[j];         else           dp[t] |= dp[t ^ 1] >> (-a[j]);       if (dp[t][1000] == 1) return i;       t ^= 1;     }     return -1;   }   int main() {     read(n);     read(k);     for (int i = 1; i <= k; i++) read(a[i]);     for (int i = 1; i <= k; i++) vis[a[i]] = 1;     int l = 0;     for (int i = 0; i <= 1000; i++)       if (vis[i]) a[++l] = i;     for (int i = 1; i <= l; i++) a[i] -= n;     k = l;     printf( %d , solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double Fictive = 5e18;   struct str {     long long k, b;     long double eval(long double x) { return x * (long double)k + b; }   };   vector<str> vec;   inline long double get_x(str fi, str se) {     return (long double)(fi.b - se.b) / (long double)(se.k - fi.k);   }   inline bool to_erase(str l1, str l2, str l3) {     long double x = get_x(l1, l3);     return (l2.eval(x) >= l3.eval(x));   }   inline void add_line(str l) {     while (vec.size() >= 2 && to_erase(vec[vec.size() - 2], vec.back(), l))       vec.pop_back();     vec.push_back(l);   }   inline long long get(long long x) {     int l = 0, r = vec.size() - 1;     while (l < r) {       int mid = (l + r) >> 1;       if (vec[mid].eval(x) >= vec[mid + 1].eval(x))         l = mid + 1;       else         r = mid;     }     return vec[l].eval(x);   }   int n, a[100100], b[100100];   long long dp[100100];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       cin >> b[i];     }     dp[1] = 0;     add_line({b[1], 0});     for (int i = 2; i <= n; i++) {       dp[i] = 1e15;       dp[i] = get(a[i]);       add_line({b[i], dp[i]});     }     cout << dp[n];   }
#include <bits/stdc++.h>   using namespace std;   int n, a[3001], b[3001], cnt = 1, sum;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     while (1) {       if (cnt == a[++sum])         cnt++;       else {         cout << cnt;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> a(10, 0), b(10, 0);     string n;     string num;     cin >> n >> num;     for (auto w : num) {       a[w -  0 ]++;     }     int minimum = INT_MAX;     for (auto w : n) b[w -  0 ]++;     for (int i = 0; i < 10; i++) {       if (i != 2 && i != 6 && i != 5 && i != 9 && b[i] > 0)         minimum = min(minimum, a[i] / b[i]);     }     if (b[2] + b[5] > 0) minimum = min(minimum, (a[2] + a[5]) / (b[2] + b[5]));     if (b[6] + b[9] > 0) minimum = min(minimum, (a[6] + a[9]) / (b[6] + b[9]));     cout << minimum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 22;   const int maxp = 777 + (1 << (maxn - 2));   const int maxm = 1E5 + 77;   char S[maxm];   int N, M, _V[maxn][maxm], V[maxm], dp[maxn][maxp], ans = 1E9 + 7;   int main() {     scanf( %d%d , &N, &M);     for (int i = 0; i < N; ++i) {       scanf( %s , S);       for (int j = 0; j < M; ++j) _V[i][j] = S[j] ==  1  ? 1 : 0;     }     for (int j = 0; j < M; ++j)       for (int i = 0, v = 1; i < N; ++i, v <<= 1) V[j] |= _V[i][j] ? v : 0;     for (int i = 0; i < M; ++i) {       ++dp[0][V[i]];     }     int tot = 1 << N;     for (int i = 1; i <= N; ++i)       for (int j = 0; j < tot; ++j) {         if (i >= 3) dp[i][j] = dp[i - 2][j] * (i - 2);         for (int p = 1; p < tot; p <<= 1) {           for (int t = 1; t <= 2 && t <= i; ++t)             dp[i][j] += (t & 1 ? 1 : -1) * dp[i - t][j ^ (t & 1 ? p : 0)];         }         dp[i][j] /= i;       }     for (int i = 0; i < tot; ++i) {       int tans = 0;       for (int j = 0; j <= N; ++j) tans += min(j, N - j) * dp[j][i];       ans = min(ans, tans);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int mxn = 2 * 100000 + 6;   int n, root;   int a[mxn];   int c[mxn];   int s[mxn];   int base;   int ans = 0x3f3f3f3f;   int main() {     cin >> n >> root;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       if (i == root && a[i] != 0) {         ++base;         a[i] = 0;       }       ++c[a[i]];     }     partial_sum(c, c + n, s);     int c0 = 0;     for (int i = 0; i < n; ++i) {       c0 += (c[i] == 0);       int mov = c[0] - 1 + n - s[i];       int sum = max(mov, c0);       if (i || n == 1) {         ans = min(ans, sum);       }     }     cout << ans + base << endl;     return 0;   }