func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 200005;   int v[MAXN], l[MAXN], r[MAXN];   int ST[4 * MAXN];   int L[4 * MAXN];   int n;   void _update(int node, int lo, int hi, int i, int j, int val) {     if (L[node]) {       ST[node] = max(ST[node], L[node]);       if (hi != lo) {         L[2 * node] = max(L[node], L[2 * node]);         L[2 * node + 1] = max(L[node], L[2 * node + 1]);       }       L[node] = 0;     }     if (lo > j || hi < i) return;     if (lo >= i && hi <= j) {       ST[node] = max(ST[node], val);       if (hi != lo) {         L[2 * node] = max(val, L[2 * node]);         L[2 * node + 1] = max(val, L[2 * node + 1]);       }       return;     }     int mid = (lo + hi) / 2;     _update(2 * node, lo, mid, i, j, val);     _update(2 * node + 1, mid + 1, hi, i, j, val);     ST[node] = max(ST[2 * node], ST[2 * node + 1]);   }   int _query(int node, int l, int r, int i, int j) {     if (L[node]) {       ST[node] = max(ST[node], L[node]);       L[2 * node] = max(L[2 * node], L[node]);       L[2 * node + 1] = max(L[2 * node + 1], L[node]);       L[node] = 0;     }     if (r < i || l > j) return -1;     if (l >= i && r <= j) return ST[node];     int mid = (l + r) / 2;     int p1 = _query(2 * node, l, mid, i, j);     int p2 = _query(2 * node + 1, mid + 1, r, i, j);     return max(p1, p2);   }   int query(int i, int j) { return _query(1, 0, n, i, j); }   void update(int i, int j, int val) { _update(1, 0, n, i, j, val); }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &v[i]);     l[0] = -1;     for (int i = 1; i < n; i++) {       l[i] = i - 1;       while (v[l[i]] >= v[i] && l[i] != -1) l[i] = l[l[i]];     }     r[n - 1] = -1;     for (int i = n - 2; i >= 0; i--) {       r[i] = i + 1;       while (v[r[i]] >= v[i] && r[i] != -1) {         r[i] = r[r[i]];       }     }     for (int i = 0; i < n; i++) {       int ri = r[i], li = l[i];       if (ri == -1) ri = n;       if (li == -1) li = -1;       int segment_length = (ri - 1) - (li + 1) + 1;       update(1, segment_length, v[i]);     }     bool first = true;     for (int i = 1; i <= n; i++) {       if (first)         first = false;       else         printf(   );       printf( %d , query(i, i));     }     printf(  n );     return 0;   }   