func_code_string: #include <bits/stdc++.h>   const int INF = 107374182;   using namespace std;   int n, k;   int ans[100005][2];   struct sa {     int ma, mi;   } segTree[1000000];   void build(int l, int r, int root) {     if (l == r) {       if (l != n + 1) {         scanf( %d , &segTree[root].ma);         segTree[root].mi = segTree[root].ma;       } else {         segTree[root].ma = 0;         segTree[root].mi = INF;       }       return;     }     int mid = (l + r) >> 1;     build(l, mid, root << 1);     build(mid + 1, r, (root << 1) | 1);     segTree[root].ma = max(segTree[root << 1].ma, segTree[(root << 1) | 1].ma);     segTree[root].mi = min(segTree[root << 1].mi, segTree[(root << 1) | 1].mi);   }   sa query(int L, int R, int l, int r, int root) {     if (L <= l && r <= R) {       return segTree[root];     }     sa ans, temp;     if (l == r) {       temp.ma = 0;       temp.mi = INF;       return temp;     }     int mid = (l + r) >> 1;     ans.ma = 0;     ans.mi = INF;     if (L <= mid) {       temp = query(L, R, l, mid, root << 1);       ans.ma = max(ans.ma, temp.ma);       ans.mi = min(ans.mi, temp.mi);     }     if (R > mid) {       temp = query(L, R, mid + 1, r, (root << 1) | 1);       ans.ma = max(ans.ma, temp.ma);       ans.mi = min(ans.mi, temp.mi);     }     return ans;   }   int main() {     scanf( %d%d , &n, &k);     {       build(1, n, 1);       int maxlength = 0, cnt = 0;       sa tempx, tempy;       for (int i = 1; i <= n; i++) {         int l = i, r = n + 1;         while (r > l + 1) {           int mid = (l + r) >> 1;           tempx = query(i, mid + 1, 1, n, 1);           if (tempx.ma - tempx.mi > k)             r = mid;           else             l = mid;         }         tempx = query(i, l, 1, n, 1);         tempy = query(i, r, 1, n, 1);         if (tempx.ma - tempx.mi <= tempy.ma - tempy.mi &&             tempy.ma - tempy.mi <= k && l < n)           l++;         if (maxlength < l - i + 1) {           maxlength = l - i + 1;           ans[0][0] = i;           ans[0][1] = l;           cnt = 1;         } else if (maxlength == l - i + 1) {           ans[cnt][0] = i;           ans[cnt++][1] = l;         }       }       printf( %d %d n , maxlength, cnt);       for (int i = 0; i < cnt; i++) {         printf( %d %d n , ans[i][0], ans[i][1]);       }     }     return 0;   }   