malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int N;   char s[1005], z[1005];   int solve1() {     int ans = 0;     int lz, rz, ls, rs;     lz = ls = 0;     rz = rs = N - 1;     while (ls <= rs) {       if (z[rz] >= s[rs])         rz--, rs--;       else         ans++, lz++, rs--;     }     return ans;   }   int solve2() {     int ans = 0;     int lz, rz, ls, rs;     lz = ls = 0;     rz = rs = N - 1;     while (ls <= rs) {       if (z[rz] > s[rs])         ans++, rz--, rs--;       else         lz++, rs--;     }     return ans;   }   int main() {     scanf( %d%s%s , &N, s, z);     sort(s, s + N);     sort(z, z + N);     printf( %d n%d , solve1(), solve2());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int dr8[] = {0, 0, 1, -1, 1, 1, -1, -1};   int dc8[] = {1, -1, 0, 0, -1, 1, -1, 1};   int dr4[] = {0, 1, -1, 0};   int dc4[] = {1, 0, 0, -1};   int dp[N][N][15][15][2];   int n1, n2, n, k1, k2;   int calc(int f, int h, int tf, int th, int pr) {     if (f > k1 || h > k2 || tf > n1 || th > n2) return 0;     if (f <= k1 && h <= k2 && tf == n1 && th == n2) return 1;     if (dp[th][tf][f][h][pr] != -1) return dp[th][tf][f][h][pr];     int ans = 0;     if (pr == 0)       ans = (1LL * calc(f + 1, 0, tf + 1, th, 0) % 100000000 +              calc(0, 1, tf, th + 1, 1) % 100000000) %             100000000;     else       ans = (1LL * calc(0, h + 1, tf, th + 1, 1) % 100000000 +              calc(1, 0, tf + 1, th, 0) % 100000000) %             100000000;     return dp[th][tf][f][h][pr] = ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     memset(dp, -1, sizeof dp);     cin >> n1 >> n2 >> k1 >> k2;     n = n1 + n2;     int ans = calc(1, 0, 1, 0, 0) % 100000000;     memset(dp, -1, sizeof dp);     ans = (1LL * ans + calc(0, 1, 0, 1, 1)) % 100000000;     cout << ans % 100000000;   }
#include <bits/stdc++.h>   using namespace std;   inline int rd() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();     return x * f;   }   const int N = 100009;   int n, m, o, a[N], pre[N], suf[N], numq, tr[N];   long long ans[N];   set<int> s[N];   struct node {     int opt, x, y, v, id;     inline bool operator<(const node& rhs) const { return x < rhs.x; }   } p[N * 7], q[N * 7];   int suf_(int v, int x) { return *s[v].upper_bound(x); }   int pre_(int v, int x) {     set<int>::iterator it = s[v].lower_bound(x);     --it;     return *it;   }   void link(int x, int y) {     ++o, p[o].opt = 0, p[o].x = x, p[o].y = pre[x], p[o].v = pre[x] - x,          p[o].id = 0;     pre[x] = y;     ++o, p[o].opt = 0, p[o].x = x, p[o].y = pre[x], p[o].v = x - pre[x],          p[o].id = 0;   }   void add(int x, int d) {     if (!x) return;     for (int i = x; i <= n; i += i & -i) tr[i] += d;   }   int ask(int x) {     int res = 0;     for (int i = x; i > 0; i -= i & -i) res += tr[i];     return res;   }   void clear(int x) {     if (!x) return;     for (int i = x; i <= n; i += i & -i) tr[i] = 0;   }   void cdq(int l, int r) {     if (l == r) return;     int mid = (l + r) >> 1;     cdq(l, mid), cdq(mid + 1, r);     for (int i = mid + 1, j = l; i <= r; ++i) {       if (!p[i].opt) continue;       for (; j <= mid && p[j].x <= p[i].x; ++j)         if (!p[j].opt) add(p[j].y, p[j].v);       ans[p[i].id] += ask(n) - ask(p[i].y - 1);     }     for (int i = l; i <= mid; ++i)       if (!p[i].opt) clear(p[i].y);     merge(p + l, p + mid + 1, p + mid + 1, p + r + 1, q + l);     for (int i = l; i <= r; ++i) p[i] = q[i];   }   signed main() {     n = rd(), m = rd();     for (int i = 1; i <= n; ++i) a[i] = rd(), s[a[i]].insert(i);     for (int i = 1; i <= n; ++i) s[i].insert(0), s[i].insert(n + 1);     for (int i = 1; i <= n; ++i)       pre[i] = pre_(a[i], i), suf[i] = suf_(a[i], i), ++o, p[o].opt = 0,       p[o].x = i, p[o].y = pre[i], p[o].v = i - pre[i], p[o].id = 0;     for (int i = 1; i <= m; ++i) {       int opt = rd(), x = rd(), y = rd();       if (opt == 2)         ++o, ++numq, p[o].opt = 1, p[o].x = y, p[o].y = x, p[o].id = numq;       else {         if (y == a[x]) continue;         int P = pre_(y, x), S = suf_(y, x);         s[y].insert(x), s[a[x]].erase(x), a[x] = y;         if (suf[x] != n + 1) link(suf[x], pre[x]);         if (pre[x]) suf[pre[x]] = suf[x];         if (S != n + 1) link(S, x);         if (P) suf[P] = x;         link(x, P);         suf[x] = S;       }     }     cdq(1, o);     for (int i = 1; i <= numq; ++i) printf( %lld n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[1100];   int need[1100];   bool visit[1100];   vector<pair<int, int> > vec;   int exist[1100];   void bfs(int st) {     queue<pair<int, int> > q;     memset(visit, 0, sizeof visit);     q.push({st, 0});     while (!q.empty()) {       int u = q.front().first;       int c = q.front().second;       q.pop();       if (visit[u]) continue;       visit[u] = 1;       if (need[u]) vec.push_back({c, u});       for (auto v : adj[u])         if (!visit[v]) q.push({v, c + 1});     }     sort(vec.begin(), vec.end());   }   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (int i = 1; i <= n; ++i) adj[i].clear();       for (int i = 0; i < n - 1; ++i) {         int a, b;         scanf( %d%d , &a, &b);         adj[a].push_back(b);         adj[b].push_back(a);       }       int k;       scanf( %d , &k);       memset(need, 0, sizeof need);       for (int i = 0; i < k; ++i) {         int x;         scanf( %d , &x);         need[x] = 1;       }       scanf( %d , &k);       memset(exist, 0, sizeof exist);       int y;       for (int i = 0; i < k; ++i) {         scanf( %d , &y);         exist[y] = 1;       }       vec.clear();       cout <<  B   << y << endl;       int st;       cin >> st;       bfs(st);       cout <<  A   << vec[0].second << endl;       cin >> y;       if (exist[y])         cout <<  C   << vec[0].second << endl;       else         cout <<  C -1  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N;   pair<int, int> P[105];   int main() {     cin >> N;     for (int i = 1; i <= N; i++) cin >> P[i].first >> P[i].second;     int K;     cin >> K;     for (int i = 1; i <= N; i++)       if (K >= P[i].first && K <= P[i].second) {         cout << N - i + 1 <<   n ;         return 0;       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   const long long int inf = 1e18;   long long int a[N];   long long int b[N];   long long int dp[N][3];   int main() {     int t;     cin >> t;     while (t--) {       int n;       scanf( %d , &n);       for (int i = 1; i <= n; i++) scanf( %lld %lld , &a[i], &b[i]);       dp[1][0] = 0;       dp[1][1] = b[1];       dp[1][2] = 2 * b[1];       for (int i = 2; i <= n; i++) {         dp[i][0] = dp[i][1] = dp[i][2] = inf;         for (int j = 0; j <= 2; j++) {           for (int k = 0; k <= 2; k++) {             if (a[i - 1] + j == a[i] + k) continue;             dp[i][k] = min(dp[i][k], dp[i - 1][j] + k * b[i]);           }         }       }       printf( %lld n , min(dp[n][0], min(dp[n][1], dp[n][2])));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e7 + 2;   const int M = (int)5e5 + 2;   const int mod = (int)1e9 + 7;   int mu[N], cnt[N];   int n, mx, x, p[M];   long long res;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( test                 .inp ,                r )) {       freopen(            test             .inp ,            r , stdin);       freopen(            test             .out ,            w , stdout);     }     cin >> n;     p[0] = 1;     for (int i = 1; i <= n; ++i) {       cin >> x;       mx = max(mx, x);       ++cnt[x];       p[i] = 2ll * p[i - 1] % mod;     }     mu[1] = 1;     fill(mu + 2, mu + mx + 1, -1);     int s;     for (int i = 2; i <= mx; ++i) {       s = cnt[i];       for (int j = 2 * i; j <= mx; j += i) mu[j] -= mu[i], s += cnt[j];       if (mu[i] != 0)         res = (res + 1ll * (p[s] - 1) * (-mu[i]) * (n - s) % mod) % mod;     }     res += mod;     cout << res % mod;   }
#include <bits/stdc++.h>   using namespace std;   unordered_map<string, int> M;   vector<string> WHAT;   vector<int> LEFT, RIGHT;   int check(int v, int place) {     vector<int> V = {v};     for (int i = 0; i < (int)WHAT.size(); i++) {       if (WHAT[i][0] ==  0  or WHAT[i][0] ==  1 )         V.push_back(WHAT[i][place] -  0 );       else {         int left = V[LEFT[i]], right = V[RIGHT[i]];         if (WHAT[i] ==  AND ) V.push_back(left & right);         if (WHAT[i] ==  OR ) V.push_back(left | right);         if (WHAT[i] ==  XOR ) V.push_back(left ^ right);       }     }     int sum = 0;     for (int i = 1; i < (int)V.size(); i++) sum += V[i];     return sum;   }   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     LEFT.resize(n);     RIGHT.resize(n);     for (int i = 0; i < n; i++) {       string var, bs, left, op, right;       cin >> var >> bs >> left;       M[var] = i + 1;       if (not(left[0] ==  0  or left[0] ==  1 )) {         cin >> op >> right;         int noleft = (left ==  ? ) ? 0 : M[left];         int noright = (right ==  ? ) ? 0 : M[right];         WHAT.push_back(op);         LEFT[i] = noleft;         RIGHT[i] = noright;       } else {         WHAT.push_back(left);       }     }     string resmin =   ;     string resmax =   ;     for (int i = 0; i < m; i++) {       int w0 = check(0, i);       int w1 = check(1, i);       if (w1 > w0)         resmax +=  1 ;       else         resmax +=  0 ;       if (w1 < w0)         resmin +=  1 ;       else         resmin +=  0 ;     }     cout << resmin <<   n  << resmax <<   n ;     return 0;   }
#include <bits/stdc++.h>   int main() {     const int N = 8;     std::string pokemons[] = { vaporeon ,  jolteon ,  flareon ,  espeon ,                                umbreon ,   leafeon ,  glaceon ,  sylveon };     int n;     scanf( %d n , &n);     std::string hidden;     std::cin >> hidden;     std::string output =   ;     for (int p = 0; p < N; p++) {       std::string current = pokemons[p];       if (current.size() != n) {         continue;       }       bool possible = 1;       for (int q = 0; q < n; q++) {         if (hidden[q] !=  .  && hidden[q] != current[q]) {           possible = 0;           break;         }       }       if (possible) {         output = current;         break;       }     }     std::cout << output << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long n, m;     while (cin >> n >> m) {       long long a[100100], b[101000], p, x, i, j, mm, l, r, cc = 0, pp, y, m1,                                                             qq = 0;       l = 1;       r = n + 1;       while (l <= r) {         x = (l + r) / 2;         mm = 1;         pp = 0;         while (1) {           if (x / mm == 0) {             break;           }           pp += x / mm;           mm *= m;         }         if (n > pp)           l = x + 1;         else           r = x - 1;       }       cout << l <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, i, n = 0, j = 0;     cin >> a >> b;     int k = sqrt(a);     if (a == b) {       cout <<  infinity  << endl;     } else       ;     if (a != b) {       for (i = 1; i * i <= a; i++) {         if ((a - b) % i == 0 && i > b) n++;         if ((a - b) % i == 0 && (a - b) / i > b && i != (a - b) / i) n++;       }       cout << n << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 6e5 + 10;   int n, k, l[maxn][2];   int fa[maxn], sz[maxn];   string s;   int get_fa(int x) {     if (x == fa[x]) return x;     return fa[x] = get_fa(fa[x]);   }   int calc(int x) {     int y;     if (x <= k)       y = x + k;     else       y = x - k;     x = get_fa(x), y = get_fa(y);     if (x == 0 || y == 0) return sz[x + y];     return min(sz[x], sz[y]);   }   void merge_dis(int x, int y) {     x = get_fa(x);     y = get_fa(y);     if (y == 0) {       swap(x, y);     }     fa[y] = x;     if (x != 0) sz[x] += sz[y];   }   int main() {     scanf( %d%d , &n, &k);     cin >> s;     for (int i = 1; i <= (int)3e5; i++)       fa[i] = i, fa[i + k] = i + k, sz[i + k] = 1;     for (int i = 1, c; i <= k; i++) {       scanf( %d , &c);       for (int j = 0, x; j < c; j++) {         scanf( %d , &x);         if (l[x][0] == 0)           l[x][0] = i;         else           l[x][1] = i;       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       if (l[i][1] == 0) {         int x = l[i][0];         if (x) {           ans -= calc(x);           if (s[i - 1] ==  1 )             fa[get_fa(x + k)] = 0;           else             fa[get_fa(x)] = 0;           ans += calc(x);         }       } else {         int x = l[i][0], y = l[i][1];         if (s[i - 1] ==  1 ) {           if (get_fa(x) != get_fa(y)) {             ans -= calc(x);             ans -= calc(y);             merge_dis(x, y);             merge_dis(x + k, y + k);             ans += calc(x);           }         } else {           if (get_fa(x + k) != get_fa(y)) {             ans -= calc(x);             ans -= calc(y);             merge_dis(x + k, y);             merge_dis(x, y + k);             ans += calc(x);           }         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename t>   t in(t q) {     cin >> q;     return q;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  [ ;     for (int i = 0; i < ((int)(v).size()); ++i) {       os << v[i];       if (i != ((int)(v).size()) - 1) os <<  , ;     }     os <<  ] ;     return os;   }   template <typename T, typename S>   ostream &operator<<(ostream &os, const map<T, S> &v) {     for (auto it : v) os <<  (  << it.first <<  :  << it.second <<  ) ;     return os;   }   template <typename T, typename S>   ostream &operator<<(ostream &os, const pair<T, S> &v) {     os <<  (  << v.first <<  ,  << v.second <<  ) ;     return os;   }   const long double PI = acosl(-1);   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());   inline int rand(int l, int r) {     return uniform_int_distribution<int>(l, r)(rng);   }   inline long long rand(long long l, long long r) {     return uniform_int_distribution<long long>(l, r)(rng64);   }   using namespace std;   const int N = 200005, M = 1005;   const long long MOD = 1e9 + 7;   const int OO = 1e9;   int a[11][11];   void solve() {     int n;     cin >> n;     for (int i = 0; i <= n; i++) {       a[i][1] = 1;       a[1][i] = 1;     }     for (int i = 2; i <= n; i++) {       for (int j = 2; j <= n; j++) {         a[i][j] = a[i - 1][j];         a[i][j] += a[i][j - 1];       }     }     cout << a[n][n] <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs  <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (1LL << 21) + 10;   int N, T, len, Imakf, bits[MAXN];   long long a[MAXN], b[MAXN];   char tem[MAXN];   void fi(const char* tem) {     if (!strlen(tem)) return;     char A[50];     const char B[4] = { . ,  i ,  n , 0}, C[5] = { . ,  o ,  u ,  t , 0};     sprintf(A,  %s%s , tem, B);     freopen(A,  r , stdin);     sprintf(A,  %s%s , tem, C);     freopen(A,  w , stdout);   }   void fwt(long long* A, int type) {     for (int mid = 1; mid < len; mid <<= 1) {       for (int j = 0; j < len; j += (mid << 1)) {         for (int k = 0; k < mid; k++) {           A[j + k + mid] += type * A[j + k];         }       }     }   }   int main() {     fi(  );     scanf( %d , &N);     len = 1LL << N, Imakf = len - 1;     for (int i = 0; i < len; i++) bits[i] = bits[i >> 1] + (i & 1);     scanf( %s , tem);     for (int i = 0; i < len; i++)       a[i] = (long long)(tem[i] -  0 ) << ((long long)bits[i] << 1);     fwt(a, 1);     scanf( %s , tem);     for (int i = 0; i < len; i++)       b[i] = (long long)(tem[i] -  0 ) << ((long long)bits[i] << 1);     fwt(b, 1);     for (int i = 0; i < len; i++) b[i] = (b[i] * a[i]);     fwt(b, -1);     for (int i = 0; i < len; i++)       printf( %lld , ((long long)b[i] >> ((long long)bits[i] << 1)) & 3);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long r, m, n, x, y, a[5000005], b[5000005];   long long fb(long long i, long long j, long long p) {     if (p < b[i]) return i - 1;     if (p >= b[j]) return j;     long long mid = (i + j) / 2;     if (b[mid] >= p && b[mid + 1] < p) return mid;     if (b[mid] > p)       return fb(i, mid, p);     else       return fb(mid + 1, j, p);   }   long long fb2(long long i, long long j, long long p) {     if (p < a[i]) return i - 1;     if (p >= a[j]) return j;     long long mid = (i + j) / 2;     if (a[mid] >= p && a[mid + 1] < p) return mid;     if (a[mid] > p)       return fb2(i, mid, p);     else       return fb2(mid + 1, j, p);   }   int main() {     ios_base::sync_with_stdio(0);     long long k = 0, t = 0, z = 1e7, l = 0, i, j;     cin >> n >> x >> y >> t;     string s;     cin >> s;     z = 0;     for (i = n - 1; i >= 0; i--) {       l = l + x;       if (s[i] ==  w ) l = l + y;       l++;       b[z++] = l;       if (l > t) break;     }     l = 0;     for (i = 0; i < n; i++) {       if (s[i] ==  w ) l = l + y;       l++;       a[i] = l;       if (l > t) break;       l = l + x;     }     sort(a, a + i);     sort(b, b + z);     long long sa = i;     l = 0;     r = 0;     i = 0;     for (i = 0; i < sa; i++) {       l = a[i];       if (l > t) break;       m = t - l - i * x;       if (m > 0) {         j = fb(0, z - 1, m) + 1;         r = max(r, i + j + 1);       } else         r = max(r, i + 1);     }     for (i = 0; i < z; i++) b[i] += a[0];     for (i = 1; i < sa; i++) a[i] = a[i] - a[0] - x;     for (i = 0; i < z; i++) {       l = b[i];       if (l > t) break;       m = t - l - (i + 2) * x;       if (m > 0) {         j = fb2(1, sa - 1, m);         r = max(r, i + j + 2);       } else         r = max(r, i + 2);     }     r = min(r, n);     cout << r;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> graph[300005];   long long col[300005];   long long ans, r, b;   pair<long long, long long> dfs(long long x, long long p = -1) {     long long a1, b1;     a1 = 0;     b1 = 0;     if (col[x] == 1) a1++;     if (col[x] == 2) b1++;     for (long long i = 0; i < graph[x].size(); i++) {       if (graph[x][i] == p) continue;       auto temp = dfs(graph[x][i], x);       if (temp.first == r && temp.second == 0) ans++;       if (temp.first == 0 && temp.second == b) ans++;       a1 += temp.first;       b1 += temp.second;     }     return {a1, b1};   }   signed main() {     long long t, i, j, a, n, a1, a2, b1, b2;     cin >> n;     b = 0;     r = 0;     ans = 0;     for (i = 1; i <= n; i++) {       cin >> j;       col[i] = j;       if (j == 1) r++;       if (j == 2) b++;     }     for (i = 0; i < n - 1; i++) {       cin >> a1 >> b1;       graph[a1].push_back(b1);       graph[b1].push_back(a1);     }     dfs(1);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int t;   string s;   int main() {     cin >> t;     while (t--) {       cin >> s;       int n = s.size();       int ans = n + 1, l = 0, c[4] = {0};       for (int i = 0; i < n; i++) {         c[s[i] -  0 ]++;         while (c[1] > 0 && c[2] > 0 && c[3] > 0) {           ans = min(i - l + 1, ans);           c[s[l++] -  0 ]--;         }       }       if (ans == n + 1)         cout << 0 << endl;       else         cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       int n, Q;       cin >> n >> Q;       string s;       cin >> s;       vector<int> pre(n, 0);       pre[0] = s[0] ==  +  ? 1 : -1;       for (int i = 1; i < n; ++i) {         pre[i] = pre[i - 1] + (s[i] ==  +  ? 1 : -1) * ((i % 2) ? -1 : 1);       }       while (Q--) {         int l, r;         cin >> l >> r;         --l, --r;         int sum = pre[r] - (l ? pre[l - 1] : 0);         if (sum == 0) {           cout << 0;         } else if ((r - l + 1) % 2 == 1) {           cout << 1;         } else {           cout << 2;         }         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long a[200005];     long long b[200005];     int i;     for (i = 0; i < n; i++) {       cin >> a[i];       a[i] = a[i] * (i + 1) * (n - i);     }     for (i = 0; i < n; i++) {       cin >> b[i];     }     sort(a, a + n);     sort(b, b + n);     long long ans = 0;     for (i = 0; i < n; i++) {       ans = (ans + ((a[i] % 998244353) * b[n - i - 1]) % 998244353) % 998244353;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int h;   long long n, des;   long long GetRes(long long l) {     if (l == 1) return 0;     if ((l + l / 2) % 2) {       return 1 + GetRes(l / 2);     } else {       return pow(2, h - (int)(log2(l)) + 1) + GetRes(l / 2);     }   }   int main() {     while (cin >> h >> n) {       des = pow(2, h) - 1 + n;       cout << GetRes(des) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[1000];     int b[1000];     for (int i = 0; i < 1000; i++) a[i] = 1;     int n, k, r = 1, fl;     cin >> n >> k;     for (int i = 0; i < k; i++) {       cin >> b[i];       a[b[i]] = 0;     }     for (int i = 0; i < k; i++) {       fl = 1;       cout << b[i] <<    ;       while (fl < n) {         if (a[r] != 0) {           cout << r <<    ;           fl++;           a[r] = 0;         }         r++;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 2e5 + 10;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   using namespace std;   int q, op, pos, r, x, len, l;   char ch[10], str[maxn];   int tr[26][maxn];   int lowbit(int x) { return x & (-x); }   void update(int x, int y, int n, int p) {     for (int i = x; i <= n; i += lowbit(i)) tr[p][i] += y;   }   int getsum(int x, int p) {     int ans = 0;     for (int i = x; i; i -= lowbit(i)) ans += tr[p][i];     return ans;   }   int main() {     str[0] =  a ;     scanf( %s n%d , str + 1, &q);     len = strlen(str);     for (int i = 1; i < len; ++i) {       update(i, 1, len, str[i] -  a );     }     while (q--) {       scanf( %d , &op);       if (op == 1) {         scanf( %d %s , &pos, ch);         update(pos, -1, len, str[pos] -  a );         str[pos] = ch[0];         update(pos, 1, len, str[pos] -  a );       } else {         scanf( %d %d , &l, &r);         int ans = 0;         for (int i = 0; i < 26; ++i) {           if (getsum(r, i) - getsum(l - 1, i)) ++ans;         }         printf( %d n , ans);       }     }   }