func_code_string: #include <bits/stdc++.h>   using namespace std;   int search(long long int *array, int start_idx, int end_idx,              long long int search_val) {     if (start_idx == end_idx)       return array[start_idx] <= search_val ? start_idx : -1;     int mid_idx = start_idx + (end_idx - start_idx) / 2;     if (search_val < array[mid_idx])       return search(array, start_idx, mid_idx, search_val);     int ret = search(array, mid_idx + 1, end_idx, search_val);     return ret == -1 ? mid_idx : ret;   }   long long int C(long long int k) { return (k * (k - 1)) / 2; }   int main() {     ios_base::sync_with_stdio;     cin.tie(NULL);     long long int n, d;     cin >> n >> d;     long long int arr[n];     for (long long int i = 0; i < n; i++) cin >> arr[i];     long long int ways = 0, current, maxallowed, index2, previndex2;     for (long long int i = 0; i < n; i++) {       current = arr[i];       maxallowed = current + d;       index2 = search(arr, 0, n - 1, maxallowed);       if (index2 - i + 1 >= 3) {         ways += C(index2 - i);       }     }     cout << ways;     return 0;   }   