func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long long INF = 1e18;   const int MAXN = 1e5 + 5;   long long i, j, m, n, k, t, d;   long long ans;   long long x[MAXN];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> d;     for (i = 1; i <= n; i++) {       cin >> x[i];     }     for (i = 1; i <= n; i++) {       long long low = i + 2, high = n, mid, ok = -1;       while (low <= high) {         mid = (low + high) / 2;         if (x[mid] - x[i] <= d) {           ok = mid;           low = mid + 1;         } else {           high = mid - 1;         }       }       if (ok == -1) continue;       ans += (ok - i) * (ok - i - 1) / 2;     }     cout << ans;     return 0;   }   