func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, d, ans = 0;   vector<long long> a;   int main() {     ios::sync_with_stdio(false);     cin >> n >> d;     while (n--) {       long long temp;       cin >> temp;       a.push_back(temp);     }     for (long long i = 0; i < a.size(); i++) {       long long idx = upper_bound(a.begin(), a.end(), a[i] + d) - a.begin();       idx--;       if (idx > i + 1) ans += ((idx - i) * (idx - i - 1)) / 2;     }     cout << ans << endl;     return 0;   }   