func_code_string: #include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, 0, 1, -1}, dy[] = {-1, 1, 0, 0};   const int dxx[] = {0, 0, 1, -1, -1, -1, 1, 1},             dyy[] = {-1, 1, 0, 0, 1, -1, 1, -1};   ifstream f(  );   ofstream g(  );   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     long long n, m, prv = 0, prvmax = -1;     cin >> n >> m;     vector<int> v(0);     for (int a; n; n--) cin >> a, v.push_back(a);     vector<pair<long long, long long> > w(0);     for (int a, b; m; m--) cin >> a >> b, w.push_back({a, b});     sort(w.begin(), w.end());     for (int i = 0; i <= w.size() - 1; i++) {       w[i].first = max(w[i].first, prvmax);       prvmax = w[i].first;       w[i].second += prv;       prv = w[i].second;     }     for (auto i : v)       if (i < w.front().first)         cout <<  0  ;       else if (i >= w.back().first)         cout << w.back().second <<    ;       else {         int st = 0, dr = w.size() - 1, rz;         while (st <= dr) {           int m = (st + dr) / 2;           if (w[m].first <= i)             st = m + 1, rz = m;           else             dr = m - 1;         }         cout << w[rz].second <<    ;       }     return 0;   }   