intmain(){ N = getnum (), K = getnum (); for (int i = 1; i <= N; i ++) { int c = getnum (), v = getnum (); C = max (C, c), value[c].push_back(v); } for (int i = 1; i <= C; i ++) { sort (value[i].begin(), value[i].end(), comp); LL sum = 0; prefix[i].push_back(sum); for (int j = 0; j < (int) value[i].size(); j ++) sum += value[i][j], prefix[i].push_back(sum); for (int j = 0; j < i; j ++) { int limit; trans[limit = 1] = j; while (trans[limit] + i <= K) limit ++, trans[limit] = trans[limit - 1] + i; solve (i, 1, limit, 1, limit); } } for (int i = 1; i <= K; i ++) { if (i > 1) putchar (' '); write (f[C][i]); } puts ("");