func_code_string: #include <bits/stdc++.h>   using namespace std;   long long MAX = 1000000000;   long long MOD = 1000000007;   pair<long long, long long> p[100010];   void solve() {     long long n;     cin >> n;     long long d;     cin >> d;     ;     for (long long i = (0); i < (n); i++) {       long long in1;       cin >> in1;       long long in2;       cin >> in2;       ;       p[i] = {in1, in2};     }     sort(p, p + n);     long long j = 0, sum = 0, ans = 0;     for (long long i = (0); i < (n); i++) {       while (p[j].first - p[i].first < d and j < n) {         sum += p[j].second;         j++;       }       ans = max(ans, sum);       sum -= p[i].second;     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long test = 1;     while (test--) {       solve();     }   }   