malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 6e5 + 20;   int main() {     int n, filas, columnas;     cin >> n;     while (n--) {       cin >> filas >> columnas;       int arr[300][300] = {0};       bool ya = false;       for (int i = 0; i < filas; i++) {         for (int j = 0; j < columnas; j++) {           cin >> arr[i][j];           if (arr[i][j] > 4)             ya = true;           else if ((i == 0 && j == 0) || (i == 0 && j == columnas - 1) ||                    (i == filas - 1 && j == 0) ||                    (i == filas - 1 && j == columnas - 1)) {             if (arr[i][j] > 2) ya = true;           } else if (i == 0 || i == filas - 1 || j == 0 || j == columnas - 1) {             if (arr[i][j] > 3) ya = true;           }         }       }       if (ya)         cout <<  NO  << endl;       else {         cout <<  YES  << endl;         for (int i = 0; i < filas; i++) {           for (int j = 0; j < columnas; j++) {             if ((i == 0 && j == 0) || (i == 0 && j == columnas - 1) ||                 (i == filas - 1 && j == 0) ||                 (i == filas - 1 && j == columnas - 1))               cout << 2 <<    ;             else if (i == 0 || i == filas - 1 || j == 0 || j == columnas - 1)               cout << 3 <<    ;             else               cout << 4 <<    ;           }           cout << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   char str[100010];   int f[100010][26 + 2], pre[100010][26], suf[100010][26], g[100010], n;   int ans[26 + 2];   int dfs(int l, int r, int c, int fl) {     if (l > r) return 0;     if (ans[c] != -1) return ans[c];     int u = 0;     for (int i = 0; i < 26; i++) {       int L = suf[l][i], R = pre[r][i];       if (R < l) continue;       int s = g[L] ^ g[R];       if (!fl)         s ^= f[L - 1][c] ^ dfs(R + 1, r, i, 0);       else         s ^= dfs(l, L - 1, i, 1) ^ f[r][i];       u |= 1 << s;     }     return ans[c] = __builtin_ctz(~u);   }   int main() {     scanf( %s , str + 1);     n = strlen(str + 1);     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 26; j++) pre[i][j] = pre[i - 1][j];       pre[i][str[i] -  a ] = i;     }     for (int i = 0; i < 26; i++) suf[n + 1][i] = n + 1;     for (int i = n; i >= 1; i--) {       for (int j = 0; j < 26; j++) suf[i][j] = suf[i + 1][j];       suf[i][str[i] -  a ] = i;     }     for (int i = 1; i <= n; i++) {       int c = str[i] -  a ;       g[i] = f[i - 1][c] ^ g[pre[i - 1][c]];       memset(ans, -1, sizeof(ans));       for (int j = 0; j < 26; j++) f[i][j] = dfs(pre[i][j] + 1, i, j, 0);     }     int m;     scanf( %d , &m);     while (m-- > 0) {       int l, r;       scanf( %d%d , &l, &r);       memset(ans, -1, sizeof(ans));       if (dfs(l, r, 26, 1))         puts( Alice );       else         puts( Bob );     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   char dis[2000010];   int a[2000010];   int main() {     int t;     scanf( %d , &t);     for (int i = 0; i < 200010; i += 3) {       dis[i] =  R , dis[i + 1] =  G , dis[i + 2] =  B ;     }     while (t--) {       int n, k;       scanf( %d %d , &n, &k);       string s;       cin >> s;       int minn = INF;       int x = 0;       while (x < 3) {         for (int i = 0; i < n; i++) {           if (s[i] != dis[i + x])             a[i] = 1;           else             a[i] = 0;           if (i != 0) a[i] = a[i - 1] + a[i];         }         x++;         minn = min(minn, a[k - 1]);         for (int i = k; i < n; i++) {           minn = min(minn, a[i] - a[i - k]);         }       }       printf( %d n , minn);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c, d, e, f, g, h, i, j, k, l, n, v, t;     cin >> n >> k;     long long m[k];     for (i = 0; i < k; i++) cin >> m[i];     if (n % 2 == 0) {       a = m[k - 1];       if (a & 1)         cout <<  odd n ;       else         cout <<  even n ;     } else {       a = 0;       for (i = 0; i < k; i++) {         if (m[i] & 1) a++;       }       if (a & 1)         cout <<  odd n ;       else         cout <<  even n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long n;     cin >> n;     int s = 0, a;     a = n / 100;     n = n % 100;     s += a;     if (n != 0) {       a = n / 20;       n %= 20;       s += a;       if (n != 0) {         a = n / 10;         n %= 10;         s += a;         if (n != 0) {           a = n / 5;           n %= 5;           s += a;           if (n != 0) s += n;         }       }     }     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 9;   int pre[MAX], suf[MAX], a[MAX];   long long ans = 0, cnt = 0;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++)       cin >> a[i], pre[i] = (i > 0 ? pre[i - 1] + a[i] : a[i]);     int sum = pre[n - 1] / 3;     if (pre[n - 1] % 3 != 0) return cout << 0, 0;     for (int i = n - 1; i >= 0; i--) suf[i] = suf[i + 1] + a[i];     if (pre[0] == sum) cnt++;     for (int i = 2; i < n; i++) {       if (suf[i] == sum) ans += cnt;       if (pre[i - 1] == sum) cnt++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long long INF = 1e18;   const double EPS = 1e-6;   const int MAX_N = 500 + 5;   int n;   int arr[MAX_N];   int memo[MAX_N][MAX_N];   int memo2[MAX_N][MAX_N];   int dp(int l, int r) {     if (l == r) return memo[l][r] = arr[l];     if (memo[l][r] != -1) return memo[l][r];     for (int i = l; i < r; ++i) {       if (dp(l, i) == dp(i + 1, r) && dp(l, i) > 0)         return memo[l][r] = dp(l, i) + 1;     }     return memo[l][r] = -10;   }   int solve(int l, int r) {     if (memo[l][r] != -10) return 1;     if (memo2[l][r] != -1) return memo2[l][r];     int mini = n;     for (int i = l; i < r; ++i) {       mini = min(mini, solve(l, i) + solve(i + 1, r));     }     return memo2[l][r] = mini;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     memset(memo, -1, sizeof memo);     memset(memo2, -1, sizeof memo2);     for (int i = 0; i < n; ++i) {       cin >> arr[i];     }     dp(0, n - 1);     cout << solve(0, n - 1) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T1, class T2>   inline void gn(T1 &x1, T2 &x2) {     gn(x1), gn(x2);   }   pair<int, int> edge[500010];   int w[500010];   int n, m, Q;   int id[500010];   int col[1010];   int root[1010];   int rev[500010];   inline int find_root(int u) {     if (root[u] == u) return u;     int first = find_root(root[u]);     col[u] ^= col[root[u]];     return root[u] = first;   }   int main() {     gn(n, m);     gn(Q);     for (int i = 1; i <= m; i++) {       gn(edge[i].first, edge[i].second);       gn(w[i]);     }     for (int i = 1; i <= m; i++) id[i] = i;     sort(id + 1, id + m + 1, [&](int u, int v) { return w[u] > w[v]; });     while (Q--) {       int L, R;       gn(L, R);       for (int i = 1; i <= n; i++) {         col[i] = 0;         root[i] = i;       }       int ans = -1;       for (int i = 1; i <= m; i++) {         if (id[i] > R || id[i] < L) continue;         int u = edge[id[i]].first, v = edge[id[i]].second;         if (find_root(u) == find_root(v)) {           if (col[u] == col[v]) {             ans = w[id[i]];             break;           }           continue;         }         col[root[u]] = col[u] ^ col[v] ^ 1;         root[root[u]] = root[v];       }       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1ll << 32;   int n, m, s, e;   string ans =   ;   bool ch(int l, int r, int idx, bool b) {     bool re = 1;     if (l <= idx && idx <= r) re = 0;     if (b) {       if (l <= idx + 1 && idx + 1 <= r) re = 0;     } else if (l <= idx - 1 && idx - 1 <= r)       re = 0;     return re;   }   int main() {     scanf( %d %d %d %d , &n, &m, &s, &e);     map<int, pair<int, int>> mp;     for (int i = 0; i < m; i++) {       int a;       scanf( %d , &a);       scanf( %d %d , &mp[a].first, &mp[a].second);     }     int j = 1;     if (s < e) {       for (int i = s; i < e; i++) {         if (mp[j].first) {           if (ch(mp[j].first, mp[j].second, i, 1))             ans +=  R ;           else {             ans +=  X ;             i--;           }           j++;         } else {           while (!mp[j].first && i < e) {             ans +=  R ;             i++;             j++;           }           i--;         }       }     } else {       for (int i = s; i > e; i--) {         if (mp[j].first) {           if (ch(mp[j].first, mp[j].second, i, 0))             ans +=  L ;           else {             ans +=  X ;             i++;           }           j++;         } else {           while (!mp[j].first && i > e) {             ans +=  L ;             i--;             j++;           }           i++;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int a[n];       vector<int> vec;       for (int i = 0; i < n; i++) {         cin >> a[i];       };       int l[n];       map<int, int> mpp;       for (int i = 0; i < n; i++) {         cin >> l[i];         if (l[i] == 0) {           mpp[i] = 0;           vec.push_back(a[i]);         } else {           mpp[i] = 1;         }       }       int j = 0;       sort(vec.rbegin(), vec.rend());       for (int i = 0; i < n; i++) {         if (mpp[i] == 0) {           cout << vec[j] <<    ;           j++;         } else {           cout << a[i] <<    ;         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }   const int INF = (((1 << 30) - 1) << 1) + 1;   const int nINF = 1 << 31;   pair<long long, long long> egcd(long long a, long long b,                                   pair<long long, long long> x = {1, 0},                                   pair<long long, long long> y = {0, 1}) {     return (b == 0)                ? x                : egcd(b, a % b, y,                       {x.first - a / b * y.first, x.second - a / b * y.second});   }   long long modInv(long long a, long long n) {     return ((egcd(a, n).first % n) + n) % n;   }   const long long M = 998244353;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long mult(long long a, long long b) { return (a * b) % M; }   long long add(long long a, long long b) { return (a + b) % M; }   struct frac {     long long n, d;     void simp() {       long long g = gcd(n, d);       n /= g;       d /= g;     }     frac(long long in_n, long long in_d) {       n = in_n, d = in_d;       simp();     }     frac operator+(frac& oth) {       frac ret(n * oth.d + d * oth.n, d * oth.d);       ret.simp();       return ret;     }   };   const int N = 2e5 + 10;   int n, p[N], m = 0, l[N], have[N];   long long bit[N];   long long getSum(int i) {     long long sum = 0;     ++i;     while (i > 0) {       sum += bit[i];       i -= i & (-i);     }     return sum;   }   void updateBIT(int i, long long val) {     ++i;     while (i <= n + 5) {       bit[i] += val;       i += i & (-i);     }   }   signed main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < (n); i++) {       cin >> p[i];       if (p[i] != -1)         have[p[i]] = 1;       else         ++m;     }     for (int i = (1); i <= (n); i++) {       l[i] = l[i - 1];       if (!have[i]) ++l[i];     }     long long k = 0;     frac einv(0, 1);     frac lm(0, 1);     long long lmi = 0;     long long inv = 0;     long long ans = 0;     for (int i = 0; i < (n); i++) {       int x = p[i];       if (x != -1) {         int above = getSum(n) - getSum(x);         inv += above;         ans = add(ans, above);         updateBIT(x, 1);         if (m) {           frac ex((m - l[x]) * k, m);           frac cex(l[x], m);           einv = einv + ex;           lm = lm + cex;           lmi = add(lmi, mult(cex.n, modInv(cex.d, M)));           ans = add(ans, mult(ex.n, modInv(ex.d, M)));         }       } else {         einv = einv + lm;         ans = add(ans, lmi);         frac ex(k, 2);         einv = einv + ex;         ans = add(ans, mult(ex.n, modInv(ex.d, M)));         ++k;       }     }     frac kinv(inv, 1);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 7;   int a[maxn];   int n, s;   int main() {     scanf( %d%d , &n, &s);     if (s >= 2 * n) {       s -= 2 * n;       puts( YES );       printf( %d , 2 + s);       for (int i = 1; i < n; ++i) printf(  %d , 2);       puts(  );       puts( 1 );     } else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, s = 0;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];       s += a[i];     }     sort(begin(a), end(a));     if (s % 2 == 0 && 2 * a[n - 1] <= s)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T x, T y) {     if (x < y) swap(x, y);     while (y > 0) {       T f = x % y;       x = y;       y = f;     }     return x;   }   struct Node {     Node *l, *r;     long long a, b;     Node() : l(NULL), r(NULL), a(0), b(0) {}   };   Node* makeTree(int fr, int to) {     Node* node = new Node();     if (fr == to) return node;     int m = (fr + to) / 2;     node->l = makeTree(fr, m);     node->r = makeTree(m + 1, to);     return node;   }   Node* update(Node* _node, int fr, int to, int x1, int x2, long long a,                long long b) {     if (x2 < fr || x1 > to) return _node;     Node* node = new Node();     *node = *_node;     if (x1 <= fr && to <= x2) {       node->a += a;       node->b += b;       return node;     }     int m = (fr + to) / 2;     node->l = update(node->l, fr, m, x1, x2, a, b);     node->r = update(node->r, m + 1, to, x1, x2, a, b);     return node;   }   long long query(Node* node, int fr, int to, long long x) {     long long res = node->a * x + node->b;     if (fr == to) return res;     int m = (fr + to) / 2;     if (x <= m)       return res + query(node->l, fr, m, x);     else       return res + query(node->r, m + 1, to, x);   }   Node* froot[75007];   const int maxx = 200002;   int main(int argc, char* argv[]) {     int n;     std::cin.sync_with_stdio(false);     std::cin.tie(nullptr);     cin >> n;     {       froot[0] = makeTree(0, maxx);       for (int i = 1; i <= n; i++) {         int x1, x2, y1, a, b, y2;         cin >> x1 >> x2 >> y1 >> a >> b >> y2;         froot[i] = update(froot[i - 1], 0, maxx, 0, x1, 0, y1);         froot[i] = update(froot[i], 0, maxx, x1 + 1, x2, a, b);         froot[i] = update(froot[i], 0, maxx, x2 + 1, maxx, 0, y2);       }       int m;       cin >> m;       long long last = 0;       while (m--) {         int l, r, x;         cin >> l >> r >> x;         last = (last + x) % 1000000000ll;         last =             query(froot[r], 0, maxx, last) - query(froot[l - 1], 0, maxx, last);         cout << last << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long GCD(long long x, long long y) {     while (y != 0) {       long long t = x % y;       x = y;       y = t;     }     return x;   }   long long n, a, b;   long long cs;   bool calc() {     scanf( %lld %lld , &a, &b);     long long g = GCD(a, b);     long long p = a / g;     long long q = b / g;     long long pq = p * q;     bool ret = (g % pq == 0);     if (ret) {       long long r = g / pq;       long long i = 1;       while (i * i * i < r) {         i++;       }       if (i * i * i == r) return true;     }     return false;   }   int main() {     scanf( %lld , &n);     while (cs < n) {       cs++;       bool ans = calc();       if (ans)         printf( Yes n );       else         printf( No n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, res = 1;   int main() {     cin >> a >> b;     if (b - (a + 1) > 20) {       cout << 0;       return 0;     }     for (long long i = a + 1; i <= b; i++) res = (res * (i % 10)) % 10;     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   void Solve() {     long long int n, q;     cin >> n >> q;     long long int a[n + 1], cnt[n + 1];     for (auto i = 1; i < n + 1; i++) cin >> a[i], cnt[i] = 0;     while (q--) {       long long int l, r;       cin >> l >> r;       cnt[l]++;       if (r != n) cnt[r + 1]--;     }     for (auto i = 2; i < n + 1; i++) cnt[i] += cnt[i - 1];     sort(cnt + 1, cnt + n + 1);     sort(a + 1, a + n + 1);     long long int ans = 0;     for (auto i = 1; i < n + 1; i++) ans += cnt[i] * a[i];     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int T = 1;     while (T--) Solve();     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   long long rand_seed() {     long long a = rng();     return a;   }   int t;   int n;   string s;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> t;     for (; t; --t) {       cin >> n;       cin >> s;       bool ok = 0;       for (int i = 0; i + 10 < n; ++i)         if (s[i] ==  8 ) ok = 1;       if (ok)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100], b[45], c[100];   int main() {     int x;     cin >> x;     int p = 0, ans = 0, q = 0, f = 0;     while (x) {       c[p++] = x % 2;       if (x % 2 == 0) f = 1;       x = x / 2;     }     int pp = 0;     for (int h = p - 1; h >= 0; h--) {       a[pp++] = c[h];     }     if (f) {       while (ans + 1) {         int flag = 0, flag1 = 0, flag2 = 0;         for (int i = 0; i < p; i++) {           if (flag) {             if (a[i] == 1)               a[i] = 0;             else if (a[i] == 0)               a[i] = 1;           } else if (a[i] == 0) {             ans++;             a[i] = 1;             flag = 1;             b[q++] = p - i;           }         }         for (int i = 0; i < p; i++) {           if (a[i] == 0) {             break;           }           if (i == p - 1) {             flag1 = 1;           }         }         if (flag1) {           break;         }         ans++;         for (int j = p - 1; j >= 0; j--) {           a[j]++;           if (a[j] == 2)             a[j] = 0;           else if (a[j] = 1)             break;         }         for (int i = 0; i < p; i++) {           if (a[i] == 0) {             break;           }           if (i == p - 1) {             flag2 = 1;           }         }         if (flag2) {           break;         }       }       cout << ans << endl;       for (int k = 0; k < q; k++) {         if (k == 0)           cout << b[k];         else           cout <<     << b[k];       }       cout << endl;     } else {       cout << 0 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long f[300005][2], g[300005];   vector<int> vec[300005];   long long powi(long long a, long long b) {     long long p;     if (!b) return 1;     p = powi(a, b / 2);     p = (p * p) % 998244353;     if (b % 2) p = (p * a) % 998244353;     return p;   }   long long mmi(long long x) { return powi(x, 998244353 - 2); }   void dfs(int s, int par = 0) {     for (int v : vec[s]) {       if (v != par) dfs(v, s);     }     f[s][0] = 1;     for (int v : vec[s]) {       if (v == par) continue;       f[s][0] *= f[v][0];       f[s][0] %= 998244353;     }     long long temp = 1;     for (int v : vec[s]) {       if (v == par) continue;       temp *= f[v][1] + f[v][0];       temp %= 998244353;     }     for (int v : vec[s]) {       if (v == par) continue;       long long temp2 = temp;       temp2 = (temp2 * mmi(f[v][1] + f[v][0])) % 998244353;       temp2 = (temp2 * g[v]) % 998244353;       f[s][1] += temp2;       f[s][1] %= 998244353;     }     f[s][0] += f[s][1];     f[s][0] %= 998244353;     g[s] = 1;     for (int v : vec[s]) {       if (v == par) continue;       g[s] *= f[v][0] + f[v][1];       g[s] %= 998244353;     }     return;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d %d , &u, &v);       vec[u].push_back(v);       vec[v].push_back(u);     }     dfs(1);     long long ans = f[1][0];     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math )   const int maxn = 1e6 + 50;   int seg[4 * maxn], ans[maxn], last_pos[maxn], next_pos[maxn];   int n, m;   vector<int> v, get_val, partial_xor;   vector<pair<pair<int, int>, int> > ques;   void update(int val, int l, int r = n) {     for (l += n, r += n; l < r; l >>= 1, r >>= 1) {       if (l & 1) seg[l++] ^= val;       if (r & 1) seg[--r] ^= val;     }   }   int get_xor(int idx) {     int res = 0;     for (idx += n; idx; idx >>= 1) res ^= seg[idx];     return res;   }   void sweep(int pos) {     int val = get_val[v[pos]];     int nxt = next_pos[pos];     update(val, pos, nxt);   }   void input() {     cin >> n;     for (int i = 0; i < n; i++) {       int b;       cin >> b;       if (i == 0)         partial_xor.push_back(b);       else         partial_xor.push_back(partial_xor[i - 1] ^ b);       get_val.push_back(b);       v.push_back(b);       last_pos[i] = n;     }     cin >> m;     for (int i = 0; i < m; i++) {       int l, r;       cin >> l >> r;       l--, r--;       ques.push_back({{l, r}, i});     }   }   void map_it() {     sort(get_val.begin(), get_val.end());     vector<int>::iterator ip;     ip = std::unique(get_val.begin(), get_val.end());     get_val.resize(std::distance(get_val.begin(), ip));     for (int i = v.size() - 1; i > -1; i--) {       v[i] = lower_bound(get_val.begin(), get_val.end(), v[i]) - get_val.begin();       next_pos[i] = last_pos[v[i]];       last_pos[v[i]] = i;     }     for (int i = 0; i < get_val.size(); i++) update(get_val[i], last_pos[i]);   }   void answer_ques(int i) {     pair<int, int> p = ques[i].first;     ans[ques[i].second] = get_xor(p.second) ^ partial_xor[p.first] ^                           partial_xor[p.second] ^ get_val[v[p.first]];   }   void calc() {     int go_pos = 0;     int i = 0;     sort(ques.begin(), ques.end());     while (go_pos < ques.size()) {       while (go_pos < ques.size() and i == ques[go_pos].first.first)         answer_ques(go_pos++);       if (go_pos == ques.size()) break;       while (i < ques[go_pos].first.first) sweep(i++);     }   }   void ansing() {     for (int i = 0; i < m; i++) cout << ans[i] <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     input();     map_it();     calc();     ansing();   }