func_code_string: #include <bits/stdc++.h>   using namespace std;   struct xy {     int x, y;   };   int a[1212121], par[1212121], depth[1212121];   vector<int> C[1212121];   void dfs(int w, int dep) {     depth[w] = dep;     for (int nxt : C[w]) dfs(nxt, dep + 1);   }   int Hn = 0, myH[1212121], sz[1212121], root[1212121], ppar[1212121];   int find(int x) {     if (ppar[x] == x) return x;     return ppar[x] = find(ppar[x]);   }   multiset<int> S[1212121], ansS;   void push(int x) {     sz[x] = 1;     int mx = 0, mxw;     for (int child : C[x]) {       sz[x] += sz[child];       if (mx < sz[child] && S[myH[child]].size() > 0) mx = sz[child], mxw = child;     }     if (mx == 0) {       int hIdx = ++Hn;       myH[x] = hIdx;       root[hIdx] = x;       S[hIdx].insert(depth[x]);       ppar[hIdx] = hIdx;       ansS.insert(0);     } else {       int hIdx = myH[x] = myH[mxw];       root[hIdx] = x;       int dep = (*S[hIdx].rbegin()) - depth[mxw];       ansS.erase(ansS.find(dep));       S[hIdx].insert(depth[x]);       for (int child : C[x])         if (child != mxw) {           if (!S[myH[child]].empty()) {             for (auto &v : S[myH[child]]) S[hIdx].insert(v);             ppar[myH[child]] = hIdx;             int dep = (*S[myH[child]].rbegin()) - depth[child];             ansS.erase(ansS.find(dep));           }           S[myH[child]].clear();         }       dep = (*S[hIdx].rbegin()) - depth[x];       ansS.insert(dep);     }   }   void pop(int x) {     int hIdx = find(myH[x]);     int dep = (*S[hIdx].rbegin()) - depth[root[hIdx]];     ansS.erase(ansS.find(dep));     S[hIdx].erase(S[hIdx].find(depth[x]));     if (S[hIdx].empty()) return;     dep = (*S[hIdx].rbegin()) - depth[root[hIdx]];     ansS.insert(dep);   }   int main() {     int n, k, i, j;     scanf( %d%d , &n, &k);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     vector<xy> ST;     ST.push_back({n + 1, n + 1});     for (i = n; i >= 1; i--) {       while (ST.back().x <= a[i]) ST.pop_back();       par[i] = ST.back().y;       C[par[i]].push_back(i);       ST.push_back({a[i], i});     }     dfs(n + 1, 0);     for (i = 1; i <= n; i++) {       push(i);       if (k <= i) {         printf( %d  , *ansS.rbegin() + 1);         if (i != n) pop(i - k + 1);       }     }     return 0;   }   