malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());   void setIO(string name) {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin.exceptions(istream::failbit);   }   const int inf = 0x3f3f3f3f, mod = 1e9 + 7, maxn = 1e5 + 5;   vector<vector<pair<int, int>>> adj;   vector<long long> pass, sub, weight, cost;   void dfs(int c, int p) {     if (p != -1 && adj[c].size() == 1) {       sub[c] = 1;     }     for (auto i : adj[c]) {       if (i.first != p) {         dfs(i.first, c);         pass[i.second] = sub[i.first];         sub[c] += sub[i.first];       }     }   }   int main() {     setIO( 1 );     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       long long s;       cin >> s;       adj = vector<vector<pair<int, int>>>(n);       pass = sub = weight = cost = vector<long long>(n);       for (int i = 0; i < n - 1; ++i) {         int a, b;         cin >> a >> b >> weight[i] >> cost[i];         --a, --b;         adj[a].push_back({b, i});         adj[b].push_back({a, i});       }       dfs(0, -1);       pair<long long, long long> total;       priority_queue<pair<long long, int>> one, two;       for (int i = 0; i < n - 1; ++i) {         if (cost[i] == 1) {           total.first += pass[i] * weight[i];           one.push({pass[i] * (weight[i] - weight[i] / 2), i});         } else {           total.second += pass[i] * weight[i];           two.push({pass[i] * (weight[i] - weight[i] / 2), i});         }       }       vector<long long> costs;       while (total.first) {         costs.push_back(total.first);         pair<long long, int> cur = one.top();         one.pop();         total.first -= cur.first;         weight[cur.second] /= 2;         one.push(             {pass[cur.second] * (weight[cur.second] - weight[cur.second] / 2),              cur.second});       }       costs.push_back(0);       long long sol = 1e18, cnt = 0;       while (total.second) {         long long lo = 0, hi = (int)costs.size() - 1, mid, res = -1;         while (lo <= hi) {           mid = (lo + hi) / 2;           if (costs[mid] + total.second <= s) {             res = mid;             hi = mid - 1;           } else {             lo = mid + 1;           }         }         if (res != -1) {           sol = min(sol, res + 2 * cnt);         }         pair<long long, int> cur = two.top();         two.pop();         total.second -= cur.first;         weight[cur.second] /= 2;         two.push(             {pass[cur.second] * (weight[cur.second] - weight[cur.second] / 2),              cur.second});         ++cnt;       }       long long lo = 0, hi = costs.size(), mid, res = -1;       while (lo <= hi) {         mid = (lo + hi) / 2;         if (costs[mid] <= s) {           res = mid;           hi = mid - 1;         } else {           lo = mid + 1;         }       }       if (res != -1) {         sol = min(sol, res + 2 * cnt);       }       cout << min(sol, res + 2 * cnt) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int M[33][33];   int S[33][33];   int m;   int n;   int solve(int sid) {     memcpy(S, M, sizeof(int) * 33 * 33);     for (int i = 0; i < m; i++) {       if ((1 << i) & sid) {         for (int k = m - 1; k < n; k++) {           for (int l = i; l < i + m; l++) {             S[k][l] *= -1;           }         }       }     }     int ret = 0;     for (int i = 0; i < n; i++) ret += S[m - 1][i];     for (int i = 0; i < m - 1; i++) {       for (int j = 0; j < n; j++) {         S[i][j] += S[m + i][j];       }     }     for (int i = 0; i < m - 1; i++) {       int row1 = S[i][m - 1], row2 = S[i][m - 1] * -1;       for (int j = 0; j < m - 1; j++) {         row1 += abs(S[i][j] + S[i][m + j]);         row2 += abs(S[i][j] - S[i][m + j]);       }       ret += max(row1, row2);     }     return ret;   }   int main() {     cin >> n;     m = (n + 1) / 2;     for (size_t i = 0; i < n; ++i) {       for (size_t j = 0; j < n; ++j) {         cin >> M[i][j];       }     }     int sol = -10000000;     for (size_t i = 0; i < (1 << m); ++i) {       sol = max(solve(i), sol);     }     cout << sol << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   const int INF = 1 << 30;   const double eps = 1e-6;   const int mod = 1000000007;   string s;   void getVal(int& a, int& b, char x) {     a = b = -1;     for (int i = 0; i < s.size(); i++) {       if (s[i] != x) continue;       if (a == -1) a = i;       b = i;     }   }   int main() {     cin >> s;     int n = s.size();     int la, ra, lb, rb, lc, rc;     bool ok = true;     getVal(la, ra,  a );     if (la == -1 || ra == -1) ok = false;     getVal(lb, rb,  b );     if (lb == -1 || rb == -1) ok = false;     getVal(lc, rc,  c );     if (lc == -1 || rc == -1) ok = false;     if (ra + 1 != lb || rb + 1 != lc)       ok = false;     else if (rc - lc != rb - lb && rc - lc != ra - la)       ok = false;     puts(ok ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, i;   double H, K, x, y, xp, yp;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N >> K >> x >> y;     for (i = 1; i < N; i++) {       cin >> xp >> yp;       H += sqrt((xp - x) * (xp - x) + (yp - y) * (yp - y)) * K / 50;       x = xp;       y = yp;     }     cout << fixed << setprecision(12) << H <<   n ;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:2000000 )   #pragma comment(linker,  /HEAP:2000000 )   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     long long m[n][n], a[n];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> m[i][j];       }     }     long long x = sqrt((m[0][1] * m[0][2]) / m[1][2]);     cout << x <<    ;     for (int i = 1; i < n; i++) {       cout << m[0][i] / x <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 600, oo = 2e9;   int nn[N], mm[N], n, m;   int check() {     int mn = oo;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (nn[i] == mm[j]) mn = min(mn, nn[i]);       }     }     if (mn == oo) return -1;     return mn;   }   int main() {     ios::sync_with_stdio(false);     int mn1 = oo, mn2 = oo, mnb1 = oo, mnb2 = oo;     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> nn[i];       mn1 = min(mn1, nn[i]);       if (nn[i]) mnb1 = min(mnb1, nn[i]);     }     for (int i = 0; i < m; ++i) {       cin >> mm[i];       mn2 = min(mn2, mm[i]);       if (mm[i]) mnb2 = min(mnb2, mm[i]);     }     int mini = min(mn1, mn2), maxi = max(mn1, mn2);     if (check() != -1)       cout << check();     else if (!mn1) {       cout << min(mn2 * 10, mnb1 * 10 + mn2);     } else if (!mn2)       cout << min(mn1 * 10, mnb2 * 10 + mn1);     else       cout << mini * 10 + maxi;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, t, temp;   bool check(int mid, vector<int>& v) {     temp = s;     for (int i = 0; i < mid; i++) {       temp[v[i]] =  # ;     }     int x = 0;     for (int i = 0; i < temp.size(); i++) {       if (t[x] == temp[i]) {         x++;       }       if (x == t.size()) return true;     }     return false;   }   int main() {     cin >> s >> t;     vector<int> v;     for (int i = 0; i < s.size(); i++) {       int a;       cin >> a;       v.push_back(a - 1);     }     int low = 0, high = s.size();     while (high - low > 1) {       int mid = low + (high - low) / 2;       if (check(mid, v))         low = mid;       else         high = mid;     }     cout << low << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int da[100010], db[100010], ida[100010], idb[100010];   map<int, int> mp;   map<int, int>::iterator it;   void solve(int n) {     for (int i = 1; i <= n; i++) {       int ret = 0x3fffffff;       it = mp.lower_bound(i - 1);       if (it != mp.end()) ret = min(ret, it->first - (i - 1));       if (it != mp.begin()) {         --it;         ret = min(ret, (i - 1) - it->first);       }       printf( %d n , ret);       mp[i - ida[db[i]]]--;       if (mp[i - ida[db[i]]] == 0) mp.erase(i - ida[db[i]]);       mp[i + n - ida[db[i]]]++;     }   }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       mp.clear();       for (int i = 1; i <= n; i++) {         scanf( %d , &da[i]);         ida[da[i]] = i;       }       for (int i = 1; i <= n; i++) {         scanf( %d , &db[i]);         idb[db[i]] = i;       }       for (int i = 1; i <= n; i++) mp[i - ida[db[i]]]++;       solve(n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long modexpo(long long x, long long p) {     long long res = 1;     x = x % 1000000007;     while (p) {       if (p % 2) res = res * x;       p >>= 1;       x = x * x % 1000000007;       res %= 1000000007;     }     return res;   }   struct compare {     bool operator()(const pair<long long, long long> a,                     const pair<long long, long long> b) const {       return a.first < b.first;     }   };   const long long nax = 2005;   long long n, m;   vector<pair<long long, long long>> robber, light, moves;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     robber.assign(n, {0, 0});     light.assign(m, {0, 0});     for (long long i = 0; i < n; i++) {       cin >> robber[i].first >> robber[i].second;     }     for (long long i = 0; i < m; i++) {       cin >> light[i].first >> light[i].second;     }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         long long a = light[j].first - robber[i].first + 1;         long long b = light[j].second - robber[i].second + 1;         a = max(a, 0LL);         b = max(b, 0LL);         moves.push_back({a, b});       }     }     long long sz = moves.size();     sort(moves.begin(), moves.end());     vector<long long> suf(sz);     suf[sz - 1] = moves[sz - 1].second;     for (long long i = sz - 2; i >= 0; i--) {       suf[i] = max(suf[i + 1], moves[i].second);     }     long long ans = suf[0];     for (long long i = 0; i < sz; i++) {       ans = min(ans, moves[i].first + (i + 1 < sz ? suf[i + 1] : 0));     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 5;   struct Ans {     long long a, b, c;   };   void solve() {     long long a, b, c;     cin >> a >> b >> c;     long long ans = 1e9;     auto x = Ans{a, b, c};     for (long long aa = 1; aa <= 2 * a; aa++) {       for (long long bb = aa; bb <= 2 * b; bb += aa) {         long long op1 = bb * (c / bb);         long long op2 = op1 + bb;         long long diff = abs(a - aa) + abs(b - bb);         long long y = diff + abs(c - op1);         long long z = diff + abs(c - op2);         if (y < ans) {           ans = y;           x.a = aa;           x.b = bb;           x.c = op1;         }         if (z < ans) {           ans = z;           x.a = aa;           x.b = bb;           x.c = op2;         }       }     }     cout << ans <<   n ;     cout << x.a <<     << x.b <<     << x.c <<   n ;   }   int main(int argc, char *argv[]) {     long long t;     ios::sync_with_stdio(0);     cin.tie(0);     std::cout << std::fixed;     std::cout << std::setprecision(15);     cin >> t;     for (long long z = 0; z < (long long)t; ++z) solve();     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--) {       long long n, k;       cin >> n >> k;       int a[n];       int ma = INT_MIN;       for (int i = 0; i < n; i++) {         cin >> a[i];         if (a[i] > ma) ma = a[i];       }       int m2 = INT_MIN;       vector<int> v1, v2;       for (int i = 0; i < n; i++) {         a[i] = ma - a[i];         if (m2 < a[i]) m2 = a[i];         v1.push_back(a[i]);       }       for (int i = 0; i < n; i++) {         a[i] = m2 - a[i];       }       if (k % 2) {         for (int i = 0; i < v1.size(); i++) cout << v1[i] <<    ;         cout << endl;       } else {         for (int i = 0; i < n; i++) cout << a[i] <<    ;         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > xy;   vector<pair<long long, long long> > ab;   vector<long long> x;   vector<long long> y;   string str, str1, str2, star[2000];   long long ara[200005], ara2[200005];   bool flagar[200005], flagar2[200005];   bool compare(pair<long long, long long> i, pair<long long, long long> j) {     return (i.first < j.first);   }   bool compare2(pair<long long, long long> i, pair<long long, long long> j) {     return (i.first > j.first);   }   long long gcd(long long a, long long b) {     if (a % b == 0) return b;     return gcd(b, a % b);   }   long long dp[2005][2005];   int main() {     long long int n, ans, temp, t, j, i, m, h, h2, m2, c, a, b, mx, d, k, x1, r,         l, mn;     cin >> str >> k;     n = str.length();     a = b = 0;     for (i = n - 1; i >= 0; i--) {       if (str[i] -  0  == 0)         a++;       else         b++;       if (a == k) {         cout << b;         return 0;       }     }     if (a < k) {       b = n - 1;     }     cout << b;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005, M = 200005;   struct node {     int x, y;   } d[N];   int h, w, n, mod = 1e9 + 7;   long long c[M] = {1, 1}, inv[M] = {1, 1}, ni[M] = {1, 1}, f[N];   long long quick_mod(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       b >>= 1;       a = a * a % mod;     }     return ans;   }   void init() {     for (int i = 2; i < M; i++) {       c[i] = c[i - 1] * i % mod;       ni[i] = (mod - mod / i) * ni[mod % i] % mod;       inv[i] = ni[i] * inv[i - 1] % mod;     }   }   long long C(int n, int m) {     if (n < m) return 0;     if (n == m || m == 0) return 1;     return c[n] * inv[m] % mod * inv[n - m] % mod;   }   bool cmp(node a, node b) {     if (a.x != b.x) return a.x < b.x;     return a.y < b.y;   }   int main() {     init();     scanf( %d%d%d , &h, &w, &n);     for (int i = 0; i < n; i++) scanf( %d%d , &d[i].x, &d[i].y);     sort(d, d + n, cmp);     d[n].x = h;     d[n].y = w;     for (int i = 0; i <= n; i++) {       f[i] = C(d[i].x + d[i].y - 2, d[i].x - 1);       for (int j = 0; j < i; j++) {         if (d[j].x > d[i].x || d[j].y > d[i].y) continue;         f[i] = (f[i] -                 f[j] * C(d[i].x - d[j].x + d[i].y - d[j].y, d[i].x - d[j].x)) %                mod;       }       f[i] = (f[i] + mod) % mod;     }     printf( %lld n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXINT = 2147483647;   const long long MAXLL = 9223372036854775807LL;   const int MAX = 400000;   long long n, q, col, pref[MAX], l, r, sum, ans, t[MAX];   string s;   int main() {     cin >> n >> q;     cin >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  1 ) col++;       pref[i] = col;     }     t[0] = 0;     for (int i = 1; i <= 100005; i++)       t[i] = (t[i - 1] + t[i - 1] + 1) % 1000000007;     for (int i = 0; i < q; i++) {       ans = 0, col = 0;       cin >> l >> r;       l--, r--;       if (l == 0)         sum = pref[r];       else         sum = pref[r] - pref[l - 1];       if (t[r - l + 1] >= t[r - l + 1 - sum])         ans += t[r - l + 1] - t[r - l + 1 - sum];       else         ans += t[r - l + 1] + 1000000007 - t[r - l + 1 - sum];       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = int64_t;   using vll = vector<ll>;   using vvll = vector<vll>;   using pll = pair<ll, ll>;   using vpll = vector<pll>;   ll a, n;   vll inp;   void func() {     cin >> a;     string s;     cin >> s;     n = s.length();     inp.resize(n);     for (ll i = 0; i < n; i++) {       inp[i] = s[i] -  0 ;     }     vll cnt(9 * n + 1, 0);     for (ll i = 0; i < n; i++) {       ll x = 0;       for (ll j = i; j < n; j++) {         x += inp[j];         cnt[x]++;       }     }     ll ans = 0;     if (a == 0) {       ll total = accumulate(cnt.begin(), cnt.end(), 0ll);       ans = 2 * (cnt[0] * total);       ans -= cnt[0] * cnt[0];     } else {       for (ll i = 1; i < 9 * n + 1; i++) {         if (i > a) break;         if (a % i == 0) {           ll j = a / i;           if (j < 9 * n + 1) {             ans += cnt[i] * cnt[j];           }         }       }     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     ;     ll t = 1;     for (ll i = 1; i <= t; i++) {       func();     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int maxn = 300007;   int n, a[maxn];   static pair<int, int> tree[maxn << 2][20];   inline int min(int u, int v) { return u > v ? v : u; }   inline int max(int u, int v) { return u > v ? u : v; }   inline void pushup(int num, int val) {     tree[num][val] = {         min(tree[num << 1][val].first, tree[num << 1 | 1][val].first),         max(tree[num << 1][val].second, tree[num << 1 | 1][val].second)};   }   pair<int, int> query(int num, int l, int r, int val, int L, int R) {     if (L <= l && r <= R) {       return tree[num][val];     }     int md = (l + r) >> 1;     if (md >= L && md >= R) {       return query(num << 1, l, md, val, L, R);     }     if (md < R && md < L) {       return query(num << 1 | 1, md + 1, r, val, L, R);     }     if (md < R && md >= L) {       pair<int, int> tmp = query(num << 1, l, md, val, L, R),                      tmp2 = query(num << 1 | 1, md + 1, r, val, L, R);       return {min(tmp.first, tmp2.first), max(tmp.second, tmp2.second)};     }   }   void build(int num, int l, int r, int val) {     if (l == r) {       if (!val) {         tree[num][0] = {max(l - a[l], 1), min(l + a[l], 3 * n)};       } else {         pair<int, int> rg = query(1, 1, 3 * n, val - 1, l, l);         tree[num][val] = query(1, 1, 3 * n, val - 1, rg.first, rg.second);       }       return;     }     int md = (l + r) >> 1;     build(num << 1, l, md, val);     build(num << 1 | 1, md + 1, r, val);     pushup(num, val);   }   inline int calc(int u) {     int ret = 0;     pair<int, int> cnt = {u, u};     for (int i = 16; i > -1; --i) {       pair<int, int> tmp = query(1, 1, 3 * n, i, cnt.first, cnt.second);       if (tmp.second - tmp.first < n - 1) {         ret += (1 << i);         cnt = tmp;       }     }     return ret;   }   int main() {     scanf( %d , &n);     if (n == 1) {       puts( 0 );       return 0;     }     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       a[i + n] = a[i + 2 * n] = a[i];     }     for (int i = 0; i < 17; ++i) {       build(1, 1, 3 * n, i);     }     for (int i = n + 1; i <= 2 * n; ++i) {       printf( %d  , calc(i) + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T& x) {     bool fu = 0;     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     if (c ==  - ) fu = 1, c = getchar();     for (x = 0; c > 32; c = getchar()) x = x * 10 + c -  0 ;     if (fu) x = -x;   };   inline char getc() {     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     return c;   }   const int mod = 1000000007;   int n, i, j, k, w;   char st[1000010];   int a[1000010];   bool vis[100010][2];   long long T[100010], p[100010][2], l[100010][2], g[100010][2], s[100010][2],       v[100010][2];   void get(int i, bool l0) {     if (vis[i][l0]) return;     vis[i][l0] = 1;     if (i > w) {       g[i][l0] = 1;       return;     }     bool l2;     long long c, LA = 0, Y;     bool fir = 1;     for (int j = 4; j <= 7; j += 3)       if (l0 || (j <= a[i])) {         c = j * T[w - i] % mod;         l2 = l0 || (j < a[i]);         get(i + 1, l2);         g[i][l0] = ((g[i][l0]) + (g[i + 1][l2]) % mod) % mod;         s[i][l0] = ((s[i][l0]) + (s[i + 1][l2] + c * g[i + 1][l2]) % mod) % mod;         v[i][l0] = ((v[i][l0]) + (v[i + 1][l2]) % mod) % mod;         v[i][l0] =             ((v[i][l0]) +              ((2 * s[i + 1][l2] - p[i + 1][l2] - l[i + 1][l2]) % mod * c) % mod) %             mod;         v[i][l0] =             ((v[i][l0]) + (c * c % mod * (g[i + 1][l2] - 1) % mod) % mod) % mod;         Y = (p[i + 1][l2] + c) % mod;         if (!fir) v[i][l0] = ((v[i][l0]) + (LA * Y % mod) % mod) % mod;         if (fir) fir = 0, p[i][l0] = Y;         LA = l[i][l0] = (l[i + 1][l2] + c) % mod;         fir = 0;       }   }   long long solve() {     scanf( %s , st + 1);     w = strlen(st + 1);     for (i = 1; i <= w; i++) a[i] = st[i] -  0 ;     T[0] = 1;     for (i = 1; i <= w; i++) T[i] = T[i - 1] * 10 % mod;     memset(vis, 0, sizeof(vis));     memset(p, 0, sizeof(p));     memset(l, 0, sizeof(l));     memset(g, 0, sizeof(g));     memset(s, 0, sizeof(s));     memset(v, 0, sizeof(v));     get(1, 0);     return v[1][0];   }   int main() {     long long s0 = solve();     long long s1 = solve();     s0 = (s1 - s0) % mod;     if (s0 < 0) s0 += mod;     cout << s0 << endl;     scanf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p, a[100005], fqn[100005], fqo[100005], mx, cur,       exc = 0, lesdan = 0, mnvl[100005], gmod = 0, rekt = 0;   int mc[100005], vl[100005];   vector<int> ok;   map<int, int> fq;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> p;     for (int i = 0; i < n; i++) {       cin >> a[i];       fq[a[i]]++;     }     sort(a, a + n + 1, greater<int>());     mx = a[0];     cur = max(mx - (n - 1), 0);     for (auto u : fq)       if (u.second >= p) exc++;     for (int i = 0; i < n; i++) {       if (a[i] < cur) break;       rekt = i;       vl[i] = n - (a[i] - cur) - i;       mnvl[i] = vl[i];       if (i != 0) mnvl[i] = min(mnvl[i], mnvl[i - 1]);       mc[((vl[i] % p) + p) % p]++;     }     int gp = n - 1 - rekt;     int cnt = 0;     while (cur < mx) {       while (a[rekt] < cur) {         mc[((vl[rekt] % p) + p) % p]--;         rekt--;         gp++;       }       if (mnvl[rekt] + cnt > 0 && (mc[gmod] + gp / p) == 0) ok.push_back(cur);       cur++;       gmod--;       gmod += p;       gmod %= p;       cnt++;     }     cout << ok.size() << endl;     for (auto u : ok) cout << u <<    ;     cout << endl;     cout.flush();     return 0;   }