func_code_string: #include <bits/stdc++.h>   const int inf = 1e5 + 10;   const long long mod = 998244353;   const int LARGEST = 0x3f3f3f3f;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};   int dy[] = {1, 1, 0, -1, -1, -1, 0, 1};   int bx[] = {0, 1, 0, -1};   int by[] = {-1, 0, 1, 0};   using namespace std;   int a[inf], stmin[inf][20], stmax[inf][20];   pair<int, int> q[inf];   int dp[inf];   int n, s, len, head, tail;   int ask(int x, int y) {     int tlen = log(y - x + 1) / log(2);     int p = max(stmax[x][tlen], stmax[y - (1 << tlen) + 1][tlen]);     int q = min(stmin[x][tlen], stmin[y - (1 << tlen) + 1][tlen]);     return p - q;   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> s >> len;     for (int i = 1; i <= n; i++) {       cin >> a[i];       stmax[i][0] = stmin[i][0] = a[i];     }     for (int j = 1; j < 20; j++)       for (int i = 1; i <= n; i++)         if (i + (1 << (j - 1)) <= n) {           stmax[i][j] = max(stmax[i][j - 1], stmax[i + (1 << (j - 1))][j - 1]);           stmin[i][j] = min(stmin[i][j - 1], stmin[i + (1 << (j - 1))][j - 1]);         }     if (len > n || ask(1, len) > s) {       cout << -1 << endl;       return 0;     }     for (int i = 1; i <= n; i++) dp[i] = LARGEST;     dp[0] = 0;     dp[len] = 1;     head = tail = 1;     q[tail++] = make_pair(dp[0], 0);     for (int i = len + 1; i <= n; i++) {       int l = 1, r = i - len + 1, ans = -1;       while (l < r) {         int mid = (l + r) >> 1;         if (ask(mid, i) <= s)           r = ans = mid;         else           l = mid + 1;       }       if ((ask(l, i) <= s) && ans == -1)         ans = l;       else if (ans != -1 && (ask(l, i) <= s))         ans = min(ans, l);       while (head < tail && q[tail - 1].first >= dp[i - len]) tail--;       q[tail++] = make_pair(dp[i - len], i - len);       if (ans != -1) {         while (head < tail && q[head].second < ans - 1) head++;         if (head < tail) dp[i] = min(dp[i], q[head].first + 1);       }     }     if (dp[n] != LARGEST)       cout << dp[n] << endl;     else       cout << -1 << endl;   }   