func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1000;   vector<pair<int, int> > type[2];   vector<int> ans[N];   int a[N], t[N];   int main() {     int n, k;     while (scanf( %d %d , &n, &k) == 2) {       type[0].clear();       type[1].clear();       for (int i = 0; i < int(k); i++) ans[i].clear();       for (int i = 0; i < int(n); i++) {         scanf( %d %d , &a[i], &t[i]);         type[t[i] - 1].push_back(make_pair(a[i], i));       }       long long full = 0, half = 0;       sort(type[0].begin(), type[0].end(), greater<pair<int, int> >());       sort(type[1].begin(), type[1].end(), greater<pair<int, int> >());       if (type[0].size() < k) {         for (int i = 0; i < int(type[0].size()); i++)           ans[i].push_back(type[0][i].second);         for (int i = 0; i < int(type[0].size()); i++) half += type[0][i].first;         for (int i = 0; i < int(type[1].size()); i++) full += type[1][i].first;         int s = k - type[0].size(), beg = type[0].size();         for (int i = 0; i < int(type[1].size()); i++) {           ans[beg + i % s].push_back(type[1][i].second);         }       } else {         for (int i = 0; i < int(k); i++) ans[i].push_back(type[0][i].second);         for (int i = k; i < int(type[0].size()); i++)           ans[k - 1].push_back(type[0][i].second);         for (int i = 0; i < int(k - 1); i++) half += a[ans[i][0]];         int idx = -1;         for (int i = 0; i < int(type[1].size()); i++)           ans[k - 1].push_back(type[1][i].second);         for (int i = 0; i < int(ans[k - 1].size()); i++) {           if (idx == -1 || a[ans[k - 1][idx]] > a[ans[k - 1][i]]) idx = i;         }         for (int i = 0; i < int(ans[k - 1].size()); i++)           if (i == idx)             half += a[ans[k - 1][i]];           else             full += a[ans[k - 1][i]];       }       printf( %I64d.%c n , full + half / 2, (half & 1) == 1 ?  5  :  0 );       for (int i = 0; i < int(k); i++) {         printf( %d , ans[i].size());         for (int a : ans[i]) printf(  %d , a + 1);         printf(  n );       }     }     return 0;   }   