func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5, inf = 1e9;   int a[maxn];   struct segtree {     int lb, rb;     int mn = 0;     segtree *l, *r;     segtree(int _lb, int _rb) {       lb = _lb, rb = _rb;       if (lb == rb)         mn = a[lb];       else {         int t = (lb + rb) / 2;         l = new segtree(lb, t);         r = new segtree(t + 1, rb);         mn = min(l->mn, r->mn);       }     }     int rmq(int lq, int rq) {       if (lb >= lq && rb <= rq)         return mn;       else if (lb > rq || rb < lq)         return inf;       return min(l->rmq(lq, rq), r->rmq(lq, rq));     }   };   segtree *p;   vector<pair<int, int> > ans;   void solve(int l, int r, int d) {     if (l > r) return;     int mn = p->rmq(l, r);     while (mn > d) ans.push_back({l + 1, r + 1}), d++;     int lb = l, rb = r;     while (lb != rb) {       int t = (lb + rb) / 2;       if (p->rmq(l, t) == d)         rb = t;       else         lb = t + 1;     }     solve(l, lb - 1, d);     solve(lb + 1, r, d);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     p = new segtree(0, n - 1);     solve(0, n - 1, 0);     cout << ans.size() <<   n ;     for (auto x : ans) cout << x.first <<     << x.second <<   n ;     return 0;   }   