func_code_string: #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;   }   