func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n, d, m, s;     cin >> n >> d;     vector<pair<int, int> > v;     vector<int> money;     for (int i = 0; i < n; i++) {       cin >> m >> s;       pair<int, int> p = make_pair(m, s);       v.push_back(p);       money.push_back(m);     }     sort(v.begin(), v.end());     sort(money.begin(), money.end());     vector<unsigned long long> pref;     pref.push_back(0);     int i;     for (i = 0; i < n; i++) {       pref.push_back(v[i].second + pref[i]);     }     for (i = 0; i <= n; i++) {     }     unsigned long long max = 0;     int index;     for (i = 0; i < n; i++) {       vector<int>::iterator up;       up = upper_bound(money.begin(), money.end(), v[i].first + d - 1);       if (pref[up - money.begin()] - pref[i] > max)         max = pref[up - money.begin()] - pref[i];     }     cout << max << endl;     return 0;   }   