func_code_string: #include <bits/stdc++.h>   using namespace std;   int N, K;   int h[100005];   bool isok[100005];   int check(int L) {     deque<int> A, B;     int ret = 0;     for (int i = 1; i <= N; ++i) {       while (A.size() && A.front() + L <= i) A.pop_front();       while (B.size() && B.front() + L <= i) B.pop_front();       while (A.size() && h[A.back()] >= h[i]) A.pop_back();       while (B.size() && h[B.back()] <= h[i]) B.pop_back();       A.push_back(i);       B.push_back(i);       if (i >= L) ret += (isok[i - L + 1] = (h[B.front()] - h[A.front()] <= K));     }     return ret;   }   int main() {     while (scanf( %d %d , &N, &K) == 2) {       for (int i = 1; i <= N; ++i) scanf( %d , h + i);       int lo = 1, hi = N + 1, mid;       while (lo + 1 < hi) {         mid = lo + hi >> 1;         if (check(mid))           lo = mid;         else           hi = mid;       }       int s = check(lo);       printf( %d %d n , lo, s);       for (int i = 1; i + lo - 1 <= N; ++i)         if (isok[i]) printf( %d %d n , i, i + lo - 1);     }   }   