func_code_string: #include <bits/stdc++.h>   using namespace std;   int ky[8] = {-1, 1, -2, 2, -2, 2, -1, 1};   int kx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};   int dy[4] = {-1, 0, 1, 0};   int dx[4] = {0, 1, 0, -1};   int ddy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};   int ddx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};   const double PI = acos(-1.0);   int n;   int c, p;   int k;   int num;   struct Group {     int c, p, idx;   };   Group a[1000];   Group b[1000];   pair<int, int> t[1000];   int ret1, ret2;   int cnt1, cnt2;   set<int> s;   vector<pair<int, int>> pos1, pos2;   int ns;   bool comp1(const Group &x, const Group &y) {     return x.p > y.p || (x.p == y.p && x.c < y.c);   }   bool comp2(const Group &x, const Group &y) {     return x.c < y.c || (x.c == y.c && x.p > y.p);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> c >> p;       a[i].c = c;       a[i].p = p;       a[i].idx = i + 1;       b[i].c = c;       b[i].p = p;       b[i].idx = i + 1;     }     sort(a, a + n, comp1);     sort(b, b + n, comp2);     cin >> k;     for (int i = 0; i < k; i++) {       cin >> num;       t[i].first = num;       t[i].second = i + 1;     }     sort(t, t + k);     for (int i = 0; i < n; i++) {       for (int j = 0; j < k; j++) {         if (s.count(j)) continue;         if (a[i].c <= t[j].first) {           ret1 += a[i].p;           cnt1++;           pos1.push_back({a[i].idx, t[j].second});           s.insert(j);           break;         }       }     }     s.clear();     for (int i = 0; i < n; i++) {       for (int j = 0; j < k; j++) {         if (s.count(j)) continue;         if (b[i].c <= t[j].first) {           ret2 += b[i].p;           cnt2++;           pos2.push_back({b[i].idx, t[j].second});           s.insert(j);           break;         }       }     }     if (ret1 <= ret2) {       cout << cnt2 <<     << ret2 <<   n ;       ns = pos2.size();       for (int i = 0; i < ns; i++)         cout << pos2[i].first <<     << pos2[i].second <<   n ;     } else {       cout << cnt1 <<     << ret1 <<   n ;       ns = pos1.size();       for (int i = 0; i < ns; i++)         cout << pos1[i].first <<     << pos1[i].second <<   n ;     }     return 0;   }   