func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   ll gcd(ll a, ll b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   ll nCr(ll n, ll r) {     ll a = 1, b = 1;     if (n < r) return 0;     if (r == 0) return 1;     if (n - r < r) r = n - r;     while (r) {       a *= n;       b *= r;       ll m = gcd(a, b);       a /= m;       b /= m;       n--, r--;     }     return a;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n, d;     cin >> n >> d;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     vector<int> b, c;     ll ans = 0;     int j = 1, prevJ = 0;     for (int i = 0; j < n; i++) {       for (j; j < n; j++) {         if (a[j] - a[i] > d) break;       }       ans += (nCr(j - i, 3) - nCr((j - i) - (j - prevJ), 3));       prevJ = j;     }     cout << ans;     return 0;   }   