problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9
values |
|---|---|---|---|---|---|---|---|
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int weight[n + 1];
int value[n + 1];
int dp[n + 1][w + 1];
weight[0] = 0;
value[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> weight[i] >> value[i];
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else if (weight[i] > j) // if weight is exceding maximum allowable weight
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], value[i] + dp[i - 1][j - weight[i]]);
}
}
cout << dp[n][w] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int weight[n + 1];
long int value[n + 1];
long int dp[n + 1][w + 1];
weight[0] = 0;
value[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> weight[i] >> value[i];
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else if (weight[i] > j) // if weight is exceding maximum allowable weight
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], value[i] + dp[i - 1][j - weight[i]]);
}
}
cout << dp[n][w] << endl;
} | [
"variable_declaration.type.widen.change"
] | 968,261 | 968,262 | u504035134 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int weight[n + 1];
int value[n + 1];
int dp[n + 1][w + 1];
weight[0] = 0;
value[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> weight[i] >> value[i];
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else if (weight[i] > j) // if weight is exceding maximum allowable weight
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], value[i] + dp[i][j - weight[i]]);
}
}
cout << dp[n][w] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int weight[n + 1];
long int value[n + 1];
long int dp[n + 1][w + 1];
weight[0] = 0;
value[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> weight[i] >> value[i];
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else if (weight[i] > j) // if weight is exceding maximum allowable weight
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], value[i] + dp[i - 1][j - weight[i]]);
}
}
cout << dp[n][w] << endl;
} | [
"variable_declaration.type.widen.change"
] | 968,263 | 968,262 | u504035134 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int val[n], weight[n];
for (int i = 0; i < n; i++) {
cin >> weight[i] >> val[i];
}
int knapsack[n + 1][w + 1];
for (int i = 0; i <= n; i++)
for (int j = 0; j <= w; j++) {
if (i == 0 or j == 0)
knapsack[i][j] = 0;
else {
if (j < weight[i - 1])
knapsack[i][j] = knapsack[i - 1][j];
else {
knapsack[i][j] = max(knapsack[i - 1][j],
val[i - 1] + knapsack[i - 1][j - weight[i - 1]]);
}
}
}
cout << knapsack[n][w];
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
#define int long long
int n, w;
cin >> n >> w;
int val[n], weight[n];
for (int i = 0; i < n; i++) {
cin >> weight[i] >> val[i];
}
int knapsack[n + 1][w + 1];
for (int i = 0; i <= n; i++)
for (int j = 0; j <= w; j++) {
if (i == 0 or j == 0)
knapsack[i][j] = 0;
else {
if (j < weight[i - 1])
knapsack[i][j] = knapsack[i - 1][j];
else {
knapsack[i][j] = max(knapsack[i - 1][j],
val[i - 1] + knapsack[i - 1][j - weight[i - 1]]);
}
}
}
// for(int i=0;i<=n;i++)
//{
// for(int j=0;j<=w;j++)
// {
// cout<<knapsack[i][j]<<" ";
// }
// cout<<"\n";
//}
cout << knapsack[n][w];
}
| [] | 968,271 | 968,272 | u727469412 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int a[n + 1][w + 1];
int x[n + 1], y[n + 1];
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 or j == 0) {
a[i][j] = 0;
} else if (j >= x[i - 1])
a[i][j] = max(a[i - 1][j - x[i - 1]] + y[i - 1], a[i - 1][j]);
else
a[i][j] = a[i - 1][j];
}
/* for(int p=0;p<=n;p++)
{
for(int q=0;q<=w;q++)
{
cout<<a[p][q]<<" ";
}
cout<<"\n";
}*/
}
cout << a[n][w];
} | #include <bits/stdc++.h>
using namespace std;
int main() {
#define int long long
int n, w;
cin >> n >> w;
int a[n + 1][w + 1];
int x[n + 1], y[n + 1];
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 or j == 0) {
a[i][j] = 0;
} else if (j >= x[i - 1])
a[i][j] = max(a[i - 1][j - x[i - 1]] + y[i - 1], a[i - 1][j]);
else
a[i][j] = a[i - 1][j];
}
/* for(int p=0;p<=n;p++)
{
for(int q=0;q<=w;q++)
{
cout<<a[p][q]<<" ";
}
cout<<"\n";
}*/
}
cout << a[n][w];
} | [] | 968,273 | 968,274 | u727469412 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define endl '\n'
#define hell 1000000007
#define mem(x) memset(x, 0, sizeof(x));
#define what_is(x) cerr << #x << " is " << x << endl;
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
void solve() {
int n, W;
cin >> n >> W;
int w[n + 1], v[n + 1];
rep(i, 0, n) cin >> w[i + 1] >> v[i + 1];
int dp[W + 1][n + 1];
rep(j, 0, n + 1) {
rep(i, 0, W + 1) {
if (i == 0 || j == 0) {
dp[i][j] = 0;
continue;
} else if (i >= w[j])
dp[i][j] = max(dp[i - w[j]][j - 1] + v[j], dp[i][j - 1]);
else
dp[i][j] = dp[i][j - 1];
}
}
int mx = 0;
rep(i, 0, W + 1) {
rep(j, 0, n + 1) { mx = max(mx, dp[i][j]); }
}
cout << mx;
}
int main() {
// #ifndef ONLINE_JUDGE
// // for getting input from input.txt
// freopen("input.txt", "r", stdin);
// // for writing output to output.txt
// freopen("output.txt", "w", stdout);
// #endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1, i = 1;
// cin>>t;
while (t--) {
// cout<<"Case #"<<i++<<": ";
solve();
}
return 0;
} | #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define endl '\n'
#define hell 1000000007
#define mem(x) memset(x, 0, sizeof(x));
#define what_is(x) cerr << #x << " is " << x << endl;
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
void solve() {
int n, W;
cin >> n >> W;
ll w[n + 1], v[n + 1];
rep(i, 0, n) cin >> w[i + 1] >> v[i + 1];
ll dp[W + 1][n + 1];
rep(j, 0, n + 1) {
rep(i, 0, W + 1) {
if (i == 0 || j == 0) {
dp[i][j] = 0;
continue;
} else if (i >= w[j])
dp[i][j] = max(dp[i - w[j]][j - 1] + v[j], dp[i][j - 1]);
else
dp[i][j] = dp[i][j - 1];
}
}
ll mx = 0;
rep(i, 0, W + 1) {
rep(j, 0, n + 1) { mx = max(mx, dp[i][j]); }
}
cout << mx;
}
int main() {
// #ifndef ONLINE_JUDGE
// // for getting input from input.txt
// freopen("input.txt", "r", stdin);
// // for writing output to output.txt
// freopen("output.txt", "w", stdout);
// #endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1, i = 1;
// cin>>t;
while (t--) {
// cout<<"Case #"<<i++<<": ";
solve();
}
return 0;
} | [
"variable_declaration.type.change"
] | 968,283 | 968,284 | u026594048 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
long long dp[100001], v[101], w[101];
int main() {
int n, W;
cin >> n >> W;
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
/*for(int i=0;i<n;i++)
{
for(int j=0;j<=W;j++)
{
if(w[i]>j)
dp[(i+1)&1][j]=dp[i&1][j];
else
dp[(i+1)&1][j]=max(dp[i&1][j],dp[i&1][j-w[i]]+v[i]);
}
}*/
for (int i = 0; i < n; i++) {
for (int j = W; j >= 0; j--) {
if (j <= w[i])
break;
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
// cout<<dp[n&1][W]<<endl;
cout << dp[W] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
long long dp[100001], v[101], w[101];
int main() {
int n, W;
cin >> n >> W;
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < n; i++) {
for (int j = W; j >= 0; j--) {
if (w[i] > j)
break;
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
cout << dp[W] << endl;
return 0;
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 968,293 | 968,294 | u133348271 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
long long dp[100001], v[101], w[101];
int main() {
int n, W;
cin >> n >> W;
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
/*for(int i=0;i<n;i++)
{
for(int j=0;j<=W;j++)
{
if(w[i]>j)
dp[(i+1)&1][j]=dp[i&1][j];
else
dp[(i+1)&1][j]=max(dp[i&1][j],dp[i&1][j-w[i]]+v[i]);
}
}*/
for (int i = 0; i < n; i++) {
for (int j = W; j >= 0; j--) {
if (j <= w[i])
break;
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
// cout<<dp[n&1][W]<<endl;
cout << dp[W] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
long long dp[100001], v[101], w[101];
int main() {
int n, W;
cin >> n >> W;
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
/*for(int i=0;i<n;i++)
{
for(int j=0;j<=W;j++)
{
if(w[i]>j)
dp[(i+1)&1][j]=dp[i&1][j];
else
dp[(i+1)&1][j]=max(dp[i&1][j],dp[i&1][j-w[i]]+v[i]);
}
}*/
for (int i = 0; i < n; i++) {
for (int j = W; j >= 0; j--) {
if (w[i] > j)
break;
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
// cout<<dp[n&1][W]<<endl;
cout << dp[W] << endl;
return 0;
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 968,293 | 968,295 | u133348271 | cpp |
p03163 | #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, w;
cin >> n;
cin >> w;
int ww[n];
int vv[n];
for (int i = 0; i < n; i++) {
cin >> ww[i];
cin >> vv[i];
}
int d[w + 1];
for (int i = 0; i < ww[0]; i++)
d[i] = 0;
for (int i = ww[0]; i <= w; i++)
d[i] = vv[0];
for (int i = 1; i < n; i++) {
int dd[w + 1];
for (int j = 0; j <= w; j++) {
if (ww[i] > j)
dd[j] = d[j];
else
dd[j] = max(vv[i] + d[j - ww[i]], d[j]);
}
for (int j = 0; j <= w; j++) {
d[j] = dd[j];
}
}
cout << d[w] << endl;
return 0;
}
| #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, w;
cin >> n;
cin >> w;
int ww[n];
long long int vv[n];
for (int i = 0; i < n; i++) {
cin >> ww[i];
cin >> vv[i];
}
long long int d[w + 1];
for (int i = 0; i < ww[0]; i++)
d[i] = 0;
for (int i = ww[0]; i <= w; i++)
d[i] = vv[0];
for (int i = 1; i < n; i++) {
long long int dd[w + 1];
for (int j = 0; j <= w; j++) {
if (ww[i] > j)
dd[j] = d[j];
else
dd[j] = max(vv[i] + d[j - ww[i]], d[j]);
}
for (int j = 0; j <= w; j++) {
d[j] = dd[j];
}
}
cout << d[w] << endl;
return 0;
} | [
"variable_declaration.type.widen.change"
] | 968,300 | 968,301 | u868863576 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int wt[n + 1], v[n + 1];
for (int i = 0; i < n; i++) {
cin >> wt[i];
cin >> v[i];
}
int val[n + 1][w + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0) {
val[i][j] = 0;
} else if (j >= wt[i - 1]) {
val[i][j] = max(v[i - 1] + val[i - 1][j - wt[i - 1]], val[i - 1][j]);
} else {
val[i][j] = val[i - 1][j];
}
}
}
// for(int i=0;i<=n;i++)
// {
// for(int j=0;j<=w;j++)
// {
// cout<<val[i][j]<<" ";
// }
// cout<<endl;
// }
cout << val[n][w] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
long long wt[n + 1], v[n + 1];
for (int i = 0; i < n; i++) {
cin >> wt[i];
cin >> v[i];
}
long long val[n + 1][w + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0) {
val[i][j] = 0;
} else if (j >= wt[i - 1]) {
val[i][j] = max(v[i - 1] + val[i - 1][j - wt[i - 1]], val[i - 1][j]);
} else {
val[i][j] = val[i - 1][j];
}
}
}
// for(int i=0;i<=n;i++)
// {
// for(int j=0;j<=w;j++)
// {
// cout<<val[i][j]<<" ";
// }
// cout<<endl;
// }
cout << val[n][w] << endl;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,316 | 968,317 | u916257071 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int max(int a, int b) { return (a > b) ? a : b; }
// Returns the maximum value that can be put in a knapsack of capacity W
int knapSack(int W, int wt[], int val[], int n) {
int i, w;
int K[n + 1][W + 1];
// Build table K[][] in bottom up manner
for (i = 0; i <= n; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
K[i][w] = 0;
else if (wt[i - 1] <= w)
K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
else
K[i][w] = K[i - 1][w];
}
}
return K[n][W];
}
int main() {
int n, W, wt[101], val[101];
cin >> n >> W;
for (int i = 0; i < n; i++) {
cin >> wt[i] >> val[i];
}
cout << knapSack(W, wt, val, n);
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
int max(int a, int b) { return (a > b) ? a : b; }
// Returns the maximum value that can be put in a knapsack of capacity W
int knapSack(int W, int wt[], int val[], int n) {
int i, w;
int K[n + 1][W + 1];
// Build table K[][] in bottom up manner
for (i = 0; i <= n; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
K[i][w] = 0;
else if (wt[i - 1] <= w)
K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
else
K[i][w] = K[i - 1][w];
}
}
return K[n][W];
}
signed main() {
int n, W, wt[101], val[101];
cin >> n >> W;
for (int i = 0; i < n; i++) {
cin >> wt[i] >> val[i];
}
cout << knapSack(W, wt, val, n);
} | [
"variable_declaration.type.primitive.change"
] | 968,320 | 968,321 | u916064357 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, tar;
cin >> n >> tar;
long long w[n], v[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
long long dp[n + 1][tar + 1];
for (int i = 0; i < n; i++)
dp[i][0] = 0;
for (int i = 0; i < tar; i++)
dp[0][i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= tar; j++) {
if (w[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
// cout<<dp[i][j]<<" ";
}
// cout<<endl;
}
cout << dp[n][tar] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, tar;
cin >> n >> tar;
long long w[n], v[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
long long dp[n + 1][tar + 1];
for (int i = 0; i <= n; i++)
dp[i][0] = 0;
for (int i = 0; i <= tar; i++)
dp[0][i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= tar; j++) {
if (w[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
// cout<<dp[i][j]<<" ";
}
// cout<<endl;
}
cout << dp[n][tar] << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 968,322 | 968,323 | u885511677 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, tar;
cin >> n >> tar;
long long w[n], v[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
long long dp[n + 1][tar + 1];
for (int i = 0; i < n; i++)
dp[i][0] = 0;
for (int i = 0; i < tar; i++)
dp[0][i] = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= tar; j++) {
if (w[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
}
cout << dp[n][tar] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, tar;
cin >> n >> tar;
long long w[n], v[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
long long dp[n + 1][tar + 1];
for (int i = 0; i <= n; i++)
dp[i][0] = 0;
for (int i = 0; i <= tar; i++)
dp[0][i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= tar; j++) {
if (w[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
// cout<<dp[i][j]<<" ";
}
// cout<<endl;
}
cout << dp[n][tar] << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 968,324 | 968,323 | u885511677 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, tar;
cin >> n >> tar;
long long w[n], v[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
long long dp[n + 1][tar + 1];
for (int i = 0; i < n; i++)
dp[i][0] = 0;
for (int i = 0; i < tar; i++)
dp[0][i] = 0;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= tar; j++) {
if (w[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
}
cout << dp[n][tar] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, tar;
cin >> n >> tar;
long long w[n], v[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
long long dp[n + 1][tar + 1];
for (int i = 0; i <= n; i++)
dp[i][0] = 0;
for (int i = 0; i <= tar; i++)
dp[0][i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= tar; j++) {
if (w[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
// cout<<dp[i][j]<<" ";
}
// cout<<endl;
}
cout << dp[n][tar] << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change",
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change"
] | 968,325 | 968,323 | u885511677 | cpp |
p03163 | #include <iostream>
using namespace std;
const int MAXN = 20000000 + 10;
int w[MAXN], v[MAXN], f[MAXN];
int main() {
int n, m, ans = -1;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = m; j >= w[i]; j--) {
f[j] = max(f[j], f[j - w[i]] + v[i]);
ans = max(ans, f[j]);
}
}
cout << ans << endl;
return 0;
}
| #include <iostream>
using namespace std;
const int MAXN = 2000000 + 10;
long long w[MAXN], v[MAXN], f[MAXN];
int main() {
long long n, m, ans = -1;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = m; j >= w[i]; j--) {
f[j] = max(f[j], f[j - w[i]] + v[i]);
ans = max(ans, f[j]);
}
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"expression.operation.binary.change",
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,326 | 968,327 | u723879945 | cpp |
p03163 | #include <iostream>
using namespace std;
const int MAXN = 20000 + 10;
int w[MAXN], v[MAXN], f[MAXN];
int main() {
int n, m, ans = -1;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = m; j >= w[i]; j--) {
f[j] = max(f[j], f[j - w[i]] + v[i]);
ans = max(ans, f[j]);
}
}
cout << ans << endl;
return 0;
}
| #include <iostream>
using namespace std;
const int MAXN = 2000000 + 10;
long long w[MAXN], v[MAXN], f[MAXN];
int main() {
long long n, m, ans = -1;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = m; j >= w[i]; j--) {
f[j] = max(f[j], f[j - w[i]] + v[i]);
ans = max(ans, f[j]);
}
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"expression.operation.binary.change",
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,328 | 968,327 | u723879945 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const int INF = 1e9 + 5;
int main() {
int n, W;
cin >> n >> W;
int w[n + 1];
int v[n + 1];
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
int d[n + 1][W + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= W; j++) {
if (i == 0 || j == 0)
d[i][j] = 0;
else if (w[i] > j)
d[i][j] = d[i - 1][j];
else
d[i][j] = max(d[i - 1][j], v[i] + d[i - 1][j - w[i]]);
}
}
cout << d[n][W];
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const int INF = 1e9 + 5;
int main() {
int n, W;
cin >> n >> W;
int w[n + 1];
int v[n + 1];
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
ll d[n + 1][W + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= W; j++) {
if (i == 0 || j == 0)
d[i][j] = 0;
else if (w[i] > j)
d[i][j] = d[i - 1][j];
else
d[i][j] = max(d[i - 1][j], v[i] + d[i - 1][j - w[i]]);
}
}
cout << d[n][W];
} | [
"variable_declaration.type.change"
] | 968,353 | 968,354 | u843739531 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int W;
cin >> N;
cin >> W;
int dp[N][W + 1] = {};
int w;
int v;
cin >> w;
cin >> dp[0][w];
for (int i = 0; i < N; i++) {
cin >> w;
cin >> v;
for (int j = 0; j < W + 1; j++) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
if (j + w <= W) {
dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v);
}
}
}
for (int j = 0; j < W; j++) {
dp[N - 1][j + 1] = max(dp[N - 1][j + 1], dp[N - 1][j]);
}
cout << dp[N - 1][W] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int W;
cin >> N;
cin >> W;
long long int dp[N][W + 1] = {};
int w;
int v;
cin >> w;
cin >> dp[0][w];
for (int i = 0; i < N - 1; i++) {
cin >> w;
cin >> v;
for (int j = 0; j < W + 1; j++) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
if (j + w <= W) {
dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v);
}
}
}
for (int j = 0; j < W; j++) {
dp[N - 1][j + 1] = max(dp[N - 1][j + 1], dp[N - 1][j]);
}
cout << dp[N - 1][W] << endl;
return 0;
} | [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 968,359 | 968,360 | u856586005 | cpp |
p03163 | #include <bits/stdc++.h>
#define lli long long
using namespace std;
typedef std::vector<lli> vi;
int main() {
lli n, w;
cin >> n >> w;
vi dp(w + 1, 0);
for (lli i = 0; i < n; i++) {
lli a, b;
cin >> a >> b;
for (lli j = w - a; j >= 0; j--) {
dp[j] = max(dp[j], dp[j] + b);
}
}
lli ans = 0;
for (lli i = 0; i <= w; i++) {
ans = max(ans, dp[i]);
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
#define lli long long
using namespace std;
typedef std::vector<lli> vi;
int main() {
lli n, w;
cin >> n >> w;
vi dp(w + 1, 0);
for (lli i = 0; i < n; i++) {
lli a, b;
cin >> a >> b;
for (lli j = w - a; j >= 0; j--) {
dp[j + a] = max(dp[j + a], dp[j] + b);
}
}
lli ans = 0;
for (lli i = 0; i <= w; i++) {
ans = max(ans, dp[i]);
}
cout << ans;
return 0;
} | [
"assignment.change"
] | 968,361 | 968,362 | u864207035 | cpp |
p03163 | ///"Bismillahir Rahmanir Raheem"///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a) a.begin(), a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i, b) for (int i = 0; i < (b); i++)
#define f1(i, b) for (int i = 1; i <= (b); i++)
#define f2(i, a, b) for (int i = (a); i <= (b); i++)
#define fr(i, b, a) for (int i = (b); i >= (a); i--)
#define rep(i, a, b, c) for (int i = (a); i != (b); i += (c))
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
const int LOGN = 20;
const int N = 110;
const int W = 100010;
long long int dp[N][W];
int main() {
int n, w;
cin >> n >> w;
// vector<int> dp(n+1,0);
vector<int> pf(n);
vector<int> wt(n);
f1(i, n) { cin >> wt[i] >> pf[i]; }
f1(i, n) {
f1(j, w) {
if (j - wt[i] >= 0)
dp[i][j] = max(dp[i - 1][j], (dp[i - 1][j - wt[i]] + pf[i]));
else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
/*for(int i = 0; i<=n; i++){
for(int j =0;j<=bw;j++){
cout<<dp[i][j]<<" ";
}
cout<<endl;
}*/
return 0;
}
| ///"Bismillahir Rahmanir Raheem"///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a) a.begin(), a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define f0(i, b) for (int i = 0; i < (b); i++)
#define f1(i, b) for (int i = 1; i <= (b); i++)
#define f2(i, a, b) for (int i = (a); i <= (b); i++)
#define fr(i, b, a) for (int i = (b); i >= (a); i--)
#define rep(i, a, b, c) for (int i = (a); i != (b); i += (c))
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
const int LOGN = 20;
const int N = 110;
const int W = 100010;
long long int dp[N][W];
int main() {
int n, w;
cin >> n >> w;
// vector<int> dp(n+1,0);
vector<int> pf(N);
vector<int> wt(N);
f1(i, n) { cin >> wt[i] >> pf[i]; }
f1(i, n) {
f1(j, w) {
if (j - wt[i] >= 0)
dp[i][j] = max(dp[i - 1][j], (dp[i - 1][j - wt[i]] + pf[i]));
else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
/*for(int i = 0; i<=n; i++){
for(int j =0;j<=bw;j++){
cout<<dp[i][j]<<" ";
}
cout<<endl;
}*/
return 0;
}
| [] | 968,367 | 968,368 | u818791965 | cpp |
p03163 | #include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
long long int W[a + 1], V[a + 1], DP[a + 1][b + 1];
// DP[i][j] i番目までの品物を、重さがj以下になるように選んだ時の価値の最大値
for (int i = 0; i <= a; ++i) {
if (i > 0)
cin >> W[i] >> V[i];
for (int j = 0; j <= b; ++j) {
DP[i][j] = 0;
}
}
for (int i = 1; i <= a; ++i) {
for (int j = 0; j <= b; ++j) {
if (j > W[i])
DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - W[i]] + V[i]);
else
DP[i][j] = DP[i - 1][j];
}
}
cout << DP[a][b] << endl;
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
long long int W[a + 1], V[a + 1], DP[a + 1][b + 1];
// DP[i][j] i番目までの品物を、重さがj以下になるように選んだ時の価値の最大値
for (int i = 0; i <= a; ++i) {
if (i > 0)
cin >> W[i] >> V[i];
for (int j = 0; j <= b; ++j) {
DP[i][j] = 0;
}
}
for (int i = 1; i <= a; ++i) {
for (int j = 0; j <= b; ++j) {
if (j >= W[i])
DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - W[i]] + V[i]);
else
DP[i][j] = DP[i - 1][j];
}
}
cout << DP[a][b] << endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 968,373 | 968,374 | u041282550 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
vector<int> v(n), w(n);
vector<vector<int>> dp;
dp.assign(n + 1, vector<int>(W + 1, 0));
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < n; i++)
for (int k = 0; k <= W; k++)
if (k < w[i])
dp[i + 1][k] = dp[i][k];
else
dp[i + 1][k] = max(dp[i][k - w[i]] + v[i], dp[i][k]);
// DEBUG: for(int i=0; i<=n; i++){ for(int k=0; k<=W; k++) cout<<dp[i][k]<<"
// "; cout<<endl; }
cout << dp[n][W];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
vector<int> v(n), w(n);
vector<vector<long long int>> dp;
dp.assign(n + 1, vector<long long int>(W + 1, 0));
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < n; i++)
for (int k = 0; k <= W; k++)
if (k < w[i])
dp[i + 1][k] = dp[i][k];
else
dp[i + 1][k] = max(dp[i][k - w[i]] + v[i], dp[i][k]);
// DEBUG: for(int i=0; i<=n; i++){ for(int k=0; k<=W; k++) cout<<dp[i][k]<<"
// "; cout<<endl; }
cout << dp[n][W];
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 968,382 | 968,383 | u307571140 | cpp |
p03163 | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
// Self settings
// clang-format off
#define MAX_N 100000
#define INF 10000000000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on
int N, W;
ll v[MAX_N], w[MAX_N];
ll dp[MAX_N + 1][MAX_N + 1];
void solve() {
dp[0][0] = 0;
ll ans = 0;
for (int i = 0; i < N; i++) {
for (int j = W; j >= 0; j--) {
if (j < w[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
}
}
cout << dp[N][W] << endl;
}
int main(void) {
cin >> N >> W;
REP(i, N) cin >> w[i] >> v[i];
solve();
return 0;
}
| #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
// Self settings
// clang-format off
#define MAX_N 100
#define MAX_W 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on
int N, W;
ll v[MAX_N], w[MAX_N];
ll dp[MAX_N + 1][MAX_W + 1];
void solve() {
dp[0][0] = 0;
ll ans = 0;
for (int i = 0; i < N; i++) {
for (int j = W; j >= 0; j--) {
if (j < w[i])
dp[i + 1][j] = dp[i][j];
else
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
}
}
cout << dp[N][W] << endl;
}
int main(void) {
cin >> N >> W;
REP(i, N) cin >> w[i] >> v[i];
solve();
return 0;
}
| [
"identifier.change",
"expression.operation.binary.change"
] | 968,386 | 968,387 | u621104964 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pr;
#define fr(i, n) for (int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template <class mytype> mytype power(mytype a, mytype b, mytype m) {
if (b == 1)
return a % m;
if (b == 0)
return 1;
mytype root = power<lli>(a, b / 2, m);
mytype ans = (root * root) % m;
if (b % 2)
ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template <class type> type gcd(type a, type b) {
if (a == 0)
return b;
else
return gcd(b % a, a);
}
template <class type> type mod_inv(type a, type p) {
return power(a, p - 2, p);
}
int main() {
int n, weight;
cin >> n >> weight;
vector<int> dp(weight + 1, 0);
for (int i1 = 0; i1 < n; i1++) {
int w, v;
cin >> w >> v;
for (int i = (weight - w); i >= 0; --i) {
dp[i + w] = max(dp[i + w], dp[i] + v);
}
}
int wans = 0;
for (int i = 0; i <= weight; i++)
wans = max(wans, dp[i]);
cout << wans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pr;
#define fr(i, n) for (int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template <class mytype> mytype power(mytype a, mytype b, mytype m) {
if (b == 1)
return a % m;
if (b == 0)
return 1;
mytype root = power<lli>(a, b / 2, m);
mytype ans = (root * root) % m;
if (b % 2)
ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template <class type> type gcd(type a, type b) {
if (a == 0)
return b;
else
return gcd(b % a, a);
}
template <class type> type mod_inv(type a, type p) {
return power(a, p - 2, p);
}
int main() {
int n, weight;
cin >> n >> weight;
vector<lli> dp(weight + 1, 0);
for (int i1 = 0; i1 < n; i1++) {
int w, v;
cin >> w >> v;
for (int i = (weight - w); i >= 0; --i) {
dp[i + w] = max(dp[i + w], dp[i] + v);
}
}
lli wans = 0;
for (int i = 0; i <= weight; i++)
wans = max(wans, dp[i]);
cout << wans << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 968,406 | 968,407 | u279511029 | cpp |
p03163 | #include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
int main() {
size_t n, wmax;
std::cin >> n >> wmax;
std::vector<size_t> w(n);
std::vector<size_t> v(n);
for (size_t i = 0; i < n; ++i)
std::cin >> w[i] >> v[i];
std::vector<size_t> dp1(wmax + 1, 0);
std::vector<size_t> dp2(wmax + 1, 0);
for (size_t i = 1; i <= n; ++i) {
const auto wi = w[i - 1];
const auto vi = v[i - 1];
for (size_t j = 0; j <= wmax; ++j) {
dp1[j] = std::max(dp1[j], dp2[j]);
if (j >= wi)
dp1[j] = std::max(dp1[j], dp2[j - wi] + vi);
}
// dp2 = dp1;
std::copy(dp1.begin(), dp1.end(), dp2.begin());
std::fill(dp1.begin(), dp1.end(), size_t(0));
}
std::cout << dp1[wmax] << std::endl;
}
| #include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
int main() {
size_t n, wmax;
std::cin >> n >> wmax;
std::vector<size_t> w(n);
std::vector<size_t> v(n);
for (size_t i = 0; i < n; ++i)
std::cin >> w[i] >> v[i];
std::vector<size_t> dp1(wmax + 1, 0);
std::vector<size_t> dp2(wmax + 1, 0);
for (size_t i = 1; i <= n; ++i) {
const auto wi = w[i - 1];
const auto vi = v[i - 1];
for (size_t j = 0; j <= wmax; ++j) {
dp1[j] = std::max(dp1[j], dp2[j]);
if (j >= wi)
dp1[j] = std::max(dp1[j], dp2[j - wi] + vi);
}
// dp2 = dp1;
std::copy(dp1.begin(), dp1.end(), dp2.begin());
std::fill(dp1.begin(), dp1.end(), size_t(0));
}
std::cout << dp2[wmax] << std::endl;
}
| [
"identifier.change",
"expression.operation.binary.change"
] | 968,416 | 968,417 | u217344789 | cpp |
p03163 | // naru-hodo
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#define ff first
#define ss second
#define ll long long
#define lli long long int
#define ull unsigned long long int
#define loop(i, x, n) for (ll int i = x; i <= n; i++)
#define rloop(i, x, n) for (ll int i = x; i >= n; i--)
using namespace std;
int main() {
lli n, c;
cin >> n >> c;
lli wt[n], v[n];
loop(i, 0, n - 1) cin >> wt[i] >> v[i];
lli mx[n + 1][c + 1];
loop(i, 0, n) {
loop(j, 0, c) {
if (i == 0 || j == 0)
mx[i][j] = 0;
else if (j - wt[i - 1] >= 0) {
mx[i][j] = max(mx[i - 1][j - wt[i - 1]] + v[i - 1], mx[i - 1][c]);
} else
mx[i][j] = mx[i - 1][c];
}
}
cout << mx[n][c];
return 0;
} | // naru-hodo
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#define ff first
#define ss second
#define ll long long
#define lli long long int
#define ull unsigned long long int
#define loop(i, x, n) for (ll int i = x; i <= n; i++)
#define rloop(i, x, n) for (ll int i = x; i >= n; i--)
using namespace std;
int main() {
lli n, c;
cin >> n >> c;
lli wt[n], v[n];
loop(i, 0, n - 1) cin >> wt[i] >> v[i];
lli mx[n + 1][c + 1];
loop(i, 0, n) {
loop(j, 0, c) {
if (i == 0 || j == 0)
mx[i][j] = 0;
else if (j - wt[i - 1] >= 0) {
mx[i][j] = max(mx[i - 1][j - wt[i - 1]] + v[i - 1], mx[i - 1][j]);
} else
mx[i][j] = mx[i - 1][j];
}
}
cout << mx[n][c];
return 0;
} | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 968,420 | 968,421 | u223929716 | cpp |
p03163 | #include <iostream>
using namespace std;
int main() {
long long n, w;
cin >> n >> w;
long long items[n][2];
for (int i = 0; i < n; i++) {
cin >> items[i][0] >> items[i][1];
}
long long dp[n + 1][w + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
dp[i][j] = -1;
}
}
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= w; j++) {
if (dp[i][j] != -1 && j + items[i][0] <= w) {
dp[i + 1][j + items[i][0]] =
max(dp[i + 1][j + items[i][0]], dp[i][j] + items[i][1]);
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
}
long long ans = 0;
for (int i = 0; i <= w; i++) {
ans = max(ans, dp[n][i]);
}
cout << ans << endl;
} | #include <iostream>
using namespace std;
int main() {
long long n, w;
cin >> n >> w;
long long items[n][2];
for (int i = 0; i < n; i++) {
cin >> items[i][0] >> items[i][1];
}
long long dp[n + 1][w + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
dp[i][j] = -1;
}
}
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= w; j++) {
if (dp[i][j] != -1) {
if (j + items[i][0] <= w) {
dp[i + 1][j + items[i][0]] =
max(dp[i + 1][j + items[i][0]], dp[i][j] + items[i][1]);
}
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
}
long long ans = 0;
for (int i = 0; i <= w; i++) {
ans = max(ans, dp[n][i]);
}
cout << ans << endl;
}
| [
"control_flow.branch.if.condition.change",
"control_flow.branch.if.add"
] | 968,427 | 968,428 | u132035173 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define INF (1 << 30)
int weight[100], value[100];
int dp[110][100010] = {0}; // [item][weight]
int main() {
int n, w;
cin >> n >> w;
for (int i = 0; i < n; i++)
cin >> weight[i] >> value[i];
for (int i = 0; i < n; i++) {
for (int sum_w = 0; sum_w <= w; sum_w++) {
// i番目を選ぶ場合
if (sum_w - weight[i] >= 0) {
dp[i + 1][sum_w] =
max(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
// 選ばない場合
dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[n][w] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define INF (1 << 60)
long long weight[100], value[100];
long long dp[110][100010] = {0}; // [item][weight]
int main() {
int n, w;
cin >> n >> w;
for (int i = 0; i < n; i++)
cin >> weight[i] >> value[i];
for (int i = 0; i < n; i++) {
for (int sum_w = 0; sum_w <= w; sum_w++) {
// i番目を選ぶ場合
if (sum_w - weight[i] >= 0) {
dp[i + 1][sum_w] =
max(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
// 選ばない場合
dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[n][w] << endl;
return 0;
}
| [
"preprocessor.define.value.change",
"literal.integer.change",
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,432 | 968,433 | u055447809 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> p;
int dp[200][200000];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, w;
cin >> n >> w;
vector<p> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
for (int i = 0; i < 200; i++) {
for (int j = 0; j < 200000; j++) {
dp[i][j] = 0;
}
}
// i番目までのもので重さj以下価値最大
for (int i = 1; i <= n; i++) {
int weight = v[i - 1].first;
int val = v[i - 1].second;
for (int j = 0; j <= w; j++) {
if (j - weight >= 0)
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight] + val);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> p;
ll dp[200][200000];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, w;
cin >> n >> w;
vector<p> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
for (int i = 0; i < 200; i++) {
for (int j = 0; j < 200000; j++) {
dp[i][j] = 0;
}
}
// i番目までのもので重さj以下価値最大
for (int i = 1; i <= n; i++) {
int weight = v[i - 1].first;
int val = v[i - 1].second;
for (int j = 0; j <= w; j++) {
if (j - weight >= 0)
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight] + val);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w] << endl;
}
| [
"variable_declaration.type.change"
] | 968,436 | 968,437 | u916743460 | cpp |
p03163 | // WA
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n, greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(), greater<int>());
#define REMOVE(v, n) remove(vector<int> v, v + v.size(), int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v, i, j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va, vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
// vector< vector<int> > v (size1, vector<int>(size2) );
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, W;
cin >> N >> W;
vector<ll> w(N), v(N);
FOR(i, 0, N) cin >> w[i] >> v[i];
ll dp[N + 1][W + 1];
//↓注意
FOR(j, 0, W + 1) { dp[0][j] = -10e10; }
dp[0][0] = 0;
FOR(i, 0, N) {
FOR(j, 0, W + 1) {
if (W - w[i] >= 0)
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
else
dp[i + 1][j] = dp[i][j];
// cout<<"i "<<i<<" j "<<j<<' '<<dp[i][j]<<endl;
}
}
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n, greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(), greater<int>());
#define REMOVE(v, n) remove(vector<int> v, v + v.size(), int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v, i, j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va, vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
// vector< vector<int> > v (size1, vector<int>(size2) );
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, W;
cin >> N >> W;
vector<ll> w(N), v(N);
FOR(i, 0, N) cin >> w[i] >> v[i];
ll dp[N + 1][W + 1];
//↓注意
FOR(j, 0, W + 1) { dp[0][j] = 0; }
dp[0][0] = 0;
FOR(i, 0, N) {
FOR(j, 0, W + 1) {
if (j - w[i] >= 0)
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
else
dp[i + 1][j] = dp[i][j];
// cout<<"i "<<i<<" j "<<j<<' '<<dp[i][j]<<endl;
}
}
cout << dp[N][W] << endl;
}
//初期値調整 | [
"literal.number.change",
"assignment.value.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 968,447 | 968,448 | u908349502 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 101;
const int MAX_W = 114514;
int N, W;
int dp[MAX_N][MAX_W];
int main() {
for (int i = 0; i < MAX_W; i++) {
dp[0][i] = 0;
}
cin >> N >> W;
for (int i = 1; i < N + 1; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (w > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
}
}
/*
for(int i=0;i<N+1;i++){
for(int j=0;j<W+1;j++){
cout << dp[i][j]<< " ";
}
cout << endl;
}*/
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 101;
const int MAX_W = 114514;
int N, W;
long long int dp[MAX_N][MAX_W];
int main() {
for (int i = 0; i < MAX_W; i++) {
dp[0][i] = 0;
}
cin >> N >> W;
for (int i = 1; i < N + 1; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (w > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
}
}
/*
for(int i=0;i<N+1;i++){
for(int j=0;j<W+1;j++){
cout << dp[i][j]<< " ";
}
cout << endl;
}*/
cout << dp[N][W] << endl;
}
| [
"variable_declaration.type.widen.change"
] | 968,449 | 968,450 | u751675422 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#include <queue>
#include <vector>
#define ll long long
#define inf INT_MAX
ll int d[20000][20000];
/*ll int solve(ll int a[][2],ll int n,ll int w,ll int i)
{
if(w>=0&&i>=n)
return 0;
if(a[i][0]>w)
{
return solve(a,n,w,i+1);
}
else
{
return max(a[i][1]+solve(a,n,w-a[i][0],i+1),solve(a,n,w,i+1));
}
}*/
main() {
memset(d, 0, sizeof(d));
ll int n, w;
cin >> n >> w;
ll int a[n + 1][2];
// a[0][0]=0;
// a[0][1]=0;
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (a[i - 1][0] > j)
d[i][j] = d[i - 1][j];
else
d[i][j] = max(a[i - 1][1] + d[i - 1][j - a[i - 1][0]], d[i - 1][j]);
}
}
/* for(int i=1;i<=n;i++)
{
for(int j=1;j<=w;j++)
{
cout<<d[i][j]<<" ";
}
cout<<endl;
}*/
cout << d[n][w] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#include <queue>
#include <vector>
#define ll long long
#define inf INT_MAX
ll int d[101][200000];
/*ll int solve(ll int a[][2],ll int n,ll int w,ll int i)
{
if(w>=0&&i>=n)
return 0;
if(a[i][0]>w)
{
return solve(a,n,w,i+1);
}
else
{
return max(a[i][1]+solve(a,n,w-a[i][0],i+1),solve(a,n,w,i+1));
}
}*/
main() {
memset(d, 0, sizeof(d));
ll int n, w;
cin >> n >> w;
ll int a[n + 1][2];
// a[0][0]=0;
// a[0][1]=0;
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (a[i - 1][0] > j)
d[i][j] = d[i - 1][j];
else
d[i][j] = max(a[i - 1][1] + d[i - 1][j - a[i - 1][0]], d[i - 1][j]);
}
}
/* for(int i=1;i<=n;i++)
{
for(int j=1;j<=w;j++)
{
cout<<d[i][j]<<" ";
}
cout<<endl;
}*/
cout << d[n][w] << endl;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 968,455 | 968,456 | u131565555 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#include <queue>
#include <vector>
#define ll long long
#define inf INT_MAX
ll int d[200][20000];
/*ll int solve(ll int a[][2],ll int n,ll int w,ll int i)
{
if(w>=0&&i>=n)
return 0;
if(a[i][0]>w)
{
return solve(a,n,w,i+1);
}
else
{
return max(a[i][1]+solve(a,n,w-a[i][0],i+1),solve(a,n,w,i+1));
}
}*/
main() {
memset(d, 0, sizeof(d));
ll int n, w;
cin >> n >> w;
ll int a[n + 1][2];
// a[0][0]=0;
// a[0][1]=0;
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (a[i - 1][0] > j)
d[i][j] = d[i - 1][j];
else
d[i][j] = max(a[i - 1][1] + d[i - 1][w - a[i - 1][0]], d[i - 1][j]);
}
}
/* for(int i=1;i<=n;i++)
{
for(int j=1;j<=w;j++)
{
cout<<d[i][j]<<" ";
}
cout<<endl;
}*/
cout << d[n][w] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#include <queue>
#include <vector>
#define ll long long
#define inf INT_MAX
ll int d[101][200000];
/*ll int solve(ll int a[][2],ll int n,ll int w,ll int i)
{
if(w>=0&&i>=n)
return 0;
if(a[i][0]>w)
{
return solve(a,n,w,i+1);
}
else
{
return max(a[i][1]+solve(a,n,w-a[i][0],i+1),solve(a,n,w,i+1));
}
}*/
main() {
memset(d, 0, sizeof(d));
ll int n, w;
cin >> n >> w;
ll int a[n + 1][2];
// a[0][0]=0;
// a[0][1]=0;
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (a[i - 1][0] > j)
d[i][j] = d[i - 1][j];
else
d[i][j] = max(a[i - 1][1] + d[i - 1][j - a[i - 1][0]], d[i - 1][j]);
}
}
/* for(int i=1;i<=n;i++)
{
for(int j=1;j<=w;j++)
{
cout<<d[i][j]<<" ";
}
cout<<endl;
}*/
cout << d[n][w] << endl;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 968,458 | 968,456 | u131565555 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
typedef long long ll;
int N;
ll W, weight[110], value[110], dp[110][100100] = {0};
int main() {
cin >> N >> W;
for (int i = 0; i < N; i++) {
cin >> weight[i] >> value[i];
}
for (int i = 0; i < N; i++) {
for (int sum_w = 0; sum_w < W; sum_w++) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
typedef long long ll;
int N;
ll W, weight[110], value[110], dp[110][100100] = {0};
int main() {
cin >> N >> W;
for (int i = 0; i < N; i++) {
cin >> weight[i] >> value[i];
}
for (int i = 0; i < N; i++) {
for (int sum_w = 0; sum_w <= W; sum_w++) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 968,459 | 968,460 | u747087681 | cpp |
p03163 | #include <iostream>
#define ll unsigned long long int
using namespace std;
int main() {
ll n, w, v1, w1;
cin >> n >> w;
ll dp[n + 1][w + 1];
ll weights[n];
ll values[n];
for (int i = 0; i < n; i++) {
cin >> w1 >> v1;
weights[i] = w1;
values[i] = v1;
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else {
if (j >= weights[i]) {
dp[i][j] = max(values[i] + dp[i - 1][j - weights[i]], dp[i - 1][j]);
} else
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w];
return 0;
} | #include <iostream>
#define ll unsigned long long int
using namespace std;
int main() {
ll n, w, v1, w1;
cin >> n >> w;
ll dp[n + 1][w + 1];
ll weights[n];
ll values[n];
for (int i = 0; i < n; i++) {
cin >> w1 >> v1;
weights[i] = w1;
values[i] = v1;
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else {
if (j >= weights[i - 1]) {
dp[i][j] =
max(values[i - 1] + dp[i - 1][j - weights[i - 1]], dp[i - 1][j]);
} else
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w];
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one",
"assignment.change"
] | 968,461 | 968,462 | u476305950 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, w;
cin >> n >> w;
int arr[n][2];
for (int idx = 0; idx < n; idx++) {
cin >> arr[idx][0] >> arr[idx][1];
}
int result[n + 1][w + 1];
for (int val = 0; val <= n; val++) {
for (int W = 0; W <= w; W++) {
if (val == 0 || W == 0) {
result[val][W] = 0;
} else if (W >= arr[val - 1][0]) {
result[val][W] =
max(result[val - 1][W],
arr[val - 1][1] + result[val - 1][W - arr[val - 1][0]]);
} else
result[val][W] = result[val - 1][W];
}
}
cout << result[n][w];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, w;
cin >> n >> w;
long long int arr[n][2];
for (int idx = 0; idx < n; idx++) {
cin >> arr[idx][0] >> arr[idx][1];
}
long long int result[n + 1][w + 1];
for (int val = 0; val <= n; val++) {
for (int W = 0; W <= w; W++) {
if (val == 0 || W == 0) {
result[val][W] = 0;
} else if (W >= arr[val - 1][0]) {
result[val][W] =
max(result[val - 1][W],
arr[val - 1][1] + result[val - 1][W - arr[val - 1][0]]);
} else
result[val][W] = result[val - 1][W];
}
}
cout << result[n][w];
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 968,467 | 968,468 | u735679698 | cpp |
p03163 | #include <iostream>
using namespace std;
int knapSack(int W, int wt[], int val[], int n) {
int i, w;
int K[n + 1][W + 1];
// Build table K[][] in bottom up manner
for (i = 0; i <= n; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
K[i][w] = 0;
else if (wt[i - 1] <= w)
K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
else
K[i][w] = K[i - 1][w];
}
}
return K[n][W];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, W;
cin >> n;
cin >> W;
int val[n], wt[n];
for (int i = 0; i < n; i++) {
cin >> wt[i];
cin >> val[i];
}
cout << knapSack(W, wt, val, n);
return 0;
} | #include <iostream>
using namespace std;
long int knapSack(int W, long int wt[], long int val[], int n) {
int i, w;
long int K[n + 1][W + 1];
// Build table K[][] in bottom up manner
for (i = 0; i <= n; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
K[i][w] = 0;
else if (wt[i - 1] <= w)
K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
else
K[i][w] = K[i - 1][w];
}
}
return K[n][W];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, W;
cin >> n;
cin >> W;
long int val[n], wt[n];
for (int i = 0; i < n; i++) {
cin >> wt[i];
cin >> val[i];
}
cout << knapSack(W, wt, val, n);
return 0;
} | [
"variable_declaration.type.widen.change"
] | 968,469 | 968,470 | u735679698 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, W;
cin >> N >> W;
vector<ll> w(N + 1), v(N + 1);
for (int i = 1; i <= N; i++)
cin >> w[i] >> v[i];
vector<vector<ll>> dp;
dp = vector<vector<ll>>(N + 1, vector<ll>(W + 1, 0));
for (int j = 0; j <= W; j++) { // (1)
if (j == w[1])
dp[1][j];
}
for (int i = 2; i <= N; i++) {
for (int j = 0; j <= W; j++) {
if (w[i] <= j) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
ll ans = 0;
for (int i = 0; i <= W; i++)
ans = max(ans, dp[N][i]);
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, W;
cin >> N >> W;
vector<ll> w(N + 1), v(N + 1);
for (int i = 1; i <= N; i++)
cin >> w[i] >> v[i];
vector<vector<ll>> dp;
dp = vector<vector<ll>>(N + 1, vector<ll>(W + 1, 0));
for (int j = 0; j <= W; j++) { // (1)
if (j == w[1])
dp[1][j] = v[1];
}
for (int i = 2; i <= N; i++) {
for (int j = 0; j <= W; j++) {
if (w[i] <= j) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
ll ans = 0;
for (int i = 0; i <= W; i++)
ans = max(ans, dp[N][i]);
cout << ans << endl;
}
| [
"assignment.change"
] | 968,474 | 968,475 | u119098168 | cpp |
p03163 | #include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FASTIO \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
const int maxN = 101;
const int maxW = 1e7 + 1;
vector<LL> F[maxN];
LL v[maxN];
int w[maxN];
int main() {
// IN;OUT;
FASTIO;
int N, W;
cin >> N >> W;
for (int i = 1; i <= N; i++) {
cin >> w[i] >> v[i];
F[i].pb(0);
}
F[0].pb(0);
for (int i = 1; i <= W; i++)
F[0].pb(-INF);
for (int i = 1; i <= N; i++)
for (int j = 1; j <= W; j++) {
LL V = F[i - 1][j];
if (j >= w[i])
V = max(V, F[i - 1][j - w[i]] + v[i]);
F[i].pb(V);
}
LL ans = -INF;
for (int i = 1; i <= N; i++)
ans = max(ans, F[i][W]);
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FASTIO \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
const int maxN = 101;
const int maxW = 1e7 + 1;
vector<LL> F[maxN];
LL v[maxN];
int w[maxN];
int main() {
// IN;OUT;
FASTIO;
int N, W;
cin >> N >> W;
for (int i = 1; i <= N; i++) {
cin >> w[i] >> v[i];
F[i].pb(0);
}
F[0].pb(0);
for (int i = 1; i <= W; i++)
F[0].pb(-INF);
for (int i = 1; i <= N; i++)
for (int j = 1; j <= W; j++) {
LL V = F[i - 1][j];
if (j >= w[i])
V = max(V, F[i - 1][j - w[i]] + v[i]);
F[i].pb(V);
}
LL ans = -INF;
for (int i = 1; i <= W; i++)
ans = max(ans, F[N][i]);
cout << ans;
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 968,478 | 968,479 | u030635914 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
ll n;
ll w;
ll weight[110], value[110];
ll dp[110][100100];
int main() {
ios::sync_with_stdio(false);
cin >> n >> w;
for (int i = 0; i < n; i++)
cin >> weight[i] >> value[i];
for (int i = 0; i < n; i++) {
for (int sum_w; sum_w <= w; sum_w++) {
if (sum_w - weight[i] >= 0)
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[n][w] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
ll n;
ll w;
ll weight[110], value[110];
ll dp[110][100100];
int main() {
ios::sync_with_stdio(false);
cin >> n >> w;
for (ll i = 0; i < n; i++)
cin >> weight[i] >> value[i];
for (ll i = 0; i < n; i++) {
for (ll sum_w = 0; sum_w <= w; sum_w++) {
if (sum_w - weight[i] >= 0)
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[n][w] << endl;
return 0;
}
| [
"control_flow.loop.for.initializer.change",
"variable_declaration.type.change",
"variable_declaration.value.change"
] | 968,501 | 968,502 | u257960005 | cpp |
p03163 | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X) << 1)
#define R(X) (((X) << 1) | 1)
#define M(X, Y) (((X) + (Y)) >> 1)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = 110;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);
template <typename T> T max_self(T &a, T b) {
if (a < b)
a = b;
return a;
}
template <typename T> T min_self(T &a, T b) {
if (a > b)
a = b;
return a;
}
template <typename T> T add(T x, T y) { return ((x % MOD) + (y % MOD)) % MOD; }
template <typename T> T mul(T x, T y) {
return ((x % MOD) * (long long)(y % MOD)) % MOD;
}
template <typename T> T sub(T x, T y) { return add(x, -y + MOD); }
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T> vector<T> read(vector<T> &v, int n) {
v.resize(n);
for (auto &x : v)
cin >> x;
}
template <typename T> void trav(vector<T> &v) {
for (int i = 0; i < (int)v.size(); ++i) {
cout << v[i];
if (i != (int)v.size() - 1)
cout << ' ';
}
}
int lg2(long long x) { return 64 - __builtin_clzll(x) - 1; }
int lg2(int x) { return 32 - __builtin_clzll(x) - 1; }
int dp[MAXN][100005];
int weight[MAXN], value[MAXN];
int solve(int n, int w) {
if (w < 0)
return -INF;
if (n < 1 && w >= 0)
return 0;
if (n < 1 || w < 0)
return -INF;
if (dp[n][w] != -1)
return dp[n][w];
return dp[n][w] =
max(value[n] + solve(n - 1, w - weight[n]), solve(n - 1, w));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, w;
cin >> n >> w;
memset(dp, -1, sizeof dp);
for (int i = 1; i <= n; ++i) {
cin >> weight[i] >> value[i];
}
cout << solve(n, w) << endl;
return 0;
}
| #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X) << 1)
#define R(X) (((X) << 1) | 1)
#define M(X, Y) (((X) + (Y)) >> 1)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = 110;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);
template <typename T> T max_self(T &a, T b) {
if (a < b)
a = b;
return a;
}
template <typename T> T min_self(T &a, T b) {
if (a > b)
a = b;
return a;
}
template <typename T> T add(T x, T y) { return ((x % MOD) + (y % MOD)) % MOD; }
template <typename T> T mul(T x, T y) {
return ((x % MOD) * (long long)(y % MOD)) % MOD;
}
template <typename T> T sub(T x, T y) { return add(x, -y + MOD); }
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T> vector<T> read(vector<T> &v, int n) {
v.resize(n);
for (auto &x : v)
cin >> x;
}
template <typename T> void trav(vector<T> &v) {
for (int i = 0; i < (int)v.size(); ++i) {
cout << v[i];
if (i != (int)v.size() - 1)
cout << ' ';
}
}
int lg2(long long x) { return 64 - __builtin_clzll(x) - 1; }
int lg2(int x) { return 32 - __builtin_clzll(x) - 1; }
ll dp[MAXN][100005];
ll weight[MAXN], value[MAXN];
ll solve(int n, int w) {
if (w < 0)
return -INF;
if (n < 1 && w >= 0)
return 0;
if (n < 1 || w < 0)
return -INF;
if (dp[n][w] != -1)
return dp[n][w];
return dp[n][w] =
max(value[n] + solve(n - 1, w - weight[n]), solve(n - 1, w));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, w;
cin >> n >> w;
memset(dp, -1, sizeof dp);
for (int i = 1; i <= n; ++i) {
cin >> weight[i] >> value[i];
}
cout << solve(n, w) << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 968,503 | 968,504 | u455493734 | cpp |
p03163 | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X) << 1)
#define R(X) (((X) << 1) | 1)
#define M(X, Y) (((X) + (Y)) >> 1)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = 110;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);
template <typename T> T max_self(T &a, T b) {
if (a < b)
a = b;
return a;
}
template <typename T> T min_self(T &a, T b) {
if (a > b)
a = b;
return a;
}
template <typename T> T add(T x, T y) { return ((x % MOD) + (y % MOD)) % MOD; }
template <typename T> T mul(T x, T y) {
return ((x % MOD) * (long long)(y % MOD)) % MOD;
}
template <typename T> T sub(T x, T y) { return add(x, -y + MOD); }
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T> vector<T> read(vector<T> &v, int n) {
v.resize(n);
for (auto &x : v)
cin >> x;
}
template <typename T> void trav(vector<T> &v) {
for (int i = 0; i < (int)v.size(); ++i) {
cout << v[i];
if (i != (int)v.size() - 1)
cout << ' ';
}
}
int lg2(long long x) { return 64 - __builtin_clzll(x) - 1; }
int lg2(int x) { return 32 - __builtin_clzll(x) - 1; }
int dp[MAXN][MAXN];
int weight[MAXN], value[MAXN];
int solve(int n, int w) {
if (w < 0)
return -INF;
if (n < 1 && w >= 0)
return 0;
if (n < 1 || w < 0)
return -INF;
if (dp[n][w] != -1)
return dp[n][w];
return dp[n][w] =
max(value[n] + solve(n - 1, w - weight[n]), solve(n - 1, w));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, w;
cin >> n >> w;
memset(dp, -1, sizeof dp);
for (int i = 1; i <= n; ++i) {
cin >> weight[i] >> value[i];
}
cout << solve(n, w) << endl;
return 0;
}
| #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X) << 1)
#define R(X) (((X) << 1) | 1)
#define M(X, Y) (((X) + (Y)) >> 1)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = 110;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);
template <typename T> T max_self(T &a, T b) {
if (a < b)
a = b;
return a;
}
template <typename T> T min_self(T &a, T b) {
if (a > b)
a = b;
return a;
}
template <typename T> T add(T x, T y) { return ((x % MOD) + (y % MOD)) % MOD; }
template <typename T> T mul(T x, T y) {
return ((x % MOD) * (long long)(y % MOD)) % MOD;
}
template <typename T> T sub(T x, T y) { return add(x, -y + MOD); }
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T> vector<T> read(vector<T> &v, int n) {
v.resize(n);
for (auto &x : v)
cin >> x;
}
template <typename T> void trav(vector<T> &v) {
for (int i = 0; i < (int)v.size(); ++i) {
cout << v[i];
if (i != (int)v.size() - 1)
cout << ' ';
}
}
int lg2(long long x) { return 64 - __builtin_clzll(x) - 1; }
int lg2(int x) { return 32 - __builtin_clzll(x) - 1; }
ll dp[MAXN][100005];
ll weight[MAXN], value[MAXN];
ll solve(int n, int w) {
if (w < 0)
return -INF;
if (n < 1 && w >= 0)
return 0;
if (n < 1 || w < 0)
return -INF;
if (dp[n][w] != -1)
return dp[n][w];
return dp[n][w] =
max(value[n] + solve(n - 1, w - weight[n]), solve(n - 1, w));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, w;
cin >> n >> w;
memset(dp, -1, sizeof dp);
for (int i = 1; i <= n; ++i) {
cin >> weight[i] >> value[i];
}
cout << solve(n, w) << endl;
return 0;
}
| [
"variable_declaration.type.change",
"identifier.replace.remove",
"literal.replace.add",
"variable_declaration.array_dimensions.change"
] | 968,505 | 968,504 | u455493734 | cpp |
p03163 | #include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
}
return a > b;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
}
return a < b;
}
int weight[110], value[110];
int dp[110][100100];
signed main() {
int N, W;
cin >> N >> W;
for (int i = 0; i < N; i++)
cin >> weight[i] >> value[i];
for (int i = 0; i < N; i++) {
for (int sum = 0; sum <= W; sum++) {
if (sum >= weight[i]) {
chmax(dp[i + 1][sum], dp[i][sum - weight[i]] + value[i]);
} else {
chmax(dp[i + 1][sum], dp[i][sum]);
}
}
}
cout << dp[N][W] << endl;
}
| #include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
}
return a > b;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
}
return a < b;
}
int weight[110], value[110];
int dp[110][100100];
signed main() {
int N, W;
cin >> N >> W;
for (int i = 0; i < N; i++)
cin >> weight[i] >> value[i];
for (int i = 0; i < N; i++) {
for (int sum = 0; sum <= W; sum++) {
if (sum >= weight[i]) {
chmax(dp[i + 1][sum], dp[i][sum - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum], dp[i][sum]);
}
}
cout << dp[N][W] << endl;
}
| [] | 968,506 | 968,507 | u439265517 | cpp |
p03163 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, w;
cin >> n >> w;
vector<pair<int, int>> v;
v.push_back(make_pair(-1, -1));
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
v.push_back(make_pair(x, y));
}
vector<vector<int>> dp(n + 1, vector<int>(w + 1));
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= w; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= v[i].first)
dp[i][j] = max(dp[i][j], dp[i - 1][j - v[i].first] + v[i].second);
}
}
int ans = 0;
for (int j = 0; j <= w; j++) {
ans = max(ans, dp[n][j]);
}
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, w;
cin >> n >> w;
vector<pair<int, int>> v;
v.push_back(make_pair(-1, -1));
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
v.push_back(make_pair(x, y));
}
vector<vector<long long>> dp(n + 1, vector<long long>(w + 1));
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= w; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= v[i].first)
dp[i][j] = max(dp[i][j], dp[i - 1][j - v[i].first] + v[i].second);
}
}
long long ans = 0;
for (int j = 0; j <= w; j++) {
ans = max(ans, dp[n][j]);
}
cout << ans;
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,513 | 968,514 | u717021668 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define vi vector<ll>
typedef long long ll;
void read() { freopen("in.txt", "r", stdin); }
ll ks(ll num_items, ll cap, const vector<ll> &w, const vector<ll> &v) {
ll dp[num_items + 1][cap + 1];
for (ll i = 0; i <= num_items; i++) {
dp[i][0] = 0;
}
for (ll i = 0; i <= cap; i++) {
dp[0][i] = 0;
}
for (ll i = 1; i <= num_items; i++) {
for (ll j = 1; j <= cap; j++) {
ll curr_value = v[i - 1];
ll curr_wt = w[i - 1];
if (curr_wt > j) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(curr_value + dp[i - 1][j - curr_wt], dp[i - 1][j]);
}
}
}
return dp[num_items][cap];
}
int main() {
read();
ll num_items, cap;
cin >> num_items >> cap;
vector<ll> w(num_items), v(num_items);
for (ll i = 0; i < num_items; i++) {
cin >> w[i] >> v[i];
}
cout << ks(num_items, cap, w, v);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define vi vector<ll>
typedef long long ll;
void read() { freopen("in.txt", "r", stdin); }
ll ks(ll num_items, ll cap, const vector<ll> &w, const vector<ll> &v) {
ll dp[num_items + 1][cap + 1];
for (ll i = 0; i <= num_items; i++) {
dp[i][0] = 0;
}
for (ll i = 0; i <= cap; i++) {
dp[0][i] = 0;
}
for (ll i = 1; i <= num_items; i++) {
for (ll j = 1; j <= cap; j++) {
ll curr_value = v[i - 1];
ll curr_wt = w[i - 1];
if (curr_wt > j) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(curr_value + dp[i - 1][j - curr_wt], dp[i - 1][j]);
}
}
}
return dp[num_items][cap];
}
int main() {
// read();
ll num_items, cap;
cin >> num_items >> cap;
vector<ll> w(num_items), v(num_items);
for (ll i = 0; i < num_items; i++) {
cin >> w[i] >> v[i];
}
cout << ks(num_items, cap, w, v);
return 0;
}
| [
"call.remove"
] | 968,520 | 968,521 | u136933076 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pll pair<ll, ll>
#define speed_up \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define mode 998244353
#define mod 1000000007
#define inf 1000000000000000000LL
#define vl vector<ll>
#define F first
#define S second
#define db long double
#define sz(x) (ll) x.size()
#define fix(n) cout << fixed << setprecision(n)
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define mset(x) memset(x, 0, sizeof x)
#define pi 3.14159265358979323
const int N = 1e5 + 5;
ll n, val[101], w[101], wt, dp[101][N];
void solve() {
cin >> n >> wt;
rep(i, 1, n + 1) cin >> w[i] >> val[i];
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= wt; j++) {
if (w[i] > j)
dp[i][j] = dp[i - 1][j];
else {
dp[i][j] = max(dp[i - 1][j], val[i] + dp[i - 1][wt - w[i]]);
}
}
}
cout << dp[n][wt];
}
int main() {
ll T = 1;
speed_up
// cin>>T;
while (T--) solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pll pair<ll, ll>
#define speed_up \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define mode 998244353
#define mod 1000000007
#define inf 1000000000000000000LL
#define vl vector<ll>
#define F first
#define S second
#define db long double
#define sz(x) (ll) x.size()
#define fix(n) cout << fixed << setprecision(n)
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define mset(x) memset(x, 0, sizeof x)
#define pi 3.14159265358979323
const int N = 1e5 + 5;
ll n, val[101], w[101], wt, dp[101][N];
void solve() {
cin >> n >> wt;
rep(i, 1, n + 1) cin >> w[i] >> val[i];
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= wt; j++) {
// if(i==0 || j==0) dp[i][j]=0;
if (w[i] > j)
dp[i][j] = dp[i - 1][j];
else {
dp[i][j] = max(dp[i - 1][j], val[i] + dp[i - 1][j - w[i]]);
}
}
}
cout << dp[n][wt];
}
int main() {
ll T = 1;
speed_up
// cin>>T;
while (T--) solve();
return 0;
}
| [
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 968,524 | 968,525 | u005899600 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
/// The greatest enemy of knowledge is not ignorance, it is illusion of
/// knowledge
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue
#define printa(a, L, R) \
for (int i = L; i < R; i++) \
cout << a[i] << (i == R - 1 ? '\n' : ' ')
#define printv(a) printa(a, 0, a.size())
#define print2d(a, r, c) \
for (int i = 0; i < r; i++) \
for (int j = 0; j < c; j++) \
cout << a[i][j] << (j == c - 1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound
#define F first
#define S second
#define mem(a, x) memset(a, x, sizeof(a))
#define inf 1e18
#define PI (acos(-1.0))
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r, n) (int)(log2(n) / log2(r))
#define pf printf
#define sf scanf
#define _ccase printf("Case %lld: ", ++cs)
#define _case cout << "Case " << ++cs << ": "
#define by(x) [](const auto &a, const auto &b) { return a.x < b.x; }
#define asche cerr << "Ekhane asche\n";
#define rev(v) reverse(v.begin(), v.end())
#define srt(v) sort(v.begin(), v.end())
#define grtsrt(v) sort(v.begin(), v.end(), greater<ll>())
#define all(v) v.begin(), v.end()
#define mnv(v) *min_element(v.begin(), v.end())
#define mxv(v) *max_element(v.begin(), v.end())
#define toint(a) atoi(a.c_str())
#define fast ios_base::sync_with_stdio(false)
#define valid(tx, ty) (tx >= 0 && tx < n && ty >= 0 && ty < m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)), v.end())
#define stree ll l = (n << 1), r = l + 1, mid = b + (e - b) / 2
#define fout(x) fixed << setprecision(x)
#define SQ(x) ((x) * (x))
#define issq(x) (((ll)(sqrt((x)))) * ((ll)(sqrt((x)))) == (x))
#define AMR \
std::ios::sync_with_stdio(false); \
cin.tie(NULL);
int n;
int w[109], v[109];
int W, dp[100009][101];
int call(int pos, int ojon) {
if (pos > n)
return 0;
int &ret = dp[ojon][pos];
if (ret != -1)
return ret;
if (w[pos] <= ojon)
ret = call(pos + 1, ojon - w[pos]) + v[pos];
ret = max(ret, call(pos + 1, ojon));
return ret;
}
int main() {
AMR;
memset(dp, -1, sizeof dp);
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
int ans = call(1, W);
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
/// The greatest enemy of knowledge is not ignorance, it is illusion of
/// knowledge
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue
#define printa(a, L, R) \
for (int i = L; i < R; i++) \
cout << a[i] << (i == R - 1 ? '\n' : ' ')
#define printv(a) printa(a, 0, a.size())
#define print2d(a, r, c) \
for (int i = 0; i < r; i++) \
for (int j = 0; j < c; j++) \
cout << a[i][j] << (j == c - 1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound
#define F first
#define S second
#define mem(a, x) memset(a, x, sizeof(a))
#define inf 1e18
#define PI (acos(-1.0))
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r, n) (int)(log2(n) / log2(r))
#define pf printf
#define sf scanf
#define _ccase printf("Case %lld: ", ++cs)
#define _case cout << "Case " << ++cs << ": "
#define by(x) [](const auto &a, const auto &b) { return a.x < b.x; }
#define asche cerr << "Ekhane asche\n";
#define rev(v) reverse(v.begin(), v.end())
#define srt(v) sort(v.begin(), v.end())
#define grtsrt(v) sort(v.begin(), v.end(), greater<ll>())
#define all(v) v.begin(), v.end()
#define mnv(v) *min_element(v.begin(), v.end())
#define mxv(v) *max_element(v.begin(), v.end())
#define toint(a) atoi(a.c_str())
#define fast ios_base::sync_with_stdio(false)
#define valid(tx, ty) (tx >= 0 && tx < n && ty >= 0 && ty < m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)), v.end())
#define stree ll l = (n << 1), r = l + 1, mid = b + (e - b) / 2
#define fout(x) fixed << setprecision(x)
#define SQ(x) ((x) * (x))
#define issq(x) (((ll)(sqrt((x)))) * ((ll)(sqrt((x)))) == (x))
#define AMR \
std::ios::sync_with_stdio(false); \
cin.tie(NULL);
int n;
ll w[109], v[109], W, dp[100009][101];
ll call(int pos, int ojon) {
if (pos > n)
return 0;
ll &ret = dp[ojon][pos];
if (ret != -1)
return ret;
if (w[pos] <= ojon)
ret = call(pos + 1, ojon - w[pos]) + v[pos];
ret = max(ret, call(pos + 1, ojon));
return ret;
}
int main() {
AMR;
memset(dp, -1, sizeof dp);
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
ll ans = call(1, W);
cout << ans << endl;
}
| [
"variable_declaration.type.change"
] | 968,528 | 968,529 | u109245895 | cpp |
p03163 | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int w[100];
int v[100];
int dp[101][100001];
int main() {
int n, W;
cin >> n >> W;
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j <= W; j++) {
if (j >= w[i]) {
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i + 1][j] = dp[i][j];
}
}
}
cout << dp[n][W] << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int w[100];
int v[100];
long long dp[101][100001];
int main() {
int n, W;
cin >> n >> W;
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j <= W; j++) {
if (j >= w[i]) {
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i + 1][j] = dp[i][j];
}
}
}
cout << dp[n][W] << endl;
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,530 | 968,531 | u804999113 | cpp |
p03163 | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
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;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;
void print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
// dp[i][sum] i-1番目の品物をつかって重さがsumを超えないように選んだ時の
//価値の最大値
int main() {
int N, W;
cin >> N >> W;
vector<int> weight(N), value(N);
vector<vector<ll>> dp(N + 1, vector<ll>(W, 0));
REP(i, N) { cin >> weight[i] >> value[i]; }
REP(i, N) {
REP(sum_w, W + 1) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
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;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;
void print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
// dp[i][sum] i-1番目の品物をつかって重さがsumを超えないように選んだ時の
//価値の最大値
int main() {
int N, W;
cin >> N >> W;
vector<int> weight(N), value(N);
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
REP(i, N) { cin >> weight[i] >> value[i]; }
REP(i, N) {
REP(sum_w, W + 1) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | [
"assignment.change"
] | 968,532 | 968,533 | u824337972 | cpp |
p03163 | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
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;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;
void print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
// dp[i][sum] i-1番目の品物をつかって重さがsumを超えないように選んだ時の
//価値の最大値
int main() {
int N, W;
cin >> N >> W;
vector<int> weight(N), value(N);
vector<vector<ll>> dp(N + 1, vector<ll>(W, 0));
REP(i, N) { cin >> weight[i] >> value[i]; }
REP(i, N) {
REP(sum_w, W) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
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;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;
void print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
// dp[i][sum] i-1番目の品物をつかって重さがsumを超えないように選んだ時の
//価値の最大値
int main() {
int N, W;
cin >> N >> W;
vector<int> weight(N), value(N);
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
REP(i, N) { cin >> weight[i] >> value[i]; }
REP(i, N) {
REP(sum_w, W + 1) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | [
"assignment.change",
"expression.operation.binary.add"
] | 968,534 | 968,533 | u824337972 | cpp |
p03163 | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
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;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;
void print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
// dp[i][sum] i-1番目の品物をつかって重さがsumを超えないように選んだ時の
//価値の最大値
int main() {
int N, W;
cin >> N >> W;
vector<int> weight(N), value(N);
vector<vector<ll>> dp(N, vector<ll>(W, 0));
REP(i, N) { cin >> weight[i] >> value[i]; }
REP(i, N) {
REP(sum_w, W) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
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;
}
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
const int MOD = 1000000007;
void print(const std::vector<int> &v) {
std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
std::cout << std::endl;
}
// dp[i][sum] i-1番目の品物をつかって重さがsumを超えないように選んだ時の
//価値の最大値
int main() {
int N, W;
cin >> N >> W;
vector<int> weight(N), value(N);
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
REP(i, N) { cin >> weight[i] >> value[i]; }
REP(i, N) {
REP(sum_w, W + 1) {
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | [
"assignment.change",
"expression.operation.binary.add"
] | 968,535 | 968,533 | u824337972 | cpp |
p03163 | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
int main() {
int W, N, wi, vi;
std::cin >> N >> W;
int w[N + 1];
int v[N + 1];
int dp[N + 1][W + 1];
memset(dp, 0, sizeof(dp));
w[0] = 0;
v[0] = 0;
dp[0][0] = 0;
for (int i = 1; i < N + 1; i++) {
std::cin >> wi >> vi;
w[i] = wi;
v[i] = vi;
}
for (int i = 1; i < N + 1; i++) {
for (int j = 0; j < W + 1; j++) {
if (w[i] > j) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = std::max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
}
}
}
std::cout << dp[N][W];
} | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
int main() {
int W, N, wi, vi;
std::cin >> N >> W;
int w[N + 1];
int v[N + 1];
long dp[N + 1][W + 1];
memset(dp, 0, sizeof(dp));
w[0] = 0;
v[0] = 0;
dp[0][0] = 0;
for (int i = 1; i < N + 1; i++) {
std::cin >> wi >> vi;
w[i] = wi;
v[i] = vi;
}
for (int i = 1; i < N + 1; i++) {
for (int j = 0; j < W + 1; j++) {
if (w[i] > j) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = std::max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
}
}
}
std::cout << dp[N][W];
} | [
"variable_declaration.type.primitive.change"
] | 968,536 | 968,537 | u816587940 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
long long n, w1, w[105], v[105];
long long f[105][100005];
main() {
cin >> n >> w1;
for (long long i = 1; i <= n; i++)
cin >> w[i] >> v[i];
for (long long i = 1; i <= w1; i++) {
for (long long j = 1; j <= n; j++) {
if (i >= w[j])
f[j][i] = max(f[j][i], f[j - 1][i - w[j]] + v[j]);
else
f[j][i] = f[j - 1][i];
}
}
cout << f[n][w1];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
long long n, w1, w[105], v[105];
long long f[105][100005];
main() {
cin >> n >> w1;
for (long long i = 1; i <= n; i++)
cin >> w[i] >> v[i];
for (long long i = 1; i <= w1; i++) {
for (long long j = 1; j <= n; j++) {
if (i >= w[j])
f[j][i] = max(f[j - 1][i], f[j - 1][i - w[j]] + v[j]);
else
f[j][i] = f[j - 1][i];
}
}
cout << f[n][w1];
return 0;
}
| [
"assignment.change"
] | 968,540 | 968,541 | u036688765 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
long long n, k, v[10005], w[10005], f[10005][10005];
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= k; j++) {
if (w[i] <= j)
f[i][j] = max(f[i - 1][j], f[i - 1][j - w[i]] + v[i]);
else
f[i][j] = f[i - 1][j];
}
cout << f[n][k];
} | #include <bits/stdc++.h>
using namespace std;
long long n, k, v[105], w[105], f[105][100005];
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= k; j++) {
if (w[i] <= j)
f[i][j] = max(f[i - 1][j], f[i - 1][j - w[i]] + v[i]);
else
f[i][j] = f[i - 1][j];
}
cout << f[n][k];
// for(int i=1; i<=n; i++){
// for(int j=1; j<=k; j++)
// cout<<f[i][j]<<" ";
// cout<<endl;
// }
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 968,543 | 968,544 | u119908442 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#include <algorithm>
#include <string>
#include <vector>
const long long int maxn = 1e3 + 2;
const long long int mod = 1e3 + 2;
int main() {
fr ll n, w;
cin >> n >> w;
ll wei[n + 2], v[n + 2];
for (ll i = 0; i < n; i++)
cin >> wei[i] >> v[i];
ll dp[n + 2][w + 2];
memset(dp, 0, sizeof(dp));
for (ll i = 0; i <= n; i++) {
for (ll j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else if (wei[i - 1] <= j)
dp[i][j] = max((v[i - 1] + dp[i - 1][w - wei[i - 1]]), dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#include <algorithm>
#include <string>
#include <vector>
const long long int maxn = 1e3 + 2;
const long long int mod = 1e3 + 2;
int main() {
fr ll n, w;
cin >> n >> w;
ll wei[n + 2], v[n + 2];
for (ll i = 0; i < n; i++)
cin >> wei[i] >> v[i];
ll dp[n + 2][w + 2];
memset(dp, 0, sizeof(dp));
for (ll i = 0; i <= n; i++) {
for (ll j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else if (wei[i - 1] <= j)
dp[i][j] = max((v[i - 1] + dp[i - 1][j - wei[i - 1]]), dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w] << endl;
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 968,545 | 968,546 | u162913456 | cpp |
p03163 | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
int main() {
ll N, W;
cin >> N >> W;
ll wt[N];
ll val[N];
for (ll i = 0; i < N; i++) {
cin >> wt[i] >> val[i];
}
ll dp[W + 1][N + 1];
for (ll w = 0; w <= W; w++) {
for (ll i = 0; i <= N; i++) {
if (w == 0 || i == 0) {
dp[w][i] = 0;
}
else {
if (wt[i - 1] <= w) {
dp[w][i] = max(dp[w][i - 1], dp[w - wt[i]][i - 1] + val[i - 1]);
}
else {
dp[w][i] = dp[w][i - 1];
}
}
}
}
cout << dp[W][N] << endl;
}
| #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
int main() {
ll N, W;
cin >> N >> W;
ll wt[N];
ll val[N];
for (ll i = 0; i < N; i++) {
cin >> wt[i] >> val[i];
}
ll dp[W + 1][N + 1];
for (ll w = 0; w <= W; w++) {
for (ll i = 0; i <= N; i++) {
if (w == 0 || i == 0) {
dp[w][i] = 0;
}
else {
if (wt[i - 1] <= w) {
dp[w][i] = max(dp[w][i - 1], dp[w - wt[i - 1]][i - 1] + val[i - 1]);
}
else {
dp[w][i] = dp[w][i - 1];
}
}
}
}
cout << dp[W][N] << endl;
}
| [
"assignment.change"
] | 968,547 | 968,548 | u771978844 | cpp |
p03163 | #include <iostream>
#include <set>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
long n, w;
scanf("%ld %ld", &n, &w);
vector<long> values(n, 0);
vector<long> weights(n, 0);
for (int i = 0; scanf("%ld %ld", &weights[i], &values[i]) != EOF; i++) {
}
vector<long long> arr(n * w, 0);
for (long i = 0; i < w; i++) {
if (i + 1 < weights[0]) {
arr[i * n] = 0;
} else {
arr[i * n] = values[0];
}
}
for (int j = 1; j < n; j++) {
for (long i = 0; i < w; i++) {
if (i + 1 < weights[j]) {
arr[i * n + j] = arr[i * n + j - 1];
} else {
arr[i * n + j] = std::max(
arr[i * n + j - 1], arr[(i - weights[j]) * n + j - 1] + values[j]);
}
}
}
// for (int j=0; j<n; j++) {
// for (int i=0; i<w; i++){
// printf("%ld ", arr[i*n+j]);
// }
// printf("\n");
//}
printf("%lld", arr[w * n - 1]);
}
| #include <iostream>
#include <set>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
long n, w;
scanf("%ld %ld", &n, &w);
vector<long> values(n, 0);
vector<long> weights(n, 0);
for (int i = 0; scanf("%ld %ld", &weights[i], &values[i]) != EOF; i++) {
}
vector<long long> arr(n * w, 0);
for (long i = 0; i < w; i++) {
if (i + 1 < weights[0]) {
arr[i * n] = 0;
} else {
arr[i * n] = values[0];
}
}
for (int j = 1; j < n; j++) {
for (long i = 0; i < w; i++) {
if (i < weights[j]) {
arr[i * n + j] = arr[i * n + j - 1];
} else {
arr[i * n + j] = std::max(
arr[i * n + j - 1], arr[(i - weights[j]) * n + j - 1] + values[j]);
}
}
}
// for (int j=0; j<n; j++) {
// for (int i=0; i<w; i++){
// printf("%lld ", arr[i*n+j]);
// }
// printf("\n");
//}
printf("%lld", arr[w * n - 1]);
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 968,553 | 968,554 | u935678852 | cpp |
p03163 | #include <iostream>
#include <set>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
long n, w;
scanf("%ld %ld", &n, &w);
vector<long> values(n, 0);
vector<long> weights(n, 0);
for (int i = 0; scanf("%ld %ld", &weights[i], &values[i]) != EOF; i++) {
}
vector<long> arr(n * w, 0);
for (int i = 0; i < w; i++) {
if (i + 1 < weights[0]) {
arr[i * n] = 0;
} else {
arr[i * n] = values[0];
}
}
for (int j = 1; j < n; j++) {
for (int i = 0; i < w; i++) {
if (i + 1 < weights[j]) {
arr[i * n + j] = arr[i * n + j - 1];
} else {
arr[i * n + j] = std::max(
arr[i * n + j - 1], arr[(i - weights[j]) * n + j - 1] + values[j]);
}
}
}
// for (int j=0; j<n; j++) {
// for (int i=0; i<w; i++){
// printf("%ld ", arr[i*n+j]);
// }
// printf("\n");
//}
printf("%ld", arr[w * n - 1]);
}
| #include <iostream>
#include <set>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
long n, w;
scanf("%ld %ld", &n, &w);
vector<long> values(n, 0);
vector<long> weights(n, 0);
for (int i = 0; scanf("%ld %ld", &weights[i], &values[i]) != EOF; i++) {
}
vector<long long> arr(n * w, 0);
for (long i = 0; i < w; i++) {
if (i + 1 < weights[0]) {
arr[i * n] = 0;
} else {
arr[i * n] = values[0];
}
}
for (int j = 1; j < n; j++) {
for (long i = 0; i < w; i++) {
if (i < weights[j]) {
arr[i * n + j] = arr[i * n + j - 1];
} else {
arr[i * n + j] = std::max(
arr[i * n + j - 1], arr[(i - weights[j]) * n + j - 1] + values[j]);
}
}
}
// for (int j=0; j<n; j++) {
// for (int i=0; i<w; i++){
// printf("%lld ", arr[i*n+j]);
// }
// printf("\n");
//}
printf("%lld", arr[w * n - 1]);
}
| [
"variable_declaration.type.widen.change",
"control_flow.loop.for.initializer.change",
"variable_declaration.type.primitive.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 968,555 | 968,554 | u935678852 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a); i <= (b); i++)
#define PER(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5 + 5;
int N, W, w[102], b[102];
ll pd[102][MAX];
ll solve() {
REP(i, 1, N)
REP(j, 1, W) {
if (w[i] <= j)
pd[i][j] = max(pd[i - 1][j], pd[i - 1][j - w[i]] + b[i]);
else
pd[i][j] = pd[i - 1][j];
}
return pd[N][W];
}
int main(int argc, char **argv) {
scanf("%d%d", &N, &W);
REP(i, 1, N)
scanf("%d%d", &w[i], &b[i]);
printf("%I64d\n", solve());
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a); i <= (b); i++)
#define PER(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5 + 5;
int N, W, w[102], b[102];
ll pd[102][MAX];
ll solve() {
REP(i, 1, N)
REP(j, 1, W) {
if (w[i] <= j)
pd[i][j] = max(pd[i - 1][j], pd[i - 1][j - w[i]] + b[i]);
else
pd[i][j] = pd[i - 1][j];
}
return pd[N][W];
}
int main(int argc, char **argv) {
scanf("%d%d", &N, &W);
REP(i, 1, N)
scanf("%d%d", &w[i], &b[i]);
printf("%lld\n", solve());
return 0;
}
| [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 968,558 | 968,559 | u991534398 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a); i <= (b); i++)
#define PER(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5 + 5;
int N, W, w[MAX], b[MAX];
ll pd[102][MAX];
ll solve() {
REP(i, 1, N)
REP(j, 1, W) {
if (w[i] <= j)
pd[i][j] = max(pd[i - 1][j], pd[i - 1][j - w[i]] + b[i]);
else
pd[i][j] = pd[i - 1][j];
}
return pd[N][W];
}
int main(int argc, char **argv) {
scanf("%d%d", &N, &W);
REP(i, 1, N)
scanf("%d%d", &w[i], &b[i]);
printf("%I64d\n", solve());
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a); i <= (b); i++)
#define PER(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5 + 5;
int N, W, w[102], b[102];
ll pd[102][MAX];
ll solve() {
REP(i, 1, N)
REP(j, 1, W) {
if (w[i] <= j)
pd[i][j] = max(pd[i - 1][j], pd[i - 1][j - w[i]] + b[i]);
else
pd[i][j] = pd[i - 1][j];
}
return pd[N][W];
}
int main(int argc, char **argv) {
scanf("%d%d", &N, &W);
REP(i, 1, N)
scanf("%d%d", &w[i], &b[i]);
printf("%lld\n", solve());
return 0;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"variable_declaration.array_dimensions.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 968,560 | 968,559 | u991534398 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
// int dp[104][100005];
int dp[100005];
int main() {
int n, we, i, j;
cin >> n >> we;
int w[n + 1], v[n + 1];
for (i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
// 2d dp
/*for(i=1;i<=n;i++)
{
for(j=we;j>=w[i];j--)
{
dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
}
}
cout<<dp[n][we];*/
// 1d dp
for (int i = 1; i <= n; i++) {
for (int j = we; j >= w[i]; j--) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
cout << dp[we];
return 0;
} | #include <bits/stdc++.h>
using namespace std;
// int dp[104][100005];
long long dp[100005];
int main() {
long long n, we, i, j;
cin >> n >> we;
long long w[n + 1], v[n + 1];
for (i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
// 2d dp
/*for(i=1;i<=n;i++)
{
for(j=we;j>=w[i];j--)
{
dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
}
}
cout<<dp[n][we];*/
// 1d dp
for (int i = 1; i <= n; i++) {
for (int j = we; j >= w[i]; j--) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
cout << dp[we];
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,565 | 968,566 | u228402731 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, max_w;
cin >> n >> max_w;
vector<int> dp(max_w + 1, 0);
vector<vector<int>> a(n, vector<int>(2));
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
for (int i = 0; i < n; i++) {
for (int j = max_w; j >= 0; j--) {
if (j + a[i][0] <= max_w) {
dp[j + a[i][0]] = max(dp[j + a[i][0]], dp[j] + a[i][1]);
}
}
}
cout << *max_element(dp.begin(), dp.end()) << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, max_w;
cin >> n >> max_w;
vector<ll> dp(max_w + 1, 0);
vector<vector<int>> a(n, vector<int>(2));
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
for (int i = 0; i < n; i++) {
for (int j = max_w; j >= 0; j--) {
if (j + a[i][0] <= max_w) {
dp[j + a[i][0]] = max(dp[j + a[i][0]], dp[j] + a[i][1]);
}
}
}
cout << *max_element(dp.begin(), dp.end()) << '\n';
return 0;
}
| [] | 968,567 | 968,568 | u415754428 | cpp |
p03163 | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
vector<vector<long long>> tab(n + 1);
vector<long long> temp(w + 1);
for (int i = 1; i <= w; i++)
temp[i] = -1;
for (int i = 0; i <= n; i++)
tab[i] = temp;
int val, wht;
for (int i = 0; i < n; i++) {
cin >> wht >> val;
int lek = w - wht;
for (int j = 0; j <= lek; j++) {
if (tab[i][j] != -1) {
tab[i + 1][j + wht] = tab[i][j] + val;
}
}
for (int j = 0; j <= w; j++) {
if (tab[i][j] > tab[i + 1][j])
tab[i + 1][j] = tab[i][j];
}
}
int ans = -1;
for (int j = w; j >= 0; j--) {
if (tab[n][j] > ans) {
ans = tab[n][j];
}
}
cout << ans << endl;
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
vector<vector<long long>> tab(n + 1);
vector<long long> temp(w + 1);
for (int i = 1; i <= w; i++)
temp[i] = -1;
for (int i = 0; i <= n; i++)
tab[i] = temp;
int val, wht;
for (int i = 0; i < n; i++) {
cin >> wht >> val;
int lek = w - wht;
for (int j = 0; j <= lek; j++) {
if (tab[i][j] != -1) {
tab[i + 1][j + wht] = tab[i][j] + val;
}
}
for (int j = 0; j <= w; j++) {
if (tab[i][j] > tab[i + 1][j])
tab[i + 1][j] = tab[i][j];
}
}
long long ans = -1;
for (int j = w; j >= 0; j--) {
if (tab[n][j] > ans) {
ans = tab[n][j];
}
}
cout << ans << endl;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,569 | 968,570 | u297798194 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM + 7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int, int>
#define lPair pair<ll, ll>
#define chmax(a, b) (a < b ? a = b : 0)
#define chmin(a, b) (a > b ? a = b : 0)
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
ll dp[101][100100] = {0};
ll N, W;
ll w[101], v[101];
int main() {
cin >> N >> W;
for (ll i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
dp[0][0] = 0;
for (ll i = 0; i < N; i++) {
for (ll j = 0; j <= W; j++) {
dp[i + 1][j] = dp[i][j];
if (j >= w[i]) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i + 1]] + v[i + 1]);
}
}
}
ll mx = 0;
for (ll i = 0; i <= W; i++) {
mx = max(mx, dp[N][i]);
}
cout << mx << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM + 7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int, int>
#define lPair pair<ll, ll>
#define chmax(a, b) (a < b ? a = b : 0)
#define chmin(a, b) (a > b ? a = b : 0)
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
ll dp[101][100100] = {0};
ll N, W;
ll w[101], v[101];
int main() {
cin >> N >> W;
for (ll i = 1; i <= N; i++) {
cin >> w[i] >> v[i];
}
dp[0][0] = 0;
for (ll i = 0; i < N; i++) {
for (ll j = 0; j <= W; j++) {
dp[i + 1][j] = dp[i][j];
if (j >= w[i + 1]) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i + 1]] + v[i + 1]);
}
}
}
ll mx = 0;
for (ll i = 0; i <= W; i++) {
mx = max(mx, dp[N][i]);
}
cout << mx << endl;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"misc.of... | 968,571 | 968,572 | u342051078 | cpp |
p03163 | #include <bits/stdc++.h>
#define rep(i, k, n) for (int i = k; i <= n; i++)
#define per(i, n, k) for (int i = n; i >= k; i--)
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn = 100005;
int f[maxn];
int n, w, ans;
int main() {
cin >> n >> w;
rep(i, 0, n - 1) {
int x, y;
cin >> x >> y;
per(j, w, x) { f[j] = max(f[j], f[j - x] + y); }
}
rep(i, 0, w) { ans = max(ans, f[i]); }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, k, n) for (int i = k; i <= n; i++)
#define per(i, n, k) for (int i = n; i >= k; i--)
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn = 100005;
ll f[maxn];
ll n, w, ans;
int main() {
cin >> n >> w;
rep(i, 0, n - 1) {
int x, y;
cin >> x >> y;
per(j, w, x) { f[j] = max(f[j], f[j - x] + y); }
}
rep(i, 0, w) { ans = max(ans, f[i]); }
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change"
] | 968,578 | 968,579 | u052685836 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
int v[n], w[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
int a[n][W + 1];
for (int i = 0; i < W + 1; i++)
a[0][i] = (i < w[0]) ? 0 : v[0];
for (int i = 1; i < n; i++) {
for (int j = 0; j <= W; j++) {
if (j < w[i])
a[i][j] = a[i - 1][j];
else
a[i][j] = (v[i] + a[i - 1][j - w[i]]) > a[i - 1][j]
? (v[i] + a[i - 1][j - w[i]])
: a[i - 1][j];
}
}
/*for(int i=0;i<n;i++){
for(int j=0;j<=W;j++)cout<<a[i][j]<<" ";
cout<<endl;
}*/
cout << a[n - 1][W];
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
int v[n], w[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
long long a[n][W + 1];
for (int i = 0; i < W + 1; i++)
a[0][i] = (i < w[0]) ? 0 : v[0];
for (int i = 1; i < n; i++) {
for (int j = 0; j <= W; j++) {
if (j < w[i])
a[i][j] = a[i - 1][j];
else
a[i][j] = (v[i] + a[i - 1][j - w[i]]) > a[i - 1][j]
? (v[i] + a[i - 1][j - w[i]])
: a[i - 1][j];
}
}
/*for(int i=0;i<n;i++){
for(int j=0;j<=W;j++)cout<<a[i][j]<<" ";
cout<<endl;
}*/
cout << a[n - 1][W];
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,585 | 968,586 | u387025271 | cpp |
p03163 | #include <bits/stdc++.h> // Tomasz Nowak
using namespace std; // XIII LO Szczecin
using L = long long;
#define FOR(i, l, r) for (int i = l; i <= r; ++i)
#define REP(i, n) FOR(i, 0, n - 1)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, W;
cin >> n >> W;
vector<int> dp(W + 1), prev_dp(W + 1);
while (n-- > 0) {
int w, v;
cin >> w >> v;
FOR(i, w, W)
dp[i] = max(dp[i], prev_dp[i - w] + v);
FOR(i, 1, W)
dp[i] = max(dp[i], dp[i - 1]);
prev_dp = dp;
}
cout << dp.back() << '\n';
}
| #include <bits/stdc++.h> // Tomasz Nowak
using namespace std; // XIII LO Szczecin
using L = long long;
#define FOR(i, l, r) for (int i = l; i <= r; ++i)
#define REP(i, n) FOR(i, 0, n - 1)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, W;
cin >> n >> W;
vector<L> dp(W + 1), prev_dp(W + 1);
while (n-- > 0) {
int w, v;
cin >> w >> v;
FOR(i, w, W)
dp[i] = max(dp[i], prev_dp[i - w] + v);
FOR(i, 1, W)
dp[i] = max(dp[i], dp[i - 1]);
prev_dp = dp;
}
cout << dp.back() << '\n';
} | [] | 968,591 | 968,592 | u412965895 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int N, W;
cin >> N >> W;
vector<vector<int>> dp(N + 10, vector<int>(W, 0));
int v, w;
for (int i = 0; i < N; i++) {
cin >> w >> v;
for (int j = 0; j <= W; j++) {
if (j - w < 0) {
dp[i + 1][j] = dp[i][j];
} else {
dp[i + 1][j] = max(dp[i][j - w] + v, dp[i][j]);
}
}
}
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int N, W;
cin >> N >> W;
vector<vector<int>> dp(110, vector<int>(100010, 0));
int v, w;
for (int i = 0; i < N; i++) {
cin >> w >> v;
for (int j = 0; j <= W; j++) {
if (j - w < 0) {
dp[i + 1][j] = dp[i][j];
} else {
dp[i + 1][j] = max(dp[i][j - w] + v, dp[i][j]);
}
}
}
cout << dp[N][W] << endl;
} | [
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 968,602 | 968,603 | u045811375 | cpp |
p03163 | #include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int static const N_MAX = 1000;
int static const W_MAX = 1000 * 100;
int N, W;
int w[N_MAX];
long long v[N_MAX];
long long dp[N_MAX][W_MAX];
long long dfs(int i, long long j) {
if (dp[i][j] >= 0)
return dp[i][j];
long long ans = 0;
if (i == N)
ans = 0;
else if (j < w[i])
ans = dfs(i + 1, j);
else
ans = max(dfs(i + 1, j - w[i]) + v[i], dfs(i + 1, j));
return dp[i][j] = ans;
}
int main() {
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
memset(dp, -1, sizeof(dp));
cout << dfs(0, W) << endl;
} | #include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int static const N_MAX = 100 + 100;
int static const W_MAX = 1000 * 100 + 100;
int N, W;
int w[N_MAX];
long long v[N_MAX];
long long dp[N_MAX][W_MAX];
long long dfs(int i, long long j) {
if (dp[i][j] >= 0)
return dp[i][j];
long long ans = 0;
if (i == N)
ans = 0;
else if (j < w[i])
ans = dfs(i + 1, j);
else
ans = max(dfs(i + 1, j - w[i]) + v[i], dfs(i + 1, j));
return dp[i][j] = ans;
}
int main() {
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
memset(dp, -1, sizeof(dp));
cout << dfs(0, W) << endl;
} | [
"literal.number.change"
] | 968,616 | 968,617 | u061804469 | cpp |
p03163 | //#include <bits/stdc++.h>/*
#include <algorithm> //sort
#include <array>
#include <cassert>
#include <cctype> //isaplha, tolower
#include <cmath> //sqrt, sin
#include <complex>
#include <cstdio>
#include <cstring> //memset
#include <ctime>
#include <deque>
#include <functional> //greater
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility> //pair
#include <vector>
//*/
#define int long long
#define uns unsigned
#define ll long long
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
using namespace std;
template <class T> ostream &operator<<(ostream &os, const pair<T, T> &p) {
return os << "(" << p.fi << "," << p.se << ")";
}
template <class T> ostream &operator<<(ostream &os, const pair<const T, T> &p) {
return os << "(" << p.fi << "," << p.se << ")";
}
template <class T> ostream &operator<<(ostream &os, const array<T, 3> &p) {
return os << "(" << p[0] << "," << p[1] << "," << p[2] << ")";
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &p) {
for (auto x : p)
os << x << ' ';
return os;
}
#define dbug(x) cerr << ">>>> " << #x << " = " << x << endl
#define _ << ", " <<
#define FOR(X, L, R) for (int X = L; X < R; X++)
#define FI(I, X) for (auto I = (X).begin(); I != (X).end(); I++)
#define print(X) \
{ \
cerr << "{ "; \
FI(I, X) cerr << *I << ' '; \
cerr << "}" << endl; \
}
#define mset(V, X) memset(V, X, sizeof(V))
#define all(X) (X).begin(), (X).end()
#define upperb(V, X) (int)(upper_bound(all(V), (X)) - V.begin())
#define lowerb(V, X) (int)(lower_bound(all(V), (X)) - V.begin())
const double EPS = 1e-9, PI = acos(-1);
const ll LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9 + 7;
const int INF = 0x3f3f3f3f, SZ = 2e5 + 20;
int n, c;
vector<pii> v;
int res, aux;
double c2, aux2;
void bt(int i) {
if (i == n)
return;
aux2 = 0;
c2 = c;
for (int j = i; j < n && c2; j++) {
if (v[j].fi <= c2) {
c2 -= v[j].fi;
aux2 += v[j].se;
} else {
aux2 += (v[j].se * c2) / v[j].fi;
c2 = 0;
}
if (aux2 + aux <= res)
return;
}
if (v[i].fi <= c) {
c -= v[i].fi;
aux += v[i].se;
if (aux > res)
res = aux;
bt(i + 1);
aux -= v[i].se;
c += v[i].fi;
}
bt(i + 1);
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> c;
FOR(i, 0, n) {
int x, y;
cin >> x >> y;
v.pb({x, y});
}
sort(all(v),
[](pii a, pii b) { return (a.se + 0.0) / a.fi > (b.se + 0.0) / b.fi; });
bt(0);
cout << res << endl;
return 0;
} | //#include <bits/stdc++.h>/*
#include <algorithm> //sort
#include <array>
#include <cassert>
#include <cctype> //isaplha, tolower
#include <cmath> //sqrt, sin
#include <complex>
#include <cstdio>
#include <cstring> //memset
#include <ctime>
#include <deque>
#include <functional> //greater
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility> //pair
#include <vector>
//*/
#define int long long
#define uns unsigned
#define ll long long
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
using namespace std;
template <class T> ostream &operator<<(ostream &os, const pair<T, T> &p) {
return os << "(" << p.fi << "," << p.se << ")";
}
template <class T> ostream &operator<<(ostream &os, const pair<const T, T> &p) {
return os << "(" << p.fi << "," << p.se << ")";
}
template <class T> ostream &operator<<(ostream &os, const array<T, 3> &p) {
return os << "(" << p[0] << "," << p[1] << "," << p[2] << ")";
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &p) {
for (auto x : p)
os << x << ' ';
return os;
}
#define dbug(x) cerr << ">>>> " << #x << " = " << x << endl
#define _ << ", " <<
#define FOR(X, L, R) for (int X = L; X < R; X++)
#define FI(I, X) for (auto I = (X).begin(); I != (X).end(); I++)
#define print(X) \
{ \
cerr << "{ "; \
FI(I, X) cerr << *I << ' '; \
cerr << "}" << endl; \
}
#define mset(V, X) memset(V, X, sizeof(V))
#define all(X) (X).begin(), (X).end()
#define upperb(V, X) (int)(upper_bound(all(V), (X)) - V.begin())
#define lowerb(V, X) (int)(lower_bound(all(V), (X)) - V.begin())
const double EPS = 1e-9, PI = acos(-1);
const ll LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9 + 7;
const int INF = 0x3f3f3f3f, SZ = 2e5 + 20;
int n, c;
vector<pii> v;
int res, aux;
double c2, aux2;
void bt(int i) {
if (i == n)
return;
aux2 = 0;
c2 = c;
for (int j = i; j < n && c2; j++) {
if (v[j].fi <= c2) {
c2 -= v[j].fi;
aux2 += v[j].se;
} else {
aux2 += (v[j].se * c2) / v[j].fi;
c2 = 0;
}
}
if (aux2 + aux <= res)
return;
if (v[i].fi <= c) {
c -= v[i].fi;
aux += v[i].se;
if (aux > res)
res = aux;
bt(i + 1);
aux -= v[i].se;
c += v[i].fi;
}
bt(i + 1);
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> c;
FOR(i, 0, n) {
int x, y;
cin >> x >> y;
v.pb({x, y});
}
sort(all(v),
[](pii a, pii b) { return (a.se + 0.0) / a.fi > (b.se + 0.0) / b.fi; });
bt(0);
cout << res << endl;
return 0;
} | [] | 968,618 | 968,619 | u235860954 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, W;
cin >> n >> W;
vector<int> dp(W + 1);
for (int i = 0; i < n; ++i) {
int w, v;
cin >> w >> v;
for (int j = W - w; j >= 0; --j) {
dp[j + w] = max(dp[j + w], dp[j] + v);
}
}
cout << *max_element(dp.begin(), dp.end()) << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, W;
cin >> n >> W;
vector<ll> dp(W + 1);
for (int i = 0; i < n; ++i) {
ll w, v;
cin >> w >> v;
for (int j = W - w; j >= 0; --j) {
dp[j + w] = max(dp[j + w], dp[j] + v);
}
}
cout << *max_element(dp.begin(), dp.end()) << '\n';
return 0;
}
| [
"variable_declaration.type.change"
] | 968,620 | 968,621 | u855388123 | cpp |
p03163 | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define ggr \
getchar(); \
getchar(); \
return 0;
#define pie 3.141592653589793
#define INF 1000000007
int bin(int bina) {
int ans = 0;
for (int i = 0; bina > 0; i++) {
ans = ans + (bina % 2) * pow(10, i);
bina = bina / 2;
}
return ans;
}
bool prime(int n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x * y / gcd(x, y); }
int jo(int n) {
int ans = 1;
rep(i, n) { ans *= 2; }
return ans;
}
int n, m, a[105], b[105], dp[105][100010];
signed main() {
cin >> n >> m;
rep(i, n) { cin >> a[i] >> b[i]; }
for (ll i = 0; i <= n; i++) {
dp[0][i] = 0;
}
rep(i, n) {
loop(w, 0, m + 1) {
if (w >= a[i]) {
dp[i + 1][w] = max(dp[i][w - a[i]] + b[i], dp[i + 1][w]);
} else
dp[i + 1][w] = dp[i][w];
}
}
cout << dp[n][m] << endl;
} | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define ggr \
getchar(); \
getchar(); \
return 0;
#define pie 3.141592653589793
#define INF 1000000007
int bin(int bina) {
int ans = 0;
for (int i = 0; bina > 0; i++) {
ans = ans + (bina % 2) * pow(10, i);
bina = bina / 2;
}
return ans;
}
bool prime(int n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x * y / gcd(x, y); }
int jo(int n) {
int ans = 1;
rep(i, n) { ans *= 2; }
return ans;
}
int n, m, a[105], b[105], dp[105][100010];
signed main() {
cin >> n >> m;
rep(i, n) { cin >> a[i] >> b[i]; }
for (ll i = 0; i <= n; i++) {
dp[0][i] = 0;
}
rep(i, n) {
loop(w, 0, m + 1) {
if (w >= a[i]) {
dp[i + 1][w] = max(dp[i][w - a[i]] + b[i], dp[i][w]);
} else
dp[i + 1][w] = dp[i][w];
}
}
cout << dp[n][m] << endl;
} | [
"expression.operation.binary.remove"
] | 968,624 | 968,625 | u409872261 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll max(ll a, ll b) { return (a >= b ? a : b); }
int main(void) {
ll n, w;
cin >> n >> w;
ll remw = w;
ll we[n], val[n];
for (ll i = 0; i < n; ++i) {
cin >> we[i] >> val[i];
}
ll dp[n + 1][w + 1] = {0};
for (ll i = 1; i <= n; ++i) {
dp[0][i] = 0;
}
for (ll i = 1; i <= n; ++i) {
for (ll j = 1; j <= w; ++j) {
if (j < we[i - 1]) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(val[i - 1] + dp[i - 1][j - we[i - 1]], dp[i - 1][j]);
}
}
}
/*for(ll i=0;i<=n;++i)
{
for(ll j=0;j<=w;++j)
cout<<dp[i][j]<<" ";
cout<<endl;
}*/
cout << dp[n][w];
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll max(ll a, ll b) { return (a >= b ? a : b); }
int main(void) {
ll n, w;
cin >> n >> w;
ll remw = w;
ll we[n], val[n];
for (ll i = 0; i < n; ++i) {
cin >> we[i] >> val[i];
}
ll dp[n + 1][w + 1] = {0};
for (ll i = 1; i <= w; ++i) {
dp[0][i] = 0;
// cout<<dp[0][i]<<" ";
}
cout << endl;
for (ll i = 1; i <= n; ++i) {
for (ll j = 1; j <= w; ++j) {
if (j < we[i - 1]) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(val[i - 1] + dp[i - 1][j - we[i - 1]], dp[i - 1][j]);
}
}
}
/*for(ll i=0;i<=n;++i)
{
for(ll j=0;j<=w;++j)
cout<<dp[i][j]<<" ";
cout<<endl;
}*/
cout << dp[n][w];
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 968,626 | 968,627 | u707655771 | cpp |
p03163 | #include <bits/stdc++.h>
#include <string>
using namespace std;
#include <string>
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
typedef long long ll;
#define MAX 1000000000
ll abs(ll a, ll b) { return (a < b ? b - a : a - b); }
int main() {
fast;
int n, i, a[105], b[105], j, k, w;
cin >> n >> k;
for (i = 0; i < n; i++)
cin >> b[i] >> a[i];
int dp[n + 1][k + 1];
for (i = 0; i <= n; i++) {
for (w = 0; w <= k; w++) {
if (i == 0 || w == 0)
dp[i][w] = 0;
else if (b[i - 1] <= w)
dp[i][w] = max(a[i - 1] + dp[i - 1][w - b[i - 1]], dp[i - 1][w]);
else
dp[i][w] = dp[i - 1][w];
}
}
cout << dp[n][k];
return 0;
}
| #include <bits/stdc++.h>
#include <string>
using namespace std;
#include <string>
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
typedef long long ll;
#define MAX 1000000000
ll abs(ll a, ll b) { return (a < b ? b - a : a - b); }
int main() {
fast;
ll n, i, a[105], b[105], j, k, w;
cin >> n >> k;
for (i = 0; i < n; i++)
cin >> b[i] >> a[i];
ll dp[n + 1][k + 1];
for (i = 0; i <= n; i++) {
for (w = 0; w <= k; w++) {
if (i == 0 || w == 0)
dp[i][w] = 0;
else if (b[i - 1] <= w)
dp[i][w] = max(a[i - 1] + dp[i - 1][w - b[i - 1]], dp[i - 1][w]);
else
dp[i][w] = dp[i - 1][w];
}
}
cout << dp[n][k];
return 0;
}
| [
"variable_declaration.type.change"
] | 968,632 | 968,633 | u347064817 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;
const int maxn = 105;
const int maxw = 1e5 + 5;
int w[maxn], v[maxn];
int n, W;
int dp[maxw];
int main() {
scanf("%d %d", &n, &W);
for (int i = 1; i <= n; i++)
scanf("%d %d", &w[i], &v[i]);
for (int i = 1; i <= n; i++) {
for (int j = W; j >= w[i]; j--) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
printf("%d\n", dp[W]);
} | #include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;
const int maxn = 105;
const int maxw = 1e5 + 5;
int w[maxn], v[maxn];
int n, W;
ll dp[maxw];
int main() {
scanf("%d %d", &n, &W);
for (int i = 1; i <= n; i++)
scanf("%d %d", &w[i], &v[i]);
for (int i = 1; i <= n; i++) {
for (int j = W; j >= w[i]; j--) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
printf("%lld\n", dp[W]);
} | [
"variable_declaration.type.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 968,634 | 968,635 | u905710781 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long int
#define ri register int
#define endl "\n"
using namespace std;
ll dp[102][(int)1e5 + 2] = {};
int main() {
ios_base::sync_with_stdio(false);
ll n, w;
cin >> n >> w;
vector<pair<ll, ll>> items(n + 1);
for (ri i = 1; i <= n; i++)
cin >> items[i].first >> items[i].second;
for (ri i = 0; i <= n; i++) {
for (ri j = 0; j <= w; j++) {
if (j - items[i].first >= 0) {
dp[i][j] =
max(dp[i - 1][j - items[i].first] + items[i].second, dp[i - 1][j]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
return 0;
}
| #include <bits/stdc++.h>
#define ll long long int
#define ri register int
#define endl "\n"
using namespace std;
ll dp[102][(int)1e5 + 2] = {};
int main() {
ios_base::sync_with_stdio(false);
ll n, w;
cin >> n >> w;
vector<pair<ll, ll>> items(n + 1);
for (ri i = 1; i <= n; i++)
cin >> items[i].first >> items[i].second;
for (ri i = 1; i <= n; i++) {
for (ri j = 0; j <= w; j++) {
if (j - items[i].first >= 0) {
dp[i][j] =
max(dp[i - 1][j - items[i].first] + items[i].second, dp[i - 1][j]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 968,636 | 968,637 | u938926508 | cpp |
p03163 | /*author : Yashvardhan
Saturday, January 12, 2019
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pi>
#define ff first
#define ss second
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " ";
__f(comma + 1, args...);
}
#else
#define debug(...)
#endif
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < v.size(); ++i)
os << v[i] << " ";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it : v)
os << it << " ";
return os;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v) {
os << v.ff << " " << v.ss;
return os;
}
const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
int dp[101][100005];
int wi[101];
int vs[101];
int pow(int a, int b, int m) {
int ans = 1;
while (b) {
if (b & 1)
ans = (ans * a) % m;
b /= 2;
a = (a * a) % m;
}
return ans;
}
int solve(int n, int w) {
if (dp[n][w] != -1)
return dp[n][w];
if (w == 0)
return dp[n][w] = 0;
if (wi[n] > w)
return dp[n][w] = solve(n - 1, w);
else
return dp[n][w] = max(solve(n - 1, w), vs[n] + solve(n - 1, w - wi[n]));
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef __APPLE__
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
time_t t1, t2;
t1 = clock();
int n, w1;
cin >> n >> w1;
for (int i = 1; i <= n; i++) {
int w, v;
cin >> w >> v;
wi[i] = w;
vs[i] = v;
}
for (int i = 0; i < 101; i++) {
for (int j = 0; j <= 100000; j++) {
dp[i][j] = -1;
}
}
cout << solve(n, w1) << endl;
t2 = clock();
cerr << endl << t2 - t1 << endl;
return 0;
}
| /*author : Yashvardhan
Saturday, January 12, 2019
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pi>
#define ff first
#define ss second
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " ";
__f(comma + 1, args...);
}
#else
#define debug(...)
#endif
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < v.size(); ++i)
os << v[i] << " ";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it : v)
os << it << " ";
return os;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v) {
os << v.ff << " " << v.ss;
return os;
}
const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
int dp[101][100005];
int wi[101];
int vs[101];
int pow(int a, int b, int m) {
int ans = 1;
while (b) {
if (b & 1)
ans = (ans * a) % m;
b /= 2;
a = (a * a) % m;
}
return ans;
}
int solve(int n, int w) {
if (dp[n][w] != -1)
return dp[n][w];
if (n == 0)
return dp[n][w] = 0;
if (wi[n] > w)
return dp[n][w] = solve(n - 1, w);
else
return dp[n][w] = max(solve(n - 1, w), vs[n] + solve(n - 1, w - wi[n]));
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef __APPLE__
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
time_t t1, t2;
t1 = clock();
int n, w1;
cin >> n >> w1;
for (int i = 1; i <= n; i++) {
int w, v;
cin >> w >> v;
wi[i] = w;
vs[i] = v;
}
for (int i = 0; i < 101; i++) {
for (int j = 0; j <= 100000; j++) {
dp[i][j] = -1;
}
}
cout << solve(n, w1) << endl;
t2 = clock();
cerr << endl << t2 - t1 << endl;
return 0;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 968,645 | 968,646 | u368039995 | cpp |
p03163 | /*author : Yashvardhan
Saturday, January 12, 2019
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pi>
#define ff first
#define ss second
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " ";
__f(comma + 1, args...);
}
#else
#define debug(...)
#endif
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < v.size(); ++i)
os << v[i] << " ";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it : v)
os << it << " ";
return os;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v) {
os << v.ff << " " << v.ss;
return os;
}
const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
int dp[101][100005];
int wi[101];
int vs[101];
int pow(int a, int b, int m) {
int ans = 1;
while (b) {
if (b & 1)
ans = (ans * a) % m;
b /= 2;
a = (a * a) % m;
}
return ans;
}
int solve(int n, int w) {
if (dp[n][w] != -1)
return dp[n][w];
if (w == 0 || n == 0)
return dp[n][w] = 0;
if (wi[n] > w)
return dp[n][w] = solve(n - 1, w);
else
return dp[n][w] = max(solve(n - 1, w), vs[n] + solve(n - 1, w - wi[n]));
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef __APPLE__
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
time_t t1, t2;
t1 = clock();
int n, w1;
cin >> n >> w1;
for (int i = 0; i < n; i++) {
int w, v;
cin >> w >> v;
wi[i] = w;
vs[i] = v;
}
for (int i = 0; i < 101; i++) {
for (int j = 0; j <= 100000; j++) {
dp[i][j] = -1;
}
}
cout << solve(n, w1) << endl;
t2 = clock();
cerr << endl << t2 - t1 << endl;
return 0;
}
| /*author : Yashvardhan
Saturday, January 12, 2019
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pi>
#define ff first
#define ss second
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " ";
__f(comma + 1, args...);
}
#else
#define debug(...)
#endif
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (int i = 0; i < v.size(); ++i)
os << v[i] << " ";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) {
for (auto it : v)
os << it << " ";
return os;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, const pair<T, S> &v) {
os << v.ff << " " << v.ss;
return os;
}
const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
int dp[101][100005];
int wi[101];
int vs[101];
int pow(int a, int b, int m) {
int ans = 1;
while (b) {
if (b & 1)
ans = (ans * a) % m;
b /= 2;
a = (a * a) % m;
}
return ans;
}
int solve(int n, int w) {
if (dp[n][w] != -1)
return dp[n][w];
if (w == 0 || n == 0)
return dp[n][w] = 0;
if (wi[n] > w)
return dp[n][w] = solve(n - 1, w);
else
return dp[n][w] = max(solve(n - 1, w), vs[n] + solve(n - 1, w - wi[n]));
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef __APPLE__
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
time_t t1, t2;
t1 = clock();
int n, w1;
cin >> n >> w1;
for (int i = 1; i <= n; i++) {
int w, v;
cin >> w >> v;
wi[i] = w;
vs[i] = v;
}
for (int i = 0; i < 101; i++) {
for (int j = 0; j <= 100000; j++) {
dp[i][j] = -1;
}
}
cout << solve(n, w1) << endl;
t2 = clock();
cerr << endl << t2 - t1 << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 968,647 | 968,648 | u368039995 | cpp |
p03163 | #include <bits/stdc++.h>
using lli = long long int;
template <typename T> bool chmax(T &a, T b) {
if (b > a) {
a = b;
return true;
}
return false;
}
lli n, w;
std::vector<std::pair<lli, lli>> vec;
std::vector<std::vector<lli>> dp;
int main() {
std::cin >> n >> w;
vec.assign(n + 1, {0, 0});
for (lli i = 0; i < n; i++) {
std::cin >> vec[i].first >> vec[i].second;
}
dp.assign(n + 1, std::vector<lli>(w + 1, 0));
for (lli i = 1; i <= n; i++) {
for (lli p = 0; p <= w; p++) {
if (p >= vec[i].first) {
chmax(dp[i][p], dp[i - 1][p - vec[i].first] + vec[i].second);
} else {
chmax(dp[i][p], dp[i - 1][p]);
}
}
}
std::cout << dp[n][w] << std::endl;
}
| #include <bits/stdc++.h>
using lli = long long int;
template <typename T> bool chmax(T &a, T b) {
if (b > a) {
a = b;
return true;
}
return false;
}
lli n, w;
std::vector<std::pair<lli, lli>> vec;
std::vector<std::vector<lli>> dp;
int main() {
std::cin >> n >> w;
vec.assign(n + 1, {0, 0});
for (lli i = 1; i <= n; i++) {
std::cin >> vec[i].first >> vec[i].second;
}
dp.assign(n + 1, std::vector<lli>(w + 1, 0));
for (lli i = 1; i <= n; i++) {
for (lli p = 0; p <= w; p++) {
if (p >= vec[i].first) {
chmax(dp[i][p], dp[i - 1][p - vec[i].first] + vec[i].second);
}
chmax(dp[i][p], dp[i - 1][p]);
}
}
std::cout << dp[n][w] << std::endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 968,653 | 968,654 | u537538698 | cpp |
p03163 | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define LL long long
template <class T> inline void chmax(T &a, T b) {
if (a < b) {
a = b;
}
}
template <class T> inline void chmin(T &a, T b) {
if (a > b) {
a = b;
}
}
const long long LLINF = 1LL << 62;
const int INF = 1LL << 30;
using namespace std;
const int N_MAX = 110;
const int W_MAX = 100010;
int main(void) {
int N, W;
cin >> N >> W;
vector<int> weight(N_MAX);
vector<int> value(N_MAX);
for (int i = 1; i <= N; i++)
cin >> weight[i] >> value[i];
vector<vector<int>> dp(N_MAX, vector<int>(W_MAX));
for (int i = 1; i <= N; i++) {
for (int w = 0; w < W_MAX; w++) {
if (w - weight[i] >= 0) {
dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight[i]] + value[i]);
} else {
dp[i][w] = max(dp[i - 1][w], dp[i][w]);
}
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define LL long long
template <class T> inline void chmax(T &a, T b) {
if (a < b) {
a = b;
}
}
template <class T> inline void chmin(T &a, T b) {
if (a > b) {
a = b;
}
}
const long long LLINF = 1LL << 62;
const int INF = 1LL << 30;
using namespace std;
const int N_MAX = 110;
const int W_MAX = 100010;
int main(void) {
int N, W;
cin >> N >> W;
vector<int> weight(N_MAX);
vector<int> value(N_MAX);
for (int i = 1; i <= N; i++)
cin >> weight[i] >> value[i];
vector<vector<LL>> dp(N_MAX, vector<LL>(W_MAX));
for (int i = 1; i <= N; i++) {
for (int w = 0; w < W_MAX; w++) {
if (w - weight[i] >= 0) {
dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight[i]] + value[i]);
} else {
dp[i][w] = max(dp[i - 1][w], dp[i][w]);
}
}
}
cout << dp[N][W] << endl;
return 0;
} | [] | 968,655 | 968,656 | u139235669 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int v[110], w[110];
int dp[110][100010] = {};
int main() {
int N, W;
cin >> N >> W;
for (int i = 0; i < N; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < N; i++) {
for (int j = 0; j <= W; j++) {
if (j - w[i] >= 0) {
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i + 1][j] = dp[i][j];
}
}
}
cout << dp[N][W] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL v[110], w[110];
LL dp[110][100010] = {};
int main() {
int N, W;
cin >> N >> W;
for (int i = 0; i < N; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < N; i++) {
for (int j = 0; j <= W; j++) {
if (j - w[i] >= 0) {
dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i + 1][j] = dp[i][j];
}
}
}
cout << dp[N][W] << endl;
}
| [
"variable_declaration.type.change"
] | 968,657 | 968,658 | u392423112 | cpp |
p03163 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for (int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in() {
T x;
cin >> x;
return (x);
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};
int N, W;
ll w[110], v[110];
ll dp[110][100100];
int main(int argc, char *argv[]) {
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
rep(i, N) {
rep(sum_w, W + 1) {
if (sum_w - w[i] >= 0)
chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
else
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for (int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in() {
T x;
cin >> x;
return (x);
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};
int N, W;
ll w[110], v[110];
ll dp[110][100100];
int main(int argc, char *argv[]) {
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
rep(i, N) {
rep(sum_w, W + 1) {
if (sum_w - w[i] >= 0)
chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
cout << dp[N][W] << endl;
return 0;
} | [
"control_flow.branch.else.remove"
] | 968,659 | 968,660 | u924820636 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for (int i(0); i < n; i++)
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(), v.end()
/*int kS(int W, int wt[], int val[], int n){
int dp[n+1][W+1];
for(int i(0);i<=n;i++){
for(int w(0);w<=W;w++){
if(i == 0|| w==0)dp[i][w];
else if(wt[i-1] <= w)dp[i][w] = max(val[i-1] +
dp[i-1][w-wt[i-1]], dp[i-1][w]); else dp[i][w] = dp[i-1][w];
}
}
return dp[n][W];
}*/
int knapSack(int W, int wt[], int val[], int n) {
int i, w;
int K[n + 1][W + 1];
// Build table K[][] in bottom up manner
for (i = 0; i <= n; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
K[i][w] = 0;
else if (wt[i - 1] <= w)
K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
else
K[i][w] = K[i - 1][w];
}
}
return K[n][W];
}
int32_t main() {
fast;
int n, w;
cin >> n >> w;
int wt[n], val[n];
rep(i, n) cin >> wt[i] >> val[i];
cout << knapSack(w, wt, val, n);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i(0); i < n; i++)
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0);
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(), v.end()
/*int kS(int W, int wt[], int val[], int n){
int dp[n+1][W+1];
for(int i(0);i<=n;i++){
for(int w(0);w<=W;w++){
if(i == 0|| w==0)dp[i][w];
else if(wt[i-1] <= w)dp[i][w] = max(val[i-1] +
dp[i-1][w-wt[i-1]], dp[i-1][w]); else dp[i][w] = dp[i-1][w];
}
}
return dp[n][W];
}*/
int knapSack(int W, int wt[], int val[], int n) {
int i, w;
int K[n + 1][W + 1];
// Build table K[][] in bottom up manner
for (i = 0; i <= n; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
K[i][w] = 0;
else if (wt[i - 1] <= w)
K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
else
K[i][w] = K[i - 1][w];
}
}
return K[n][W];
}
int32_t main() {
fast;
int n, w;
cin >> n >> w;
int wt[n], val[n];
rep(i, n) cin >> wt[i] >> val[i];
cout << knapSack(w, wt, val, n);
return 0;
}
| [] | 968,661 | 968,662 | u821240599 | cpp |
p03163 | #include <cstring>
#include <iostream>
using namespace std;
const int W = 100010, N = 105;
int w[N], v[N], dp[N][W], n, m;
int main() {
memset(dp, 0, sizeof(dp));
cin >> n >> m;
for (int i = 1; i <= n; ++i)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++)
for (int j = 0; j <= m; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= w[i])
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
}
cout << dp[n][m];
return 0;
} | #include <cstring>
#include <iostream>
using namespace std;
const int W = 100010, N = 105;
long long w[N], v[N], dp[N][W], n, m;
int main() {
memset(dp, 0, sizeof(dp));
cin >> n >> m;
for (int i = 1; i <= n; ++i)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++)
for (int j = 0; j <= m; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= w[i])
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
}
cout << dp[n][m];
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 968,667 | 968,668 | u251934001 | cpp |
p03163 | #include <cstring>
#include <iostream>
using namespace std;
const int W = 100010, N = 105;
int w[N], v[N], dp[N][W], n, m;
int main() {
memset(dp, 0, sizeof(dp));
cin >> m >> n;
for (int i = 1; i <= n; ++i)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++)
for (int j = 0; j <= m; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= w[i])
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
}
cout << dp[n][m];
return 0;
} | #include <cstring>
#include <iostream>
using namespace std;
const int W = 100010, N = 105;
long long w[N], v[N], dp[N][W], n, m;
int main() {
memset(dp, 0, sizeof(dp));
cin >> n >> m;
for (int i = 1; i <= n; ++i)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++)
for (int j = 0; j <= m; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= w[i])
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
}
cout << dp[n][m];
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"expression.operation.binary.remove"
] | 968,669 | 968,668 | u251934001 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define M 998244353
#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"
#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)
#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) \
for (auto i : v) \
cout << i << " ";
ll n, wt;
vii arr;
vvi dp;
ll solve(ll w, ll i) {
if (i == n)
return 0;
if (dp[i][w])
return dp[i][w];
ll v = 0;
if (w >= arr[i].first)
v = solve(w - arr[i].first, i + 1) + arr[i].second;
v = max(v, solve(w, i + 1));
return dp[i][w] = v;
}
int main() {
fast;
cin >> n >> wt;
arr.resize(n);
dp.resize(n, vi(wt));
REP(i, 0, n)
cin >> arr[i].first >> arr[i].second;
cout << solve(wt, 0) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define M 998244353
#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"
#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)
#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) \
for (auto i : v) \
cout << i << " ";
ll n, wt;
vii arr;
vvi dp;
ll solve(ll w, ll i) {
if (i == n)
return 0;
if (dp[i][w])
return dp[i][w];
ll v = 0;
if (w >= arr[i].first)
v = solve(w - arr[i].first, i + 1) + arr[i].second;
v = max(v, solve(w, i + 1));
return dp[i][w] = v;
}
int main() {
fast;
cin >> n >> wt;
arr.resize(n);
dp.resize(n, vi(wt + 1, 0));
REP(i, 0, n)
cin >> arr[i].first >> arr[i].second;
cout << solve(wt, 0) << endl;
return 0;
}
| [
"call.arguments.add"
] | 968,676 | 968,677 | u760200622 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll dp[100100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
int n, w;
cin >> n >> w;
int a[n], b[n];
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
for (int i = 0; i < n; i++) {
for (int j = w - a[i]; j >= 0; j--) {
dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
}
}
ll ans = 0;
for (int i = 1; i < w; i++) {
ans = max(ans, dp[i]);
}
cout << ans << endl;
return 0;
}
/*
Things to look out for:
- Integer overflows
- Array bounds
- Special cases
Be careful!
*/
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll dp[100100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
int n, w;
cin >> n >> w;
int a[n], b[n];
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
for (int i = 0; i < n; i++) {
for (int j = w - a[i]; j >= 0; j--) {
dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
}
}
ll ans = 0;
for (int i = 0; i <= w; i++) {
ans = max(ans, dp[i]);
}
cout << ans << endl;
return 0;
}
/*
Things to look out for:
- Integer overflows
- Array bounds
- Special cases
Be careful!
*/
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 968,680 | 968,681 | u626595726 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll dp[100100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
int n, w;
cin >> n >> w;
int a[n], b[n];
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
for (int i = 0; i < n; i++) {
for (int j = w - a[i]; j >= 0; j--) {
dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
}
}
ll ans = 0;
for (int i = 1; i < w; i++) {
ans = max(ans, dp[i]);
}
cout << ans << endl;
return 0;
}
/*
Things to look out for:
- Integer overflows
- Array bounds
- Special cases
Be careful!
*/
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll dp[100100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
int n, w;
cin >> n >> w;
int a[n], b[n];
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
for (int i = 0; i < n; i++) {
for (int j = w - a[i]; j >= 0; j--) {
dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
}
}
ll ans = 0;
for (int i = 1; i <= w; i++) {
ans = max(ans, dp[i]);
}
cout << ans << endl;
return 0;
}
/*
Things to look out for:
- Integer overflows
- Array bounds
- Special cases
Be careful!
*/
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 968,680 | 968,682 | u626595726 | cpp |
p03163 | #include <bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ << " " <<
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, pair<int, int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
int dp[101][100010];
int main(int argc, char const *argv[]) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, W;
cin >> n >> W;
int wt[n + 1], v[n + 1];
for (int i = 1; i <= n; i++)
cin >> wt[i] >> v[i];
for (int i = 1; i <= n; i++) {
for (int w = 1; w <= W; w++) {
if (wt[i] <= w)
dp[i][w] = max(v[i] + dp[i - 1][w - wt[i]], dp[i - 1][w]);
else
dp[i][w] = dp[i - 1][w];
}
}
cout << dp[n][W];
return 0;
} | #include <bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ << " " <<
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<int, pair<int, int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
ll dp[101][100010];
int main(int argc, char const *argv[]) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n, W;
cin >> n >> W;
ll wt[n + 1], v[n + 1];
for (int i = 1; i <= n; i++)
cin >> wt[i] >> v[i];
for (int i = 1; i <= n; i++) {
for (int w = 1; w <= W; w++) {
if (wt[i] <= w)
dp[i][w] = max(v[i] + dp[i - 1][w - wt[i]], dp[i - 1][w]);
else
dp[i][w] = dp[i - 1][w];
}
}
cout << dp[n][W];
return 0;
} | [
"variable_declaration.type.change"
] | 968,685 | 968,686 | u235034547 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
int main() {
// fastio
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, W;
cin >> n >> W;
ll weg[n];
ll val[n];
ll dp[n + 1][W + 1];
for (ll i = 0; i < n; i++) {
cin >> weg[i] >> val[i];
}
for (ll i = 0; i <= n; i++) {
for (ll w = 0; w <= W; w++) {
if (i == 0 || w == 0) {
dp[i][w] = 0;
} else if (w >= weg[i - 1]) {
dp[i][w] = max(val[i - 1] + dp[i - 1][w - weg[i - 1]], dp[i - 1][w]);
} else {
dp[i][w] = dp[i - 1][w];
}
}
// cout<<i<<endl;
}
cout << dp[n - 1][W] << endl;
return 0;
} | #include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
int main() {
// fastio
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, W;
cin >> n >> W;
ll weg[n];
ll val[n];
ll dp[n + 1][W + 1];
for (ll i = 0; i < n; i++) {
cin >> weg[i] >> val[i];
}
for (ll i = 0; i <= n; i++) {
for (ll w = 0; w <= W; w++) {
if (i == 0 || w == 0) {
dp[i][w] = 0;
} else if (w >= weg[i - 1]) {
dp[i][w] = max(val[i - 1] + dp[i - 1][w - weg[i - 1]], dp[i - 1][w]);
} else {
dp[i][w] = dp[i - 1][w];
}
}
// cout<<i<<endl;
}
cout << dp[n][W] << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 968,691 | 968,692 | u358609371 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
long long *value, *weight, dp[100005][102] = {};
int main() {
fast;
long long n, w, ans;
cin >> n >> w;
value = new long long[n + 1];
weight = new long long[n + 1];
weight[0] = value[0] = 0;
for (int i = 0; i < n; i++) {
cin >> weight[i + 1] >> value[i + 1];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (j - weight[i] >= 0)
dp[j][i] = max(dp[j][i - 1], dp[j - weight[i]][i - 1] + value[i]);
else
dp[j][i] = dp[j - 1][i - 1];
}
}
// for(int i=1; i<=w; i++){
// for(int j=1; j<=n; j++){
// cout<<dp[i][j]<<" ";
// }
// cout<<endl;
// }
cout << dp[w][n];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
long long *value, *weight, dp[100005][102] = {};
int main() {
fast;
long long n, w, ans;
cin >> n >> w;
value = new long long[n + 1];
weight = new long long[n + 1];
weight[0] = value[0] = 0;
for (int i = 0; i < n; i++) {
cin >> weight[i + 1] >> value[i + 1];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (j - weight[i] >= 0)
dp[j][i] = max(dp[j][i - 1], dp[j - weight[i]][i - 1] + value[i]);
else
dp[j][i] = dp[j][i - 1];
}
}
// for(int i=1; i<=w; i++){
// for(int j=1; j<=n; j++){
// cout<<dp[i][j]<<" ";
// }
// cout<<endl;
// }
cout << dp[w][n];
return 0;
}
| [
"expression.operation.binary.remove"
] | 968,693 | 968,694 | u511167544 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define DIM 100007
#define INF 2E60
#define MAXN 1023
#define LG 18
typedef long long ll;
typedef long double ld;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pair<ll, ll> pll;
typedef pll parr[DIM];
struct pp {
ll a, b;
bool operator<(const pp &V) const {
if (a == V.a)
return b < V.b;
return a < V.a;
}
bool operator==(const pp &V) const {
if (a == V.a && b == V.b)
return 1;
return 0;
}
};
ll n, w;
parr A;
ll D[107][DIM];
int main() {
cin >> n >> w;
for (int i = 1; i <= n; i++)
cin >> A[i].first >> A[i].second;
ll sum = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++)
D[i][j] = -INF;
}
D[0][0] = 0;
ll res = 0;
for (int i = 1; i <= n; i++) {
sum += A[i].first;
// cout << A[i].first << ' '<<A[i].second<<endl;
ll to = min(w, sum);
for (int j = 0; j <= to; j++) {
ll p = D[i - 1][j];
if (j >= A[i].first && D[i - 1][j - A[i].first] != -INF)
p = min(p, (D[i - 1][j - A[i].first] + A[i].second));
// cout << D[i - 1][j - A[i].first] <<' '<<i<<' '<<j <<' '<<A[i].second<<'
// '<<p<< endl;
D[i][j] = p;
if (j <= w)
res = max(res, p);
}
}
cout << res << endl;
}
// 11
// | #include <bits/stdc++.h>
using namespace std;
#define DIM 100007
#define INF 2E60
#define MAXN 1023
#define LG 18
typedef long long ll;
typedef long double ld;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pair<ll, ll> pll;
typedef pll parr[DIM];
struct pp {
ll a, b;
bool operator<(const pp &V) const {
if (a == V.a)
return b < V.b;
return a < V.a;
}
bool operator==(const pp &V) const {
if (a == V.a && b == V.b)
return 1;
return 0;
}
};
ll n, w;
parr A;
ll D[107][DIM];
int main() {
cin >> n >> w;
for (int i = 1; i <= n; i++)
cin >> A[i].first >> A[i].second;
ll sum = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++)
D[i][j] = -INF;
}
D[0][0] = 0;
ll res = 0;
for (int i = 1; i <= n; i++) {
sum += A[i].first;
// cout << A[i].first << ' '<<A[i].second<<endl;
ll to = min(w, sum);
for (int j = 0; j <= to; j++) {
ll p = D[i - 1][j];
if (j >= A[i].first && D[i - 1][j - A[i].first] != -INF)
p = max(p, (D[i - 1][j - A[i].first] + A[i].second));
// cout << D[i - 1][j - A[i].first] <<' '<<i<<' '<<j <<' '<<A[i].second<<'
// '<<p<< endl;
D[i][j] = p;
if (j <= w)
res = max(res, p);
}
}
cout << res << endl;
}
// 11
// | [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change"
] | 968,702 | 968,703 | u980798691 | cpp |
p03163 | #include <bits/stdc++.h>
using lli = long long int;
template <typename T> bool chmax(T &a, T b) {
if (b > a) {
a = b;
return true;
}
return false;
}
lli n, w;
std::vector<std::pair<lli, lli>> vec;
std::vector<std::vector<lli>> dp;
int main() {
std::cin >> n >> w;
vec.assign(n + 1, {0, 0});
for (lli i = 0; i < n; i++) {
std::cin >> vec[i].first >> vec[i].second;
}
dp.assign(n + 1, std::vector<lli>(w + 1, 0));
for (lli i = 1; i <= n; i++) {
for (lli p = 0; p <= w; p++) {
if (p >= vec[i].first) {
chmax(dp[i][p], dp[i - 1][p]);
chmax(dp[i][p], dp[i - 1][p - vec[i].first] + vec[i].second);
} else {
chmax(dp[i][p], dp[i - 1][p]);
}
}
}
std::cout << dp[n][w] << std::endl;
} | #include <bits/stdc++.h>
using lli = long long int;
template <typename T> bool chmax(T &a, T b) {
if (b > a) {
a = b;
return true;
}
return false;
}
lli n, w;
std::vector<std::pair<lli, lli>> vec;
std::vector<std::vector<lli>> dp;
int main() {
std::cin >> n >> w;
vec.assign(n + 1, {0, 0});
for (lli i = 0; i < n; i++) {
// std::cin >> vec[i].first >> vec[i].second;
std::cin >> vec[i + 1].first >> vec[i + 1].second;
}
dp.assign(n + 1, std::vector<lli>(w + 1, 0));
for (lli i = 1; i <= n; i++) {
for (lli p = 0; p <= w; p++) {
if (p >= vec[i].first) {
chmax(dp[i][p], dp[i - 1][p]);
chmax(dp[i][p], dp[i - 1][p - vec[i].first] + vec[i].second);
} else {
chmax(dp[i][p], dp[i - 1][p]);
}
}
}
std::cout << dp[n][w] << std::endl;
}
| [
"expression.operation.binary.add"
] | 968,710 | 968,711 | u222293734 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
long long dp[110][100100]; // do[i][j]=i番目のものまでで重さjのときの価値の最大値
int main(void) {
long long N, W;
cin >> N >> W;
long long w[N], v[N];
for (int i = 0; i < N; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < N; i++) {
for (int j = 0; j <= W; j++) {
// i番目の商品を選んだ場合
if (j - w[i] >= 0) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
}
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
using namespace std;
long long dp[110][100100]; // do[i][j]=i番目のものまでで重さjのときの価値の最大値
int main(void) {
long long N, W;
cin >> N >> W;
long long w[N], v[N];
for (int i = 0; i < N; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < N; i++) {
for (int j = 0; j <= W; j++) {
// i番目の商品を選んだ場合
if (j - w[i] >= 0) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
}
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[N][W] << endl;
} | [] | 968,712 | 968,713 | u168774513 | cpp |
p03163 | #include <stdio.h>
const int W = 1e5 + 10;
long long int max(long long int a, long long int b) { return a > b ? a : b; }
int main() {
int n, w, p, v;
long long int a[W], ans = 0;
scanf("%d%d", &n, &w);
for (int i = 0; i <= w; i++)
a[i] = 0;
for (int i = 0; i < n; i++) {
scanf("%d%d", &p, &v);
for (int j = w; j >= p; j--)
a[i] = max(a[i], a[i - p] + v);
}
for (int j = w; j >= 0; j--)
ans = max(ans, a[j]);
printf("%lld\n", ans);
} | #include <stdio.h>
const int W = 1e5 + 10;
long long int max(long long int a, long long int b) { return a > b ? a : b; }
int main() {
int n, w, p, v;
long long int a[W], ans = 0;
scanf("%d%d", &n, &w);
for (int i = 0; i <= w; i++)
a[i] = 0;
for (int i = 0; i < n; i++) {
scanf("%d%d", &p, &v);
for (int j = w; j >= p; j--)
a[j] = max(a[j], a[j - p] + v);
}
for (int j = w; j >= 0; j--)
ans = max(ans, a[j]);
printf("%lld\n", ans);
} | [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 968,714 | 968,715 | u241347678 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int n, v[101], w[101], W;
int dp[100100];
void solve() {
for (int i = 0; i < n; i++)
for (int j = W; j >= w[i]; j--)
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
printf("%d", dp[W]);
}
int main() {
cin >> n;
cin >> W;
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
solve();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int n, v[101], w[101], W;
long long dp[100100];
void solve() {
for (int i = 0; i < n; i++)
for (int j = W; j >= w[i]; j--)
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
printf("%lld", dp[W]);
}
int main() {
cin >> n;
cin >> W;
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
solve();
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 968,722 | 968,723 | u785442356 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int n, v[101], w[101], W;
int dp[100100];
void solve() {
for (int i = 0; i < n; i++)
for (int j = W; j >= w[i]; j--)
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
printf("%d", dp[W]);
}
int main() {
cin >> n;
cin >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
solve();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int n, v[101], w[101], W;
long long dp[100100];
void solve() {
for (int i = 0; i < n; i++)
for (int j = W; j >= w[i]; j--)
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
printf("%lld", dp[W]);
}
int main() {
cin >> n;
cin >> W;
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
solve();
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"literal.string.change",
"call.arguments.change",
"io.output.change",
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expressi... | 968,724 | 968,723 | u785442356 | cpp |
p03163 | // verma_ankit484
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, wt;
vector<ll> v;
vector<ll> w;
vector<vector<ll>> dp;
void knap() {
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= wt; j++) {
if (j < w[i]) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
}
}
}
cout << dp[n][wt] << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef AV
freopen("int.txt", "r", stdin);
#endif
cin >> n >> wt;
v.assign(n + 1, 0);
w.assign(n + 1, 0);
dp.assign(n + 1, vector<ll>(wt + 1, 0));
for (ll i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
knap();
return 0;
}
| // verma_ankit484
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, wt;
vector<ll> v;
vector<ll> w;
vector<vector<ll>> dp;
void knap() {
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= wt; j++) {
if (j < w[i]) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
}
}
}
cout << dp[n][wt] << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef AV
freopen("int.txt", "r", stdin);
#endif
cin >> n >> wt;
v.assign(n + 1, 0);
w.assign(n + 1, 0);
dp.assign(n + 1, vector<ll>(wt + 1, 0));
for (ll i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
knap();
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 968,725 | 968,726 | u090859759 | cpp |
p03163 | #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
void pairsort(int a[], int b[], int n) {
pair<int, int> pairt[n];
for (int i = 0; i < n; i++) {
pairt[i].first = a[i];
pairt[i].second = b[i];
}
sort(pairt, pairt + n);
for (int i = 0; i < n; i++) {
a[i] = pairt[i].first;
b[i] = pairt[i].second;
}
}
int main() {
int n, w;
cin >> n >> w;
int wt[n], values[n];
for (int i = 0; i < n; i++)
cin >> wt[i] >> values[i];
pairsort(wt, values, n);
int knapsack[n + 1][w + 1];
for (int i = 0; i <= n; i++)
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
knapsack[i][j] = 0;
else if (j >= wt[i - 1]) {
knapsack[i][j] = max(values[i - 1] + knapsack[i - 1][j - wt[i - 1]],
knapsack[i - 1][j]);
} else
knapsack[i][j] = knapsack[i - 1][j];
}
cout << knapsack[n][w];
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
void pairsort(int a[], int b[], int n) {
pair<int, int> pairt[n];
for (int i = 0; i < n; i++) {
pairt[i].first = a[i];
pairt[i].second = b[i];
}
sort(pairt, pairt + n);
for (int i = 0; i < n; i++) {
a[i] = pairt[i].first;
b[i] = pairt[i].second;
}
}
int main() {
int n, w;
cin >> n >> w;
int wt[n], values[n];
for (int i = 0; i < n; i++)
cin >> wt[i] >> values[i];
pairsort(wt, values, n);
long long int knapsack[n + 1][w + 1];
for (int i = 0; i <= n; i++)
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
knapsack[i][j] = 0;
else if (j >= wt[i - 1]) {
knapsack[i][j] = max(values[i - 1] + knapsack[i - 1][j - wt[i - 1]],
knapsack[i - 1][j]);
} else
knapsack[i][j] = knapsack[i - 1][j];
}
cout << knapsack[n][w];
}
| [
"variable_declaration.type.widen.change"
] | 968,737 | 968,738 | u278938713 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
const int mod = (int)1e9 + 7;
const int MANY = 1 << 30;
const int N = (int)1e5 + 10;
int a[N][3], n, m;
int d[N];
int32_t main() {
//#ifndef QQQ
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
//#endif
#ifdef QQQ
freopen("../input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(11);
cerr << fixed << setprecision(6);
cin >> n >> m;
vector<int> w(n), c(n);
for (int i = 0; i < n; ++i) {
cin >> w[i] >> c[i];
}
for (int i = 0; i < n; ++i) {
for (int j = m - w[i]; j >= 0; --j) {
uax(d[j + w[i]], d[j] + c[i]);
}
}
int ans = -MANY;
for (int k = 0; k <= m; ++k) {
uax(ans, d[k]);
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
const int mod = (int)1e9 + 7;
const int MANY = 1 << 30;
const int N = (int)1e5 + 10;
int a[N][3], n, m;
int64_t d[N];
int32_t main() {
//#ifndef QQQ
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
//#endif
#ifdef QQQ
freopen("../input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(11);
cerr << fixed << setprecision(6);
cin >> n >> m;
vector<int> w(n), c(n);
for (int i = 0; i < n; ++i) {
cin >> w[i] >> c[i];
}
for (int i = 0; i < n; ++i) {
for (int j = m - w[i]; j >= 0; --j) {
uax(d[j + w[i]], d[j] + c[i]);
}
}
int64_t ans = -MANY;
for (int k = 0; k <= m; ++k) {
uax(ans, d[k]);
}
cout << ans;
} | [
"variable_declaration.type.primitive.change"
] | 968,742 | 968,743 | u407516534 | cpp |
p03163 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
vector<pair<int, int>> all(n);
for (int i = 0; i < n; i++) {
cin >> all[i].first >> all[i].second;
}
sort(all.begin(), all.end());
vector<vector<int>> dp(n + 1, vector<int>(w + 1, 0));
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else {
if (j >= all[i - 1].first)
dp[i][j] = max(all[i - 1].second + dp[i - 1][j - all[i - 1].first],
dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w];
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, w;
cin >> n >> w;
vector<pair<int, int>> all(n);
for (int i = 0; i < n; i++) {
cin >> all[i].first >> all[i].second;
}
sort(all.begin(), all.end());
vector<vector<unsigned long long>> dp(n + 1,
vector<unsigned long long>(w + 1, 0));
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
if (i == 0 || j == 0)
dp[i][j] = 0;
else {
if (j >= all[i - 1].first)
dp[i][j] = max(all[i - 1].second + dp[i - 1][j - all[i - 1].first],
dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w];
} | [
"variable_declaration.type.primitive.change"
] | 968,748 | 968,749 | u416986249 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.