malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e6 + 5;   const int mod = 51123987;   char s[maxn];   struct Pam {     vector<pair<int, int> > next[maxn];     int fail[maxn];     int len[maxn];     int num[maxn];     int S[maxn];     long long a[maxn], b[maxn];     int last, n, p;     int newNode(int l) {       next[p].clear();       len[p] = l;       return p++;     }     void init() {       n = last = p = 0;       newNode(0);       newNode(-1);       S[n] = -1;       fail[0] = 1;     }     int getFail(int x) {       while (S[n - len[x] - 1] != S[n]) {         x = fail[x];       }       return x;     }     int find(int u, int c) {       vector<pair<int, int> >& x = next[u];       int sz = x.size();       for (int i = 0; i < sz; ++i) {         if (x[i].first == c) return x[i].second;       }       return 0;     }     int add(int c) {       S[++n] = c;       int cur = getFail(last);       int x = find(cur, c);       if (!x) {         int now = newNode(len[cur] + 2);         x = now;         fail[now] = find(getFail(fail[cur]), c);         next[cur].push_back(make_pair(c, now));         num[now] = num[fail[now]] + 1;       }       last = x;       return num[last];     }     void solve(int len) {       memset(a, 0, sizeof(a));       memset(b, 0, sizeof(b));       init();       for (int i = 0; i < len; i++) {         a[i] = add(s[i] -  a );       }       init();       for (int i = len - 1; i >= 0; i--) {         b[i] = (b[i + 1] + add(s[i] -  a )) % mod;       }       long long ans = (b[0] * (b[0] - 1) / 2) % mod;       for (int i = 0; i < len; i++) {         ans = ((ans - (a[i] * b[i + 1]) + mod) % mod) % mod;       }       printf( %lld n , ans);     }   } pam;   int main() {     int n;     while (~scanf( %d , &n)) {       scanf( %s , s);       pam.solve(n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 5e5 + 100, INF = 1e9;   int N, M, X[MX], cnt;   map<int, int> mp;   struct Seg {     int z;     int l, r;     Seg *L, *R;     void update(int x) { z = min(z, x); }     void pushdown() { L->update(z), R->update(z); }     void init(int a, int b);     void Min(int a, int b, int x);     int ask(int a);   } T[MX << 1], *Cnt = T;   Seg* New() { return ++Cnt; }   void Seg::init(int a, int b) {     l = a, r = b, z = INF;     if (l == r) return;     int m = (l + r) >> 1;     L = New(), L->init(l, m);     R = New(), R->init(m + 1, r);   }   void Seg::Min(int a, int b, int x) {     if (a <= l && r <= b) {       update(x);       return;     }     pushdown();     if (a <= L->r) L->Min(a, b, x);     if (b >= R->l) R->Min(a, b, x);   }   int Seg::ask(int a) {     if (l == r) return z;     pushdown();     if (a <= L->r)       return L->ask(a);     else       return R->ask(a);   }   struct Query {     int id, l, nx;   } Q[MX];   int H[MX], qc;   void add(int id, int l, int r) {     Q[++qc].id = id, Q[qc].l = l, Q[qc].nx = H[r], H[r] = qc;   }   int ans[MX];   int A[MX];   void Solve() {     for (int i = (1); i <= (N); ++i) {       int c = X[i];       if (A[c]) {         int delta = i - A[c];         T->Min(1, A[c], delta);       }       A[c] = i;       for (int j = H[i]; j; j = Q[j].nx) ans[Q[j].id] = T->ask(Q[j].l);     }   }   int main() {     scanf( %d%d , &N, &M);     int x;     for (int i = (1); i <= (N); ++i) {       scanf( %d , &x);       if (!mp.count(x)) mp[x] = ++cnt;       X[i] = mp[x];     }     T->init(1, N);     int l, r;     for (int i = (1); i <= (M); ++i) {       scanf( %d%d , &l, &r);       add(i, l, r);     }     Solve();     for (int i = (1); i <= (M); ++i)       printf( %d n , (ans[i] == INF ? -1 : ans[i]));     return 0;   }
#include <bits/stdc++.h>   long long n, s[2][100010], k;   long long dp[100010][2];   long long ans = 1;   long long p(long long a, long long b) {     if (b == 0) return 1LL;     if (b == 1) return a % 998244353;     long long x = p(a, b >> 1);     x *= x;     x %= 998244353;     x *= p(a, b & 1);     x %= 998244353;     return x;   }   void solve(long long *a, long long len) {     long long l, r;     l = 0;     while (!(~a[l]) && a[l]) l++;     if (l == len + 1) {       ans = ans * k % 998244353 * p(k - 1, len) % 998244353;       return;     }     ans *= p(k - 1, l);     ans %= 998244353;     r = len;     while (r >= 0 && !(~a[r])) r--;     if (r < len) ans *= p(k - 1, len - r), ans %= 998244353;     r++;     for (int i = l, count = 0; i <= r; i++) {       if (a[i] == -1) {         count++;         continue;       } else if (count) {         if (a[i] == a[i - count - 1])           ans *= dp[count][1];         else           ans *= dp[count][0];         ans %= 998244353;         count = 0;       } else if (i && a[i] == a[i - 1]) {         ans = 0;         return;       }     }     return;   }   int main() {     scanf( %lld%lld , &n, &k);     for (int i = 0; i < n; i++) scanf( %lld , &s[i & 1][i >> 1]);     dp[1][0] = k - 2;     dp[1][1] = k - 1;     for (int i = 2; i <= n >> 1; i++) {       dp[i][0] = dp[i - 1][1] + dp[i - 1][0] * (k - 2) % 998244353;       dp[i][1] = dp[i - 1][0] * (k - 1) % 998244353;       dp[i][0] %= 998244353;       dp[i][1] %= 998244353;     }     solve(s[0], n - 1 >> 1);     if (!ans) {       puts( 0 );       return 0;     }     solve(s[1], (n - 1 >> 1) - (n & 1));     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 7;   const int maxn = 1e5 + 5;   int n, m;   int a[maxn];   int num[maxn];   int main() {     cin >> n;     long long sum1 = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       sum1 += a[i];     }     num[n] = a[n];     long long sum2 = 0;     for (int i = n - 1; i >= 1; i--) {       num[i] = max(a[i], num[i + 1] - 1);     }     for (int i = 1; i < n; i++) {       if (num[i] > num[i + 1]) {         num[i + 1] = num[i];       }     }     for (int i = 1; i <= n; i++) {       sum2 += num[i] + 1;     }     cout << sum2 - sum1 - n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[30][30];   int a, b;   int main() {     while (~scanf( %d%d , &a, &b)) {       for (int i = 0; i < a; i++) scanf( %s , s[i]);       int ss = 0;       for (int i = 0; i < a; i++) {         for (int j = 0; j < b; j++) {           int d = 99999999;           if (s[i][j] ==  0 ) {             for (int k = 0; k <= i; k++) {               if (s[i - k][j] ==  1 ) break;               int l;               for (l = 1; l <= j; l++) {                 if (s[i - k][j - l] ==  1 ) break;               }               d = min(d, l);               ss = max(ss, d * 2 + (k + 1) * 2);             }           }         }       }       printf( %d n , ss);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 7010;   map<long long, int> cnt;   int n;   long long ar[N], br[N];   bitset<N> bit[N];   bitset<N> res;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> ar[i];       cnt[ar[i]]++;     }     for (int i = 1; i <= n; i++) {       cin >> br[i];     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if ((ar[i] | ar[j]) == ar[i]) {           bit[i][j] = 1;         } else {           bit[i][j] = 0;         }       }     }     for (int i = 1; i <= n; i++) {       if (cnt[ar[i]] >= 2) {         res = (res | bit[i]);       }     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       if (res[i]) {         ans += br[i];       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int n, ans = 0;   vector<pair<int, int>> b;   vector<int> a(26);   int main() {     cin >> s >> n;     for (int i = 0; i < s.length(); ++i) {       a[s[i] -  a ]++;     }     for (int i = 0; i < 26; ++i) {       b.push_back(make_pair(a[i], i));     }     sort(b.begin(), b.end());     for (int i = 0; i < 26; ++i) {       if (n >= b[i].first) {         n -= b[i].first;         b[i].first = 0;       }     }     for (int i = 0; i < 26; ++i) {       if (b[i].first != 0) ans++;     }     cout << ans << endl;     for (int i = 0; i < s.length(); ++i) {       for (int j = 0; j < 26; ++j) {         if (s[i] -  a  == b[j].second && b[j].first > 0) {           cout << s[i];         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 5;   struct node {     int op;     int l;     int r;     int d;   } cmd[maxn];   ;   int a[maxn];   int b[maxn];   int main() {     ios::sync_with_stdio(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; i++)       cin >> cmd[i].op >> cmd[i].l >> cmd[i].r >> cmd[i].d;     for (int i = 1; i <= n; i++) a[i] = 100000000;     for (int i = 1; i <= m; i++) {       if (cmd[i].op == 1) {         for (int j = cmd[i].l; j <= cmd[i].r; j++) b[j] += cmd[i].d;       } else {         for (int j = cmd[i].l; j <= cmd[i].r; j++) {           a[j] = min(a[j], cmd[i].d - b[j]);         }       }     }     for (int i = 1; i <= n; i++) b[i] = a[i];     for (int i = 1; i <= m; i++) {       if (cmd[i].op == 1) {         for (int j = cmd[i].l; j <= cmd[i].r; j++) b[j] += cmd[i].d;       } else {         int flag = INT_MIN;         for (int j = cmd[i].l; j <= cmd[i].r; j++) flag = max(flag, b[j]);         if (flag != cmd[i].d) {           cout <<  NO ;           return 0;         }       }     }     cout <<  YES  << endl;     for (int i = 1; i <= n; i++) cout << a[i] <<    ;     return 0;   }
/*   Creater :        ANSHUMAN MISHRA    All Losses In this World Are Due To Lack Of Ability.   If You Want To Curse Someone , Curse Your Own Weakness    */         #include <bits/stdc++.h>   using namespace std;      #define ll long long   #define pii pair<int,int>   #define yes cout<< YES n    #define no cout<< NO n       const int N=1e5+5;   int cnt[26][N];      signed main(){       ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);       #ifndef ONLINE_JUDGE           freopen( in.txt , r ,stdin);       #endif          int t=1;cin>>t;       while(t--){           int n,m;           cin>>n>>m;           for (int i=0;i<m;++i) for (int j=0;j<26;++j) cnt[j][i]=0;              string s;           for (int i=0;i<n;++i){               cin>>s;               for (int j=0;j<m;++j)                   cnt[s[j]- a ][j]++;           }           /*           for (int i=0;i<m;++i){               for (int j=0;j<26;++j){                   /*                   if (cnt[j][i]==1){                       ans+= (j+ a );                       break;                   }                   cout<<cnt[j][i]<<   ;               }               cout<<  n ;           }*/              for (int i=0;i<n-1;++i){               cin>>s;               for (int j=0;j<m;++j)                   cnt[s[j]- a ][j]--;           }                            string ans=  ;           for (int i=0;i<m;++i){               for (int j=0;j<26;++j){                                      if (cnt[j][i]==1){                       ans+= (j+ a );                       break;                   }                   //cout<<cnt[j][i]<<   ;               }               //cout<<  n ;           }           cout<<ans<<endl;           cout.flush();          }             return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Get() {     char c;     while (c = getchar(), c <  0  || c >  9 )       ;     int X = c - 48;     while (c = getchar(), c >=  0  && c <=  9 ) X = X * 10 + c - 48;     return X;   }   void Output(long long X) {     int Data[20], Len = 0;     while (X) {       Data[Len++] = X % 10;       X /= 10;     }     if (!Len) Data[Len++] = 0;     while (Len--) putchar(Data[Len] + 48);     putchar(  n );   }   const int Code[11][10] = {       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  1,       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  2,  3,  4,  5,       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0,  6,  7,  8,  9,  10, 11,       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  12, 13, 14, 15, 16, 17, 18, 19,       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,   };   int N;   long long S[30][100001];   void Add(int X, int P, long long Delta) {     while (P <= N) {       S[X][P] += Delta;       P += P & -P;     }   }   long long Sum(int X, int P) {     long long Ans = 0;     while (P) {       Ans += S[X][P];       P -= P & -P;     }     return Ans;   }   int main() {     static long long Data[100000];     N = Get();     for (int i = 0; i < N; i++) Data[i] = Get();     memset(S, 0, sizeof(S));     for (int i = 0; i < N; i++)       for (int j = 2; j <= 10; j += 2) Add(Code[j][i % j], i + 1, Data[i]);     int Query = Get();     while (Query--) {       int Type = Get();       if (Type == 1) {         int X = Get() - 1, Y = Get();         for (int i = 2; i <= 10; i += 2) Add(Code[i][X % i], X + 1, Y - Data[X]);         Data[X] = Y;       } else {         int L = Get() - 1, R = Get(), M = (Get() - 1) * 2;         long long Ans = 0;         for (int i = 0, j = 1; i < M; i++, j++) {           int X = Code[M][(L + i) % M];           Ans += (Sum(X, R) - Sum(X, L)) * min(j, M + 2 - j);         }         Output(Ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1010], b[1010];   bool vis[1010];   int main() {     int n, i, ans, nn, lb;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     memset(vis, false, sizeof(vis));     ans = 0;     nn = 0;     while (1) {       lb = 0;       b[0] = 0;       for (i = 1; i <= n; i++)         if (vis[i] == false && a[i] > b[lb]) {           b[++lb] = a[i];           vis[i] = true;           nn++;         }       ans += (lb - 1);       if (nn == n) break;     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int INF = 0x3f3f3f3f;   const int maxn = 100010;   inline int read() {     int x = 0, f = 1;     char ch = 0;     while (!isdigit(ch)) {       ch = getchar();       if (ch ==  - ) f = -1;     }     while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();     return x * f;   }   int n, m;   int a[maxn], b[maxn], low[maxn], pre[maxn], f[maxn], la[maxn];   int gap[maxn];   void work() {     memset(low, 63, sizeof(low));     pre[1] = low[1] = 0, f[1] = la[1] = 1;     for (int k = 2; k <= n; ++k) {       if (a[k] + 1) {         int L = 1, R = n;         while (L <= R) {           int mid = (L + R) >> 1;           if (low[mid] < a[k])             L = mid + 1;           else             R = mid - 1;         }         pre[k] = la[L - 1];         la[L] = k;         f[k] = L, low[L] = a[k];       } else {         pre[k] = -1, f[k] = -1;         int j = n;         for (int i = m; i >= 1; i--) {           while (low[j] >= b[i]) j--;           low[j + 1] = b[i], la[j + 1] = -1;         }       }     }   }   void work2() {     int L, R, rem = m;     int x = n;     while (x)       if (a[x] + 1) {         if (pre[x] >= 0) {           x = pre[x];           continue;         }         R = lower_bound(b + 1, b + rem + 1, a[x]) - b - 1;         for (int y = x - 1; y != 0; y--) {           if (a[y] == -1 || a[y] >= a[x]) continue;           L = upper_bound(b + 1, b + rem + 1, a[y]) - b;           if (f[x] - f[y] - 1 == min(R - L + 1, gap[x] - gap[y])) {             for (int i = y, j = L; i <= x && j <= R; i++)               if (a[i] == -1) a[i] = b[j], b[j] = -1, j++;             x = y;             rem = L - 1;             break;           }         }       }     for (int i = 1, j = 1; i <= n; ++i) {       if (a[i] + 1) continue;       while (b[j] == -1) ++j;       a[i] = b[j];       b[j++] = -1;     }   }   int main() {     n = read();     a[1] = 0;     a[n + 2] = INF;     for (int i = 2; i <= n + 1; ++i)       a[i] = read(), gap[i] = gap[i - 1] + (a[i] == -1);     m = read();     gap[n + 2] = gap[n + 1];     n += 2;     for (int i = 1; i <= m; ++i) b[i] = read();     sort(b + 1, b + m + 1);     m = unique(b + 1, b + m + 1) - b - 1;     work();     work2();     for (int i = 2; i < n; ++i) printf( %d  , a[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, m;   int a[200003];   pair<int, int> p[200003];   int main() {     cin >> t;     while (t--) {       cin >> n;       for (int i = 1; i <= n; ++i) {         cin >> a[i];       }       long long re = 0;       for (int i = 1; i <= n;) {         int val = a[i], j;         for (j = i; j <= n && 1ll * a[j] * a[i] > 0; ++j) val = max(val, a[j]);         re += val;         i = j;       }       cout << re <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     set<string> s0;     for (int i = 0; i < n; i++) {       cin >> s;       unordered_set<char> s1;       s.erase(remove_if(s.begin(), s.end(),                         [&](char const c) { return !(s1.insert(c).second); }),               s.end());       sort(s.begin(), s.end());       s0.insert(s);     }     cout << s0.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define intt long long int   #define F first    #define S second   #define pb push_back      int main()   {       int n;cin>>n;       int arr[n+1];              vector<int> pos;       pos.pb(-1);          for(int i=1;i<=n;i++) {cin>>arr[i];if(arr[i]==1) pos.pb(i); }       int m=pos.size()-1; // no. of 1s          int dp[n][m+1]; // dp[][]== ith posn tak use karke , pehle j 1 s ko shift karna hai .          for(int i=0;i<=n;i++)dp[i][0]=0;       for(int i=1;i<=m;i++) dp[0][i]=1e9;          for(int i=1;i<=n;i++)       {           for(int j=1;j<=m;j++)           {                  if(arr[i]==1)               dp[i][j]=dp[i-1][j];               else                dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+abs(pos[j]-i));           }       }       cout<<dp[n][m]<<endl;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   string t[6] = { lios ,  liala ,  etr ,  etra ,  initis ,  inites };   bool mark[3];   int md = -1;   int typ(string s) {     for (int i = 0; i < 6; i++)       if (t[i].size() <= s.size()) {         bool flag = true;         for (int j = 0; j < t[i].size(); j++)           if (t[i][j] != s[s.size() - t[i].size() + j]) flag = false;         if (flag) return i;       }     return -1;   }   int main() {     ios::sync_with_stdio(false);     string s;     bool flag = true;     bool x = false;     int cnt = 0;     while (cin >> s) {       cnt++;       int p = typ(s);       if (p == -1)         flag = false, x = true;       else if (md != -1 && p % 2 != md)         flag = false;       else if (p / 2 == 0 && (mark[1] || mark[2]))         flag = false;       else if (p / 2 == 1 && (mark[1] || mark[2]))         flag = false;       else if (p / 2 == 2 && !mark[1])         flag = false;       if (flag) {         md = p % 2;         mark[p / 2] = true;       }     }     if ((!mark[1] && cnt > 1) || x || (cnt > 1 && !flag)) {       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   typedef long long ll;   typedef long double ld;   #define rep(a, b) for(ll a = 0; a < (b); ++a)   #define pb push_back   #define st first   #define nd second   #define all(a) a.begin(), a.end()   #define lg(a) (31-__builtin_clz(a))   void solve() {           int n;           cin >> n;           ll T[n];           rep(i, n) cin >> T[i];           sort(T, T+n);           ll ans=0, odejmij=0;           rep(i, n-1) ans+=T[i+1]-T[i];           rep(i, n) {                   ans-=i*T[i]-odejmij;                   odejmij+=T[i];           }           cout << ans <<   n ;   }   int main() {           ios_base::sync_with_stdio(0); cin.tie(0);           int _=1;           cin >> _;           while(_--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int c = 1, mx = 0;     string s;     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] !=  A  && s[i] !=  O  && s[i] !=  I  && s[i] !=  U  &&           s[i] !=  Y  && s[i] !=  E ) {         c++;       } else {         if (c > mx) mx = c;         c = 1;       }     }     if (c > mx) mx = c;     cout << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, s, i, a[1003], res, x;   int main() {     cin >> n >> x;     for (i = 1; i <= n; i++) {       cin >> a[i];       s += a[i];     }     if (s <= 0) s *= (-1);     res = s / x;     if (s % x > 0) res++;     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   struct node {     int s, r, no;   } xx[500001], dance[500001], fire[500001];   bool cmp(node x, node y) { return x.s > y.s || (x.s == y.s && x.r > y.r); }   int S[500001];   int ans[500001];   int mal = 0;   int k;   int q;   bool yes[500001];   double eps = 1e-6;   int h, t;   map<int, int> X;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> xx[i].s >> xx[i].r;     for (int i = 1; i <= n; i++) xx[i].no = i;     sort(xx + 1, xx + n + 1, cmp);     for (int i = 1; i <= n; i++) {       if (mal > xx[i].r) continue;       if (mal == xx[i].r && q == xx[i].s) {         dance[++k] = xx[i];         continue;       }       if (q == xx[i].s) continue;       if (mal == xx[i].r) continue;       {         dance[++k] = xx[i];         mal = xx[i].r;         q = xx[i].s;       }     }     h = 1;     fire[++t] = dance[1];     for (int i = 2; i <= k; i++) {       if (h <= t && dance[i].r <= fire[t].r) continue;       while (h < t) {         long long s1 = fire[t - 1].s, s2 = fire[t].s, r1 = fire[t - 1].r,                   r2 = fire[t].r;         long long s3 = dance[i].s, r3 = dance[i].r;         long long k1 = (s3 - s2) * (r1 - r2) * r3 * s1;         long long k2 = (s1 - s2) * (r3 - r2) * r1 * s3;         if (k1 < k2)           t--;         else           break;       }       fire[++t] = dance[i];     }     int xxx = 0;     for (int i = 1; i <= t; i++) {       X[fire[i].s] = fire[i].r;     }     for (int i = 1; i <= n; i++) {       if (X[xx[i].s] == xx[i].r) ans[++xxx] = xx[i].no;     }     sort(ans + 1, ans + xxx + 1);     for (int i = 1; i <= xxx; i++) cout << ans[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   const int maxn = 2e5 + 10;   template <class T>   inline T read() {     int f = 1;     T ret = 0;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       ret = (ret << 1) + (ret << 3) + ch -  0 ;       ch = getchar();     }     ret *= f;     return ret;   }   template <class T>   inline void write(T n) {     if (n < 0) {       putchar( - );       n = -n;     }     if (n >= 10) {       write(n / 10);     }     putchar(n % 10 +  0 );   }   template <class T>   inline void writeln(const T &n) {     write(n);     puts(  );   }   template <typename T>   void _write(const T &t) {     write(t);   }   template <typename T, typename... Args>   void _write(const T &t, Args... args) {     write(t), putchar(   );     _write(args...);   }   template <typename T, typename... Args>   inline void write_line(const T &t, const Args &...data) {     _write(t, data...);   }   char s[maxn];   int pre, last;   int r, l;   int main(int argc, char const *argv[]) {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     cin >> s + 1;     for (int i = 1; i <= n / 2; i++)       if (s[i] ==  ? )         ++l;       else         pre += s[i] -  0 ;     for (int i = n / 2 + 1; i <= n; i++)       if (s[i] ==  ? )         ++r;       else         last += s[i] -  0 ;     if (pre == last) {       if (l == r)         cout <<  Bicarp n ;       else         cout <<  Monocarp n ;       return 0;     } else {       if (pre > last) swap(pre, last), swap(l, r);       if (l <= r)         cout <<  Monocarp n ;       else {         int left = last - pre;         l -= r;         l /= 2;         if (l * 9 == left)           cout <<  Bicarp n ;         else           cout <<  Monocarp n ;       }     }     return 0;   }