func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, x, y;     cin >> n >> m;     vector<pair<int, int>> v;     for (int i = 0; i < m; i++) {       cin >> x >> y;       v.push_back({y, x});     }     sort(v.begin(), v.end());     int ans = 0, counter = 0;     for (int i = m - 1; i >= 0; i--) {       if (counter + v[i].second <= n) {         ans += v[i].first * v[i].second;         counter += v[i].second;       } else {         ans += v[i].first * (n - counter);         break;       }     }     cout << ans << endl;     return 0;   }   