func_code_string: #include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     long long r;     while (b != 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   int const nmax = 1010;   int k, n;   vector<pair<int, int> > st, pe;   vector<int> ans[nmax];   bool dc[nmax];   long double p[nmax];   void solve() {     memset(dc, 0, sizeof(dc));     cin >> k >> n;     for (int i = 0; i < k; i++) {       int c, t;       cin >> c >> t;       p[i] = c;       if (t == 1)         st.push_back(pair<int, int>(c, i));       else         pe.push_back(pair<int, int>(c, i));     }     sort(st.begin(), st.end());     sort(pe.begin(), pe.end());     int k = 0;     while (!st.empty()) {       if (k >= n) k = n - 1;       dc[k] = 1;       ans[k].push_back(st.back().second);       st.pop_back();       k++;     }     for (int i = n - 1; i >= 0; i--) {       if (int((ans[i]).size()) > 0) break;       ans[i].push_back(pe.front().second);       pe.erase(pe.begin());     }     while (!pe.empty()) {       if (k >= n) k = n - 1;       ans[k].push_back(pe.back().second);       pe.pop_back();       k++;     }     long double sum = 0;     for (int i = 0; i < n; i++) {       long double m = INT_MAX;       for (int j = 0; j < int((ans[i]).size()); j++) {         int k = ans[i][j];         sum += p[k];         m = ((m) > (p[k]) ? (p[k]) : (m));       }       if (dc[i]) sum -= m / 2;     }     cout << fixed << setprecision(1) << sum <<   n ;     for (int i = 0; i < n; i++) {       cout << int((ans[i]).size()) <<    ;       for (int j = 0; j < int((ans[i]).size()); j++) cout << ans[i][j] + 1 <<    ;       cout <<   n ;     }   }   int main() {     solve();     return 0;   }   