Problem:
Problem C. Santa's Gift
Santa is going to pack gifts into a bag for a family. There are $N$ kinds of gifts. The size and the price of the $i$-th gift ($1 \leq i \leq N$) are $s_i$ and $p_i$, respectively. The size of the bag is $C$, thus Santa can pack gifts so that the total size of the gifts does not exceed $C$. Children are unhappy if they are given multiple items of the same kind gift, so Santa has to choose at most one gift of the same kind per child.
In addition, if a child did not receive a gift that the other children in the same family receive, he/she will complain about that. Hence Santa must distribute gifts fairly to all the children of a family, by giving the same set of gifts to each child. In other words, for a family with $k$ children, Santa must pack zero or $k$ items for each kind of gifts. Santa gives one bag to one family, therefore, the total size of the gifts for each family does not exceed $C$.
Santa wants to maximize the total price of packed items for a family but does not know the number of children in the family he is going to visit yet. The number seems at most $M$. To prepare all the possible cases, calculate the maximum total price of items for a family with $k$ children for each $1 \leq k \leq M$.
Input
The input consists of a single test case in the following format.
$C$ $N$ $M$
$s_1$ $p_1$
$...$
$s_N$ $p_N$
The first line contains three integers $C$, $N$ and $M$, where $C$ ($1 \leq C \leq 10^4$) is the size of the bag, $N$ ($1 \leq N \leq 10^4$) is the number of kinds of the gifts, and $M$ ($1 \leq M \leq 10^4$) is the maximum number of children in the family. The $i$-th line of the following $N$ lines contains two integers $s_i$ and $p_i$ ($1 \leq s_i, p_i \leq 10^4$), where $s_i$ and $p_i$ are the size and the price of the $i$-th gift, respectively.
Output
The output should consist of $M$ lines. In the $k$-th line, print the maximum total price of gifts for a family with $k$ children.
Examples
Sample Input 1
6 3 2
1 2
2 10
3 5
Output for Sample Input 1
17
24
Sample Input 2
200 5 5
31 41
59 26
53 58
97 93
23 84
Output for Sample Input 2
235
284
375
336
420
Sample Input 3
1 1 2
1 1
Output for Sample Input 3
1
0
Sample Input 4
2 2 2
1 1
2 100
Output for Sample Input 4
100
2

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

const ll INF = 1e18;
ll mod = 998244353;

ifstream in;
ofstream out;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    if (argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll c, n, m;
    cin >> c >> n >> m;
    vector<ll> dp(c + 1, -INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        ll s, p;
        cin >> s >> p;
        for (int j = c; j - s >= 0; j--) {
            chmax(dp[j], dp[j - s] + p);
        }
    }

    for (int i = 1; i <= m; i++) {
        ll ans = 0;
        for (int j = 0; i * j <= c; j++) {
            if (dp[j] >= 0)
                chmax(ans, i * dp[j]);
        }
        cout << ans << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3712
final_rank: 1

code_snippet: #include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ve = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,s,n) for(ll i = (ll)s;i < (ll)n;i++)
#define rrep(i,l,r) for(ll i = r-1;i >= l;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
#define UB(A,x) (int)(upper_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T> inline bool chmax(T &a,T b){if(a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a,T b){if(a > b){a = b;return true;}return false;}
ld dist(ld x1,ld y1,ld x2, ld y2){return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}


int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  int C,n,m;cin >> C >> n >> m;
  vi s(n),p(n);
  rep(i,0,n)cin >> s[i] >> p[i];
  vi dp(C+1,-1);
  dp[0] = 0;
  rep(i,0,n){
    vi DP(C+1,-1);
    rep(j,0,C+1){
      chmax(DP[j],dp[j]);
      if(j+s[i] <= C)chmax(DP[j+s[i]],dp[j]+p[i]);
    }
    swap(dp,DP);
  }
  rep(i,0,C)chmax(dp[i+1],dp[i]);
  rep(i,1,m+1){
    cout << dp[C/i]*i << endl;
  }
  

  return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 3596
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll c, n, m;
    cin >> c >> n >> m;
    vector<pair<ll,ll>> s_p(n);
    rep(i, n){
        cin >> s_p[i].first >> s_p[i].second;
    }

    vector<ll> dp(10000 + 1LL, 0);

    rep(i, n){
        for(ll j = 10000LL; j >= 0; j--){
            if(j - s_p[i].first >= 0){
                dp[j] = max(dp[j], dp[j - s_p[i].first] + s_p[i].second);
            }
        }
    }

    ll ma = 0;
    rep(i, 10001){
        ma = max(ma, dp[i]);
        dp[i] = ma;
    }

    rep(i, m){
        ll temp = c / (i + 1);
        cout << dp[temp] * (i + 1) << '\n';
    }
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3592
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll c, n, m;
    cin >> c >> n >> m;
    vector<pair<ll,ll>> s_p(n);
    rep(i, n){
        cin >> s_p[i].first >> s_p[i].second;
    }

    vector<ll> dp(10000 + 1LL, 0);

    rep(i, n){
        for(ll j = 10000LL; j >= 0; j--){
            if(j - s_p[i].first >= 0 && dp[j - s_p[i].first] != 0){
                dp[j] = max(dp[j], dp[j - s_p[i].first] + s_p[i].second);
            }
        }
        dp[s_p[i].first] = max(dp[s_p[i].first], s_p[i].second);
    }

    ll ma = 0;
    rep(i, 10001){
        ma = max(ma, dp[i]);
        dp[i] = ma;
    }

    rep(i, m){
        ll temp = c / (i + 1);
        cout << dp[temp] * (i + 1) << '\n';
    }
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3588
final_rank: 3

code_snippet: ////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e4;
LL dp[N + 5];
LL pref[N + 5];
LL s[N + 5], p[N + 5];

void hora(int tc) {
	int c,n,m;
	cin>>c>>n>>m;
	for(int i = 0;i < n;i++) cin>>s[i]>>p[i];
	memset(dp, -1, sizeof dp);
	dp[0] = 0;
	for(int i = 0;i < n;i++) {
		for(int j = c;j >= s[i];j--) if(dp[j - s[i]] != -1) dp[j] = max(dp[j], dp[j - s[i]] + p[i]);
	}
	pref[0] = 0;
	for(int i = 1;i <= c;i++) pref[i] = max(pref[i - 1], dp[i]);
	for(int i = 1;i <= m;i++) {
		cout<<pref[c / i] * i<<endl;
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3780
final_rank: 4

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <ranges>
namespace ranges = std::ranges;
int C, N, M;
int main() {
    std::cin >> C >> N >> M;
    std::vector<int> dp(C + 1, -1);
    dp[0] = 0;
    for (int i = 0 ; i < N ; i++) {
        int s, p;
        std::cin >> s >> p;
        std::vector<int> next = dp;
        for (int j = 0 ; j + s <= C ; j++) if (dp[j] != -1)
            next[j + s] = std::max(next[j + s], dp[j] + p);
        dp = std::move(next);
    }
    std::vector<int> ans(M + 1);
    for (int i = 1 ; i <= C ; i++) {
        for (int j = 1 ; j <= M and i * j <= C ; j++) {
            ans[j] = std::max(ans[j], dp[i] * j);
        }
    }
    for (int i = 1 ; i <= M ; i++) std::cout << ans[i] << '\n';
}
accuracy: 1
time_ms: 40
memory_kb: 3712
final_rank: 2

code_snippet: #include <bits/stdc++.h>


using namespace std;
//make -f ../makefile SRC=

/*
TODO
*/


//------------------------------------------------------------------------------
bool DEBUG = false;
const int INF = 1000000000;

const int MAX_N = 10000;
static int weight[MAX_N];
static int value[MAX_N];

const int MAX_W = 10000;
static int S0[MAX_W+1];
static int S1[MAX_W+1];

//------------------------------------------------------------------------------
void debug(int N, int K)
{
    printf("N=%d, capacity=%d\n", N, K);
    for (int i=0; i<N; ++i)
    {
        printf("w=%d, v=%d\n", weight[i], value[i]);
    }

}

int dp(int N, int K)
{
    //printf("dp(): K=%d\n", K);
    for (int k=0; k<K+1; ++k) { S0[k] = 0; S1[k] = 0; }

    for (int i=0; i<N; ++i)
    {
        int v = value[i];
        int w = weight[i];
        S1[w] = max(S1[w], v);

        int w1 = 1;
        while (w1+w <= K)
        {
            if (S0[w1]) S1[w1+w] = max(S1[w1+w], S0[w1]+v);
            w1++;
        }

        for (int k=1; k<K+1; ++k) { S0[k] = max(S0[k],S1[k]); S1[k] = 0; }
        if (DEBUG) {printf("S0, i=%d:\n",i); for (int k=0; k<=K; ++k) if (S0[k]) printf("k=%d, S0=%d\n",k,S0[k]); printf("\n");}
    }

    int res = 0;
    for (int k=1; k<=K; ++k) res = max(res, S0[k]);
    return res;
}
//------------------------------------------------------------------------------
void solve(int N, int K, int M)
{
    if (DEBUG) debug(N, K);
    //--------------------------------------------------------------------------
    // base cases:
    //--------------------------------------------------------------------------
    // init params:
    //--------------------------------------------------------------------------
    // compute:
    for (int m=1; m<=M; ++m)
    {
        int res = 0;
        int K1 = K/m;
        if (K1 > 0) res = dp(N, K1);
        res *= m;
        printf("%d\n", res);
    }

}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    //--------------------------------------------------------------------------
    int T, capacity, N, M, w, v, num;
    //num = scanf("%d ", &T);
    //for (int t=1; t<=T; ++t)
    //{
        num = scanf("%d %d %d ", &capacity, &N, &M);
        for (int i=0; i<N; ++i) num = scanf("%d %d ", &weight[i], &value[i]);
        solve(N, capacity, M);
    //}

    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 1
time_ms: 1080
memory_kb: 3724
final_rank: 16

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

#include <unistd.h>

namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf


uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
    char num[10000][4];
    constexpr Pre() : num() {
        for (int i = 0; i < 10000; i++) {
            int n = i;
            for (int j = 3; j >= 0; j--) {
                num[i][j] = n % 10 | '0';
                n /= 10;
            }
        }
    }
} constexpr pre;

inline void load() {
    memmove(ibuf, ibuf + pil, pir - pil);
    pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
    pil = 0;
    if (pir < SZ)
        ibuf[pir++] = '\n';
}

inline void flush() {
    fwrite(obuf, 1, por, stdout);
    por = 0;
}

void rd(char &c) {
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
}

void rd(string &x) {
    x.clear();
    char c;
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
    do {
        x += c;
        if (pil == pir)
            load();
        c = ibuf[pil++];
    } while (!isspace(c));
}

template <typename T> void rd_real(T &x) {
    string s;
    rd(s);
    x = stod(s);
}

template <typename T> void rd_integer(T &x) {
    if (pil + 100 > pir)
        load();
    char c;
    do
        c = ibuf[pil++];
    while (c < '-');
    bool minus = 0;
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (c == '-') {
            minus = 1, c = ibuf[pil++];
        }
    }
    x = 0;
    while ('0' <= c) {
        x = x * 10 + (c & 15), c = ibuf[pil++];
    }
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (minus)
            x = -x;
    }
}

void rd(int &x) {
    rd_integer(x);
}
void rd(ll &x) {
    rd_integer(x);
}
void rd(i128 &x) {
    rd_integer(x);
}
void rd(uint &x) {
    rd_integer(x);
}
void rd(ull &x) {
    rd_integer(x);
}
void rd(u128 &x) {
    rd_integer(x);
}
void rd(double &x) {
    rd_real(x);
}
void rd(long double &x) {
    rd_real(x);
}

template <class T, class U> void rd(pair<T, U> &p) {
    return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T> void rd_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
        auto &x = std::get<N>(t);
        rd(x);
        rd_tuple<N + 1>(t);
    }
}
template <class... T> void rd(tuple<T...> &tpl) {
    rd_tuple(tpl);
}

template <size_t N = 0, typename T> void rd(array<T, N> &x) {
    for (auto &d : x)
        rd(d);
}
template <class T> void rd(vector<T> &x) {
    for (auto &d : x)
        rd(d);
}

void read() {}
template <class H, class... T> void read(H &h, T &...t) {
    rd(h), read(t...);
}

void wt(const char c) {
    if (por == SZ)
        flush();
    obuf[por++] = c;
}
void wt(const string s) {
    for (char c : s)
        wt(c);
}
void wt(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++)
        wt(s[i]);
}

template <typename T> void wt_integer(T x) {
    if (por > SZ - 100)
        flush();
    if (x < 0) {
        obuf[por++] = '-', x = -x;
    }
    int outi;
    for (outi = 96; x >= 10000; outi -= 4) {
        memcpy(out + outi, pre.num[x % 10000], 4);
        x /= 10000;
    }
    if (x >= 1000) {
        memcpy(obuf + por, pre.num[x], 4);
        por += 4;
    } else if (x >= 100) {
        memcpy(obuf + por, pre.num[x] + 1, 3);
        por += 3;
    } else if (x >= 10) {
        int q = (x * 103) >> 10;
        obuf[por] = q | '0';
        obuf[por + 1] = (x - q * 10) | '0';
        por += 2;
    } else
        obuf[por++] = x | '0';
    memcpy(obuf + por, out + outi + 4, 96 - outi);
    por += 96 - outi;
}

template <typename T> void wt_real(T x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << double(x);
    string s = oss.str();
    wt(s);
}

void wt(int x) {
    wt_integer(x);
}
void wt(ll x) {
    wt_integer(x);
}
void wt(i128 x) {
    wt_integer(x);
}
void wt(uint x) {
    wt_integer(x);
}
void wt(ull x) {
    wt_integer(x);
}
void wt(u128 x) {
    wt_integer(x);
}
void wt(double x) {
    wt_real(x);
}
void wt(long double x) {
    wt_real(x);
}

template <class T, class U> void wt(const pair<T, U> val) {
    wt(val.first);
    wt(' ');
    wt(val.second);
}
template <size_t N = 0, typename T> void wt_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
        if constexpr (N > 0) {
            wt(' ');
        }
        const auto x = std::get<N>(t);
        wt(x);
        wt_tuple<N + 1>(t);
    }
}
template <class... T> void wt(tuple<T...> tpl) {
    wt_tuple(tpl);
}
template <class T, size_t S> void wt(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}
template <class T> void wt(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}

void print() {
    wt('\n');
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
    wt(head);
    if (sizeof...(Tail))
        wt(' ');
    print(forward<Tail>(tail)...);
}
void __attribute__((destructor)) _d() {
    flush();
}
} // namespace fastio


using fastio::flush;
using fastio::print;
using fastio::read;

inline void first(bool i = true) {
    print(i ? "first" : "second");
}
inline void Alice(bool i = true) {
    print(i ? "Alice" : "Bob");
}
inline void Takahashi(bool i = true) {
    print(i ? "Takahashi" : "Aoki");
}
inline void yes(bool i = true) {
    print(i ? "yes" : "no");
}
inline void Yes(bool i = true) {
    print(i ? "Yes" : "No");
}
inline void No() {
    print("No");
}
inline void YES(bool i = true) {
    print(i ? "YES" : "NO");
}
inline void NO() {
    print("NO");
}
inline void Yay(bool i = true) {
    print(i ? "Yay!" : ":(");
}
inline void Possible(bool i = true) {
    print(i ? "Possible" : "Impossible");
}
inline void POSSIBLE(bool i = true) {
    print(i ? "POSSIBLE" : "IMPOSSIBLE");
}

/**
 * @brief Fast IO
 */

int main() {
    int C, N, M;
    cin >> C >> N >> M;
    vector<int> DP(C+1,0);
    rep(i,0,N) {
        int A, B;
        cin >> A >> B;
        vector<int> NewDP(C+1,0);
        rep(j,0,C+1) {
            chmax(NewDP[j], DP[j]);
            if (j + A <= C) chmax(NewDP[j+A], DP[j]+B);
        }
        swap(DP,NewDP);
    }
    rep(i,1,M+1) {
        cout << DP[C/i] * i << endl;
    }
}
accuracy: 1
time_ms: 120
memory_kb: 3564
final_rank: 12

code_snippet: // competitive-verifier: PROBLEM
#ifdef ATCODER
#pragma GCC target("sse4.2,avx512f,avx512dq,avx512ifma,avx512cd,avx512bw,avx512vl,bmi2")
#endif
#pragma GCC optimize("Ofast,fast-math,unroll-all-loops")
#include <bits/stdc++.h>
#ifndef ATCODER
#pragma GCC target("sse4.2,avx2,bmi2")
#endif
template <class T, class U>
constexpr bool chmax(T &a, const U &b) {
    return a < (T)b ? a = (T)b, true : false;
}
template <class T, class U>
constexpr bool chmin(T &a, const U &b) {
    return (T)b < a ? a = (T)b, true : false;
}
constexpr std::int64_t INF = 1000000000000000003;
constexpr int Inf = 1000000003;
constexpr double EPS = 1e-7;
constexpr double PI = 3.14159265358979323846;
#define FOR(i, m, n) for (int i = (m); i < int(n); ++i)
#define FORR(i, m, n) for (int i = (m)-1; i >= int(n); --i)
#define FORL(i, m, n) for (int64_t i = (m); i < int64_t(n); ++i)
#define rep(i, n) FOR (i, 0, n)
#define repn(i, n) FOR (i, 1, n + 1)
#define repr(i, n) FORR (i, n, 0)
#define repnr(i, n) FORR (i, n + 1, 1)
#define all(s) (s).begin(), (s).end()
struct Sonic {
    Sonic() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(20);
    }
    constexpr void operator()() const {}
} sonic;
using namespace std;
using ll = std::int64_t;
using ld = long double;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    return is >> p.first >> p.second;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &i : v) is >> i;
    return is;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) os << (it == v.begin() ? "" : " ") << *it;
    return os;
}
template <class Head, class... Tail>
void co(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cout << head << '\n';
    else std::cout << head << ' ', co(std::forward<Tail>(tail)...);
}
template <class Head, class... Tail>
void ce(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cerr << head << '\n';
    else std::cerr << head << ' ', ce(std::forward<Tail>(tail)...);
}
void Yes(bool is_correct = true) { std::cout << (is_correct ? "Yes\n" : "No\n"); }
void No(bool is_not_correct = true) { Yes(!is_not_correct); }
void YES(bool is_correct = true) { std::cout << (is_correct ? "YES\n" : "NO\n"); }
void NO(bool is_not_correct = true) { YES(!is_not_correct); }
void Takahashi(bool is_correct = true) { std::cout << (is_correct ? "Takahashi" : "Aoki") << '\n'; }
void Aoki(bool is_not_correct = true) { Takahashi(!is_not_correct); }
int main(void)
{
    int c, n, m;
    cin >> c >> n >> m;
    vector<int> s(n), p(n);
    rep(i, n) cin >> s[i] >> p[i];
    vector<int> dp(c + 1);
    rep(i, n)
    {
        auto ndp = dp;
        repr(j, c)
        {
            if (j + s[i] <= c)
                chmax(ndp[j + s[i]], dp[j] + p[i]);
        }
        dp = ndp;
    }
    rep(i, c) chmax(dp[i + 1], dp[i]);
    repn(i, m) co(dp[c / i] * i);
    return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3640
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define per(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define per2(i, l, r) for (int i = (r)-1; i >= (l); i--)
#define each(e, v) for (auto &e : v)
#define MM << " " <<
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
using maxheap = priority_queue<T>;

template <typename T>
bool chmax(T &x, const T &y) {
    return (x < y) ? (x = y, true) : false;
}

template <typename T>
bool chmin(T &x, const T &y) {
    return (x > y) ? (x = y, true) : false;
}

template <typename T>
int flg(T x, int i) {
    return (x >> i) & 1;
}

template <typename T>
void print(const vector<T> &v, T x = 0) {
    int n = v.size();
    for (int i = 0; i < n; i++) cout << v[i] + x << (i == n - 1 ? '\n' : ' ');
    if (v.empty()) cout << '\n';
}

template <typename T>
void printn(const vector<T> &v, T x = 0) {
    int n = v.size();
    for (int i = 0; i < n; i++) cout << v[i] + x << '\n';
}

template <typename T>
int lb(const vector<T> &v, T x) {
    return lower_bound(begin(v), end(v), x) - begin(v);
}

template <typename T>
int ub(const vector<T> &v, T x) {
    return upper_bound(begin(v), end(v), x) - begin(v);
}

template <typename T>
void rearrange(vector<T> &v) {
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
}

template <typename T>
vector<int> id_sort(const vector<T> &v, bool greater = false) {
    int n = v.size();
    vector<int> ret(n);
    iota(begin(ret), end(ret), 0);
    sort(begin(ret), end(ret), [&](int i, int j) { return greater ? v[i] > v[j] : v[i] < v[j]; });
    return ret;
}

template <typename S, typename T>
pair<S, T> operator+(const pair<S, T> &p, const pair<S, T> &q) {
    return make_pair(p.first + q.first, p.second + q.second);
}

template <typename S, typename T>
pair<S, T> operator-(const pair<S, T> &p, const pair<S, T> &q) {
    return make_pair(p.first - q.first, p.second - q.second);
}

template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &p) {
    S a;
    T b;
    is >> a >> b;
    p = make_pair(a, b);
    return is;
}

template <typename S, typename T>
ostream &operator<<(ostream &os, const pair<S, T> &p) {
    return os << p.first << ' ' << p.second;
}

struct io_setup {
    io_setup() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;
// const int MOD = 1000000007;
const int MOD = 998244353;

void solve() {
    int C, N, M;
    cin >> C >> N >> M;

    vector<int> s(N), p(N);
    rep(i, N) cin >> s[i] >> p[i];

    vector<int> dp(C + 1, -inf), ndp = dp;
    dp[0] = 0;

    rep(i, N) {
        fill(all(ndp), -inf);
        rep(j, C + 1) {
            if (dp[j] == -inf) continue;
            chmax(ndp[j], dp[j]);
            if (j + s[i] <= C) chmax(ndp[j + s[i]], dp[j] + p[i]);
        }
        swap(dp, ndp);
    }

    rep2(i, 1, M + 1) {
        int ans = 0;
        for (int j = 0; j * i <= C; j++) {
            chmax(ans, dp[j]); //
        }
        cout << ans * i << '\n';
    }
}

int main() { solve(); }
accuracy: 1
time_ms: 140
memory_kb: 3592
final_rank: 15

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main(){
    int C, N, M, u, v;
    cin >> C >> N >> M;
    vector<int> dp(C + 1, -(1 << 29));
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        cin >> u >> v;
        for(int j = C - u; j >= 0; j--){
            dp[j + u] = max(dp[j + u], dp[j] + v);
        }
    }
    for(int i = 0; i < C; i++)dp[i + 1] = max(dp[i + 1], dp[i]);
    for(int i = 1; i <= M; i++){
        cout << i * dp[C / i] << '\n';
    }
}
accuracy: 1
time_ms: 80
memory_kb: 3472
final_rank: 9

code_snippet: #include <bits/stdc++.h>
////#include <atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;
using vll = vector<int>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
#define all(A) A.begin(),A.end()
#define ALL(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
using pqr = priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>;

template<class T>
bool chmax(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p < q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T>
bool chmin(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p > q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

ll gcd(ll(a), ll(b)) {
    if (b == 0)return a;
    ll c = a;
    while (a % b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

vector<ll> fact, factinv, inv;
ll mod = 998244353;
void prenCkModp(ll n) {
    fact.resize(n + 5);
    factinv.resize(n + 5);
    inv.resize(n + 5);
    fact.at(0) = fact.at(1) = 1;
    factinv.at(0) = factinv.at(1) = 1;
    inv.at(1) = 1;
    for (ll i = 2; i < n + 5; i++) {
        fact.at(i) = (fact.at(i - 1) * i) % mod;
        inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
        factinv.at(i) = (factinv.at(i - 1) * inv.at(i)) % mod;
    }

}
ll nCk(ll n, ll k) {
    if (k < 0)return 0;
    if (n < k) return 0;
    return fact.at(n) * (factinv.at(k) * factinv.at(n - k) % mod) % mod;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll C,N,M;
    cin>>C>>N>>M;
    vvll DP(N+1,vll(C+1,0));
    rep(i,N){
        int S,P;
        cin>>S>>P;
        rep(c,C+1){
            chmax(DP[i+1][c],DP[i][c]);
            if(c+S<=C)chmax(DP[i+1][c+S],DP[i][c]+P);
        }
    }
    rep(c,C){
        chmax(DP[N][c+1],DP[N][c]);
    }
    rep(k,M){
        cout<<DP[N][C/(k+1)]*(k+1)<<endl;
    }

}
accuracy: 1
time_ms: 190
memory_kb: 383500
final_rank: 17

code_snippet: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#define setIO(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define closefile fclose(stdin), fclose(stdout)
#define m_p make_pair
#define sz(x) (int)x.size()
#define see(x) cerr << x << " "
#define seeln(x) cerr << x << endl
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl
#define outarr(x, l, r) {cerr << #x"[" << l << " ~ " << r << "] = "; for (int _i = l; _i <= r; ++_i) cerr << x[_i] << " "; cerr << endl;}
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define gc() getchar()
//#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T> void read(T &x) {
    x = 0; int c = gc(); int flag = 0;
    while (c < '0' || c > '9') flag |= (c == '-'), c = gc();
    while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = gc();
    if (flag) x = -x;
}
template <class T> bool checkmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
template <class T> bool checkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
constexpr int N = 10005, inf = 0x3f3f3f3f;
int n, m, c;
int dp[N];

void init() {
    scanf("%d%d%d", &c, &n, &m);
    fill(dp + 1, dp + c + 1, 0);
    dp[0] = 0;
    for (int i = 1, siz, p; i <= n; ++i) {
        scanf("%d%d", &siz, &p);
        for (int j = c; j >= siz; --j) {
            checkmax(dp[j], dp[j - siz] + p);
        }
    }
}

void solve() {
    for (int i = 1; i <= m; ++i) {
        printf("%lld\n", (ll)dp[c / i] * i);
    }
}

int main() {
    init();
    solve();
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3592
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int c, n, m, s, p;
    cin >> c >> n >> m;
    vector<int> dp(c + 1, 0);
    while(n--){
        cin >> s >> p;
        for(int j = c; j >= s; j--) dp[j] = max(dp[j], dp[j - s] + p);
    }
    for(int i = 1; i <= m; i++) cout << dp[c / i] * i << "\n";
    
}
accuracy: 1
time_ms: 60
memory_kb: 3140
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main(){
	int C,N,M; cin >> C >> N >> M;
	vector<int> dp(C + 1, 0);
	for(int i = 0; i < N; i++) {
		int w,v; cin >> w >> v;
		vector<int> nt(C + 1, 0);
		for(int j = 0; j <= C; j++) {
			nt[j] = max(nt[j], dp[j]);
			if(j + w <= C) nt[j + w] = max(nt[j + w], dp[j] + v);
		}
		swap(dp, nt);
	}

	for(int k = 1; k <= M; k++) cout << dp[C / k] * k << '\n';
}
accuracy: 1
time_ms: 110
memory_kb: 3500
final_rank: 11

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int C,N,M; cin >> C >> N >> M;
	vector<int> w(N), v(N);
	rep(i,N) cin >> w[i] >> v[i];
	vector<int> dp(C + 1, 0);
	for(int i = 0; i < N; i++) {
		vector<int> nt(C + 1, 0);
		for(int j = 0; j <= C; j++) {
			nt[j] = max(nt[j], dp[j]);
			if(j + w[i] <= C) nt[j + w[i]] = max(nt[j + w[i]], dp[j] + v[i]);
		}
		swap(dp, nt);
	}

	for(int k = 1; k <= M; k++) cout << dp[C / k] * k << '\n';
}
accuracy: 1
time_ms: 130
memory_kb: 3596
final_rank: 14

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int C,N,M; cin >> C >> N >> M;
	vector<int> w(N), v(N);
	rep(i,N) cin >> w[i] >> v[i];
	vector<int> dp(C + 1, 0);
	for(int i = 0; i < N; i++) {
		vector<int> nt(C + 1, 0);
		for(int j = 0; j <= C; j++) {
			nt[j] = max(nt[j], dp[j]);
			if(j + w[i] <= C) nt[j + w[i]] = max(nt[j + w[i]], dp[j] + v[i]);
		}
		swap(dp, nt);
	}

	for(int k = 1; k <= M; k++) {
		int ans = 0;
		for(int j = 0; j <= C / k; j++) ans = max(ans, dp[j]);
		cout << k * ans << '\n';
	}
}
accuracy: 1
time_ms: 130
memory_kb: 3592
final_rank: 13

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int C,N,M; cin >> C >> N >> M;
	vector<int> w(N), v(N);
	rep(i,N) cin >> w[i] >> v[i];
	vector<vector<int>> dp(N + 1, vector<int> (C + 1, 0));
	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= C; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if(j + w[i] <= C) 
				dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
		}
	}

	for(int k = 1; k <= M; k++) {
		int ans = 0;
		for(int j = 0; j <= C / k; j++) ans = max(ans, dp[N][j]);
		cout << k * ans << '\n';
	}
}
accuracy: 1
time_ms: 230
memory_kb: 383224
final_rank: 19

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int dp[10010][10010];

int main(){
    //オーバーフローは大丈夫ですか？？
    cin.tie(0);ios::sync_with_stdio(false);
    int c,n,m;
    cin>>c>>n>>m;
    V<int> s(n),p(n);
    rep(i,n)cin>>s[i]>>p[i];
    rep(i,n+1){
        rep(j,c+1) dp[i][j]=-1;

    }
    dp[0][0]=0;
    rep(i,n){
        for(int j=0;j<=c;j++){
            if(dp[i][j]==-1) continue;
            chmax(dp[i+1][j],dp[i][j]);
            if(j+s[i]<=c){
                chmax(dp[i+1][j+s[i]],dp[i][j]+p[i]);
            }
        }
    }
    for(int k=1;k<=m;k++){
        int ans=0;
        for(int i=0;i<=c;i++){
            if(i*k>c) break;;
            chmax(ans,dp[n][i]*k);
        }
        out(ans);
    }
}
accuracy: 1
time_ms: 160
memory_kb: 394700
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int c, n, m;
  cin >> c >> n >> m;

  vector<int> s(n), p(n);
  for (int i = 0; i < n; i++) cin >> s.at(i) >> p.at(i);

  vector<vector<int>> dp(n + 1, vector<int>(c + 1, -1e9));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= c; j++) {
      if (dp[i][j] == -1e9) continue;
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
      if (j + s.at(i) <= c) {
        dp[i + 1][j + s.at(i)] = max(dp[i + 1][j + s.at(i)], dp[i][j] + p.at(i));
      }
    }
  }

  for (int j = 1; j <= c; j++) dp[n][j] = max(dp[n][j], dp[n][j - 1]);

  for (int i = 1; i <= m; i++) {
    cout << (long long) dp[n][c / i] * i << '\n';
  }
}
accuracy: 1
time_ms: 320
memory_kb: 383336
final_rank: 20