func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int> > white, black;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       int c, s;       cin >> c >> s;       if (c) {         black.push_back(make_pair(s, i + 1));       } else {         white.push_back(make_pair(s, i + 1));       }     }     sort(black.begin(), black.end());     sort(white.begin(), white.end());     int p_b = 0, p_w = 0;     while (p_b < black.size() && p_w < white.size()) {       cout << black[p_b].second <<     << white[p_w].second <<    ;       if (black[p_b].first < white[p_w].first) {         cout << black[p_b].first << endl;         pair<int, int>& p = white[p_w];         p.first -= black[p_b].first;         p_b++;       } else {         cout << white[p_w].first << endl;         pair<int, int>& p = black[p_b];         p.first -= white[p_w].first;         p_w++;       }     }     if (p_b < black.size()) {       p_b++;       while (p_b < black.size()) {         cout << white[0].second <<     << black[p_b++].second <<   0  << endl;       }     }     if (p_w < white.size()) {       p_w++;       while (p_w < white.size()) {         cout << black[0].second <<     << white[p_w++].second <<   0  << endl;       }     }     return 0;   }   