malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 888888;   int n, m, i, j, e;   int ss[N], ff[N], dd[N], x[N], last[N], pred[N], good[N], deg[N], used[N];   int main() {     scanf( %d %d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d %d %d , ss + i, ff + i, dd + i);       ss[i + m] = ff[i];       ff[i + m] = ss[i];       dd[i + m] = dd[i];     }     for (i = 1; i <= n; i++) last[i] = 0;     for (i = 1; i <= m + m; i++) {       good[i] = 0;       pred[i] = last[ss[i]];       last[ss[i]] = i;     }     for (i = 1; i <= n; i++) deg[i] = 0;     for (i = 1; i <= m + m; i++) deg[ss[i]] += dd[i];     for (i = 1; i <= n; i++) deg[i] /= 2;     for (i = 1; i <= n; i++) used[i] = 0;     deg[1] = deg[n] = 0;     i = 1;     e = 1;     x[1] = 1;     while (i <= e) {       j = last[x[i]];       while (j > 0) {         if (ff[j] == n) good[j] = 1;         if (used[ff[j]] < deg[ff[j]]) {           good[j] = 1;           used[ff[j]] += dd[j];           if (used[ff[j]] == deg[ff[j]]) {             e++;             x[e] = ff[j];           }         }         j = pred[j];       }       i++;     }     for (i = 1; i <= m; i++) printf( %d n , 1 - good[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, const U &b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, const U &b) {     if (a < b) a = b;   }   char s[100100], ss[4][100100];   int nxt[100100][26], N[4];   int dp[255][255][255], n;   inline void calc(int a_st, int a_ed, int b_st, int b_ed, int c_st, int c_ed) {     for (int i = a_st; i <= a_ed; i++) {       for (int j = b_st; j <= b_ed; j++) {         for (int k = c_st; k <= c_ed; k++) {           if (!i && !j && !k)             dp[i][j][k] = 0;           else {             dp[i][j][k] = 0x3f3f3f3f;             if (i && dp[i - 1][j][k] < n)               smin(dp[i][j][k], nxt[dp[i - 1][j][k] + 1][ss[1][i] -  a ]);             if (j && dp[i][j - 1][k] < n)               smin(dp[i][j][k], nxt[dp[i][j - 1][k] + 1][ss[2][j] -  a ]);             if (k && dp[i][j][k - 1] < n)               smin(dp[i][j][k], nxt[dp[i][j][k - 1] + 1][ss[3][k] -  a ]);           }         }       }     }   }   int main() {     int q;     scanf( %d %d %s , &n, &q, s + 1);     for (int i = 26; i--;) nxt[n + 1][i] = n + 1;     for (int i = n; i >= 1; i--) {       for (int j = 26; j--;) nxt[i][j] = nxt[i + 1][j];       nxt[i][s[i] -  a ] = i;     }     while (q--) {       char c;       scanf(  %c , &c);       if (c ==  + ) {         int id;         scanf( %d %c , &id, &c);         ss[id][++N[id]] = c;         if (id == 1) calc(N[1], N[1], 0, N[2], 0, N[3]);         if (id == 2) calc(0, N[1], N[2], N[2], 0, N[3]);         if (id == 3) calc(0, N[1], 0, N[2], N[3], N[3]);       } else {         int id;         scanf( %d , &id);         N[id]--;       }       puts(dp[N[1]][N[2]][N[3]] <= n ?  YES  :  NO );     }   }
#include <bits/stdc++.h>   using namespace std;   long long binaryExponentiation(long long x, long long m) {     if (x == 1) {       return 0;     } else {       return 1 + (((binaryExponentiation((x / 2), m))));     }   }   long long sumd(long long a) {     long long ans = 0;     while (a != 0) {       ans += a % 10;       a = a / 10;     }     return ans;   }   long long check(long long n, long long A[], long long m) {     long long ans = 0;     for (long long q = 0; q < m; q++) {       if ((A[q] - n) > 0) ans += A[q] - n;     }     return ans;   }   void solve() {     long long n;     cin >> n;     while (n--) {       long long a;       cin >> a;       cout << -(a - 1) <<     << a << endl;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct __s {     __s() {       if (1) {         ios_base::Init i;         cin.sync_with_stdio(0);         cin.tie(0);       }     }     ~__s() {       if (!1)         fprintf(stderr,  Execution time: %.3lf s. n ,                 (double)clock() / CLOCKS_PER_SEC);       long long n;       cin >> n;     }   } __S;   long long a[1111111];   long long ai[1111111];   int main(void) {     long long n;     cin >> n;     for (long long i = 0; i < (long long)(n); i++) {       cin >> a[i];       a[i]--;       ai[a[i]] = i;     }     long long cnt = 0;     for (long long i = 0; i < (long long)(n); i++) {       if (i == a[i]) continue;       long long j = ai[i];       swap(a[i], a[j]);       swap(ai[a[i]], ai[a[j]]);       cnt++;     }     long long m1 = 3 * n - cnt;     long long m2 = 7 * n + 1 - cnt;     if (m1 % 2 == 0)       cout <<  Petr  <<   n ;     else       cout <<  Um_nik  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1000000000000000;   int main() {     int t, n;     cin >> t;     for (int i = 0; i < t; i++) {       cin >> n;       string s, t;       if (n & 1) {         if (n == 1)           cout <<  a  <<   n ;         else {           s = string(n / 2,  a ) +  bc  + string(n / 2 - 1,  a );           cout << s <<   n ;         }       } else {         s = string(n / 2,  a ) +  b  + string(n / 2 - 1,  a );         cout << s <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     vector<int> v;     string s;     cin >> n >> s;     s +=    ;     k = 1;     for (int i = 0; i < s.length() - 1; i++) {       if (s[i + 1] == s[i]) {         k++;       } else {         if (s[i] ==  B ) {           v.push_back(k);         }         k = 1;       }     }     if (v.size()) {       cout << v.size() <<   n ;       for (int i = 0; i < v.size(); i++) {         cout << v[i] <<    ;       }     } else {       cout << 0 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double pi = 3.141592653589793238462;   string numkey =  0123456789 ;   string uni =  abcdefghijklmnopqrstuvwxyz ;   bool check(char ch) {     string s =  aeiou ;     for (long long int i = 0; i < s.size(); i++) {       if (s[i] == ch) return true;     }     return false;   }   signed main() {     string s;     cin >> s;     long long int n = s.length(), ctr = 0;     set<char> st;     for (long long int i = 0; i < n; i++) {       if (check(s[i]) == false)         ctr++, st.insert(s[i]);       else         ctr = 0, st.clear();       if (ctr > 2 && st.size() > 1) {         st.clear();         cout <<    ;         st.insert(s[i]);         ctr = 1;       }       cout << s[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int LIMIT = 1000;   long long n;   long long sqrt2(long long n) {     long long r = max((long long)sqrt(n) + 1, 0LL);     while (r * r > n) {       r--;     }     return r;   }   int sum(long long n) {     int result = 0;     while (n) {       result += n % 10;       n /= 10;     }     return result;   }   int main() {     cin >> n;     for (long long s = 1; s < LIMIT; ++s) {       long long d = s * s + 4 * n;       long long r = sqrt2(d);       if (r * r == d && (r - s) % 2 == 0) {         long long x = (r - s) / 2;         if (sum(x) == s) {           cout << x << endl;           return 0;         }       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t[4000050], tag[4000050];   vector<int> v[1005000];   inline void refresh(int now) { t[now] = max(t[now << 1], t[now << 1 | 1]); }   void pushdown(int l, int r, int now) {     if (l == r) {       tag[now] = 0;       return;     }     tag[now << 1] += tag[now];     tag[now << 1 | 1] += tag[now];     int mid = (l + r) >> 1;     t[now << 1] += tag[now];     t[now << 1 | 1] += tag[now];     tag[now] = 0;   }   void add(int l, int r, int now, int LL, int RR, int data) {     if (LL <= l && r <= RR) {       t[now] += data;       tag[now] += data;       return;     }     if (tag[now]) pushdown(l, r, now);     int mid = (l + r) >> 1;     if (LL <= mid) add(l, mid, now << 1, LL, RR, data);     if (mid < RR) add(mid + 1, r, now << 1 | 1, LL, RR, data);     refresh(now);   }   int query(int l, int r, int now, int LL, int RR) {     if (LL <= l && r <= RR) {       return t[now];     }     if (tag[now]) pushdown(l, r, now);     int mid = (l + r) >> 1;     int ans = -1e9;     if (LL <= mid) ans = max(query(l, mid, now << 1, LL, RR), ans);     if (mid < RR) ans = max(ans, query(mid + 1, r, now << 1 | 1, LL, RR));     refresh(now);     return ans;   }   int i, j, k, n, m, st[1005000][2], siz[1005000], id[1005000], it, sb;   void dfs(int x) {     siz[x]++;     for (auto i : v[x]) {       dfs(i);       siz[x] += siz[i];     }     id[x] = ++it;   }   int main() {     scanf( %d%d , &n, &sb);     for (i = 1; i <= n; i++) {       scanf( %d , &k);       while (m && st[m][1] < k) {         v[i].push_back(st[m][0]);         m--;       }       st[++m][0] = i;       st[m][1] = k;     }     n++;     while (m) {       v[n].push_back(st[m][0]);       m--;     }     dfs(n);     for (i = 1; i <= sb; i++) {       add(1, n, 1, id[i] - siz[i] + 1, id[i], 1);     }     for (i = sb; i < n; i++) {       printf( %d  , t[1]);       add(1, n, 1, id[i + 1] - siz[i + 1] + 1, id[i + 1], 1);       add(1, n, 1, id[i - sb + 1] - siz[i - sb + 1] + 1, id[i - sb + 1], -1);     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<long long, long long> > a;   set<int> extr;   set<int>::iterator it;   vector<int> e;   int f[300005];   long long mnx = 999999999999999999, mny = 999999999999999999,             mxx = -999999999999999999, mxy = -999999999999999999;   int main() {     cin >> n;     a.reserve(n);     for (int i = 0; i < n; i++) {       long long x, y;       cin >> x >> y;       a.push_back({x, y});     }     long long m = 0;     for (int i = 0; i < n; i++) {       if (a[i].first <= a[m].first) {         m = i;         mnx = a[m].first;       }     }     extr.insert(m);     f[m] = 1;     m = 0;     for (int i = 0; i < n; i++) {       if (a[i].second <= a[m].second) {         m = i;         mny = a[m].second;       }     }     extr.insert(m);     f[m] = 1;     m = 0;     for (int i = 0; i < n; i++) {       if (a[i].first >= a[m].first) {         m = i;         mxx = a[m].first;       }     }     extr.insert(m);     f[m] = 1;     m = 0;     for (int i = 0; i < n; i++) {       if (a[i].second >= a[m].second) {         m = i;         mxy = a[m].second;       }     }     extr.insert(m);     f[m] = 1;     for (it = extr.begin(); it != extr.end(); it++) {       e.push_back(*it);     }     long long p = -999999999999999999;     for (int i = 0; i < e.size(); i++) {       for (int j = i + 1; j < e.size(); j++) {         for (int k = 0; k < n; k++) {           if (k == e[i] || k == e[j]) continue;           long long minx = min(a[e[i]].first, min(a[e[j]].first, a[k].first));           long long maxx = max(a[e[i]].first, max(a[e[j]].first, a[k].first));           long long miny = min(a[e[i]].second, min(a[e[j]].second, a[k].second));           long long maxy = max(a[e[i]].second, max(a[e[j]].second, a[k].second));           if (p < ((maxx - minx) + (maxy - miny)) * 2) {             p = ((maxx - minx) + (maxy - miny)) * 2;           }         }       }     }     cout << p <<    ;     for (int i = 0; i < n - 3; i++)       cout << ((mxx - mnx) + (mxy - mny)) * 2 <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int a[100005];   map<int, int> s;   int main(void) {     long long ans = 0, z = 0;     int k, b, n;     scanf( %d%d%d , &k, &b, &n);     int zcnt = 0;     s[0]++;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       zcnt = (a[i] ? 0 : zcnt + 1);       z += zcnt;       a[i] = (a[i] + a[i - 1]) % (k - 1);       int P = (a[i] - b + k - 1) % (k - 1);       ans += s[P];       s[a[i]]++;     }     if (b == 0)       ans = z;     else if (b == k - 1)       ans -= z;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fen[100100];   int n, ans = -1, a[100100];   int calc(int ind) {     int ans = 0;     for (int i = ind; i >= 1; i -= i & (-i)) ans ^= fen[i];     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     memset(fen, 0, sizeof(fen));     cin >> n;     for (int i = 2; i <= n; i++) {       int t;       int p = 0;       set<int> s;       for (int j = 2; j * (j + 1) / 2 <= i; j++) {         int k = i - j * (j + 1) / 2;         if (k % j != 0) continue;         k /= j;         t = calc(k + j) ^ calc(k);         if (i == n and ans == -1 and !t) ans = j;         s.insert(t);       }       while (s.count(p)) p++;       for (int j = i; j <= n; j += j & (-j)) fen[j] ^= p;     }     cout << ans;     return 0;   }
#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 std::cin;   using std::cout;   const int maxn = 100100;   int n, m, s;   long long t;   int f[2][maxn], *to = f[0], *lol = f[1];   int jump[40][maxn];   inline void cpy(int* a, int b, int len) {     b %= n;     if (b + len < n) {       memcpy(a, to + b, len << 2);     } else {       memcpy(a, to + b, n - b << 2);       memcpy(a + n - b, to, len - (n - b) << 2);     }   }   int main() {     std::ios::sync_with_stdio(false), std::cin.tie(0);     std::cin >> n >> m >> s >> t, --s;     for (int i = 0; i < n; ++i) to[i] = i;     for (int T = 0; T < n; ++T) {       cpy(lol, T, m);       cpy(lol + m, m - T + n, n - m);       std::swap(to, lol);     }     for (int i = 0; i < n; ++i) jump[0][i] = to[i];     for (int i = 1; i < 40; ++i) {       for (int j = 0; j < n; ++j) {         jump[i][j] = jump[i - 1][jump[i - 1][j]];       }     }     for (; t % n != 0; --t) {       if (s < m) {         s = (s + t) % n;       } else {         s = ((s - t) % n + n) % n;       }     }     t /= n;     for (int i = 39; i >= 0; --i)       if (t >> i & 1) {         s = jump[i][s];       }     cout << s + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int d(int a, int b, int a1, int b1) { return abs(a - a1) + abs(b - b1); }   int main() {     int n;     cin >> n;     int x1, x2, y1, y2;     cin >> x1 >> y1 >> x2 >> y2;     if (y1 == y2 && (y1 == 0 || y1 == n)) {       cout << abs(x1 - x2) << endl;       return 0;     }     if (x1 == x2 && (x1 == 0 || x1 == n)) {       cout << abs(y1 - y2) << endl;       return 0;     }     if (abs(y1 - y2) == n) {       swap(x1, y1);       swap(x2, y2);     }     if (abs(x1 - x2) == n) {       cout << n + min(y1 + y2, 2 * n - y1 - y2) << endl;       return 0;     }     int mi = 2 * n;     for (int i = 0; i <= n; i += n)       for (int j = 0; j <= n; j += n) {         mi = min(mi, d(x1, y1, i, j) + d(x2, y2, i, j));       }     cout << mi << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   inline int rand(int x, int y) {     ++y;     return (rng() % (y - x)) + x;   }   int n, m;   string A;   int ind(char ch) {     if (ch ==  A ) return 0;     if (ch ==  T ) return 1;     if (ch ==  G ) return 2;     return 3;   }   struct node {     int second, e, m;     int v;     node *l, *r;     node(int _s, int _e) {       second = _s, e = _e, m = (second + e) / 2;       v = 0;       if (second != e) {       }       l = NULL;       r = NULL;     }     void update(int x, int nv) {       if (second == e) {         v += nv;         return;       }       if (x > m) {         create(r, m + 1, e);         assert(r != NULL);         r->update(x, nv);       } else {         create(l, second, m);         assert(l != NULL);         l->update(x, nv);       }       v = 0;       v += get(l);       v += get(r);     }     int rmq(int x, int y) {       if (second == x && e == y) return v;       if (x > m)         return rcall(x, y);       else if (y <= m)         return lcall(x, y);       else         return lcall(x, m) + rcall(m + 1, y);     }     int rcall(int x, int y) {       if (r == NULL) return 0;       return r->rmq(x, y);     }     int lcall(int x, int y) {       if (l == NULL) return 0;       return l->rmq(x, y);     }     void create(node *&tmp, int x, int y) {       if (tmp != NULL) return;       tmp = new node(x, y);       assert(tmp != NULL);     }     int get(node *l) {       if (l == NULL) return 0;       return l->v;     }   } * seg[4][11][10];   void doo(int i, int op) {     for (int j = 1; j < 11; j++) {       { seg[ind(A[i])][j][i % j]->update(i, 1 * op); }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> A;     n = A.length();     cin >> m;     for (int i = 0; i < 4; i++)       for (int j = 0; j < 11; j++)         for (int k = 0; k < 10; k++) seg[i][j][k] = new node(0, n - 1);     for (int i = 0; i < n; i++) {       for (int j = 1; j < 11; j++) {         { seg[ind(A[i])][j][i % j]->update(i, 1); }       }     }     for (int ii = 0; ii < m; ii++) {       int op;       cin >> op;       if (op == 1) {         int x, c;         char ch;         cin >> x >> ch;         c = ind(ch);         --x;         doo(x, -1);         A[x] = ch;         doo(x, 1);       } else {         int l, r;         string e;         cin >> l >> r >> e;         --l, --r;         int ans = 0;         for (int i = 0; i < e.length(); i++) {           if (i + l > r) continue;           ans +=               seg[ind(e[i])][e.length()][((i + l) % (int)e.length())]->rmq(l, r);         }         cout << ans <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2005;   const int MOD = 1e9 + 7;   long long int dp[MAXN][MAXN];   void c() {     for (int i = 0; i < MAXN; i++) {       for (int j = 0; j < MAXN; j++) {         if (i == j)           dp[i][j] = 1;         else if (j == 0)           dp[i][j] = 1;         else if (i == 0)           dp[i][j] = 0;         else {           dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % MOD;         }       }     }   }   int main() {     c();     int n, m, k;     cin >> n >> m >> k;     cout << (dp[n - 1][2 * k] * dp[m - 1][2 * k]) % MOD <<   n ;   }
#include <bits/stdc++.h>   using std::sort;   struct Edge {     int v, w, next;   } e[200002];   int ecnt, h[100002];   inline void add_edge(int u, int v, int w) {     e[++ecnt] = {v, w, h[u]};     h[u] = ecnt;     e[++ecnt] = {u, w, h[v]};     h[v] = ecnt;   }   int size[100002], dis1[100002], dis2[100002], dp[100002];   int L, W;   int node[100002], cnt;   bool vis[100002];   inline int max(int x, int y) { return x > y ? x : y; }   void get_root(int u, int fa, int s, int &cur) {     size[u] = 1, dp[u] = 0;     for (int i = h[u]; i; i = e[i].next)       if (!vis[e[i].v] && e[i].v != fa)         get_root(e[i].v, u, s, cur), size[u] += size[e[i].v],             dp[u] = max(dp[u], size[e[i].v]);     dp[u] = max(dp[u], s - size[u]);     if (dp[u] < dp[cur]) cur = u;   }   void fill(int u, int fa, int w) {     size[u] = 1;     dis1[u] = dis1[fa] + w;     dis2[u] = dis2[fa] + 1;     for (int i = h[u]; i; i = e[i].next)       if (!vis[e[i].v] && e[i].v != fa)         fill(e[i].v, u, e[i].w), size[u] += size[e[i].v];   }   void get_node(int u, int fa) {     node[++cnt] = u;     for (int i = h[u]; i; i = e[i].next)       if (!vis[e[i].v] && e[i].v != fa) get_node(e[i].v, u);   }   inline bool cmp(int u, int v) { return dis1[u] < dis1[v]; }   int c[100002];   inline void add(int x, int v) {     x++;     for (; x <= 100000; x += ((x) & -(x))) c[x] += v;   }   inline int sum(int x) {     x++;     if (x <= 0) return 0;     int ans = 0;     for (; x > 0; x -= ((x) & -(x))) ans += c[x];     return ans;   }   long long Ans;   inline long long solve() {     long long ans = 0;     sort(node + 1, node + cnt + 1, cmp);     for (int i = 1; i <= cnt; i++) add(dis2[node[i]], 1);     int j = cnt;     for (int i = 1; i < j; i++) {       while (i < j && dis1[node[i]] + dis1[node[j]] > W)         add(dis2[node[j]], -1), j--;       if (i >= j) break;       add(dis2[node[i]], -1);       ans += sum(L - dis2[node[i]]);     }     add(dis2[node[j]], -1);     return ans;   }   inline void clear() { cnt = 0; }   void dfs(int u) {     dis1[u] = dis2[u] = 0;     fill(u, 0, 0);     for (int i = h[u]; i; i = e[i].next)       if (!vis[e[i].v]) get_node(e[i].v, u), Ans -= solve(), clear();     get_node(u, 0), Ans += solve(), clear();     vis[u] = 1;     for (int i = h[u]; i; i = e[i].next)       if (!vis[e[i].v]) {         int rt = 0;         get_root(e[i].v, 0, size[e[i].v], rt);         dfs(rt);       }   }   int main() {     int n, tu, tw;     dp[0] = 114514;     dis2[0] = -1;     scanf( %d%d%d , &n, &L, &W);     for (int i = 2; i <= n; i++) scanf( %d%d , &tu, &tw), add_edge(i, tu, tw);     int rt = 0;     get_root(1, 0, n, rt);     dfs(rt);     printf( %I64d , Ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100100;   bool isPrime[N];   vector<int> primes;   vector<int> adj[N];   void init() {     memset(isPrime, true, sizeof(isPrime));     for (int i = 2; i * i <= N; i++)       if (isPrime[i]) {         for (int j = i * i; j < N; j += i) isPrime[j] = false;       }     for (int i = (2); i < (N); i++)       if (isPrime[i]) primes.push_back(i);   }   vector<int> a;   set<pair<int, int> > s;   inline void mySwap(int j, int i) {     s.erase(make_pair(-a[i], i));     s.insert(make_pair(-a[i], j));     swap(a[i], a[j]);   }   int main() {     init();     adj[2].push_back(2);     for (int i = 4; i < N; i += 2) {       for (int j = 0; primes[j] < i; j++) {         if (binary_search(primes.begin(), primes.end(), i - primes[j])) {           adj[i].push_back(primes[j]);           adj[i].push_back(i - primes[j]);           break;         }       }       assert((int)adj[i].size() == 2);     }     int n;     cin >> n;     a.resize(n);     for (int i = 0; i < (n); i++) {       cin >> a[i];       s.insert(make_pair(-a[i], i));     }     vector<pair<int, int> > ans;     for (int i = 0; i < (n); i++) {       pair<int, int> cur = *s.begin();       s.erase(s.begin());       int pos = cur.second;       int end = n - i - 1;       int diff = (end - pos);       if (diff == 0) continue;       if (isPrime[diff + 1]) {         ans.push_back(make_pair(pos, end));         mySwap(pos, end);         continue;       } else {         if (diff % 2 == 0) {           diff += 2;           assert((int)adj[diff].size() % 2 == 0);           int len1 = adj[diff][0], len2 = adj[diff][1];           assert(len1 + len2 == diff);           ans.push_back(make_pair(pos, pos + len1 - 1));           mySwap(pos, pos + len1 - 1);           ans.push_back(make_pair(pos + len1 - 1, end));           mySwap(pos + len1 - 1, end);           continue;         } else {           ans.push_back(make_pair(pos, pos + 1));           mySwap(pos, pos + 1);           diff += 1;           pos += 1;           int len1 = adj[diff][0], len2 = adj[diff][1];           assert(len1 + len2 == diff);           ans.push_back(make_pair(pos, pos + len1 - 1));           mySwap(pos, pos + len1 - 1);           ans.push_back(make_pair(pos + len1 - 1, end));           mySwap(pos + len1 - 1, end);           continue;         }       }     }     cout << (int)ans.size() << endl;     for (int i = 0; i < ((int)ans.size()); i++) {       int l = min(ans[i].first, ans[i].second) + 1;       int r = max(ans[i].first, ans[i].second) + 1;       assert(isPrime[r - l + 1]);       cout << l <<     << r << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unordered_map<char, int> check;     int n, count = 0;     cin >> n;     string temp;     cin >> temp;     for (int i = 0; i < temp.size() - 1; i += 2) {       check[temp[i]]++;       char ch = temp[i + 1];       ch = tolower(ch);       if (check.find(ch) != check.end()) {         if (check[ch] == 1)           check.erase(ch);         else           check[ch]--;       } else {         count++;       }     }     cout << count;     return 0;   }