func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > ps, is, psum(100001), isum(100001);   long long m, n, d;   class cmp {    public:     bool operator()(pair<long long, long long> &a,                     pair<long long, long long> &b) {       return a.first > b.first || (a.first == b.first && a.second < b.second);     }   };   long long bsearch(long long w, long long lo, long long hi) {     long long mid = lo + (hi - lo) / 2;     if (lo > hi) return -1;     if (lo == hi) {       return (isum[lo].second <= w) ? lo : -1;     }     if (isum[mid].second > w) return bsearch(w, lo, mid);     long long ret = bsearch(w, mid + 1, hi);     return ret == -1 ? mid : ret;   }   int main() {     long long i, j, t1, t2;     cin >> n >> m >> d;     for (i = 0; i < n; i++) {       cin >> t1 >> t2;       ps.push_back(pair<long long, long long>(t1, t2));     }     for (i = 0; i < m; i++) {       cin >> t1 >> t2;       is.push_back(pair<long long, long long>(t1, t2));     }     sort(ps.begin(), ps.end(), cmp());     sort(is.begin(), is.end(), cmp());     psum[0] = pair<long long, long long>(0, 0),     isum[0] = pair<long long, long long>(0, 0);     for (i = 1; i <= n; i++) {       j = i - 1;       psum[i] = pair<long long, long long>(ps[j].first + psum[i - 1].first,                                            ps[j].second + psum[i - 1].second);     }     for (i = 1; i <= m; i++) {       j = i - 1;       isum[i] = pair<long long, long long>(is[j].first + isum[i - 1].first,                                            is[j].second + isum[i - 1].second);     }     long long ans = 0;     for (i = 1; i <= n; i++) {       pair<long long, long long> tp = psum[i];       long long ind = bsearch(d - tp.second, 1, m);       if (ind == -1) break;       ans = max(ans, tp.first + isum[ind].first);     }     cout << ans << endl;   }   