func_code_string: #include <bits/stdc++.h>   long long n, m, Q;   long long T;   std::vector<long long> req, l, r;   std::vector<long long> fill(std::vector<long long>& req) {     std::vector<long long> ans(m + 1);     long long tem = T;     for (long long i = m; i; i--) {       ans[i] = 0;       if (i < m) ans[i] = ans[i + 1];       if (~req[i]) ans[i] = req[i];       tem -= ans[i];     }     if (tem < 0) return std::vector<long long>();     for (long long i = m, last = m + 1; tem && ~i; i--) {       if (~req[i]) {         long long mx = (i < m) ? (last - 1 - i) * (req[i] - ans[i + 1]) : 0;         if (mx <= tem) {           for (long long j = i + 1; j < last; j++) ans[j] = req[i];           tem -= mx;         } else {           for (long long j = i + 1; j < last; j++)             ans[j] +=                 (tem / (last - 1 - i)) + ((tem % (last - 1 - i)) >= (j - i));           tem = 0;         }         last = i;       }     }     if (tem) return std::vector<long long>();     return ans;   }   long long q[100001], h, t;   bool check(std::vector<long long> a, std::vector<long long> b) {     long long n = (long long)a.size() - 1, m = (long long)b.size() - 1;     h = t = 0;     for (long long i = 2; i <= n; i++) a[i] += a[i - 1];     for (long long i = 2; i <= m; i++) b[i] += b[i - 1];     for (long long i = 1; i <= n; i++) a[i] -= 1ll * i * m;     for (long long i = 1; i <= m; i++) b[i] -= 1ll * i * n;     for (long long i = 1; i <= m; i++) {       while (h < t - 1 && (1ll * (b[q[t]] - b[i]) * (q[t] - q[t - 1]) >=                            1ll * (b[q[t - 1]] - b[q[t]]) * (i - q[t])))         --t;       q[++t] = i;     }     for (long long i = 1; i <= n; i++) {       while (h < t - 1 && (b[q[t]] + q[t] * i) >= (b[q[t - 1]] + q[t - 1] * i))         --t;       if (b[q[t]] + q[t] * i < a[n] - a[i]) return 0;     }     return 1;   }   bool judge(long long x, long long y = -1) {     std::vector<long long> Req = req;     if (~y) {       for (long long i = 1; i <= x; i++) Req[i] = y;     }     std::vector<long long> now = fill(Req);     if (now.empty()) return 0;     if (now[1] != now[x]) {       for (long long i = 1; i <= x; i++)         if (~req[i] && req[i] != now[1]) return 0;       for (long long i = 1; i <= x; i++) Req[i] = now[1];       now = fill(Req);       if (now.empty()) return 0;     }     std::reverse(now.begin() + 1, now.end());     return check(l, now) & check(now, r);   }   signed main() {     scanf( %lld%lld , &n, &m);     l.resize(n + 1), r.resize(n + 1);     for (long long i = 1; i <= n; i++) scanf( %lld%lld , &l[i], &r[i]);     std::sort(l.begin() + 1, l.end());     std::sort(r.begin() + 1, r.end());     req.resize(m + 1);     for (long long i = 1; i <= m; i++) req[i] = -1;     req[0] = 0x7f7f7f7f;     scanf( %lld , &Q);     for (long long i = 1, a, b; i <= Q; i++) {       scanf( %lld%lld , &a, &b);       req[a] = b;     }     scanf( %lld , &T);     long long l = 1, r = m, mid, ans = -1;     while (l <= r) {       mid = (l + r) >> 1;       if (judge(mid))         ans = mid, l = mid + 1;       else         r = mid - 1;     }     if (!~ans) {       printf( -1 -1 );       return 0;     }     for (long long i = 1; i <= ans; i++)       if (~req[i]) {         printf( %lld %lld n , ans, req[i]);         return 0;       }     l = fill(req)[1], r = n;     long long ans1;     while (l <= r) {       mid = (l + r) >> 1;       if (judge(ans, mid))         ans1 = mid, l = mid + 1;       else         r = mid - 1;     }     printf( %lld %lld n , ans, ans1);   }   