func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   void max_self(T &a, const T &b) {     if (a < b) a = b;   }   template <class T>   void min_self(T &a, const T &b) {     if (a > b) a = b;   }   const int INF = 1e9 + 7;   const double PI = acos(-1.0);   const double EPS = (1e-9);   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int N, d;     long long cnt = 0;     cin >> N >> d;     vector<int> pos(N);     for (int &ele : pos) cin >> ele;     for (auto itr = pos.begin(); itr != pos.end(); ++itr) {       auto lim = upper_bound((pos).begin(), (pos).end(), *itr + d);       int len = distance(itr, lim) - 1;       cnt += (long long)len * (len - 1) / 2;     }     cout << cnt <<   n ;     return 0;   }   