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>
#include <iostream>
using namespace std;
int knapSack(long long int W[], long long int V[], long long int n,
long long int w) {
long long int res[n + 1][w + 1];
for (long long int i = 0; i <= w; i++) {
res[0][i] = 0;
}
for (long long int j = 0; j <= n; j++) {
res[j][0] = 0;
}
for (long long int i = 1; i <= n; i++) {
for (long long int j = 1; j <= w; j++) {
if (W[i - 1] <= j) {
res[i][j] = max(res[i - 1][j], V[i - 1] + res[i - 1][j - W[i - 1]]);
} else {
res[i][j] = res[i - 1][j];
}
}
}
return res[n][w];
}
int main() {
long long int n, w;
cin >> n >> w;
long long int W[n], V[n];
for (long long int i = 0; i < n; i++) {
cin >> W[i] >> V[i];
}
cout << knapSack(W, V, n, w) << endl;
return 0;
}
| #include <bits/stdc++.h>
#include <iostream>
using namespace std;
long long int knapSack(long long int W[], long long int V[], long long int n,
long long int w) {
long long int res[n + 1][w + 1];
for (long long int i = 0; i <= w; i++) {
res[0][i] = 0;
}
for (long long int j = 0; j <= n; j++) {
res[j][0] = 0;
}
for (long long int i = 1; i <= n; i++) {
for (long long int j = 1; j <= w; j++) {
if (W[i - 1] <= j) {
res[i][j] = max(res[i - 1][j], V[i - 1] + res[i - 1][j - W[i - 1]]);
} else {
res[i][j] = res[i - 1][j];
}
}
}
return res[n][w];
}
int main() {
long long int n, w;
cin >> n >> w;
long long int W[n], V[n];
for (long long int i = 0; i < n; i++) {
cin >> W[i] >> V[i];
}
cout << knapSack(W, V, n, w) << endl;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 967,296 | 967,297 | u624791303 | cpp |
p03163 | #include <algorithm>
#include <climits>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
vector<vector<int>> f;
int w[103], v[103];
int n, W;
int main() {
cin >> n >> W;
f.assign(n + 1, vector<int>(W + 1, 0));
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++)
for (int j = 0; j <= W; j++) {
f[i][j] = f[i - 1][j];
if (j >= w[i])
f[i][j] = max(f[i][j], f[i - 1][j - w[i]] + v[i]);
}
cout << f[n][W];
return 0;
}
| #include <algorithm>
#include <climits>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
vector<vector<long long>> f;
int w[103], v[103];
int n, W;
int main() {
cin >> n >> W;
f.assign(n + 1, vector<long long>(W + 1, 0));
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++)
for (int j = 0; j <= W; j++) {
f[i][j] = f[i - 1][j];
if (j >= w[i])
f[i][j] = max(f[i][j], f[i - 1][j - w[i]] + v[i]);
}
cout << f[n][W];
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,300 | 967,301 | u226546224 | cpp |
p03163 | #include <bits/stdc++.h>
#define pb push_back
#define pair pair<int, int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi = acos(-1.0);
int main() {
int n, w;
scanf("%d %d", &n, &w);
vector<pair> v(n + 1);
for (int i = 1; i <= n; i++)
scanf("%d %d", &v[i].f, &v[i].se);
auto it = v.begin();
it++;
sort(it, v.end());
ll ans[n + 1][w + 1];
for (int i = 0; i <= n; i++)
ans[i][0] = 0;
for (int i = 0; i <= w; i++)
ans[0][i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
// cout<<v[i].f<<" "<<v[i].se<<"\n";
if (v[i].f > j)
ans[i][j] = ans[i - 1][j];
else
ans[i][j] = max(ans[i - 1][j], ans[i - 1][j - v[i].f] + v[i].se);
}
}
/* for(int i=0;i<=n;i++)
{
for(int j=0;j<=w;j++)
printf("%d ",ans[i][j]);
printf("\n");
}*/
printf("%d", ans[n][w]);
} | #include <bits/stdc++.h>
#define pb push_back
#define pair pair<int, int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi = acos(-1.0);
int main() {
int n, w;
scanf("%d %d", &n, &w);
vector<pair> v(n + 1);
for (int i = 1; i <= n; i++)
scanf("%d %d", &v[i].f, &v[i].se);
auto it = v.begin();
it++;
sort(it, v.end());
ll ans[n + 1][w + 1];
for (int i = 0; i <= n; i++)
ans[i][0] = 0;
for (int i = 0; i <= w; i++)
ans[0][i] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
// cout<<v[i].f<<" "<<v[i].se<<"\n";
if (v[i].f > j)
ans[i][j] = ans[i - 1][j];
else
ans[i][j] = max(ans[i - 1][j], ans[i - 1][j - v[i].f] + v[i].se);
}
}
/* for(int i=0;i<=n;i++)
{
for(int j=0;j<=w;j++)
printf("%d ",ans[i][j]);
printf("\n");
}*/
printf("%lli", ans[n][w]);
} | [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 967,302 | 967,303 | u768104057 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
int n, w;
cin >> n >> w;
vector<int> weights(n);
vector<int> values(n);
vector<pair<int, int>> ipair(n);
for (int i = 0; i < n; i++) {
cin >> weights[i] >> values[i];
ipair[i] = make_pair(weights[i], values[i]);
}
sort(ipair.begin(), ipair.end());
vector<vector<int>> dp(n + 1, vector<int>(w + 1, 0));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
int p = ipair[i - 1].first;
int q = ipair[i - 1].second;
if (p <= j) {
dp[i][j] = max(dp[i - 1][j], q + dp[i - 1][j - p]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int32_t main() {
int n, w;
cin >> n >> w;
vector<int> weights(n);
vector<int> values(n);
vector<pair<int, int>> ipair(n);
for (int i = 0; i < n; i++) {
cin >> weights[i] >> values[i];
ipair[i] = make_pair(weights[i], values[i]);
}
sort(ipair.begin(), ipair.end());
vector<vector<long long>> dp(n + 1, vector<long long>(w + 1, 0));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
int p = ipair[i - 1].first;
int q = ipair[i - 1].second;
if (p <= j) {
dp[i][j] = max(dp[i - 1][j], q + dp[i - 1][j - p]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w];
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,304 | 967,305 | u636031746 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int n;
int W;
long long w[128], v[128];
long long dp[128][101000];
int main() {
cin >> n >> W;
for (int i = 1; i <= n; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= w[i]; ++j)
dp[i][j] = dp[i - 1][j];
for (int j = w[i]; j <= W; ++j) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
}
}
long long ans = 0;
for (int i = 1; i <= W; ++i)
ans = max(ans, dp[n][i]);
cout << ans << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int n;
int W;
long long w[128], v[128];
long long dp[128][101000];
int main() {
cin >> n >> W;
for (int i = 1; i <= n; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= w[i]; ++j)
dp[i][j] = dp[i - 1][j];
for (int j = w[i]; j <= W; ++j) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
}
}
long long ans = 0;
for (int i = 1; i <= W; ++i)
ans = max(ans, dp[n][i]);
cout << ans << "\n";
return 0;
} | [
"assignment.change"
] | 967,306 | 967,307 | u262428225 | cpp |
p03163 | #include <iostream>
#include <vector>
using namespace std;
inline bool chmax(long long a, long long b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int max(long long x, long long y) { return (x > y) ? x : y; }
int main() {
int n;
long long W;
cin >> n;
cin >> W;
vector<long long> weight(n), value(n);
for (int i = 0; i < n; i++) {
cin >> weight[i] >> value[i];
}
vector<vector<long long>> dp(n + 2, vector<long long>(100100, 0));
// sort(x,n);
for (int i = 0; i < n; i++) {
for (int j = 0; j <= W; j++) {
if (j >= weight[i]) {
// dp[i][j] = max( dp[i-1][j] , dp[i-1][j - x[i].weight] + x[i].value);
chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);
}
chmax(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[n][W];
}
| #include <iostream>
#include <vector>
using namespace std;
inline bool chmax(long long &a, long long b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int max(long long x, long long y) { return (x > y) ? x : y; }
int main() {
int n;
long long W;
cin >> n;
cin >> W;
vector<long long> weight(n), value(n);
for (int i = 0; i < n; i++) {
cin >> weight[i] >> value[i];
}
vector<vector<long long>> dp(n + 2, vector<long long>(100100, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j <= W; j++) {
if (j >= weight[i]) {
chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);
}
chmax(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[n][W];
}
| [] | 967,308 | 967,309 | u465135730 | cpp |
p03163 | #include <bits/stdc++.h>
#define LL long long
#define re register
#define SIZE 105
using namespace std;
template <typename T> inline void read(T &x) {
int f;
char c;
x = 0, f = 0, c = getchar();
while (c < '0' && '9' < c)
f |= (c == '-'), c = getchar();
while ('0' <= c && c <= '9')
x = (x << 3) + (x << 1) + c - 48, c = getchar();
x = f ? -x : x;
}
int n, W;
int w[SIZE];
LL v[SIZE];
LL dp[SIZE], ans = 0;
int main() {
read(n);
read(W);
for (re int i = 1; i <= n; ++i)
read(w[i]), read(v[i]);
for (re int i = 1; i <= n; ++i)
for (re int j = W; j >= 1; --j)
if (j - w[i] >= 0)
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
else
break;
for (re int i = 1; i <= W; ++i)
ans = max(ans, dp[i]);
printf("%d\n", ans);
return 0;
} | #include <bits/stdc++.h>
#define LL long long
#define re register
#define SIZE 105
using namespace std;
template <typename T> inline void read(T &x) {
int f;
char c;
x = 0, f = 0, c = getchar();
while (c < '0' && '9' < c)
f |= (c == '-'), c = getchar();
while ('0' <= c && c <= '9')
x = (x << 3) + (x << 1) + c - 48, c = getchar();
x = f ? -x : x;
}
int n, W;
int w[SIZE];
LL v[SIZE];
LL dp[10000005], ans = 0;
int main() {
read(n);
read(W);
for (re int i = 1; i <= n; ++i)
read(w[i]), read(v[i]);
for (re int i = 1; i <= n; ++i)
for (re int j = W; j >= 1; --j)
if (j - w[i] >= 0)
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
else
break;
for (re int i = 1; i <= W; ++i)
ans = max(ans, dp[i]);
printf("%lld\n", ans);
return 0;
} | [
"identifier.replace.remove",
"literal.replace.add",
"variable_declaration.array_dimensions.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 967,317 | 967,318 | u714811652 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int maxn = 100 + 10;
const int maxw = 1e5 + 10;
template <typename T> void read(T &x) {
T f = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 3) + (x << 1) + c - 48;
c = getchar();
}
x *= f;
}
int n, W;
int w[maxn], v[maxn];
int f[maxw];
int main() {
read(n);
read(W);
for (re int i = 1; i <= n; i++) {
read(w[i]);
read(v[i]);
}
for (re int i = 1; i <= n; i++) {
for (re int j = W; j >= w[i]; j--) {
f[j] = max(f[j], f[j - w[i]] + v[i]);
}
}
cout << f[W] << endl;
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int maxn = 100 + 10;
const int maxw = 1e5;
template <typename T> void read(T &x) {
T f = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 3) + (x << 1) + c - 48;
c = getchar();
}
x *= f;
}
ll n, W;
ll w[maxn], v[maxn];
ll f[maxw];
int main() {
read(n);
read(W);
for (re int i = 1; i <= n; i++) {
read(w[i]);
read(v[i]);
}
for (re int i = 1; i <= n; i++) {
for (re int j = W; j >= w[i]; j--) {
f[j] = max(f[j], f[j - w[i]] + v[i]);
}
}
cout << f[W] << endl;
return 0;
}
| [
"expression.operation.binary.remove",
"variable_declaration.type.change"
] | 967,319 | 967,320 | u343169347 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
const int N = 105, M = 1e6 + 123;
int n, s;
int w[N], a[N], can[M], dp[M], ans;
int main() {
cin >> n >> s;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> a[i];
}
can[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = s - 1; j >= 0; j--) {
if (can[j]) {
can[j + w[i]] = 1;
dp[j + w[i]] = max(dp[j + w[i]], dp[j] + a[i]);
if (j + w[i] <= s)
ans = max(ans, dp[j + w[i]]);
}
}
}
cout << ans;
}
| #include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 105, M = 1e6 + 123;
int n, s;
int w[N], a[N], can[M], dp[M], ans;
main() {
cin >> n >> s;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> a[i];
}
can[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = s - 1; j >= 0; j--) {
if (can[j]) {
can[j + w[i]] = 1;
dp[j + w[i]] = max(dp[j + w[i]], dp[j] + a[i]);
if (j + w[i] <= s)
ans = max(ans, dp[j + w[i]]);
}
}
}
cout << ans;
}
| [
"function.return_value.remove"
] | 967,321 | 967,322 | u909486901 | cpp |
p03163 | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9 + 7;
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
for (auto &i : v)
os << i << " ";
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &i : v)
is >> i;
return is;
}
template <typename K, typename V>
ostream &operator<<(ostream &os, unordered_map<K, V> m) {
for (auto &i : m)
os << i.first << ":" << i.second << endl;
return os;
}
template <typename T> inline bool chmin(T &x, T y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T> inline bool chmax(T &x, T y) {
if (x < y) {
x = y;
return true;
}
return false;
}
int N, W, w[101], v[101];
ll dp[101][200020];
int main() {
cin >> N;
rep(i, 0, N) cin >> w[i] >> v[i];
rep(i, 0, N) rep(tot, 0, W) {
chmax(dp[i + 1][tot], dp[i][tot]);
chmax(dp[i + 1][tot + w[i]], dp[i][tot] + v[i]);
}
ll res = 0;
rep(tot, 0, W + 1) chmax(res, dp[N][tot]);
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9 + 7;
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
for (auto &i : v)
os << i << " ";
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &i : v)
is >> i;
return is;
}
template <typename K, typename V>
ostream &operator<<(ostream &os, unordered_map<K, V> m) {
for (auto &i : m)
os << i.first << ":" << i.second << endl;
return os;
}
template <typename T> inline bool chmin(T &x, T y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T> inline bool chmax(T &x, T y) {
if (x < y) {
x = y;
return true;
}
return false;
}
int N, W, w[101], v[101];
ll dp[101][200020];
int main() {
cin >> N >> W;
rep(i, 0, N) cin >> w[i] >> v[i];
rep(i, 0, N) rep(tot, 0, W) {
chmax(dp[i + 1][tot], dp[i][tot]);
chmax(dp[i + 1][tot + w[i]], dp[i][tot] + v[i]);
}
ll res = 0;
rep(tot, 0, W + 1) chmax(res, dp[N][tot]);
cout << res << endl;
return 0;
}
| [
"expression.operation.binary.add"
] | 967,323 | 967,324 | u171804186 | cpp |
p03163 | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9 + 7;
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
for (auto &i : v)
os << i << " ";
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &i : v)
is >> i;
return is;
}
template <typename K, typename V>
ostream &operator<<(ostream &os, unordered_map<K, V> m) {
for (auto &i : m)
os << i.first << ":" << i.second << endl;
return os;
}
template <typename T> inline bool chmin(T &x, T y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T> inline bool chmax(T &x, T y) {
if (x < y) {
x = y;
return true;
}
return false;
}
int N, W, w[101], v[101];
ll dp[101][100010];
int main() {
cin >> N;
rep(i, 0, N) cin >> w[i] >> v[i];
rep(i, 0, N) rep(tot, 0, W) {
chmax(dp[i + 1][tot], dp[i][tot]);
chmax(dp[i + 1][tot + w[i]], dp[i][tot] + v[i]);
}
ll res = 0;
rep(tot, 0, W + 1) chmax(res, dp[N][tot]);
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9 + 7;
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
for (auto &i : v)
os << i << " ";
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (auto &i : v)
is >> i;
return is;
}
template <typename K, typename V>
ostream &operator<<(ostream &os, unordered_map<K, V> m) {
for (auto &i : m)
os << i.first << ":" << i.second << endl;
return os;
}
template <typename T> inline bool chmin(T &x, T y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T> inline bool chmax(T &x, T y) {
if (x < y) {
x = y;
return true;
}
return false;
}
int N, W, w[101], v[101];
ll dp[101][200020];
int main() {
cin >> N >> W;
rep(i, 0, N) cin >> w[i] >> v[i];
rep(i, 0, N) rep(tot, 0, W) {
chmax(dp[i + 1][tot], dp[i][tot]);
chmax(dp[i + 1][tot + w[i]], dp[i][tot] + v[i]);
}
ll res = 0;
rep(tot, 0, W + 1) chmax(res, dp[N][tot]);
cout << res << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 967,325 | 967,324 | u171804186 | cpp |
p03163 | #include <bits/stdc++.h>
#include <cstring>
using namespace std;
const int Nmax = 105;
typedef long long ll;
struct {
int weight;
ll cost;
} a[Nmax];
int N, W;
inline ll Max(ll a, ll b) { return (a > b) ? a : b; }
int main() {
cin >> N >> W;
for (int i = 1; i <= N; ++i)
cin >> a[i].weight >> a[i].cost;
vector<int> dp(W + 1, 0), dp0(W + 1, 0);
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= W; ++j)
if (a[i].weight <= j)
dp[j] = Max(dp0[j], dp0[j - a[i].weight] + a[i].cost);
else
dp[j] = dp0[j];
dp0 = dp;
}
cout << dp0[W];
return 0;
}
| #include <bits/stdc++.h>
#include <cstring>
using namespace std;
const int Nmax = 105;
typedef long long ll;
struct {
int weight;
ll cost;
} a[Nmax];
int N, W;
const inline ll Max(ll a, ll b) { return (a > b) ? a : b; }
int main() {
cin >> N >> W;
for (int i = 1; i <= N; ++i)
cin >> a[i].weight >> a[i].cost;
vector<ll> dp(W + 1, 0), dp0(W + 1, 0);
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= W; ++j)
if (a[i].weight <= j)
dp[j] = Max(dp0[j], dp0[j - a[i].weight] + a[i].cost);
else
dp[j] = dp0[j];
dp0 = dp;
}
cout << dp0[W];
return 0;
}
| [] | 967,328 | 967,329 | u361594188 | cpp |
p03163 | #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace std;
const int Max_N = 1e2 + 10;
const int Max_W = 1e5 + 10;
const int Max_value = 1e5 + 10;
int v[Max_value];
int w[Max_W];
int dp[Max_N][Max_W];
int main() {
int N;
cin >> N;
int W;
cin >> W;
for (int i = 1; i <= N; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= W; 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[N][W];
return 0;
}
| #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace std;
const int Max_N = 1e2 + 10;
const int Max_W = 1e5 + 10;
const int Max_value = 1e5 + 10;
long long v[Max_value];
int w[Max_W];
long long dp[Max_N][Max_W];
int main() {
int N;
cin >> N;
int W;
cin >> W;
for (int i = 1; i <= N; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= W; 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[N][W];
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,330 | 967,331 | u449291092 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265
// typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP(a, b) make_pair(a, b)
#define MOD 1000000007LL
#define INF 1000000000
#define rep(a, i, b) for (ll i = (a); i < (b); ++i)
#define reps(a, i, b) for (ll i = (a); i <= (b); ++i)
#define repd(num, i, ed) for (ll(i) = (num)-1; (i) >= e38d; --(i))
#define repkt(bg, i, num, kt) for (ll(i) = (bg); (i) < (num) && (kt); ++(i))
#define repchar(i) for (char(i) = 48; (i) <= 122; (i)++)
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a, n) \
for (ll i = 0, j = sizeof(a) / sizeof(a[0]); i < j; ++i) \
a[i] = n;
#define repe(num, i, ed) for (ll(i) = (num); (i) >= ed; --(i))
#define endl "\n"
const int mod = 1e9 + 7;
int n, W;
void max_(int &a, int b) { a = max(a, b); }
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
cin >> n >> W;
vector<int> dp(W + 1);
for (int item = 0; item < n; ++item) {
int w, val;
cin >> w >> val;
for (int i = W - w; i >= 0; --i)
max_(dp[i + w], dp[i] + val);
}
sort(dp.begin(), dp.end());
cout << dp.back() << endl;
// for(auto x:dp) cout<<x<<" ";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265
// typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP(a, b) make_pair(a, b)
#define MOD 1000000007LL
#define INF 1000000000
#define rep(a, i, b) for (ll i = (a); i < (b); ++i)
#define reps(a, i, b) for (ll i = (a); i <= (b); ++i)
#define repd(num, i, ed) for (ll(i) = (num)-1; (i) >= e38d; --(i))
#define repkt(bg, i, num, kt) for (ll(i) = (bg); (i) < (num) && (kt); ++(i))
#define repchar(i) for (char(i) = 48; (i) <= 122; (i)++)
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a, n) \
for (ll i = 0, j = sizeof(a) / sizeof(a[0]); i < j; ++i) \
a[i] = n;
#define repe(num, i, ed) for (ll(i) = (num); (i) >= ed; --(i))
#define endl "\n"
const int mod = 1e9 + 7;
ll n, W;
void max_(ll &a, ll b) { a = max(a, b); }
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
cin >> n >> W;
vector<ll> dp(W + 1);
for (int item = 0; item < n; ++item) {
ll w, val;
cin >> w >> val;
for (int i = W - w; i >= 0; --i)
max_(dp[i + w], dp[i] + val);
}
sort(dp.begin(), dp.end());
cout << dp.back() << endl;
// for(auto x:dp) cout<<x<<" ";
return 0;
} | [
"variable_declaration.type.change"
] | 967,332 | 967,333 | u254886300 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, wt;
cin >> n >> wt;
int *w = new int[n];
int *v = new int[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < n - 1; i++) {
int m = i;
for (int j = i + 1; j < n; j++) {
if (w[m] > w[j])
m = j;
}
if (m != i) {
swap(w[m], w[i]);
swap(v[m], v[i]);
}
}
long long dp[n + 1][wt + 1];
for (int i = 0; i <= n; i++) {
dp[i][0] = 0;
}
for (int i = 1; i <= wt; i++)
dp[0][i] = 0;
int m = 0;
for (int i = 1; i <= n; i++) {
int t = w[i - 1];
for (int j = 0; j < t; j++) {
dp[i][j] = dp[i - 1][j];
}
for (int j = t; j <= wt; j++) {
dp[i][j] = max(dp[i - 1][j], v[i - 1] + dp[i - 1][j - t]);
if (m < dp[i][j])
m = dp[i][j];
}
}
cout << m;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, wt;
cin >> n >> wt;
int *w = new int[n];
int *v = new int[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
for (int i = 0; i < n - 1; i++) {
int m = i;
for (int j = i + 1; j < n; j++) {
if (w[m] > w[j])
m = j;
}
if (m != i) {
swap(w[m], w[i]);
swap(v[m], v[i]);
}
}
long long dp[n + 1][wt + 1];
for (int i = 0; i <= n; i++) {
dp[i][0] = 0;
}
for (int i = 1; i <= wt; i++)
dp[0][i] = 0;
long long m = 0;
for (int i = 1; i <= n; i++) {
int t = w[i - 1];
for (int j = 0; j < t; j++) {
dp[i][j] = dp[i - 1][j];
}
for (int j = t; j <= wt; j++) {
dp[i][j] = max(dp[i - 1][j], v[i - 1] + dp[i - 1][j - t]);
if (m < dp[i][j])
m = dp[i][j];
}
}
cout << m;
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,334 | 967,335 | u601256119 | cpp |
p03163 | #include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define p(s) std::cout << s;
#define pl(s) std::cout << s << endl;
#define printIf(j, s1, s2) cout << (j ? s1 : s2) << endl;
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
#define all(v) v.begin(), v.end()
#define showVector(v) \
REP(i, v.size()) { \
p(v[i]); \
p(" ") \
} \
pl("")
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;
}
typedef long long int ll;
typedef pair<int, int> P_ii;
typedef pair<double, double> P_dd;
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
const int mod = 1000000007;
const int MOD = 1000000007;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
void addM(long long &a, long long b) {
a += b;
if (a >= MOD)
a -= MOD;
}
void mulM(long long &a, long long b) { a = ((a % MOD) * (b % MOD)) % MOD; }
// a^b mod M
long myPow(long a, long b, int M) {
long ret = 1;
long tmp = a;
while (b > 0) {
if ((b & 1) == 1)
ret = (ret * tmp) % M;
tmp = (tmp * tmp) % M;
b = b >> 1;
}
return ret;
}
// nCk mod M
int nCk(int n, int k, int M) {
long ret = 1;
int mi = min(k, n - k);
for (int i = 1; i <= mi; i++) {
ret = (ret * myPow(i, M - 2, M)) % M;
}
for (int i = n - mi + 1; i <= n; i++) {
ret = (ret * i) % M;
}
return (int)ret;
}
int main() {
int N, W;
cin >> N >> W;
auto dp = make_vec<int>(N + 1, W + 1);
fill_v(dp, 0);
vector<int> weight(N), value(N);
REP(i, N) cin >> weight[i] >> value[i];
REP(i, N) REP(j, W + 1) {
if (j < weight[i]) {
dp[i + 1][j] = dp[i][j];
} else {
dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
}
}
pl(dp[N][W])
return 0;
} | #include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define p(s) std::cout << s;
#define pl(s) std::cout << s << endl;
#define printIf(j, s1, s2) cout << (j ? s1 : s2) << endl;
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
#define all(v) v.begin(), v.end()
#define showVector(v) \
REP(i, v.size()) { \
p(v[i]); \
p(" ") \
} \
pl("")
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;
}
typedef long long int ll;
typedef pair<int, int> P_ii;
typedef pair<double, double> P_dd;
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
const int mod = 1000000007;
const int MOD = 1000000007;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
void addM(long long &a, long long b) {
a += b;
if (a >= MOD)
a -= MOD;
}
void mulM(long long &a, long long b) { a = ((a % MOD) * (b % MOD)) % MOD; }
// a^b mod M
long myPow(long a, long b, int M) {
long ret = 1;
long tmp = a;
while (b > 0) {
if ((b & 1) == 1)
ret = (ret * tmp) % M;
tmp = (tmp * tmp) % M;
b = b >> 1;
}
return ret;
}
// nCk mod M
int nCk(int n, int k, int M) {
long ret = 1;
int mi = min(k, n - k);
for (int i = 1; i <= mi; i++) {
ret = (ret * myPow(i, M - 2, M)) % M;
}
for (int i = n - mi + 1; i <= n; i++) {
ret = (ret * i) % M;
}
return (int)ret;
}
int main() {
int N, W;
cin >> N >> W;
auto dp = make_vec<ll>(N + 1, W + 1);
fill_v(dp, 0);
vector<ll> weight(N), value(N);
REP(i, N) cin >> weight[i] >> value[i];
REP(i, N) REP(j, W + 1) {
if (j < weight[i]) {
dp[i + 1][j] = dp[i][j];
} else {
dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
}
}
pl(dp[N][W])
return 0;
} | [] | 967,339 | 967,340 | u491550356 | cpp |
p03163 | #include <iostream>
using namespace std;
main() {
int n;
cin >> n;
int W;
cin >> W;
int weight[n], value[n];
for (int ii = 0; ii < n; ii++)
cin >> weight[ii] >> value[ii];
int dp[n + 2][W + 2];
for (int ii = 0; ii <= n; ii++) {
for (int jj = 0; jj <= W; jj++) {
dp[ii][jj] = 0;
}
}
for (int ii = 0; ii < n; ii++) {
for (int jj = 0; jj <= W; jj++) {
if (jj - weight[ii] >= 0)
dp[ii + 1][jj] = max(dp[ii][jj], dp[ii][jj - weight[ii]] + value[ii]);
else
dp[ii + 1][jj] = dp[ii][jj];
}
}
cout << dp[n][W] << endl;
}
| #include <iostream>
using namespace std;
main() {
int n;
cin >> n;
int W;
cin >> W;
int weight[n], value[n];
for (int ii = 0; ii < n; ii++)
cin >> weight[ii] >> value[ii];
long dp[n + 2][W + 2];
for (int ii = 0; ii <= n; ii++) {
for (int jj = 0; jj <= W; jj++) {
dp[ii][jj] = 0;
}
}
for (int ii = 0; ii < n; ii++) {
for (int jj = 0; jj <= W; jj++) {
if (jj - weight[ii] >= 0)
dp[ii + 1][jj] = max(dp[ii][jj], dp[ii][jj - weight[ii]] + value[ii]);
else
dp[ii + 1][jj] = dp[ii][jj];
}
}
cout << dp[n][W] << endl;
}
| [
"variable_declaration.type.primitive.change"
] | 967,345 | 967,346 | u346834985 | cpp |
p03163 | #include <iostream>
using namespace std;
main() {
int n;
int W;
cin >> n;
cin >> W;
int weight[n];
int value[n];
for (int ii = 0; ii < n; ii++) {
cin >> weight[ii];
cin >> value[ii];
}
long dp[n + 1][W + 1];
for (int ii = 0; ii < n; ii++) {
for (int jj = 0; jj < W; jj++) {
dp[ii][jj] = 0;
}
}
for (int ii = 0; ii < W; ii++) {
dp[0][ii] = 0;
}
for (int ii = 0; ii < n; ii++) {
for (int jj = 0; jj <= W; jj++) {
if (jj - weight[ii] >= 0)
dp[ii + 1][jj] = max(dp[ii][jj], dp[ii][jj - weight[ii]] + value[ii]);
else
dp[ii + 1][jj] = dp[ii][jj];
}
}
cout << dp[n][W] << endl;
// for(int ii=0;ii<n+1;ii++){
// for(int jj=0;jj<W+1;jj++){
// cout << dp[ii][jj] << " ";
// }
// cout<<endl;
// }
}
| #include <iostream>
using namespace std;
main() {
int n;
int W;
cin >> n;
cin >> W;
int weight[n];
int value[n];
for (int ii = 0; ii < n; ii++) {
cin >> weight[ii];
cin >> value[ii];
}
long dp[n + 1][W + 1];
for (int ii = 0; ii < n + 1; ii++) {
for (int jj = 0; jj < W + 1; jj++) {
dp[ii][jj] = 0;
}
}
for (int ii = 0; ii < W; ii++) {
dp[0][ii] = 0;
}
for (int ii = 0; ii < n; ii++) {
for (int jj = 0; jj <= W; jj++) {
if (jj - weight[ii] >= 0)
dp[ii + 1][jj] = max(dp[ii][jj], dp[ii][jj - weight[ii]] + value[ii]);
else
dp[ii + 1][jj] = dp[ii][jj];
}
}
cout << dp[n][W] << endl;
// for(int ii=0;ii<n+1;ii++){
// for(int jj=0;jj<W+1;jj++){
// cout << dp[ii][jj] << " ";
// }
// cout<<endl;
// }
}
| [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 967,347 | 967,348 | u346834985 | cpp |
p03163 | #include <iostream>
using namespace std;
main() {
int N, W;
cin >> N >> W;
int w[N], v[N];
for (int ii = 0; ii < N; ii++) {
cin >> w[ii] >> v[ii];
}
int dp[N + 1][W + 1];
for (int ii = 0; ii < N + 1; ii++) {
for (int jj = 0; jj < W + 1; jj++) {
dp[ii][jj] = 0;
}
}
dp[0][0] = 0;
for (int ii = 0; ii < N; ii++) {
for (int jj = 0; jj < W + 1; jj++) {
if (jj >= w[ii])
dp[ii + 1][jj] = max(dp[ii + 1][jj], dp[ii][jj - w[ii]] + v[ii]);
else
dp[ii + 1][jj] = max(dp[ii + 1][jj], dp[ii][jj]);
}
}
cout << dp[N][W] << endl;
}
| #include <iostream>
using namespace std;
main() {
int N, W;
cin >> N >> W;
int w[N], v[N];
for (int ii = 0; ii < N; ii++) {
cin >> w[ii] >> v[ii];
}
long dp[N + 1][W + 1];
for (int ii = 0; ii < N + 1; ii++) {
for (int jj = 0; jj < W + 1; jj++) {
dp[ii][jj] = 0;
}
}
dp[0][0] = 0;
for (int ii = 0; ii < N; ii++) {
for (int jj = 0; jj < W + 1; jj++) {
if (jj >= w[ii])
dp[ii + 1][jj] = max(dp[ii + 1][jj], dp[ii][jj - w[ii]] + v[ii]);
dp[ii + 1][jj] = max(dp[ii + 1][jj], dp[ii][jj]);
}
}
cout << dp[N][W] << endl;
}
| [
"variable_declaration.type.primitive.change",
"control_flow.branch.else.remove"
] | 967,349 | 967,350 | u346834985 | cpp |
p03163 | /*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX XXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX X
X XXX XX XXXX XXXX X XXX XXX XXXX XXXX XXXX XXXXXX X
X XXXXXXXXX XXX XXX XXXXX XXX XXX XXXXXXX XX XX XXX XX X
X XXXXX XXX XXX XXXXX XXX XXX XXX XXX XXX X XXX X
X XXX X XXX XXX XXX XXXXX XXX XXX XXX XXX XXX XXX XXXXX XXX X
XX XXX XX XXX XX XX XXX XXX XXX XX X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX XXXX XX X XXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXX XXXXXX X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XX X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXXXXX XXX X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX XXX X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define loop(i, start, end) for (auto i = start; i < end; i++)
#define loopi(end) loop(i, 0, end)
#define loopj(end) loop(j, 0, end)
#define loopk(end) loop(k, 0, end)
#define get_i(n) \
int n; \
cin >> n;
#define get_ch(n) \
char x; \
cin >> x;
#define get_doub(n) \
double n; \
cin >> n;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vb vector<bool>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define clear(a) memset(a, 0, sizeof(a))
#define all(a) (a).begin(), (a).end()
const long long modulo = 1e18 + 3;
const ll INF = 1e18;
const int inf = 2e9;
const double PI = 3.141592653589793238463;
//#define FILE "substrcmp"
#define FAST_IO
#define FSOL
#ifdef FSOL
void solve() {
get_i(n);
get_i(ma);
vi w(n), cost(n);
loopi(n) cin >> w[i] >> cost[i];
vvi dp(n + 1, vi(ma + 1));
loop(i, 1, n + 1) loopj(ma + 1) {
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]] + cost[i - 1]);
}
cout << dp[n][ma];
}
#else
void solve() {}
#endif
int main() {
#ifdef FAST_IO
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#endif
#ifdef DEBUG
freopen("debug.in", "r", stdin);
auto timestamp = std::chrono::system_clock::now();
#else
#ifdef FILE
freopen(FILE ".in", "r", stdin);
freopen(FILE ".out", "w", stdout);
#endif
#endif
solve();
#ifdef DEBUG
cout << endl
<< "Time elapsed: "
<< chrono::duration_cast<chrono::milliseconds>(
std::chrono::system_clock::now() - timestamp)
.count()
<< " ms" << endl;
#endif
return 0;
} | /*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX XXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX X
X XXX XX XXXX XXXX X XXX XXX XXXX XXXX XXXX XXXXXX X
X XXXXXXXXX XXX XXX XXXXX XXX XXX XXXXXXX XX XX XXX XX X
X XXXXX XXX XXX XXXXX XXX XXX XXX XXX XXX X XXX X
X XXX X XXX XXX XXX XXXXX XXX XXX XXX XXX XXX XXX XXXXX XXX X
XX XXX XX XXX XX XX XXX XXX XXX XX X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX XXXX XX X XXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXX XXXXXX X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XX X X X XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXX XXXXXX XXX X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX XXXXX XXX X XXX XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define loop(i, start, end) for (auto i = start; i < end; i++)
#define loopi(end) loop(i, 0, end)
#define loopj(end) loop(j, 0, end)
#define loopk(end) loop(k, 0, end)
#define get_i(n) \
int n; \
cin >> n;
#define get_ch(n) \
char x; \
cin >> x;
#define get_doub(n) \
double n; \
cin >> n;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vb vector<bool>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define clear(a) memset(a, 0, sizeof(a))
#define all(a) (a).begin(), (a).end()
const long long modulo = 1e18 + 3;
const ll INF = 1e18;
const int inf = 2e9;
const double PI = 3.141592653589793238463;
//#define FILE "substrcmp"
#define FAST_IO
#define FSOL
#ifdef FSOL
void solve() {
get_i(n);
get_i(ma);
vi w(n), cost(n);
loopi(n) cin >> w[i] >> cost[i];
vvll dp(n + 1, vll(ma + 1));
loop(i, 1, n + 1) loopj(ma + 1) {
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]] + cost[i - 1]);
}
cout << dp[n][ma];
}
#else
void solve() {}
#endif
int main() {
#ifdef FAST_IO
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#endif
#ifdef DEBUG
freopen("debug.in", "r", stdin);
auto timestamp = std::chrono::system_clock::now();
#else
#ifdef FILE
freopen(FILE ".in", "r", stdin);
freopen(FILE ".out", "w", stdout);
#endif
#endif
solve();
#ifdef DEBUG
cout << endl
<< "Time elapsed: "
<< chrono::duration_cast<chrono::milliseconds>(
std::chrono::system_clock::now() - timestamp)
.count()
<< " ms" << endl;
#endif
return 0;
} | [
"variable_declaration.type.change",
"identifier.change",
"call.function.change",
"call.arguments.change"
] | 967,353 | 967,354 | u829509166 | cpp |
p03163 | #include <iostream>
using namespace std;
int knapsack(long long int n, long long int W, long long int w[],
long long int v[]) {
long long int arr[n + 1][W + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= W; j++) {
if (i == 0 || j == 0) {
arr[i][j] = 0;
} else {
if (j < w[i - 1]) {
arr[i][j] = arr[i - 1][j];
} else {
arr[i][j] = arr[i - 1][j] > arr[i - 1][j - w[i - 1]] + v[i - 1]
? arr[i - 1][j]
: arr[i - 1][j - w[i - 1]] + v[i - 1];
}
}
}
}
return arr[n][W];
}
int main() {
long long int N, W;
cin >> N;
cin >> W;
long long int w[N], v[N];
for (int i = 0; i < N; i++) {
cin >> w[i];
cin >> v[i];
}
cout << knapsack(N, W, w, v);
return 0;
}
| #include <iostream>
using namespace std;
long long int knapsack(long long int n, long long int W, long long int w[],
long long int v[]) {
long long int arr[n + 1][W + 1];
for (long long int i = 0; i <= n; i++) {
for (long long int j = 0; j <= W; j++) {
if (i == 0 || j == 0) {
arr[i][j] = 0;
} else {
if (j < w[i - 1]) {
arr[i][j] = arr[i - 1][j];
} else {
arr[i][j] = arr[i - 1][j] > arr[i - 1][j - w[i - 1]] + v[i - 1]
? arr[i - 1][j]
: arr[i - 1][j - w[i - 1]] + v[i - 1];
}
}
}
}
return arr[n][W];
}
int main() {
long long int N, W;
cin >> N;
cin >> W;
long long int w[N], v[N];
for (int i = 0; i < N; i++) {
cin >> w[i];
cin >> v[i];
}
cout << knapsack(N, W, w, v);
return 0;
}
| [
"control_flow.loop.for.initializer.change"
] | 967,355 | 967,356 | u549985733 | cpp |
p03163 | #include <bits/stdc++.h>
#include <iostream>
#define ll long long
using namespace std;
int main() {
// your code goes here
ll n;
cin >> n;
ll w;
cin >> w;
ll arr[n + 1][2];
arr[0][0] = 0;
arr[0][1] = 0;
for (ll i = 1; i <= n; i++) {
cin >> arr[i][0] >> arr[i][1];
}
for (ll i = 0; i < n - 1; i++) {
for (ll j = i + 1; j < n; j++) {
if (arr[j][0] > arr[i][0]) {
ll t = arr[j][0];
arr[j][0] = arr[i][0];
arr[i][0] = t;
t = arr[j][1];
arr[j][1] = arr[i][1];
arr[i][1] = t;
}
}
}
ll brr[n + 1][w + 1];
for (ll i = 0; i <= n; i++) {
brr[i][0] = 0;
}
for (ll i = 0; i <= w; i++) {
brr[0][i] = 0;
}
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= w; j++) {
if (j - arr[i][0] >= 0)
brr[i][j] = max(brr[i - 1][j], brr[i - 1][j - arr[i][0]] + arr[i][1]);
else
brr[i][j] = brr[i - 1][j];
}
}
cout << brr[n][w];
return 0;
} | #include <bits/stdc++.h>
#include <iostream>
#define ll long long
using namespace std;
int main() {
// your code goes here
ll n;
cin >> n;
ll w;
cin >> w;
ll arr[n + 1][2];
arr[0][0] = 0;
arr[0][1] = 0;
for (ll i = 1; i <= n; i++) {
cin >> arr[i][0] >> arr[i][1];
}
for (ll i = 1; i < n; i++) {
for (ll j = i + 1; j <= n; j++) {
if (arr[j][0] > arr[i][0]) {
ll t = arr[j][0];
arr[j][0] = arr[i][0];
arr[i][0] = t;
t = arr[j][1];
arr[j][1] = arr[i][1];
arr[i][1] = t;
}
}
}
ll brr[n + 1][w + 1];
for (ll i = 0; i <= n; i++) {
brr[i][0] = 0;
}
for (ll i = 0; i <= w; i++) {
brr[0][i] = 0;
}
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= w; j++) {
if (j - arr[i][0] >= 0)
brr[i][j] = max(brr[i - 1][j], brr[i - 1][j - arr[i][0]] + arr[i][1]);
else
brr[i][j] = brr[i - 1][j];
}
}
cout << brr[n][w];
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 967,362 | 967,363 | u324078303 | cpp |
p03163 |
#include <algorithm>
#include <functional>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <cstring>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <utility>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define dump(c) \
{ \
for (auto it = c.begin(); it != c.end(); ++it) \
if (it == c.begin()) \
cout << *it; \
else \
cout << ' ' << *it; \
cout << endl; \
}
#define dumpMap(m) \
{ \
for (auto it : m) \
cout << it.first << "=>" << it.second << ' '; \
}
const int MOD = 1000000007;
LL dp[101][100001];
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N + 1);
vector<int> v(N + 1);
for (int i = 1; i <= N; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= N;
++i) { //! checking up to i-th item (where i is in 1..N range)
for (int j = 0; j <= W; ++j) { //! the weight is less than or equal to 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 - 1][W] << endl;
return 0;
}
|
#include <algorithm>
#include <functional>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <cstring>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <utility>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define dump(c) \
{ \
for (auto it = c.begin(); it != c.end(); ++it) \
if (it == c.begin()) \
cout << *it; \
else \
cout << ' ' << *it; \
cout << endl; \
}
#define dumpMap(m) \
{ \
for (auto it : m) \
cout << it.first << "=>" << it.second << ' '; \
}
const int MOD = 1000000007;
LL dp[101][100001];
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N + 1);
vector<int> v(N + 1);
for (int i = 1; i <= N; ++i) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= N;
++i) { //! checking up to i-th item (where i is in 1..N range)
for (int j = 0; j <= W; ++j) { //! the weight is less than or equal to 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[" << i << "] = ";
// for (int k = 0; k <=W; ++k) {
// cout << dp[i][k] << ' ';
// }
// cout << endl;
}
cout << dp[N][W] << endl;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 967,372 | 967,373 | u851470173 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int dp[105][100005];
long long knap(long long w[], long long v[], int i, long long n, long long W) {
if (i > n || W <= 0)
return 0;
if (dp[i][W] != -1)
return dp[i][W];
if (w[i] > W)
return dp[i][W] = knap(w, v, i + 1, n, W);
return dp[i][W] = max(v[i] + knap(w, v, i + 1, n, W - w[i]),
knap(w, v, i + 1, n, W));
}
int main() {
long long n;
long long W;
cin >> n >> W;
long long v[n], w[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
memset(dp, -1, sizeof(dp));
cout << knap(w, v, 0, n - 1, W) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
long long dp[105][100005];
long long knap(long long w[], long long v[], int i, long long n, long long W) {
if (i > n || W <= 0)
return 0;
if (dp[i][W] != -1)
return dp[i][W];
if (w[i] > W)
return dp[i][W] = knap(w, v, i + 1, n, W);
return dp[i][W] = max(v[i] + knap(w, v, i + 1, n, W - w[i]),
knap(w, v, i + 1, n, W));
}
int main() {
long long n;
long long W;
cin >> n >> W;
long long v[n], w[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
memset(dp, -1, sizeof(dp));
cout << knap(w, v, 0, n - 1, W) << endl;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,376 | 967,377 | u770801122 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, W;
cin >> N >> W;
vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (j - w >= 0)
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w] + v);
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;
int main() {
long N, W;
cin >> N >> W;
vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (j - w >= 0)
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w] + v);
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[N][W] << endl;
} | [
"control_flow.branch.else.remove"
] | 967,380 | 967,381 | u777258731 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, W;
cin >> N >> W;
vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (j - w >= 0)
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w] + v);
else
dp[i + 1][j] = max(dp[i + 1][j], dp[i][0]);
}
}
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, W;
cin >> N >> W;
vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (j - w >= 0)
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w] + v);
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[N][W] << endl;
} | [
"control_flow.branch.else.remove",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 967,382 | 967,381 | u777258731 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, W;
cin >> N >> W;
vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (j - w >= 0)
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w] + v);
else
dp[i + 1][j] = max(dp[i + 1][j], dp[i][0]);
}
}
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, W;
cin >> N >> W;
vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = 0; j < W + 1; j++) {
if (j - w >= 0)
dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v);
else
dp[i + 1][j] = max(dp[i][j], dp[i][0]);
}
}
cout << dp[N][W] << endl;
} | [
"expression.operation.binary.remove"
] | 967,382 | 967,383 | u777258731 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N), v(N);
vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));
for (int i = 0; i < N; i++) {
cin >> w[i];
cin >> 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 + 1][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
}
// for(int i=0;i<=N;i++) {
// for(int j=0;j<=W;j++) {
// cout << dp[i][j] << " ";
// }
// cout << endl;
// }
cout << dp[N][W] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N), v(N);
vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));
for (int i = 0; i < N; i++) {
cin >> w[i];
cin >> 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] = max(dp[i + 1][j], dp[i][j]);
}
}
}
// for(int i=0;i<=N;i++) {
// for(int j=0;j<=W;j++) {
// cout << dp[i][j] << " ";
// }
// cout << endl;
// }
cout << dp[N][W] << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 967,397 | 967,398 | u286539644 | cpp |
p03163 | #pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include <cstring>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define getL(a) scanf("%lld", &a)
#define getLL(a, b) scanf("%lld%lld", &a, &b)
#define getLLL(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define BEND(c) (c).begin(), (c).end()
#define BEND2(c) (c).rbegin(), (c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s", a)
#define pfi(a) printf("%d", a);
#define pfii(a, b) printf("%d%d", a, b);
#define pfl(a) printf("%lld", a);
#define pfll(a, b) printf("%lld%lld", a, b);
#define pfd(a) printf("%lf", a);
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0);
#define endl "\n"
#define sag (sol | 1)
//#define sol (root<<1)
#define ort (bas + son) / 2
#define SIZE (int)(1e9 + 7)
#define MAXN (ll)((1e5 + 5))
#define K 25
#define ALPHABET_SIZE 26
#define N (int)(1e5 + 10)
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vi> graph;
int n, C;
int value[100005], weight[100005];
int dp[100005];
int main() {
cin >> n >> C;
for (int i = 1; i <= n; i++) {
cin >> weight[i] >> value[i];
}
for (int i = n; i >= 1; i--) {
for (int c = C; c >= weight[i]; c--) {
// for (int c = weight[i] ; c <= C ; c++) {
dp[c] = max(dp[c], dp[c - weight[i]] + value[i]);
}
}
cout << dp[C] << endl;
}
| #pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include <cstring>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define getL(a) scanf("%lld", &a)
#define getLL(a, b) scanf("%lld%lld", &a, &b)
#define getLLL(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define BEND(c) (c).begin(), (c).end()
#define BEND2(c) (c).rbegin(), (c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s", a)
#define pfi(a) printf("%d", a);
#define pfii(a, b) printf("%d%d", a, b);
#define pfl(a) printf("%lld", a);
#define pfll(a, b) printf("%lld%lld", a, b);
#define pfd(a) printf("%lf", a);
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0);
#define endl "\n"
#define sag (sol | 1)
//#define sol (root<<1)
#define ort (bas + son) / 2
#define SIZE (int)(1e9 + 7)
#define MAXN (ll)((1e5 + 5))
#define K 25
#define ALPHABET_SIZE 26
#define N (int)(1e5 + 10)
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vi> graph;
int n, C;
int value[100005], weight[100005];
int dp[100005];
signed main() {
cin >> n >> C;
for (int i = 1; i <= n; i++) {
cin >> weight[i] >> value[i];
}
for (int i = n; i >= 1; i--) {
for (int c = C; c >= weight[i]; c--) {
// for (int c = weight[i] ; c <= C ; c++) {
dp[c] = max(dp[c], dp[c - weight[i]] + value[i]);
}
}
cout << dp[C] << endl;
}
/*
vi dp(MAXN,2);
vi vec(MAXN);
int main(){
int n ;
cin >>n;
for (int i = 1; i <=n ; ++i)
cin >> vec[i];
for (int j = 2; j <=n ; ++j)
for (int i = vec[j]; i <j ; ++i)
dp[j]=(dp[i]+dp[j])%SIZE;
int res = 0;
for (int k = 1; k <=n ; ++k)
res=(dp[k]+res)%SIZE;
cout <<res;
return 0;
}
/*
int binaryse(vi vec, int key){
for(auto el : vec)cout << el <<" ";
cout << endl;
cout << "key:"<<key <<endl;
int l = 0;
int r = vec.size()-1;
if(vec.size() == 0)return 0;
while(l <=r-3){
int mid= (l+r)/2;
if(key <= vec[mid]){
r= mid;
}else{
l = mid-1;
}
}
int res =0;
int tm =vec.size();
for (int i = 0; i < min(3,tm) ; ++i) {
if(vec[l+i] <= key)res=l;
}
return (res+1);
}
int dp [55][55];
int main(){
int n , v;
cin >> n>>v;
vi vec(n);
for (int i = 0; i <n ; ++i) {
cin >> vec[i];
}
int gg ;
cin >> gg;
vvi days(n+1,vi());
for (int l,r,f,j = 0; j <gg ; ++j) {
cin >> l>>r>>f;
for (int i = l; i <=r ; ++i)
days[i].pb(f);
}
for (int k = 1; k <=n ; ++k) {
sort(BEND(days[k]));
}
for (int i = 1; i <n+1 ; ++i) {
for (int j = 1; j <days[i].size() ; ++j) {
days[i][j] += days[i][j-1];
}
}
int ans = 0;
for (int m = 1; m <=n ; ++m) {
int cc = binaryse(days[m],vec[m-1]-v);
ans+=cc;
cout << cc<<"-"<<endl;
}
cout << ans;
return 0;
}
/*
int main ( ) {
int n;
cin >> n;
ll res = 0;
vi vec;
ll sum =0;
for (int cur, i = 0; i < n; ++i) {
cin >> cur;
vec.pb(cur);
sum +=cur;
}
//cout << sum <<endl;
int tek =0;
int cift = 0;
int t =0;
for (int j = 0; j <n ; ++j) {
t = res;
res+=vec[j]/2;
if(vec[j]%2){
if(cift %2 ==1)tek=0;
//cout<<tek<<"\n";
tek++;
if(tek%2==0 and cift %2==0){
//cout << j<<"\n";
res++;
}
cift =0;
}else{
cift++;
}
cout << res-t<<" ";
if (j %5 == 4)cout<<endl;
// cout << tek<<" "<<cift<<endl;
}
cout << res;
return 0;
}
/*
int main ( ){
int n ;
cin >>n ;
ll res =0;
vi vec;
for (int cur , i = 0; i <n ; ++i) {
cin >>cur;
vec.pb(cur);
}
bool ctr =0;
int ncift=0;
bool ci =0;
for (int j = 0; j <n ; ++j) {
if(vec[j]%2 ){
if(ctr==1 and ci == 1){
res+=(vec[j]+1)/2;
continue;
}
}
if(j < n-1 and vec[j]%2==1 and vec[j+1] %2 ==1){
res+=(vec[j]+vec[j+1])/2;
//cout << res<<" ";
j++;
}else if(j < n-1 and vec[j]%2==1 and vec[j+1] %2 !=1){
ctr =1;
}else{
ncift++;
if(ncift==2){
ci =1;
ncift=0;
}
res+=vec[j]/2;
}
}
cout << res;
return 0;
}
/*
int main(){
IOS
int a,b,d;
cin>>a>>b>>d;
int tmp =0;
int k ;
cin >> k;
tmp = k % d;
bool ctr =0;
ll sum =k;
vi vec;
for (int i = 0; i <a ; ++i) {
for (int cur,j = 0; j <b ; ++j) {
if(i == 0 and j == 0 )vec.pb(k);
else{
cin >> cur;
sum+=k;
if(cur % d != tmp ){
ctr=1;
}
vec.pb(cur);
}
}
}
sort(BEND(vec));
if(ctr){
cout << -1;
return 0;
}
int mm =(a*b +1)/2;
mm= vec[mm];
int sonuc= 0;
for (int l = 0; l <(a*b) ; ++l) {
sonuc+=abs(vec[l]-mm)/d;
}
int sonuc2= 0;
mm =(a*b +1)/2 -1 ;
for (int l = 0; l <(a*b) ; ++l) {
sonuc2+=abs(vec[l]-mm)/d;
}
sonuc =min(sonuc ,sonuc2);
cout << sonuc;
return 0;
}
/*
int main (){
IOS
int a,b;
cin >>a>>b;
vi vec(a);
for (int i = 0; i <a ; ++i) {
cin>>vec[i];
}
//sort(BEND(vec));
int res =0;
int son =2;
for (int i = 0; i <a -2; ++i) {
if(i+2 > son)break;
for (int k = son; k <a ; ++k) {
if(vec[i] + b < vec[k]){
cout << i<<" "<<k <<endl;
//res+=a-k;
son = k;
break;
}else {
// cout<<i<<"e"<<k<<endl;
res+=(k-i-1);}
}
son++;
}
cout << res;
return 0;
}
*/ | [
"variable_declaration.type.primitive.change"
] | 967,404 | 967,405 | u198530799 | cpp |
p03163 | #include <iostream>
using namespace std;
int DP[110][200100];
int W[110], V[110];
int main() {
int N, K;
cin >> N >> K;
for (int i = 0; i < N; i++)
cin >> W[i] >> V[i];
for (int i = 0; i < N; i++)
for (int j = 0; j <= K; j++)
DP[i + 1][j + W[i]] = max(DP[i + 1][j + W[i]], DP[i][j] + V[i]),
DP[i + 1][j] = max(DP[i + 1][j], DP[i][j]);
int Ans = 0;
for (int i = 0; i <= K; i++)
Ans = max(Ans, DP[N][i]);
cout << Ans;
return 0;
} | #include <iostream>
using namespace std;
#define int long long
int DP[110][200100];
int W[110], V[110];
signed main() {
int N, K;
cin >> N >> K;
for (int i = 0; i < N; i++)
cin >> W[i] >> V[i];
for (int i = 0; i < N; i++)
for (int j = 0; j <= K; j++)
DP[i + 1][j + W[i]] = max(DP[i + 1][j + W[i]], DP[i][j] + V[i]),
DP[i + 1][j] = max(DP[i + 1][j], DP[i][j]);
int Ans = 0;
for (int i = 0; i <= K; i++)
Ans = max(Ans, DP[N][i]);
cout << Ans;
return 0;
} | [
"variable_declaration.type.primitive.change"
] | 967,406 | 967,407 | u538921909 | cpp |
p03163 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll MOD = (1e9 + 7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }
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;
}
ll factorial(ll n, ll m = 2) {
// calculate n!
m = max(2LL, m);
ll rtn = 1;
for (ll i = m; i <= n; i++) {
rtn = (rtn * i) % MOD;
}
return rtn;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
ll modpow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % MOD;
a = a * a % MOD;
n >>= 1;
}
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, W;
cin >> N >> W;
vector<ll> w(N), v(N);
rep(i, N) cin >> w[i] >> v[i];
vector<vector<ll>> dp(N + 1, vector<ll>(W, 0));
for (int i = N - 1; i >= 0; --i) {
rep(j, W + 1) {
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[0][W] << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll MOD = (1e9 + 7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }
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;
}
ll factorial(ll n, ll m = 2) {
// calculate n!
m = max(2LL, m);
ll rtn = 1;
for (ll i = m; i <= n; i++) {
rtn = (rtn * i) % MOD;
}
return rtn;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
ll modpow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % MOD;
a = a * a % MOD;
n >>= 1;
}
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, W;
cin >> N >> W;
vector<ll> w(N), v(N);
rep(i, N) cin >> w[i] >> v[i];
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
for (int i = N - 1; i >= 0; --i) {
rep(j, W + 1) {
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[0][W] << endl;
return 0;
} | [
"assignment.change"
] | 967,410 | 967,411 | u963903527 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> v(N);
vector<int> w(N);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
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 (w[i - 1] <= j) {
// cout<<"maybe add item "<<i<<endl;
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[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;
int main() {
int N, W;
cin >> N >> W;
vector<long> v(N);
vector<long> w(N);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
vector<vector<long>> dp(N + 1, vector<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 (w[i - 1] <= j) {
// cout<<"maybe add item "<<i<<endl;
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
} else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[N][W] << endl;
return 0;
}
| [
"variable_declaration.type.primitive.change"
] | 967,412 | 967,413 | u874719061 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = (int)(j); i < (int)(n); i++)
#define REP(i, j, n) for (int i = (int)(j); i <= (int)(n); i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(), (a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>
#define priq priority_queue<int>
#define disup(A, key) distance(A.begin(), upper_bound(ALL(A), (int)(key)))
#define dislow(A, key) distance(A.begin(), lower_bound(ALL(A), (int)(key)))
#define tii tuple<int, int, int>
signed main() {
int N, W;
cin >> N >> W;
vii dp(N + 1, vi(W + 1));
REP(i, 1, N) {
int w, v;
cin >> w >> v;
rep(j, 0, w) dp[i][j] = dp[i - 1][j];
REP(j, w, v) { dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v); }
}
cout << dp[N][W] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = (int)(j); i < (int)(n); i++)
#define REP(i, j, n) for (int i = (int)(j); i <= (int)(n); i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(), (a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>
#define priq priority_queue<int>
#define disup(A, key) distance(A.begin(), upper_bound(ALL(A), (int)(key)))
#define dislow(A, key) distance(A.begin(), lower_bound(ALL(A), (int)(key)))
#define tii tuple<int, int, int>
signed main() {
int N, W;
cin >> N >> W;
vii dp(N + 1, vi(W + 1));
REP(i, 1, N) {
int w, v;
cin >> w >> v;
rep(j, 0, w) dp[i][j] = dp[i - 1][j];
REP(j, w, W) { dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v); }
}
cout << dp[N][W] << endl;
}
| [] | 967,414 | 967,415 | u347057617 | cpp |
p03163 | #include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n) for (int i = 1; i < n + 1; i++)
int main() {
int N, W;
cin >> N >> W;
ll values[100001];
ll val;
int w;
rep(i, W + 1) values[i] = 0;
Rep(i, N) {
cin >> w >> val;
for (int ww = 0; ww < W + 1; ww++) {
if (ww < w)
continue;
else
values[ww] = max(values[ww - w] + val, values[ww]);
}
}
cout << values[W];
return 0;
} | #include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n) for (int i = 1; i < n + 1; i++)
int main() {
int N, W;
cin >> N >> W;
ll values[100001];
ll val;
int w;
rep(i, W + 1) values[i] = 0;
Rep(i, N) {
cin >> w >> val;
for (int ww = W; ww > -1; ww--) {
if (ww < w)
continue;
else
values[ww] = max(values[ww - w] + val, values[ww]);
}
}
cout << values[W];
return 0;
} | [
"variable_declaration.value.change",
"identifier.replace.add",
"literal.replace.remove",
"control_flow.loop.for.initializer.change",
"control_flow.loop.for.condition.change"
] | 967,420 | 967,421 | u563710899 | cpp |
p03163 | #include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int val[n], we[n];
for (int i = 0; i < n; i++)
cin >> we[i] >> val[i];
ll dp[n + 1][w + 1];
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 (we[i - 1] <= w)
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - we[i - 1]] + val[i - 1]);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w];
return 0;
} | #include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
int n, w;
cin >> n >> w;
int val[n], we[n];
for (int i = 0; i < n; i++)
cin >> we[i] >> val[i];
ll dp[n + 1][w + 1];
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 (we[i - 1] <= j)
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - we[i - 1]] + val[i - 1]);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w];
return 0;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 967,422 | 967,423 | u035864973 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
vector<int> weight, value;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
weight.push_back(a);
value.push_back(b);
}
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] = 0;
else if (weight[i - 1] <= w)
dp[i][w] =
max(value[i - 1] + dp[i - 1][w - weight[i - 1]], dp[i - 1][w]);
else
dp[i][w] = dp[i - 1][w];
}
}
cout << dp[n][W] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
vector<long long> weight, value;
for (int i = 0; i < n; i++) {
long long a, b;
cin >> a >> b;
weight.push_back(a);
value.push_back(b);
}
long long 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] = 0;
else if (weight[i - 1] <= w)
dp[i][w] =
max(value[i - 1] + dp[i - 1][w - weight[i - 1]], dp[i - 1][w]);
else
dp[i][w] = dp[i - 1][w];
}
}
cout << dp[n][W] << endl;
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,433 | 967,434 | u201678045 | cpp |
p03163 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x), 0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// cout << fixed << setprecision(10);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int w[110], v[110];
int dp[110][110] = {};
int main() {
int N, W;
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
for (int n = 0; n < N; n++) {
for (int sum_w = 0; sum_w <= W; sum_w++) {
if (sum_w - w[n] >= 0) {
dp[n + 1][sum_w] = max(dp[n + 1][sum_w], dp[n][sum_w - w[n]] + v[n]);
}
dp[n + 1][sum_w] = max(dp[n + 1][sum_w], dp[n][sum_w]);
}
}
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x), 0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// cout << fixed << setprecision(10);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int w[110], v[110];
ll dp[110][100100] = {};
int main() {
int N, W;
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
for (int n = 0; n < N; n++) {
for (int sum_w = 0; sum_w <= W; sum_w++) {
if (sum_w - w[n] >= 0) {
dp[n + 1][sum_w] = max(dp[n + 1][sum_w], dp[n][sum_w - w[n]] + v[n]);
}
dp[n + 1][sum_w] = max(dp[n + 1][sum_w], dp[n][sum_w]);
}
}
cout << dp[N][W] << endl;
} | [
"variable_declaration.type.change",
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 967,437 | 967,438 | u850516963 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, wt;
cin >> n >> wt;
int w[n], v[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
int dp[n + 1][wt + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= wt; j++) {
if (i == 0 || j == 0) {
dp[i][j] = 0;
} else if (w[i - 1] <= j) {
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][wt];
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
ll n, wt;
cin >> n >> wt;
ll w[n], v[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
ll dp[n + 1][wt + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= wt; j++) {
if (i == 0 || j == 0) {
dp[i][j] = 0;
} else if (w[i - 1] <= j) {
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][wt];
/*for(int i=0;i<=n;i++)
{
for(int j=0;j<=wt;j++)
{
cout<<dp[i][j]<<"\t";
}
cout<<endl;
}*/
return 0;
}
| [
"variable_declaration.type.change"
] | 967,447 | 967,448 | u202550027 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e2 + 10;
const int M = 1e5 + 10;
const int INF = 2e9;
int v[N], w[N];
ll dp[N][M];
int main() {
int n, W;
cin >> n >> W;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= W; j++) {
if (w[i] <= j) {
dp[i][j] = max(dp[i - 1][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][W];
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e2 + 10;
const int M = 1e5 + 10;
const int INF = 2e9;
int v[N], w[N];
ll dp[N][M];
int main() {
int n, W;
cin >> n >> W;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; 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];
}
}
}
cout << dp[n][W];
return 0;
} | [] | 967,455 | 967,456 | u554906051 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e2 + 10;
const int M = 1e5 + 10;
const int INF = 2e9;
int v[N], w[N];
ll dp[N][M];
int main() {
int n, W;
cin >> n >> W;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= W; j++) {
if (w[i] <= j) {
dp[i][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][W];
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e2 + 10;
const int M = 1e5 + 10;
const int INF = 2e9;
int v[N], w[N];
ll dp[N][M];
int main() {
int n, W;
cin >> n >> W;
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; 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];
}
}
}
cout << dp[n][W];
return 0;
} | [
"assignment.change"
] | 967,457 | 967,456 | u554906051 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main() {
ll n, W;
cin >> n >> W;
ll w[n], v[n];
for (ll i = 0; i < n; i++)
cin >> w[i] >> v[i];
ll dp[n + 1][n + 1];
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 (w[i - 1] <= j)
dp[i][j] = max(dp[i - 1][j], v[i - 1] + dp[i - 1][j - w[i - 1]]);
else
dp[i][j] = dp[i - 1][j];
}
cout << dp[n][W];
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main() {
ll n, W;
cin >> n >> W;
ll w[n], v[n];
for (ll i = 0; i < n; i++)
cin >> w[i] >> v[i];
ll dp[n + 1][W + 1];
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 (w[i - 1] <= j)
dp[i][j] = max(dp[i - 1][j], v[i - 1] + dp[i - 1][j - w[i - 1]]);
else
dp[i][j] = dp[i - 1][j];
}
cout << dp[n][W];
return 0;
}
| [
"identifier.change",
"expression.operation.binary.change"
] | 967,458 | 967,459 | u439465393 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, i, j, k, W, w, v;
cin >> n >> W;
int dp[W + 1] = {0};
for (i = 0; i < n; i++) {
cin >> w >> v;
for (j = W - w; j >= 0; j--) {
dp[j + w] = max(dp[j + w], dp[j] + v);
// cout<<j+w<<" "<<dp[j+w]<<endl;
}
}
k = 0;
for (i = 0; i < W + 1; i++) {
k = max(k, dp[i]);
}
cout << k;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
// your code goes here
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, i, j, k, W, w, v;
cin >> n >> W;
int dp[W + 1] = {0};
for (i = 0; i < n; i++) {
cin >> w >> v;
for (j = W - w; j >= 0; j--) {
dp[j + w] = max(dp[j + w], dp[j] + v);
// cout<<j+w<<" "<<dp[j+w]<<endl;
}
}
k = 0;
for (i = 0; i < W + 1; i++) {
k = max(k, dp[i]);
}
cout << k;
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 967,460 | 967,461 | u108436978 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
using namespace std;
int main() {
ll n, w;
cin >> n >> w;
ll val[n], weight[n];
ll dp[n + 1][w + 1];
for (int i = 0; i < n; i++) {
cin >> val[i] >> weight[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 - 1] <= j)
dp[i][j] = max(val[i - 1] + dp[i - 1][j - weight[i - 1]], dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w] << endl;
} | #include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
using namespace std;
int main() {
ll n, w;
cin >> n >> w;
ll val[n], weight[n];
ll dp[n + 1][w + 1];
for (int i = 0; i < n; i++) {
cin >> weight[i] >> val[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 - 1] <= j)
dp[i][j] = max(val[i - 1] + dp[i - 1][j - weight[i - 1]], dp[i - 1][j]);
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w] << endl;
} | [
"expression.operation.binary.remove"
] | 967,464 | 967,465 | u091412362 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
const int N = 1e5 + 10;
ll n, W;
ll dp[102][N];
std::vector<pair<ll, ll>> v;
ll go(ll idx, ll pick) {
if (idx == v.size())
return 0;
if (dp[idx][pick] != -1)
return dp[idx][pick];
ll xx = -inf, yy = -inf;
if (pick + v[idx].second <= W)
xx = v[idx].second + go(idx + 1, pick + v[idx].first);
yy = go(idx + 1, pick);
return dp[idx][pick] = max(xx, yy);
}
int main(int argc, char const *argv[]) {
cin >> n >> W;
for (int i = 0; i < n; ++i) {
ll x, y;
cin >> x >> y;
v.push_back({x, y});
}
sort(v.begin(), v.end());
memset(dp, -1, sizeof dp);
cout << go(0, 0);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
const int N = 1e5 + 10;
ll n, W;
ll dp[102][N];
std::vector<pair<ll, ll>> v;
ll go(ll idx, ll pick) {
if (idx == v.size())
return 0;
if (dp[idx][pick] != -1)
return dp[idx][pick];
ll xx = -inf, yy = -inf;
if (pick + v[idx].first <= W)
xx = v[idx].second + go(idx + 1, pick + v[idx].first);
yy = go(idx + 1, pick);
return dp[idx][pick] = max(xx, yy);
}
int main(int argc, char const *argv[]) {
cin >> n >> W;
for (int i = 0; i < n; ++i) {
ll x, y;
cin >> x >> y;
v.push_back({x, y});
}
sort(v.begin(), v.end());
memset(dp, -1, sizeof dp);
cout << go(0, 0);
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 967,466 | 967,467 | u597330339 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int knapSack(ll W, ll wt[], ll val[], ll n) {
ll i, w;
ll 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() {
ll n, W;
cin >> n >> W;
ll val[n], wt[n];
for (int i = 0; i < n; i++)
cin >> wt[i] >> val[i];
cout << knapSack(W, wt, val, n);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll knapSack(ll W, ll wt[], ll val[], ll n) {
ll i, w;
ll 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() {
ll n, W;
cin >> n >> W;
ll val[n], wt[n];
for (ll i = 0; i < n; i++)
cin >> wt[i] >> val[i];
cout << knapSack(W, wt, val, n);
return 0;
} | [
"control_flow.loop.for.initializer.change",
"variable_declaration.type.change"
] | 967,472 | 967,473 | u370388551 | cpp |
p03163 | #include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N, 0), v(N, 0);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= W; j++) {
if (w[i - 1] <= j) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N, 0), v(N, 0);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= W; j++) {
if (w[i - 1] <= j) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[N][W] << endl;
return 0;
} | [
"assignment.change"
] | 967,479 | 967,480 | u569272329 | cpp |
p03163 | #include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N, 0), v(N, 0);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= W; j++) {
if (w[i] <= j) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i - 1]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N, 0), v(N, 0);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= W; j++) {
if (w[i - 1] <= j) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[N][W] << endl;
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one",
"assignment.change"
] | 967,481 | 967,480 | u569272329 | cpp |
p03163 | #include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N, 0), v(N, 0);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= W; j++) {
if (w[i - 1] <= j) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[N][W] << endl;
return 0;
} | #include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N, 0), v(N, 0);
for (int i = 0; i < N; i++) {
cin >> w[i] >> v[i];
}
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= W; j++) {
if (w[i - 1] <= j) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[N][W] << endl;
return 0;
} | [
"call.arguments.change",
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"assignment.change"
] | 967,482 | 967,480 | u569272329 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
int q[1000000], dp[1000000];
main() {
int n, w, i, j, a, b, mx = -1;
cin >> n >> w;
dp[0] = 1;
for (i = 0; i < n; ++i) {
cin >> a >> b;
for (j = w; j >= a; j--) {
if (dp[j - a] != 0) {
dp[j] = max(dp[j], dp[j - a] + b);
mx = max(mx, dp[j]);
}
}
}
cout << mx;
} | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
int q[1000000], dp[1000000];
main() {
int n, w, i, j, a, b, mx = -1;
cin >> n >> w;
dp[0] = 1;
for (i = 0; i < n; ++i) {
cin >> a >> b;
for (j = w; j >= a; j--) {
if (dp[j - a] != 0) {
dp[j] = max(dp[j], dp[j - a] + b);
mx = max(mx, dp[j]);
}
}
}
cout << mx - 1;
} | [
"expression.operation.binary.add"
] | 967,486 | 967,487 | u526671873 | cpp |
p03163 | // ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░
// PointBlank's code (⌐■_■)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define repp(i, a, b) for (ll i = a; i <= b; i++)
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, b, a) for (ll i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define in_edges(m) \
repp(i, 1, m) { \
ll a, b; \
cin >> a >> b; \
v[a].pb(b), v[b].pb(a); \
}
#define debug(this) cerr << "> " << #this << " : " << this << "\n"
#define endl "\n"
ll power(ll x, ll y);
const ll MOD = 1000000007;
ll dp[102][100005], w, v;
int main() // PointBlank's code ¯\_(ツ)_/¯
{
quickio ll n, W;
cin >> n >> W;
ll w[n], v[n];
rep(i, 0, n) cin >> w[i] >> v[i];
repp(i, 1, n) repp(ww, 1, W) if (w[i - 1] <= ww) dp[i][ww] =
max(v[i - 1] + dp[i - 1][ww - w[i - 1]], dp[i - 1][ww]);
else dp[i][ww] = dp[i][ww];
cout << dp[n][W];
}
ll power(ll x, ll y) {
ll res = 1;
x %= MOD;
while (y > 0) {
if (y & 1)
res = (res * x) % MOD;
y = y >> 1, x = (x * x) % MOD;
}
return res;
} | // ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░
// PointBlank's code (⌐■_■)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define repp(i, a, b) for (ll i = a; i <= b; i++)
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, b, a) for (ll i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define in_edges(m) \
repp(i, 1, m) { \
ll a, b; \
cin >> a >> b; \
v[a].pb(b), v[b].pb(a); \
}
#define debug(this) cerr << "> " << #this << " : " << this << "\n"
#define endl "\n"
ll power(ll x, ll y);
const ll MOD = 1000000007;
ll dp[102][100005], w, v;
int main() // PointBlank's code ¯\_(ツ)_/¯
{
quickio ll n, W;
cin >> n >> W;
ll w[n], v[n];
rep(i, 0, n) cin >> w[i] >> v[i];
repp(i, 1, n) repp(ww, 1, W) if (w[i - 1] <= ww) dp[i][ww] =
max(v[i - 1] + dp[i - 1][ww - w[i - 1]], dp[i - 1][ww]);
else dp[i][ww] = dp[i - 1][ww];
cout << dp[n][W];
}
ll power(ll x, ll y) {
ll res = 1;
x %= MOD;
while (y > 0) {
if (y & 1)
res = (res * x) % MOD;
y = y >> 1, x = (x * x) % MOD;
}
return res;
} | [
"assignment.change"
] | 967,488 | 967,489 | u960071235 | cpp |
p03163 | #include <iostream>
#include <vector>
using namespace std;
int knapSack(int W, vector<int> wt, vector<int> val, int n) {
int i, w;
int K[n + 1][W + 1];
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);
int n, W;
cin >> n >> W;
vector<int> w(n);
vector<int> v(n);
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
cout << knapSack(W, w, v, n) << endl;
return 0;
}
| #include <iostream>
#include <vector>
using namespace std;
long long knapSack(int W, vector<int> wt, vector<int> val, int n) {
int i, w;
long long K[n + 1][W + 1];
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);
int n, W;
cin >> n >> W;
vector<int> w(n);
vector<int> v(n);
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
cout << knapSack(W, w, v, n) << endl;
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,492 | 967,493 | u340245438 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int n, w, val[105], peso[105], dp[105][100005];
int main() {
cin >> n >> w;
for (int i = 1; i <= n; i++) {
cin >> peso[i] >> val[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (peso[i] <= j) {
dp[i][j] = max(dp[i - 1][j], val[i] + dp[i - 1][j - peso[i]]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long long n, w, val[105], peso[105], dp[105][100005];
int main() {
cin >> n >> w;
for (int i = 1; i <= n; i++) {
cin >> peso[i] >> val[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (peso[i] <= j) {
dp[i][j] = max(dp[i - 1][j], val[i] + dp[i - 1][j - peso[i]]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,498 | 967,499 | u790908308 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep1(i, b) for (int i = 1; i <= b; i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int, int>
#define int long long
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// ios_base& scientific (ios_base& str);
int t;
// cin>>t;
while (t--) {
int n, w;
cin >> n >> w;
int wei[n], val[n];
rep(i, n) { cin >> wei[i] >> val[i]; }
int dp[w + 1][n + 1] = {0};
rep(i, w + 1) {
rep(j, n + 1) { dp[i][j] = 0; }
}
REP(i, 1, w + 1) {
REP(j, 1, n + 1) {
if (wei[j - 1] <= i) {
dp[i][j] = max(dp[i][j - 1], val[j - 1] + dp[i - wei[j - 1]][j - 1]);
} else {
dp[i][j] = dp[i][j - 1];
}
}
}
cout << dp[w][n] << " ";
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep1(i, b) for (int i = 1; i <= b; i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int, int>
#define int long long
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// ios_base& scientific (ios_base& str);
int t = 1;
// cin>>t;
while (t--) {
int n, w;
cin >> n >> w;
int wei[n], val[n];
rep(i, n) { cin >> wei[i] >> val[i]; }
int dp[w + 1][n + 1] = {0};
rep(i, w + 1) {
rep(j, n + 1) { dp[i][j] = 0; }
}
REP(i, 1, w + 1) {
REP(j, 1, n + 1) {
if (wei[j - 1] <= i) {
dp[i][j] = max(dp[i][j - 1], val[j - 1] + dp[i - wei[j - 1]][j - 1]);
} else {
dp[i][j] = dp[i][j - 1];
}
}
}
cout << dp[w][n] << " ";
}
return 0;
}
| [
"variable_declaration.value.change"
] | 967,500 | 967,501 | u423234259 | cpp |
p03163 | #include <iostream>
using namespace std;
int main() {
int n, W;
cin >> n >> W;
int weight[n], val[n], dp[n + 1][W + 1];
for (int i = 0; i < n; i++) {
cin >> weight[i] >> val[i];
}
for (int i = 0; i < n + 1; i++) {
for (int j = 0; j < W + 1; j++) {
if (i == 0 || j == 0) {
dp[i][j] = 0;
} else if (j >= weight[i - 1]) {
dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - weight[i - 1]]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][W];
return 0;
}
| #include <iostream>
using namespace std;
int main() {
long int n, W;
cin >> n >> W;
long int weight[n], val[n], dp[n + 1][W + 1];
for (long int i = 0; i < n; i++) {
cin >> weight[i] >> val[i];
}
for (long int i = 0; i < n + 1; i++) {
for (long int j = 0; j < W + 1; j++) {
if (i == 0 || j == 0) {
dp[i][j] = 0;
} else if (j >= weight[i - 1]) {
dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - weight[i - 1]]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][W];
return 0;
}
| [
"variable_declaration.type.widen.change"
] | 967,502 | 967,503 | u252229477 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
// lint knapsack(int limit, vector<int> &v, vector<int> &w) {
// vector<lint> dyn(limit+1, -1); int n = w.size();
// dyn[0] = 0;
// for (int i = 0; i < n; ++i)
// for (int j = limit; j >= w[i]; --j)
// if (dyn[j - w[i]] >= 0)
// dyn[j] = max(dyn[j], dyn[j - w[i]] + v[i]);
// lint result = 0;
// for (int i = 0; i <= limit; ++i)
// result = max(result, dyn[i]);
// return result;
// }
vector<int> Knapsack(int limit, vector<int> &v, vector<int> &w) {
vector<vector<int>> dyn(v.size() + 1);
dyn[0].resize(limit + 1);
for (int i = 0; i < v.size(); ++i) {
dyn[i + 1] = dyn[i];
for (int j = 0; j <= limit - w[i]; ++j)
dyn[i + 1][w[i] + j] = max(dyn[i + 1][w[i] + j], dyn[i][j] + v[i]);
}
vector<int> result;
for (int i = v.size() - 1; i >= 0; --i)
if (dyn[i][limit] != dyn[i + 1][limit]) {
limit -= w[i];
result.push_back(i);
}
return result;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, w;
cin >> n >> w;
vector<int> v(n), c(n);
for (int i = 0; i < n; ++i)
cin >> c[i] >> v[i];
// cout << knapsack(w, v, c) << '\n';
auto res = Knapsack(w, v, c);
lint total = 0;
for (int u : res)
total += v[u];
cout << total << '\n';
} | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
// lint knapsack(int limit, vector<int> &v, vector<int> &w) {
// vector<lint> dyn(limit+1, -1); int n = w.size();
// dyn[0] = 0;
// for (int i = 0; i < n; ++i)
// for (int j = limit; j >= w[i]; --j)
// if (dyn[j - w[i]] >= 0)
// dyn[j] = max(dyn[j], dyn[j - w[i]] + v[i]);
// lint result = 0;
// for (int i = 0; i <= limit; ++i)
// result = max(result, dyn[i]);
// return result;
// }
vector<int> Knapsack(int limit, vector<int> &v, vector<int> &w) {
vector<vector<lint>> dyn(v.size() + 1);
dyn[0].resize(limit + 1);
for (int i = 0; i < v.size(); ++i) {
dyn[i + 1] = dyn[i];
for (int j = 0; j <= limit - w[i]; ++j)
dyn[i + 1][w[i] + j] = max(dyn[i + 1][w[i] + j], dyn[i][j] + v[i]);
}
vector<int> result;
for (int i = v.size() - 1; i >= 0; --i)
if (dyn[i][limit] != dyn[i + 1][limit]) {
limit -= w[i];
result.push_back(i);
}
return result;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, w;
cin >> n >> w;
vector<int> v(n), c(n);
for (int i = 0; i < n; ++i)
cin >> c[i] >> v[i];
// cout << knapsack(w, v, c) << '\n';
auto res = Knapsack(w, v, c);
lint total = 0;
for (int u : res)
total += v[u];
cout << total << '\n';
} | [] | 967,508 | 967,509 | u608306652 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint Knapsack(int limit, vector<int> &v, vector<int> &w) {
vector<lint> dyn(limit, -1);
int n = w.size();
dyn[0] = 0;
for (int i = 0; i < n; ++i)
for (int j = limit; j >= w[i]; --j)
if (dyn[j - w[i]] >= 0)
dyn[j] = max(dyn[j], dyn[j - w[i]] + v[i]);
lint result = 0;
for (int i = 0; i <= limit; ++i)
result = max(result, dyn[i]);
return result;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, w;
cin >> n >> w;
vector<int> v(n), c(n);
for (int i = 0; i < n; ++i)
cin >> c[i] >> v[i];
cout << Knapsack(w, v, c) << '\n';
} | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint Knapsack(int limit, vector<int> &v, vector<int> &w) {
vector<lint> dyn(limit + 1, -1);
int n = w.size();
dyn[0] = 0;
for (int i = 0; i < n; ++i)
for (int j = limit; j >= w[i]; --j)
if (dyn[j - w[i]] >= 0)
dyn[j] = max(dyn[j], dyn[j - w[i]] + v[i]);
lint result = 0;
for (int i = 0; i <= limit; ++i)
result = max(result, dyn[i]);
return result;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, w;
cin >> n >> w;
vector<int> v(n), c(n);
for (int i = 0; i < n; ++i)
cin >> c[i] >> v[i];
cout << Knapsack(w, v, c) << '\n';
} | [
"assignment.change"
] | 967,510 | 967,511 | u608306652 | cpp |
p03163 | #include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define SORT(v, n) sort(v, v + n)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
int w[110];
int v[110];
int dp[110][100100] = {0};
signed main() {
ios::sync_with_stdio(false);
int N, W;
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
rep(i, N) {
for (int j = 0; j <= W; j++) {
if (j - w[i] >= 0)
chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
chmax(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[N][W] << endl;
return 0;
}
| #include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define SORT(v, n) sort(v, v + n)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
int w[110];
int v[110];
int dp[110][100100] = {0};
signed main() {
ios::sync_with_stdio(false);
int N, W;
cin >> N >> W;
rep(i, N) cin >> w[i] >> v[i];
rep(i, N) {
for (int j = 0; j <= W; j++) {
if (j - w[i] >= 0)
chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
chmax(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[N][W] << endl;
return 0;
}
| [] | 967,514 | 967,515 | u865767009 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
void max_self(ll &a, ll b) { a = max(a, b); }
void solve() {
int n, w;
cin >> n >> w;
vector<ll> dp(w + 1); // 0,1,2............w
// dp[i] = maximum value of items with total weight
for (int item = 0; item < n; item++) {
ll weight, value;
cin >> weight >> value;
for (int w_a = w - weight; w_a >= 0; w_a--) {
max_self(dp[w_a + weight], dp[w_a] + value);
}
}
ll answer = 0;
for (int i = 0; i <= w; i++) {
max_self(answer, dp[i]);
}
}
int main() { solve(); } | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
void max_self(ll &a, ll b) { a = max(a, b); }
void solve() {
int n, w;
cin >> n >> w;
vector<ll> dp(w + 1); // 0,1,2............w
// dp[i] = maximum value of items with total weight
for (int item = 0; item < n; item++) {
ll weight, value;
cin >> weight >> value;
for (int w_a = w - weight; w_a >= 0; w_a--) {
max_self(dp[w_a + weight], dp[w_a] + value);
}
}
ll answer = 0;
for (int i = 0; i <= w; i++) {
max_self(answer, dp[i]);
}
cout << answer;
}
int main() { solve(); } | [] | 967,518 | 967,519 | u440619190 | cpp |
p03163 | #include <bits/stdc++.h>
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
using namespace std;
int main() {
int n, w;
cin >> n >> w;
vector<int> weight(n), value(n);
for (int i = 0; i < n; i++)
cin >> weight[i] >> value[i];
vector<vector<int>> dp(n + 1, vector<int>(w + 1));
for (int i = n - 1; i >= 0; i--) {
for (int j = 1; j <= w; j++) {
if ((j - weight[i]) >= 0)
dp[i][j] = max(value[i] + dp[i + 1][j - weight[i]], dp[i + 1][j]);
else
dp[i][j] = dp[i + 1][j];
}
}
cout << dp[0][w] << "\n";
return 0;
} | #include <bits/stdc++.h>
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
using namespace std;
int main() {
fast;
int n, w;
cin >> n >> w;
vector<int> weight(n), value(n);
for (int i = 0; i < n; i++)
cin >> weight[i] >> value[i];
vector<vector<long long>> dp(n + 1, vector<long long>(w + 1));
for (int i = n - 1; i >= 0; i--) {
for (int j = 1; j <= w; j++) {
if ((j - weight[i]) >= 0)
dp[i][j] = max(value[i] + dp[i + 1][j - weight[i]], dp[i + 1][j]);
else
dp[i][j] = dp[i + 1][j];
}
}
cout << dp[0][w] << "\n";
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,524 | 967,525 | u560322763 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define debug(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << "[" << *it << " = " << a << "]" << endl;
err(++it, args...);
}
using ll = long long int;
int main() {
int N, W;
scanf("%d%d", &N, &W);
vector<int> w(N + 1), v(N + 1);
for (int i = 1; i <= N; i++) {
scanf("%d %d", &w[i], &v[i]);
}
vector<vector<int>> dp(N + 1, vector<int>(W));
for (int i = 1; i <= N; i++) {
for (int j = 0; j < w[i]; j++) {
dp[i][j] = dp[i - 1][j];
}
for (int j = w[i]; j <= W; j++) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
}
}
printf("%lld\n", dp[N][W]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define debug(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << "[" << *it << " = " << a << "]" << endl;
err(++it, args...);
}
using ll = long long;
int main() {
int N, W;
scanf("%d%d", &N, &W);
vector<int> w(N + 1), v(N + 1);
for (int i = 1; i <= N; i++) {
scanf("%d %d", &w[i], &v[i]);
}
vector<vector<ll>> dp(N + 1, vector<ll>(W + 1));
for (int i = 1; i <= N; i++) {
for (int j = 0; j < w[i]; j++) {
dp[i][j] = dp[i - 1][j];
}
for (int j = w[i]; j <= W; j++) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
}
}
printf("%lld\n", dp[N][W]);
return 0;
}
| [
"variable_declaration.type.narrow.change",
"call.arguments.change"
] | 967,528 | 967,529 | u602028344 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
bool mycmp(pair<int, int> a, pair<int, int> b) {
if (a.first < b.first)
return true;
else if (a.first == b.first) {
if (a.second < b.second)
return true;
return false;
}
return false;
}
int main() {
int num, w;
cin >> num >> w;
vector<pair<int, int>> w_v;
for (int i = 0; i < num; i++) {
int a, b;
cin >> a >> b;
w_v.push_back(make_pair(a, b));
}
sort(w_v.begin(), w_v.end());
int sol = 0;
vector<vector<int>> dp(w_v.size(), vector<int>(w + 1, 0));
for (int i = 0; i < w_v.size(); i++) {
for (int j = 0; j < dp[i].size(); j++) {
if (i == 0) {
while (j < dp[i].size() && j < w_v[i].first) {
j++;
}
dp[i][j] = w_v[i].second;
} else {
while (j < dp[i].size() && j < w_v[i].first) {
dp[i][j] = dp[i - 1][j];
j++;
}
dp[i][j] =
max(dp[i - 1][j], w_v[i].second + dp[i - 1][j - (w_v[i].first)]);
}
sol = max(sol, dp[i][j]);
}
}
cout << sol << endl;
} | #include <bits/stdc++.h>
using namespace std;
bool mycmp(pair<int, int> a, pair<int, int> b) {
if (a.first < b.first)
return true;
else if (a.first == b.first) {
if (a.second < b.second)
return true;
return false;
}
return false;
}
int main() {
int num, w;
cin >> num >> w;
vector<pair<int, int>> w_v;
for (int i = 0; i < num; i++) {
int a, b;
cin >> a >> b;
w_v.push_back(make_pair(a, b));
}
sort(w_v.begin(), w_v.end());
long sol = 0;
vector<vector<long>> dp(w_v.size(), vector<long>(w + 1, 0));
for (int i = 0; i < w_v.size(); i++) {
for (int j = 0; j < dp[i].size(); j++) {
if (i == 0) {
while (j < dp[i].size() && j < w_v[i].first) {
j++;
}
dp[i][j] = w_v[i].second;
} else {
while (j < dp[i].size() && j < w_v[i].first) {
dp[i][j] = dp[i - 1][j];
j++;
}
dp[i][j] =
max(dp[i - 1][j], w_v[i].second + dp[i - 1][j - (w_v[i].first)]);
}
sol = max(sol, dp[i][j]);
}
}
cout << sol << endl;
} | [
"variable_declaration.type.primitive.change"
] | 967,539 | 967,540 | u058785367 | cpp |
p03163 | /*
Choo Lo jo mujhe tum kabhi, kho na jaoon main raat din
Nazaron mein tum ho basey
Keh do jo tum ek baar, Mere ho bas tum mere
Nazaron mein tum ho basey
*/
#include <bits/stdc++.h>
#include <cstdio>
#define deb(x) cout << #x << " -> " << x << el
#define db double
#define ll long long int
#define ull unsigned long long int
#define umap unordered_map
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define pass cout << "pass\n"
#define vi vector<int>
#define pb push_back
#define vec vector
#define el "\n"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define umap unordered_map
#define f(i, x, y) for (int i = x; i < y; ++i)
#define ff(i, x, y) for (int i = x; i <= y; ++i)
#define mem(x) memset(x, 0, sizeof(x))
#define mems(x, y) memset(x, y, sizeof(x))
#define FIO \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define ppi pair<int, pii>
#define mat vector<vector<ll>>
#define mod 1000000007
#define MAX 100005
using namespace std;
const int INF = 1e9 + 5;
void solve() {
int n, W;
sc(n);
sc(W);
vec<int> dp(W + 1, 0);
for (int item = 0; item < n; ++item) {
int weight, value;
cin >> weight >> value;
for (int i = W; i >= weight; --i) {
dp[i] = max(dp[i], dp[i - weight] + value);
}
}
cout << *max_element(dp.begin(), dp.end()) << el;
}
int main() {
int ccc = 1;
// sc(ccc);
while (ccc--) {
solve();
}
return 0;
}
| /*
Choo Lo jo mujhe tum kabhi, kho na jaoon main raat din
Nazaron mein tum ho basey
Keh do jo tum ek baar, Mere ho bas tum mere
Nazaron mein tum ho basey
*/
#include <bits/stdc++.h>
#include <cstdio>
#define deb(x) cout << #x << " -> " << x << el
#define db double
#define ll long long int
#define ull unsigned long long int
#define umap unordered_map
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define pass cout << "pass\n"
#define vi vector<int>
#define pb push_back
#define vec vector
#define el "\n"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define umap unordered_map
#define f(i, x, y) for (int i = x; i < y; ++i)
#define ff(i, x, y) for (int i = x; i <= y; ++i)
#define mem(x) memset(x, 0, sizeof(x))
#define mems(x, y) memset(x, y, sizeof(x))
#define FIO \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define ppi pair<int, pii>
#define mat vector<vector<ll>>
#define mod 1000000007
#define MAX 100005
using namespace std;
const int INF = 1e9 + 5;
void solve() {
int n, W;
sc(n);
sc(W);
vec<ll> dp(W + 1, 0);
for (int item = 0; item < n; ++item) {
int weight, value;
cin >> weight >> value;
for (int i = W; i >= weight; --i) {
dp[i] = max(dp[i], dp[i - weight] + value);
}
}
cout << *max_element(dp.begin(), dp.end()) << el;
}
int main() {
int ccc = 1;
// sc(ccc);
while (ccc--) {
solve();
}
return 0;
}
| [] | 967,541 | 967,542 | u764866999 | cpp |
p03163 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;
int main() {
_ int n, w;
cin >> n >> w;
vector<int> weights(n, 0);
vector<int> values(n, 0);
for (int i = 0; i < n; i++) {
cin >> weights[i] >> values[i];
}
vector<vector<int>> dp(n + 1, vector<int>(w + 1, 0));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (weights[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] =
max(dp[i - 1][j], dp[i - 1][j - weights[i - 1]] + values[i - 1]);
}
}
cout << dp[n][w] << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;
int main() {
_ int n, w;
cin >> n >> w;
vector<ll> weights(n, 0);
vector<ll> values(n, 0);
for (int i = 0; i < n; i++) {
cin >> weights[i] >> values[i];
}
vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
if (weights[i - 1] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] =
max(dp[i - 1][j], dp[i - 1][j - weights[i - 1]] + values[i - 1]);
}
}
cout << dp[n][w] << endl;
return 0;
} | [
"call.arguments.change"
] | 967,547 | 967,548 | u376415869 | cpp |
p03163 | #include <iostream>
using namespace std;
int n;
int max_weight;
int w[100];
long long int v[100];
long long int dp[101][100001];
int ans = 0;
int main() {
cin >> n >> max_weight;
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < max_weight; j++) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
if (j + w[i] <= max_weight)
dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
}
}
for (int i = 0; i <= max_weight; i++) {
if (dp[n][i] > ans)
ans = dp[n][i];
}
cout << ans << endl;
} | #include <iostream>
using namespace std;
int n;
int max_weight;
int w[101];
long long int v[101];
long long int dp[101][100001];
long long int ans = 0;
int main() {
cin >> n >> max_weight;
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j <= max_weight; j++) {
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
if (j + w[i] <= max_weight)
dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
}
}
for (int i = 0; i <= max_weight; i++) {
if (dp[n][i] >= ans)
ans = dp[n][i];
}
cout << ans << endl;
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change"
] | 967,551 | 967,550 | u693953100 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long dp[105][N];
int main() {
long long n, W;
scanf("%lld %lld", &n, &W);
for (int i = 1; i <= n; i++) {
int v, w;
scanf("%lld %lld", &w, &v);
for (int j = 0; j < w; j++)
dp[i][j] = dp[i - 1][j];
for (int j = w; j <= W; j++)
dp[i][j] = max(dp[i - 1][j], v + dp[i - 1][j - w]);
}
printf("%lld\n", dp[n][W]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long dp[105][N];
int main() {
long long n, W;
scanf("%lld %lld", &n, &W);
for (int i = 1; i <= n; i++) {
long long v, w;
scanf("%lld %lld", &w, &v);
for (int j = 0; j < w; j++)
dp[i][j] = dp[i - 1][j];
for (int j = w; j <= W; j++)
dp[i][j] = max(dp[i - 1][j], v + dp[i - 1][j - w]);
}
printf("%lld\n", dp[n][W]);
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,560 | 967,561 | u377964143 | 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 = 1e5 + 5;
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_clz(x) - 1; }
// Variables Declaration
int N, W;
vector<pair<ll, ll>> vect;
ll dp[110][MAXN];
ll solve(int n, int w) {
if (dp[n][w] >= 0)
return dp[n][w];
if (n >= N)
return 0;
if (w == 0)
return 0;
if (w - vect[n].first < 0)
return solve(n + 1, w);
ll sol = 0;
// debug(n); debugg(w);
sol = max(solve(n + 1, w) + 0,
solve(n + 1, w - vect[n].first) + vect[n].second);
return dp[n][w] = sol;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(dp, 0, sizeof(dp));
cin >> N >> W;
vect.resize(N + 1);
for (int i = 1; i <= N; ++i) {
pair<int, int> tmp;
cin >> tmp.first >> tmp.second;
vect[i] = tmp;
}
// cout << solve(0, W) << endl;
for (int i = 1; i <= N; ++i) {
for (int j = 0; j <= W; ++j) {
if (j - vect[i].first >= 0) {
dp[i + 1][j] =
max(dp[i + 1][j], dp[i][j - vect[i].first] + vect[i].second);
}
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[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 = 1e5 + 5;
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_clz(x) - 1; }
// Variables Declaration
int N, W;
vector<pair<ll, ll>> vect;
ll dp[110][MAXN];
ll solve(int n, int w) {
if (dp[n][w] >= 0)
return dp[n][w];
if (n >= N)
return 0;
if (w == 0)
return 0;
if (w - vect[n].first < 0)
return solve(n + 1, w);
ll sol = 0;
// debug(n); debugg(w);
sol = max(solve(n + 1, w) + 0,
solve(n + 1, w - vect[n].first) + vect[n].second);
return dp[n][w] = sol;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(dp, 0, sizeof(dp));
cin >> N >> W;
vect.resize(N + 1);
for (int i = 1; i <= N; ++i) {
pair<int, int> tmp;
cin >> tmp.first >> tmp.second;
vect[i] = tmp;
}
// cout << solve(0, W) << endl;
for (int i = 1; i <= N; ++i) {
for (int j = 0; j <= W; ++j) {
if (j - vect[i].first >= 0) {
dp[i + 1][j] =
max(dp[i + 1][j], dp[i][j - vect[i].first] + vect[i].second);
}
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
}
}
cout << dp[N + 1][W] << endl;
return 0;
}
| [
"expression.operation.binary.add"
] | 967,562 | 967,563 | u232320029 | cpp |
p03163 | #include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a) begin((a)), end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
ll WEIGHTS[110], VALUE[110];
ll DP[100010][2];
int main() {
ll N, W;
cin >> N >> W;
rep(i, 0, N) { cin >> WEIGHTS[i] >> VALUE[i]; }
rep(i, 0, N) {
rrep(sum_w, 0, W) {
if (sum_w - WEIGHTS[i] >= 0) {
DP[i + 1][sum_w] =
max(DP[i + 1][sum_w], DP[i][sum_w - WEIGHTS[i]] + VALUE[i]);
}
DP[i + 1][sum_w] = max(DP[i + 1][sum_w], DP[i][sum_w]);
}
}
cout << DP[N][W] << endl;
} | #include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a) begin((a)), end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
ll WEIGHTS[110], VALUE[110];
ll DP[110][100100] = {0};
int main() {
ll N, W;
cin >> N >> W;
rep(i, 0, N) { cin >> WEIGHTS[i] >> VALUE[i]; }
rep(i, 0, N) {
rrep(sum_w, 0, W) {
if (sum_w - WEIGHTS[i] >= 0) {
DP[i + 1][sum_w] =
max(DP[i + 1][sum_w], DP[i][sum_w - WEIGHTS[i]] + VALUE[i]);
}
DP[i + 1][sum_w] = max(DP[i + 1][sum_w], DP[i][sum_w]);
}
}
cout << DP[N][W] << endl;
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"variable_declaration.value.change"
] | 967,566 | 967,567 | u729217226 | cpp |
p03163 | #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
int main() {
int n, x;
cin >> n >> x;
vector<int> w(n);
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> w.at(i) >> v.at(i);
}
vector<vector<int>> dp(n + 1, vector<int>(x + 1));
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= x; j++) {
if (j - w.at(i - 1) >= 0) {
dp.at(i).at(j) =
max(dp.at(i).at(j), dp.at(i - 1).at(j - w.at(i - 1)) + v.at(i - 1));
}
dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i - 1).at(j));
}
}
cout << dp.at(n).at(x) << endl;
}
| #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
int main() {
ll n, x;
cin >> n >> x;
vector<ll> w(n);
vector<ll> v(n);
for (int i = 0; i < n; i++) {
cin >> w.at(i) >> v.at(i);
}
vector<vector<ll>> dp(n + 1, vector<ll>(x + 1));
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= x; j++) {
if (j - w.at(i - 1) >= 0) {
dp.at(i).at(j) =
max(dp.at(i).at(j), dp.at(i - 1).at(j - w.at(i - 1)) + v.at(i - 1));
}
dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i - 1).at(j));
}
}
cout << dp.at(n).at(x) << endl;
}
| [
"variable_declaration.type.change",
"call.arguments.change"
] | 967,568 | 967,569 | u366125700 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
void testcase() {
int n, w;
cin >> n >> w;
vector<int> values(n), weights(n);
for (int i = 0; i < n; i++) {
cin >> weights[i] >> values[i];
}
vector<int> dp(w + 1);
for (int i = 0; i < n; i++) {
for (int j = w; j >= 0; j--) {
if (j - weights[i] >= 0) {
dp[j] = max(dp[j], dp[j - weights[i]] + values[i]);
}
}
}
cout << *max_element(dp.begin(), dp.end());
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
#ifdef AKP
freopen("in.txt", "r", stdin);
#endif
int t = 1;
// cin >> t;
while (t--) {
testcase();
cout << '\n';
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
void testcase() {
int n, w;
cin >> n >> w;
vector<long long> values(n), weights(n);
for (int i = 0; i < n; i++) {
cin >> weights[i] >> values[i];
}
vector<long long> dp(w + 1);
for (int i = 0; i < n; i++) {
for (int j = w; j >= 0; j--) {
if (j - weights[i] >= 0) {
dp[j] = max(dp[j], dp[j - weights[i]] + values[i]);
}
}
}
cout << *max_element(dp.begin(), dp.end());
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
#ifdef AKP
freopen("in.txt", "r", stdin);
#endif
int t = 1;
// cin >> t;
while (t--) {
testcase();
cout << '\n';
}
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,574 | 967,575 | u475283806 | 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;
vector<long long> dp(W + 1);
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = W; j >= w; j--) {
dp[j] = max(dp[j - w] + v, dp[j]);
}
// for (int k = 0; k <= N; k++)
}
long long ans = 0;
for (int i = 0; i <= N; i++) {
ans = max(dp[i], ans);
}
cout << ans;
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;
vector<long long> dp(W + 1);
for (int i = 0; i < N; i++) {
int w, v;
cin >> w >> v;
for (int j = W; j >= w; j--) {
dp[j] = max(dp[j - w] + v, dp[j]);
}
// for (int k = 0; k <= N; k++)
}
long long ans = 0;
for (int i = 0; i <= W; i++) {
ans = max(dp[i], ans);
}
cout << ans;
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 967,579 | 967,580 | u237011692 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define int long long int
const int INF = 1e9 + 5;
#undef int
int main() {
#define int long long int
int n, w;
cin >> n >> w;
vector<int> weight(n, 0);
vector<int> values(n, 0);
int dp[n + 5][w + 5];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < n; i++) {
cin >> weight[i];
cin >> values[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 (j >= weight[i - 1]) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i]] + values[i - 1]);
}
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w];
} | #include <bits/stdc++.h>
using namespace std;
#define int long long int
const int INF = 1e9 + 5;
#undef int
int main() {
#define int long long int
int n, w;
cin >> n >> w;
vector<int> weight(n, 0);
vector<int> values(n, 0);
int dp[n + 5][w + 5];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < n; i++) {
cin >> weight[i];
cin >> values[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 (j >= weight[i - 1]) {
dp[i][j] =
max(dp[i - 1][j], dp[i - 1][j - weight[i - 1]] + values[i - 1]);
}
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w];
} | [
"assignment.change"
] | 967,583 | 967,584 | u720279479 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define int long long int
const int INF = 1e9 + 5;
#undef int
int main() {
#define int long long int
int n, w;
cin >> n >> w;
vector<int> weight(n, 0);
vector<int> values(n, 0);
int dp[n + 5][w + 5];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < n; i++) {
cin >> weight[i];
cin >> values[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 (j >= weight[i]) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i]] + values[i - 1]);
}
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w];
} | #include <bits/stdc++.h>
using namespace std;
#define int long long int
const int INF = 1e9 + 5;
#undef int
int main() {
#define int long long int
int n, w;
cin >> n >> w;
vector<int> weight(n, 0);
vector<int> values(n, 0);
int dp[n + 5][w + 5];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < n; i++) {
cin >> weight[i];
cin >> values[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 (j >= weight[i - 1]) {
dp[i][j] =
max(dp[i - 1][j], dp[i - 1][j - weight[i - 1]] + values[i - 1]);
}
else
dp[i][j] = dp[i - 1][j];
}
}
cout << dp[n][w];
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one",
"assignment.change"
] | 967,585 | 967,584 | u720279479 | cpp |
p03163 | #include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 20;
int N, W;
int dp[MN];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> N >> W;
for (int i = 1, w, v; i <= N; i++) {
cin >> w >> v;
for (int j = W; j >= w; j--)
dp[j] = max(dp[j], dp[j - w] + v);
}
cout << dp[W] << '\n';
return 0;
}
| #include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 20;
int N, W;
ll dp[MN];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> N >> W;
for (int i = 1, w, v; i <= N; i++) {
cin >> w >> v;
for (int j = W; j >= w; j--)
dp[j] = max(dp[j], dp[j - w] + v);
}
cout << dp[W] << '\n';
return 0;
}
| [
"variable_declaration.type.change"
] | 967,593 | 967,594 | u338847482 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, w;
cin >> n >> w;
vector<pair<int, int>> items(n);
int weight, val;
for (int i = 0; i < n; ++i) {
cin >> weight >> val;
items[i] = {weight, val};
}
int dp[n + 1][w + 1];
for (int i = 0; i <= n; ++i) {
dp[i][0] = 0;
}
for (int i = 0; i <= w; ++i) {
i < items[0].first ? dp[0][i] = 0 : dp[0][i] = items[0].second;
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= w; ++j) {
if (items[i].first <= j) {
dp[i][j] =
max(dp[i - 1][j], items[i].second + dp[i - 1][j - items[i].first]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, w;
cin >> n >> w;
vector<pair<int, int>> items(n);
int weight, val;
for (int i = 0; i < n; ++i) {
cin >> weight >> val;
items[i] = {weight, val};
}
long long dp[n + 1][w + 1];
for (int i = 0; i <= n; ++i) {
dp[i][0] = 0;
}
for (int i = 0; i <= w; ++i) {
i < items[0].first ? dp[0][i] = 0 : dp[0][i] = items[0].second;
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= w; ++j) {
if (items[i].first <= j) {
dp[i][j] =
max(dp[i - 1][j], items[i].second + dp[i - 1][j - items[i].first]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << '\n';
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,599 | 967,600 | u264922697 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100001][101];
ll n, W;
ll w[100001], v[100001];
ll ans(ll ind, ll c) {
if (c < 0)
return -1 * numeric_limits<ll>::infinity();
if (ind > n - 1)
return 0;
if (dp[ind][c] != -1)
return dp[ind][c];
dp[ind][c] = max(ans(ind + 1, c), ans(ind + 1, c - w[ind]) + v[ind]);
return dp[ind][c];
}
int main() {
memset(dp, -1, sizeof(dp));
cin >> n >> W;
for (ll i = 0; i < n; i++)
cin >> w[i] >> v[i];
cout << ans(0, W) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[101][100001];
ll n, W;
ll w[100001], v[100001];
ll ans(ll ind, ll c) {
if (c < 0)
return numeric_limits<ll>::min();
if (ind > n - 1)
return 0;
if (dp[ind][c] != -1)
return dp[ind][c];
dp[ind][c] = max(ans(ind + 1, c), ans(ind + 1, c - w[ind]) + v[ind]);
return dp[ind][c];
}
int main() {
memset(dp, -1, sizeof(dp));
cin >> n >> W;
for (ll i = 0; i < n; i++)
cin >> w[i] >> v[i];
cout << ans(0, W) << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"expression.operation.binary.remove",
"identifier.change",
"function.return_value.change",
"expression.operation.binary.change"
] | 967,601 | 967,602 | u555510163 | cpp |
p03163 | #include <algorithm>
#include <memory.h>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int N, W;
// freopen("input.txt", "r", stdin);
scanf("%d%d", &N, &W);
vector<int> w(N);
vector<int> v(N);
for (int i = 0; i < N; i++) {
scanf("%d%d", &w[i], &v[i]);
}
vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= W; j++) {
if (j >= w[i - 1])
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
else
dp[i][j] = dp[i - 1][j];
}
}
printf("%d\n", dp[N][W]);
return 0;
} | #include <algorithm>
#include <memory.h>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int N, W;
// freopen("input.txt", "r", stdin);
scanf("%d%d", &N, &W);
vector<int> w(N);
vector<int> v(N);
for (int i = 0; i < N; i++) {
scanf("%d%d", &w[i], &v[i]);
}
vector<vector<long>> dp(N + 1, vector<long>(W + 1, 0));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= W; j++) {
if (j >= w[i - 1])
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
else
dp[i][j] = dp[i - 1][j];
}
}
printf("%ld\n", dp[N][W]);
return 0;
} | [
"variable_declaration.type.primitive.change",
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 967,606 | 967,607 | u532328625 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll unsigned long long
#define MAXN 200
using namespace std;
vector<vector<int>> adj;
vector<bool> visited;
vector<int> parent;
ll tree[MAXN];
ll bin[MAXN];
int fbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
r = m - 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
int lbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
l = m + 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
void dfs(int s) {
visited[s] = true;
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
parent[adj[s][i]] = s;
dfs(adj[s][i]);
}
}
}
int bfs(int s) {
if (visited[s])
return 0;
queue<int> q;
int ans = 0;
q.push(s);
visited[s] = true;
while (!q.empty()) {
s = q.front();
q.pop();
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
visited[adj[s][i]] = true;
q.push(adj[s][i]);
}
}
}
return ans;
}
void sieve(int n, vector<int> &primes) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
for (int p = 2; p <= n; p++)
if (prime[p]) {
primes.push_back(p);
}
}
int phi(int n) {
int result = n;
for (int p = 2; p * p <= n; ++p) {
if (n % p == 0) {
while (n % p == 0)
n /= p;
result -= result / p;
}
}
if (n > 1)
result -= result / n;
return result;
}
void fin(int n, vector<int> &divs) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
divs.push_back(i);
else {
divs.push_back(i);
divs.push_back(n / i);
}
}
}
}
int ct(int x) {
int ans = 0;
while (x > 0) {
ans += (x & 1);
x >>= 1;
}
return ans;
}
void build(int sti, int lo, int hi) {
if (lo == hi) {
tree[sti] = 0;
bin[sti] = 0;
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (lo + hi) / 2;
build(left, lo, mid);
build(right, mid + 1, hi);
bin[sti] = bin[left] + bin[right];
return;
}
void update(int sti, int sl, int sr, int in, int type) {
if (sl == sr && sl == in) {
if (type == 1) {
tree[sti] = 2 * tree[sti] + 1;
bin[sti] = ct(tree[sti]);
} else {
tree[sti] /= 2;
bin[sti] = ct(tree[sti]);
}
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (sl + sr) / 2;
if (in <= mid) {
update(left, sl, mid, in, type);
} else {
update(right, mid + 1, sr, in, type);
}
bin[sti] = bin[left] + bin[right];
}
int query(int sti, int sl, int sr, int lo, int hi) {
if (sl == lo && sr == hi) {
return bin[sti];
}
int mid = (sl + sr) / 2;
int left = 2 * sti, right = 2 * sti + 1;
if (hi <= mid) {
return query(left, sl, mid, lo, hi);
} else if (lo > mid) {
return query(right, mid + 1, sr, lo, hi);
} else {
return query(left, sl, mid, lo, mid) +
query(right, mid + 1, sr, mid + 1, hi);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n, W;
cin >> n >> W;
ll w[n], v[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
ll dp[n + 1][W + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= W; j++) {
dp[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= W; j++) {
if (j - w[i] >= 0) {
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[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>
#define ll long long
#define MAXN 200
using namespace std;
vector<vector<int>> adj;
vector<bool> visited;
vector<int> parent;
ll tree[MAXN];
ll bin[MAXN];
int fbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
r = m - 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
int lbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
l = m + 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
void dfs(int s) {
visited[s] = true;
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
parent[adj[s][i]] = s;
dfs(adj[s][i]);
}
}
}
int bfs(int s) {
if (visited[s])
return 0;
queue<int> q;
int ans = 0;
q.push(s);
visited[s] = true;
while (!q.empty()) {
s = q.front();
q.pop();
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
visited[adj[s][i]] = true;
q.push(adj[s][i]);
}
}
}
return ans;
}
void sieve(int n, vector<int> &primes) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
for (int p = 2; p <= n; p++)
if (prime[p]) {
primes.push_back(p);
}
}
int phi(int n) {
int result = n;
for (int p = 2; p * p <= n; ++p) {
if (n % p == 0) {
while (n % p == 0)
n /= p;
result -= result / p;
}
}
if (n > 1)
result -= result / n;
return result;
}
void fin(int n, vector<int> &divs) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
divs.push_back(i);
else {
divs.push_back(i);
divs.push_back(n / i);
}
}
}
}
int ct(int x) {
int ans = 0;
while (x > 0) {
ans += (x & 1);
x >>= 1;
}
return ans;
}
void build(int sti, int lo, int hi) {
if (lo == hi) {
tree[sti] = 0;
bin[sti] = 0;
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (lo + hi) / 2;
build(left, lo, mid);
build(right, mid + 1, hi);
bin[sti] = bin[left] + bin[right];
return;
}
void update(int sti, int sl, int sr, int in, int type) {
if (sl == sr && sl == in) {
if (type == 1) {
tree[sti] = 2 * tree[sti] + 1;
bin[sti] = ct(tree[sti]);
} else {
tree[sti] /= 2;
bin[sti] = ct(tree[sti]);
}
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (sl + sr) / 2;
if (in <= mid) {
update(left, sl, mid, in, type);
} else {
update(right, mid + 1, sr, in, type);
}
bin[sti] = bin[left] + bin[right];
}
int query(int sti, int sl, int sr, int lo, int hi) {
if (sl == lo && sr == hi) {
return bin[sti];
}
int mid = (sl + sr) / 2;
int left = 2 * sti, right = 2 * sti + 1;
if (hi <= mid) {
return query(left, sl, mid, lo, hi);
} else if (lo > mid) {
return query(right, mid + 1, sr, lo, hi);
} else {
return query(left, sl, mid, lo, mid) +
query(right, mid + 1, sr, mid + 1, hi);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n, W;
cin >> n >> W;
ll w[n], v[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
ll dp[n + 1][W + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= W; j++) {
dp[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= W; j++) {
if ((j - w[i - 1]) >= 0) {
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][W] << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 967,608 | 967,609 | u691653216 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll unsigned long long
#define MAXN 200
using namespace std;
vector<vector<int>> adj;
vector<bool> visited;
vector<int> parent;
ll tree[MAXN];
ll bin[MAXN];
int fbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
r = m - 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
int lbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
l = m + 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
void dfs(int s) {
visited[s] = true;
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
parent[adj[s][i]] = s;
dfs(adj[s][i]);
}
}
}
int bfs(int s) {
if (visited[s])
return 0;
queue<int> q;
int ans = 0;
q.push(s);
visited[s] = true;
while (!q.empty()) {
s = q.front();
q.pop();
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
visited[adj[s][i]] = true;
q.push(adj[s][i]);
}
}
}
return ans;
}
void sieve(int n, vector<int> &primes) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
for (int p = 2; p <= n; p++)
if (prime[p]) {
primes.push_back(p);
}
}
int phi(int n) {
int result = n;
for (int p = 2; p * p <= n; ++p) {
if (n % p == 0) {
while (n % p == 0)
n /= p;
result -= result / p;
}
}
if (n > 1)
result -= result / n;
return result;
}
void fin(int n, vector<int> &divs) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
divs.push_back(i);
else {
divs.push_back(i);
divs.push_back(n / i);
}
}
}
}
int ct(int x) {
int ans = 0;
while (x > 0) {
ans += (x & 1);
x >>= 1;
}
return ans;
}
void build(int sti, int lo, int hi) {
if (lo == hi) {
tree[sti] = 0;
bin[sti] = 0;
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (lo + hi) / 2;
build(left, lo, mid);
build(right, mid + 1, hi);
bin[sti] = bin[left] + bin[right];
return;
}
void update(int sti, int sl, int sr, int in, int type) {
if (sl == sr && sl == in) {
if (type == 1) {
tree[sti] = 2 * tree[sti] + 1;
bin[sti] = ct(tree[sti]);
} else {
tree[sti] /= 2;
bin[sti] = ct(tree[sti]);
}
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (sl + sr) / 2;
if (in <= mid) {
update(left, sl, mid, in, type);
} else {
update(right, mid + 1, sr, in, type);
}
bin[sti] = bin[left] + bin[right];
}
int query(int sti, int sl, int sr, int lo, int hi) {
if (sl == lo && sr == hi) {
return bin[sti];
}
int mid = (sl + sr) / 2;
int left = 2 * sti, right = 2 * sti + 1;
if (hi <= mid) {
return query(left, sl, mid, lo, hi);
} else if (lo > mid) {
return query(right, mid + 1, sr, lo, hi);
} else {
return query(left, sl, mid, lo, mid) +
query(right, mid + 1, sr, mid + 1, hi);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, W;
cin >> n >> W;
int w[n], v[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
int dp[n + 1][W + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= W; j++) {
dp[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= W; j++) {
if (j - w[i - 1] >= 0) {
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[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>
#define ll long long
#define MAXN 200
using namespace std;
vector<vector<int>> adj;
vector<bool> visited;
vector<int> parent;
ll tree[MAXN];
ll bin[MAXN];
int fbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
r = m - 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
int lbs(int arr[], int l, int r, int x) {
int res = 0;
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x) {
res = m;
l = m + 1;
} else if (arr[m] < x)
l = m + 1;
else
r = m - 1;
res = l;
}
return res;
}
void dfs(int s) {
visited[s] = true;
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
parent[adj[s][i]] = s;
dfs(adj[s][i]);
}
}
}
int bfs(int s) {
if (visited[s])
return 0;
queue<int> q;
int ans = 0;
q.push(s);
visited[s] = true;
while (!q.empty()) {
s = q.front();
q.pop();
for (int i = 0; i < adj[s].size(); i++) {
if (!visited[adj[s][i]]) {
visited[adj[s][i]] = true;
q.push(adj[s][i]);
}
}
}
return ans;
}
void sieve(int n, vector<int> &primes) {
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
for (int p = 2; p <= n; p++)
if (prime[p]) {
primes.push_back(p);
}
}
int phi(int n) {
int result = n;
for (int p = 2; p * p <= n; ++p) {
if (n % p == 0) {
while (n % p == 0)
n /= p;
result -= result / p;
}
}
if (n > 1)
result -= result / n;
return result;
}
void fin(int n, vector<int> &divs) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
divs.push_back(i);
else {
divs.push_back(i);
divs.push_back(n / i);
}
}
}
}
int ct(int x) {
int ans = 0;
while (x > 0) {
ans += (x & 1);
x >>= 1;
}
return ans;
}
void build(int sti, int lo, int hi) {
if (lo == hi) {
tree[sti] = 0;
bin[sti] = 0;
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (lo + hi) / 2;
build(left, lo, mid);
build(right, mid + 1, hi);
bin[sti] = bin[left] + bin[right];
return;
}
void update(int sti, int sl, int sr, int in, int type) {
if (sl == sr && sl == in) {
if (type == 1) {
tree[sti] = 2 * tree[sti] + 1;
bin[sti] = ct(tree[sti]);
} else {
tree[sti] /= 2;
bin[sti] = ct(tree[sti]);
}
return;
}
int left = 2 * sti, right = 2 * sti + 1, mid = (sl + sr) / 2;
if (in <= mid) {
update(left, sl, mid, in, type);
} else {
update(right, mid + 1, sr, in, type);
}
bin[sti] = bin[left] + bin[right];
}
int query(int sti, int sl, int sr, int lo, int hi) {
if (sl == lo && sr == hi) {
return bin[sti];
}
int mid = (sl + sr) / 2;
int left = 2 * sti, right = 2 * sti + 1;
if (hi <= mid) {
return query(left, sl, mid, lo, hi);
} else if (lo > mid) {
return query(right, mid + 1, sr, lo, hi);
} else {
return query(left, sl, mid, lo, mid) +
query(right, mid + 1, sr, mid + 1, hi);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n, W;
cin >> n >> W;
ll w[n], v[n];
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
ll dp[n + 1][W + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= W; j++) {
dp[i][j] = 0;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= W; j++) {
if ((j - w[i - 1]) >= 0) {
dp[i][j] = max(v[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][W] << endl;
return 0;
}
| [
"variable_declaration.type.change",
"control_flow.branch.if.condition.change"
] | 967,610 | 967,609 | u691653216 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))
#define INF 2e9
#define INF_LL 1LL << 60
#define ll long long
#define MOD 1e9 + 7
#define MAX_V
const double PI = 3.14159265358979323846;
#define print2D(h, w, arr) \
REP(i, h) { \
REP(j, w) cout << arr[i][j] << " "; \
cout << endl; \
}
#define print_line(vec, n) \
{ \
for (int i = 0; i < (n - 1); i++) \
cout << (vec)[i] << " "; \
cout << (vec)[(n)-1] << endl; \
}
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
cout << first << " ";
print(rest...);
}
struct PreMain {
PreMain() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} premain;
int dp[101][100001];
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N), v(N);
REP(i, N) cin >> w[i] >> v[i];
REP(i, N) REP(j, W + 1) {
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;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))
#define INF 2e9
#define INF_LL 1LL << 60
#define ll long long
#define MOD 1e9 + 7
#define MAX_V
const double PI = 3.14159265358979323846;
#define print2D(h, w, arr) \
REP(i, h) { \
REP(j, w) cout << arr[i][j] << " "; \
cout << endl; \
}
#define print_line(vec, n) \
{ \
for (int i = 0; i < (n - 1); i++) \
cout << (vec)[i] << " "; \
cout << (vec)[(n)-1] << endl; \
}
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
cout << first << " ";
print(rest...);
}
struct PreMain {
PreMain() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} premain;
ll dp[101][100001];
int main() {
int N, W;
cin >> N >> W;
vector<int> w(N), v(N);
REP(i, N) cin >> w[i] >> v[i];
REP(i, N) REP(j, W + 1) {
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;
return 0;
} | [
"variable_declaration.type.change"
] | 967,611 | 967,612 | u127768253 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
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;
}
int n, W;
int weight[110], value[110];
int dp[110][10010];
int main() {
cin >> n >> W;
for (int i = 0; i < n; ++i)
cin >> weight[i] >> value[i];
for (int w = 0; w <= W; w++)
dp[0][w] = 0;
for (int i = 0; i < n; i++) {
for (int w = 0; w <= W; w++) {
if (w >= weight[i])
dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
else
dp[i + 1][w] = dp[i][w];
}
}
cout << dp[n][W] << endl;
} | //制約をよく見る。この場合 型をlong long にしないと通らない。
#include <bits/stdc++.h>
using namespace std;
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;
}
int n, W;
//型はlong long、 少し大きめに取っておく
long long weight[110], value[110];
long long dp[110][100010];
int main() {
cin >> n >> W;
for (int i = 0; i < n; ++i)
cin >> weight[i] >> value[i];
for (int w = 0; w <= W; w++)
dp[0][w] = 0;
for (int i = 0; i < n; i++) {
for (int w = 0; w <= W; w++) {
// a[i]を選択するか否か
if (w >= weight[i])
dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
else
dp[i + 1][w] = dp[i][w];
}
}
cout << dp[n][W] << endl;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 967,617 | 967,616 | u979078704 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
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;
}
int n, W;
int weight[110], value[110];
int dp[110][10010];
int main() {
cin >> n >> W;
for (int i = 0; i < n; ++i)
cin >> weight[i] >> value[i];
for (int w = 0; w <= W; w++)
dp[0][w] = 0;
for (int i = 0; i < n; i++) {
for (int w = 0; w <= W; w++) {
if (w >= weight[i])
dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
else
dp[i + 1][w] = dp[i][w];
}
}
cout << dp[n][W] << endl;
} | #include <bits/stdc++.h>
using namespace std;
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;
}
int n, W;
long long weight[110], value[110];
long long dp[110][100010];
int main() {
cin >> n >> W;
for (int i = 0; i < n; ++i)
cin >> weight[i] >> value[i];
for (int w = 0; w <= W; w++)
dp[0][w] = 0;
for (int i = 0; i < n; i++) {
for (int w = 0; w <= W; w++) {
if (w >= weight[i])
dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
else
dp[i + 1][w] = dp[i][w];
}
}
cout << dp[n][W] << endl;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 967,617 | 967,618 | u979078704 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int N = 109;
int n, w, value[N], weight[N];
int dp[N][100009];
int solve(int i, int w) {
if (i >= n)
return 0;
if (dp[i][w] != -1)
return dp[i][w];
if (weight[i] > w)
return dp[i][w] = solve(i + 1, w);
else {
return dp[i][w] =
max(solve(i + 1, w), solve(i + 1, w - weight[i]) + value[i]);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("in","r",stdin);
memset(dp, -1, sizeof(dp));
cin >> n >> w;
for (int i = 0; i < n; i++)
cin >> weight[i] >> value[i];
cout << solve(0, w);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
const int N = 109;
int n, w, value[N], weight[N];
long long dp[N][100009];
long long solve(int i, int w) {
if (i >= n)
return 0;
if (dp[i][w] != -1)
return dp[i][w];
if (weight[i] > w)
return dp[i][w] = solve(i + 1, w);
else {
return dp[i][w] =
max(solve(i + 1, w), solve(i + 1, w - weight[i]) + value[i]);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(dp, -1, sizeof(dp));
cin >> n >> w;
for (int i = 0; i < n; i++)
cin >> weight[i] >> value[i];
cout << solve(0, w);
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,619 | 967,620 | u389142513 | cpp |
p03163 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) // for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const long long INF = 1LL << 60;
using namespace std;
typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;
// 比較+dpテーブル更新 最大問題
// 更新する方の参照をaに渡すこと.
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
// 比較+dpテーブル更新 最小問題// 更新する方の参照をaに渡すこと.
// 最小問題なので,
// 更新される側にある数字が比較されてる数字よりも大きければ更新する.こうすることで,
// 常に小さいものが選ばれていく.
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
// このdpTableのイメージとしては, 中身に入っているのは価値の大きさ,
// 最初の配列はindex,次の配列はその時の合計の重さである
// long long dp[110][1000010] = {0};
long long weight[110];
long long value[110];
signed main() {
fast;
int N, W = 0;
cin >> N >> W;
vector<vector<long long int>> dp(N + 1, vector<long long int>(W + 1, 0));
REP(i, N) { cin >> value[i] >> weight[i]; }
// DPループ
for (int i = 0; i < N; ++i) {
for (int sum_w = 0; sum_w <= W; ++sum_w) {
// i 番目の品物を選ぶ場合
// 0 になってはいけない
// イメージ: インデクスが1ずれて,
// それから重さがWのマスに飛んでいくイメージ
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
// i 番目の品物を選ばない場合
// ただindexを1ずらす.
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
// 最適値の出力
// 最後はindexN, 重さWのマスの値を出力すればよい.
// (けどindexが最後のマスにおいても重さWを使い切らない方が返って価値が高くなる時があるような気がするので一応最後の段について全て比較した方がいいのかもしれない.)
cout << dp[N][W] << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) // for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const long long INF = 1LL << 60;
using namespace std;
typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;
// 比較+dpテーブル更新 最大問題
// 更新する方の参照をaに渡すこと.
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
// 比較+dpテーブル更新 最小問題// 更新する方の参照をaに渡すこと.
// 最小問題なので,
// 更新される側にある数字が比較されてる数字よりも大きければ更新する.こうすることで,
// 常に小さいものが選ばれていく.
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
// このdpTableのイメージとしては, 中身に入っているのは価値の大きさ,
// 最初の配列はindex,次の配列はその時の合計の重さである
// long long dp[110][1000010] = {0};
long long weight[110];
long long value[110];
signed main() {
fast;
int N, W = 0;
cin >> N >> W;
vector<vector<long long int>> dp(N + 1, vector<long long int>(W + 1, 0));
REP(i, N) { cin >> weight[i] >> value[i]; }
// DPループ
for (int i = 0; i < N; ++i) {
for (int sum_w = 0; sum_w <= W; ++sum_w) {
// i 番目の品物を選ぶ場合
// 0 になってはいけない
// イメージ: インデクスが1ずれて,
// それから重さがWのマスに飛んでいくイメージ
if (sum_w - weight[i] >= 0) {
chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
}
// i 番目の品物を選ばない場合
// ただindexを1ずらす.
chmax(dp[i + 1][sum_w], dp[i][sum_w]);
}
}
// 最適値の出力
// 最後はindexN, 重さWのマスの値を出力すればよい.
// (けどindexが最後のマスにおいても重さWを使い切らない方が返って価値が高くなる時があるような気がするので一応最後の段について全て比較した方がいいのかもしれない.)
cout << dp[N][W] << endl;
}
| [
"identifier.change",
"expression.operation.binary.change"
] | 967,630 | 967,631 | u369980487 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w1;
cin >> n >> w1;
int v[n];
int w[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
// int dp[101][100001];
int dp[n + 1][w1 + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w1; j++)
dp[i][j] = 0;
}
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= w1; j++) {
dp[i + 1][j] = max(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]] + v[i]);
}
}
cout << dp[n][w1];
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, w1;
cin >> n >> w1;
long long int v[n];
int w[n];
for (int i = 0; i < n; i++)
cin >> w[i] >> v[i];
// int dp[101][100001];
long long int dp[n + 1][w1 + 1];
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w1; j++) {
dp[i][j] = 0;
}
}
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= w1; j++) {
dp[i + 1][j] = max(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]] + v[i]);
}
}
cout << dp[n][w1];
} | [
"variable_declaration.type.widen.change"
] | 967,632 | 967,633 | u620775604 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
long long dp[110][100010];
int main() {
int n, w;
cin >> n >> w;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
dp[i][j] = 0;
}
}
vector<ii> a(n);
for (auto &x : a) {
cin >> x.first >> x.second;
}
for (int i = 1; i <= n; i++) {
int ww = a[i - 1].first;
int v = a[i - 1].second;
for (int j = 0; j <= w; j++) {
if (j >= ww) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - ww] + v);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
long long dp[110][100010];
int main() {
int n, w;
cin >> n >> w;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= w; j++) {
dp[i][j] = 0;
}
}
vector<ii> a(n);
for (auto &x : a) {
cin >> x.first >> x.second;
}
for (int i = 1; i <= n; i++) {
int ww = a[i - 1].first;
int v = a[i - 1].second;
for (int j = 0; j <= w; j++) {
if (j >= ww) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - ww] + v);
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
cout << dp[n][w] << endl;
return 0;
}
| [
"assignment.change"
] | 967,634 | 967,635 | u077971896 | cpp |
p03163 | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
struct edge {
int to;
ll cap;
int rev;
};
int main() {
ll N, W;
cin >> N >> W;
vector<ll> w(N), v(N);
rep(i, N) cin >> w[i] >> v[i];
vector<vector<ll>> dp(2, vector<ll>(1e8 + 5));
rep(i, 2) rep(j, 100010) dp[i][j] = -inf;
int crt = 0, nxt = 1;
dp[crt][0] = 0;
rep(i, N) {
rep(j, 100010) dp[nxt][j] = -inf;
rep(j, W + 1) {
if (dp[crt][j] == -inf)
continue;
if (j + w[i] <= W)
dp[nxt][j + w[i]] = max(dp[nxt][j + w[i]], dp[crt][j] + v[i]);
dp[nxt][j] = max(dp[nxt][j], dp[crt][j]);
}
swap(crt, nxt);
}
ll res = -inf;
rep(j, W + 1) res = max(res, dp[crt][j]);
cout << res << endl;
return 0;
} | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
struct edge {
int to;
ll cap;
int rev;
};
int main() {
ll N, W;
cin >> N >> W;
vector<ll> w(N), v(N);
rep(i, N) cin >> w[i] >> v[i];
vector<vector<ll>> dp(2, vector<ll>(100010));
rep(i, 2) rep(j, 100010) dp[i][j] = -inf;
int crt = 0, nxt = 1;
dp[crt][0] = 0;
rep(i, N) {
rep(j, 100010) dp[nxt][j] = -inf;
rep(j, W + 1) {
if (dp[crt][j] == -inf)
continue;
if (j + w[i] <= W)
dp[nxt][j + w[i]] = max(dp[nxt][j + w[i]], dp[crt][j] + v[i]);
dp[nxt][j] = max(dp[nxt][j], dp[crt][j]);
}
swap(crt, nxt);
}
ll res = -inf;
rep(j, W + 1) res = max(res, dp[crt][j]);
cout << res << endl;
return 0;
} | [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 967,654 | 967,655 | u819300485 | cpp |
p03163 | #include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ifstream f("test.in");
ofstream g("test.out");
int n, W, dp[100005], w[105], v[105];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++) {
for (int j = W - w[i]; j >= 0; j--)
dp[j + w[i]] = max(v[i] + dp[j], dp[j + w[i]]);
}
int ans = 0;
for (int i = 0; i <= W; i++)
ans = max(ans, dp[i]);
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ifstream f("test.in");
ofstream g("test.out");
ll n, W, dp[100005], w[105], v[105];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
for (int i = 1; i <= n; i++) {
for (int j = W - w[i]; j >= 0; j--)
dp[j + w[i]] = max(v[i] + dp[j], dp[j + w[i]]);
}
ll ans = 0;
for (int i = 0; i <= W; i++)
ans = max(ans, dp[i]);
cout << ans;
return 0;
}
| [
"variable_declaration.type.change"
] | 967,664 | 967,665 | u842916328 | cpp |
p03163 | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (ll)(b); i++)
// N<=100, W<=10^5
ll dp[110][100010];
struct Item {
ll w, v;
};
ll solve(int n, ll maxW, vector<Item> items) {
rep(i, 110) {
rep(j, 100010) { dp[i][j] = -1; }
}
dp[0][0] = 0;
rep(i, n) {
Item item = items[i];
rep(j, maxW) {
if (dp[i][j] < 0) {
continue;
}
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
if (j + item.w <= maxW) {
dp[i + 1][j + item.w] = max(dp[i + 1][j + item.w], dp[i][j] + item.v);
}
}
}
ll ret = 0;
rep(j, maxW) { ret = max(ret, dp[n][j]); }
return ret;
}
int main() {
int n;
ll maxW;
vector<Item> items;
cin >> n >> maxW;
rep(i, n) {
ll w, v;
cin >> w >> v;
items.push_back({w, v});
}
ll ans = solve(n, maxW, items);
cout << ans << "\n";
}
| #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (ll)(b); i++)
// N<=100, W<=10^5
ll dp[110][100010];
struct Item {
ll w, v;
};
ll solve(int n, ll maxW, vector<Item> items) {
rep(i, 110) {
rep(j, 100010) { dp[i][j] = -1; }
}
dp[0][0] = 0;
rep(i, n) {
Item item = items[i];
rep(j, maxW) {
if (dp[i][j] < 0) {
continue;
}
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
if (j + item.w <= maxW) {
dp[i + 1][j + item.w] = max(dp[i + 1][j + item.w], dp[i][j] + item.v);
}
}
}
ll ret = 0;
rep(j, maxW + 1) { ret = max(ret, dp[n][j]); }
return ret;
}
int main() {
int n;
ll maxW;
vector<Item> items;
cin >> n >> maxW;
rep(i, n) {
ll w, v;
cin >> w >> v;
items.push_back({w, v});
}
ll ans = solve(n, maxW, items);
cout << ans << "\n";
}
| [
"expression.operation.binary.add"
] | 967,666 | 967,667 | u129315407 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, W;
cin >> n >> W;
vector<int> dp(1 << 17, 0);
fill(dp.begin() + 1, dp.end(), -(1ll << 60));
dp[0] = 0;
for (int i = 1; i <= n; ++i) {
int w, v;
cin >> w >> v;
for (int j = W; j >= w; --j) {
dp[j] = max(dp[j], dp[j - w] + v);
}
}
cout << *max_element(dp.begin(), dp.begin() + W + 1) << '\n';
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, W;
cin >> n >> W;
vector<long long> dp(1 << 17, 0);
fill(dp.begin() + 1, dp.end(), -(1ll << 60));
dp[0] = 0;
for (int i = 1; i <= n; ++i) {
int w, v;
cin >> w >> v;
for (int j = W; j >= w; --j) {
dp[j] = max(dp[j], dp[j - w] + v);
}
}
cout << *max_element(dp.begin(), dp.begin() + W + 1) << '\n';
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change"
] | 967,682 | 967,683 | u459737327 | cpp |
p03162 | #include <bits/stdc++.h>
using i64 = long long;
using std::cin;
using std::cout;
using std::endl;
int main() {
int n;
scanf("%d", &n);
std::vector<std::vector<int>> dp(n + 1, std::vector<int>(3, 0));
for (int i = 0; i < n; i++) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
dp[i + 1][0] = a + std::max(dp[i][1], dp[i][2]);
dp[i + 1][1] = b + std::max(dp[i][1], dp[i][2]);
dp[i + 1][2] = c + std::max(dp[i][0], dp[i][1]);
}
printf("%d\n", std::max({dp[n][0], dp[n][1], dp[n][2]}));
return 0;
}
| #include <bits/stdc++.h>
using i64 = long long;
using std::cin;
using std::cout;
using std::endl;
int main() {
int n;
scanf("%d", &n);
std::vector<std::vector<int>> dp(n + 1, std::vector<int>(3, 0));
for (int i = 0; i < n; i++) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
dp[i + 1][0] = a + std::max(dp[i][1], dp[i][2]);
dp[i + 1][1] = b + std::max(dp[i][0], dp[i][2]);
dp[i + 1][2] = c + std::max(dp[i][0], dp[i][1]);
}
printf("%d\n", std::max({dp[n][0], dp[n][1], dp[n][2]}));
return 0;
}
| [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 967,684 | 967,685 | u424655672 | cpp |
p03162 | #include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif
using namespace std;
int D[3][100000], A[100000], B[100000], C[100000];
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
TEST(freopen("input.txt", "r", stdin));
TEST(freopen("output.txt", "w", stdout));
TEST(freopen("debug.txt", "w", stderr));
int N, K;
cin >> N >> K;
for (int i = 0; i < N; i++)
cin >> A[i] >> B[i] >> C[i];
D[0][0] = A[0];
D[1][0] = B[0];
D[2][0] = C[0];
for (int i = 1; i < N; i++) {
D[0][i] = max(D[1][i - 1], D[2][i - 1]) + A[i];
D[1][i] = max(D[0][i - 1], D[2][i - 1]) + B[i];
D[2][i] = max(D[0][i - 1], D[1][i - 1]) + C[i];
}
cout << max(D[0][N - 1], max(D[1][N - 1], D[2][N - 1])) << '\n';
return 0;
} | #include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif
using namespace std;
int D[3][100000], A[100000], B[100000], C[100000];
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
TEST(freopen("input.txt", "r", stdin));
TEST(freopen("output.txt", "w", stdout));
TEST(freopen("debug.txt", "w", stderr));
int N;
cin >> N;
for (int i = 0; i < N; i++)
cin >> A[i] >> B[i] >> C[i];
D[0][0] = A[0];
D[1][0] = B[0];
D[2][0] = C[0];
for (int i = 1; i < N; i++) {
D[0][i] = max(D[1][i - 1], D[2][i - 1]) + A[i];
D[1][i] = max(D[0][i - 1], D[2][i - 1]) + B[i];
D[2][i] = max(D[0][i - 1], D[1][i - 1]) + C[i];
}
cout << max(D[0][N - 1], max(D[1][N - 1], D[2][N - 1])) << '\n';
return 0;
} | [
"variable_declaration.remove",
"expression.operation.binary.remove"
] | 967,686 | 967,687 | u548859367 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll a, b, c, d, dp[10000][10000], cost[10000000], weight[1000000];
ll func(ll i, ll w) {
if (i > a) {
return 0;
}
ll p = 0, q = 0;
if (dp[i][w] != -1) {
return dp[i][w];
}
if (w + weight[i] <= b) {
p = cost[i] + func(i + 1, w + weight[i]);
}
q = func(i + 1, w);
dp[i][w] = max(p, q);
// cout<<dp[i][w]<<endl;
return dp[i][w];
}
int main() {
memset(dp, -1, sizeof(dp));
ll ans;
cin >> a >> b;
for (int i = 0; i < a; i++) {
cin >> c >> d;
weight[i] = c;
cost[i] = d;
}
ans = func(0, 0);
cout << ans << endl;
// cout<<nCr(a,b)<<endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll a, b, c, d, dp[105][100005], cost[100005], weight[100005];
ll func(ll i, ll w) {
if (i > a) {
return 0;
}
ll p = 0, q = 0;
if (dp[i][w] != -1) {
return dp[i][w];
}
if (w + weight[i] <= b) {
p = cost[i] + func(i + 1, w + weight[i]);
}
q = func(i + 1, w);
dp[i][w] = max(p, q);
// cout<<dp[i][w]<<endl;
return dp[i][w];
}
int main() {
memset(dp, -1, sizeof(dp));
ll ans;
cin >> a >> b;
for (int i = 0; i < a; i++) {
cin >> c >> d;
weight[i] = c;
cost[i] = d;
}
ans = func(0, 0);
cout << ans << endl;
// cout<<nCr(a,b)<<endl;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 967,700 | 967,701 | u863370423 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define cc(x) cout << #x << " = " << x << endl
#define ok cout << "ok" << endl
#define endl '\n'
typedef long long ll;
typedef pair<int, int> ii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int N = 1e5 + 10;
int dp[N], p[N], v[N];
int n, w;
int main() {
ios_base::sync_with_stdio(false);
memset(dp, -INF, sizeof dp);
cin >> n >> w;
for (int i = 0; i < n; i++) {
cin >> p[i] >> v[i];
}
dp[0] = 0;
for (int i = 0; i < n; i++) {
for (int j = N - 1; j - p[i] >= 0; j--) {
dp[j] = max(dp[j], dp[j - p[i]] + v[i]);
}
}
int ans = 0;
for (int i = 0; i <= w; i++)
ans = max(ans, dp[i]);
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define cc(x) cout << #x << " = " << x << endl
#define ok cout << "ok" << endl
#define endl '\n'
typedef long long ll;
typedef pair<int, int> ii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const ll N = 1e5 + 10;
ll dp[N], p[N], v[N];
ll n, w;
int main() {
ios_base::sync_with_stdio(false);
memset(dp, -INF, sizeof dp);
cin >> n >> w;
for (int i = 0; i < n; i++) {
cin >> p[i] >> v[i];
}
dp[0] = 0;
for (int i = 0; i < n; i++) {
for (int j = N - 1; j - p[i] >= 0; j--) {
dp[j] = max(dp[j], dp[j - p[i]] + v[i]);
}
}
ll ans = 0;
for (int i = 0; i <= w; i++)
ans = max(ans, dp[i]);
cout << ans << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 967,702 | 967,703 | u863370423 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 1e2 + 5;
int n, w, weight[A], val[A];
ll dp[A][100005];
int build() {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
ll ret = dp[i - 1][j];
if (j - weight[i] >= 0)
ret = max(ret, dp[i - 1][j - weight[i]] + val[i]);
dp[i][j] = ret;
}
}
return dp[n][w];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> w;
for (int i = 1; i <= n; i++)
cin >> weight[i] >> val[i];
cout << build();
return 0;
}
/*
states : indx , weight
base case : dp[0][ay 7aga] = 0, dp[ay 7aga][0] = 0
transitions : dp[i][j] = dp[i-1][j] | dp[i-1][j-w] + val
0 0
3 30
4 50
5 60
*/
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 1e2 + 5;
int n, w, weight[A], val[A];
ll dp[A][100005];
ll build() {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= w; j++) {
ll ret = dp[i - 1][j];
if (j - weight[i] >= 0)
ret = max(ret, dp[i - 1][j - weight[i]] + val[i]);
dp[i][j] = ret;
}
}
return dp[n][w];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> w;
for (int i = 1; i <= n; i++)
cin >> weight[i] >> val[i];
cout << build();
return 0;
}
/*
states : indx , weight
base case : dp[0][ay 7aga] = 0, dp[ay 7aga][0] = 0
transitions : dp[i][j] = dp[i-1][j] | dp[i-1][j-w] + val
0 0
3 30
4 50
5 60
*/
| [] | 967,714 | 967,715 | u018679195 | cpp |
p03163 | #pragma GCC optimize("O3")
#include <algorithm>
#include <bits/stdc++.h>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#define forr(i, a, b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define input \
ios_base::sync_with_stdio(0); \
cin.tie(0);
const double PI = acos(-1.0);
using namespace std;
// typedef pair<double,double>pdd;
typedef long long ll;
typedef pair<ll, ll> pii;
// typedef complex<double> point;
// int x[8]={1,0,0,-1,-1,-1,1,1};
// int y[8]={0,1,-1,0,-1,1,-1,1};
// char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 100000 + 9;
ll n, cap, mem[109][N], w[N], v[N];
ll dp(int i, int tot) {
if (tot == 0)
return 0;
if (i > n)
return 0;
if (mem[i][tot] != -1)
return mem[i][tot];
int c1 = 0, c2 = 0;
if (w[i] <= tot)
c1 = v[i] + dp(i + 1, tot - w[i]);
c2 = dp(i + 1, tot);
return mem[i][tot] = max(c1, c2);
}
int main() {
// freopen("calc.in","r",stdin);
// freopen("calc.out","w",stdout);
//__builtin_popcount()
input cin >> n >> cap;
forr(i, 1, n) cin >> w[i] >> v[i];
memset(mem, -1, sizeof mem);
cout << dp(1, cap) << endl;
return 0;
}
| #pragma GCC optimize("O3")
#include <algorithm>
#include <bits/stdc++.h>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#define forr(i, a, b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define input \
ios_base::sync_with_stdio(0); \
cin.tie(0);
const double PI = acos(-1.0);
using namespace std;
// typedef pair<double,double>pdd;
typedef long long ll;
typedef pair<ll, ll> pii;
// typedef complex<double> point;
// int x[8]={1,0,0,-1,-1,-1,1,1};
// int y[8]={0,1,-1,0,-1,1,-1,1};
// char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 100000 + 9;
ll n, cap, mem[109][N], w[N], v[N];
ll dp(int i, int tot) {
if (tot == 0)
return 0;
if (i > n)
return 0;
if (mem[i][tot] != -1)
return mem[i][tot];
ll c1 = 0, c2 = 0;
if (w[i] <= tot)
c1 = v[i] + dp(i + 1, tot - w[i]);
c2 = dp(i + 1, tot);
return mem[i][tot] = max(c1, c2);
}
int main() {
// freopen("calc.in","r",stdin);
// freopen("calc.out","w",stdout);
//__builtin_popcount()
input cin >> n >> cap;
forr(i, 1, n) cin >> w[i] >> v[i];
memset(mem, -1, sizeof mem);
cout << dp(1, cap) << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 967,718 | 967,719 | u922603181 | cpp |
p03163 | #pragma GCC optimize("O3")
#include <algorithm>
#include <bits/stdc++.h>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#define forr(i, a, b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define input \
ios_base::sync_with_stdio(0); \
cin.tie(0);
const double PI = acos(-1.0);
using namespace std;
// typedef pair<double,double>pdd;
typedef long long ll;
typedef pair<ll, ll> pii;
// typedef complex<double> point;
// int x[8]={1,0,0,-1,-1,-1,1,1};
// int y[8]={0,1,-1,0,-1,1,-1,1};
// char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 100000 + 9;
int n, cap, mem[109][N], w[N], v[N];
int dp(int i, int tot) {
if (tot == 0)
return 0;
if (i > n)
return 0;
if (mem[i][tot] != -1)
return mem[i][tot];
int c1 = 0, c2 = 0;
if (w[i] <= tot)
c1 = v[i] + dp(i + 1, tot - w[i]);
c2 = dp(i + 1, tot);
return mem[i][tot] = max(c1, c2);
}
int main() {
// freopen("calc.in","r",stdin);
// freopen("calc.out","w",stdout);
//__builtin_popcount()
input cin >> n >> cap;
forr(i, 1, n) cin >> w[i] >> v[i];
memset(mem, -1, sizeof mem);
cout << dp(1, cap) << endl;
return 0;
}
| #pragma GCC optimize("O3")
#include <algorithm>
#include <bits/stdc++.h>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#define forr(i, a, b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define input \
ios_base::sync_with_stdio(0); \
cin.tie(0);
const double PI = acos(-1.0);
using namespace std;
// typedef pair<double,double>pdd;
typedef long long ll;
typedef pair<ll, ll> pii;
// typedef complex<double> point;
// int x[8]={1,0,0,-1,-1,-1,1,1};
// int y[8]={0,1,-1,0,-1,1,-1,1};
// char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 100000 + 9;
ll n, cap, mem[109][N], w[N], v[N];
ll dp(int i, int tot) {
if (tot == 0)
return 0;
if (i > n)
return 0;
if (mem[i][tot] != -1)
return mem[i][tot];
ll c1 = 0, c2 = 0;
if (w[i] <= tot)
c1 = v[i] + dp(i + 1, tot - w[i]);
c2 = dp(i + 1, tot);
return mem[i][tot] = max(c1, c2);
}
int main() {
// freopen("calc.in","r",stdin);
// freopen("calc.out","w",stdout);
//__builtin_popcount()
input cin >> n >> cap;
forr(i, 1, n) cin >> w[i] >> v[i];
memset(mem, -1, sizeof mem);
cout << dp(1, cap) << endl;
return 0;
}
| [
"variable_declaration.type.change"
] | 967,720 | 967,719 | u922603181 | cpp |
p03163 | /// *** --- ||| In the name of ALLAH ||| --- *** ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int)x.size()
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))
#define optimize() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define fraction() \
cout.unsetf(ios::floatfield); \
cout.precision(10); \
cout.setf(ios::fixed, ios::floatfield);
#define file() \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define dbg(args...) \
do { \
cerr << #args << " : "; \
faltu(args); \
} while (0)
void faltu() { cerr << endl; }
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
cerr << arg << ' ';
faltu(rest...);
}
ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int mx = 1e5 + 123;
ll dp[102][mx];
int n, w[mx], v[mx], W;
int solve(int i, int j) {
if (i > n)
return 0;
if (dp[i][j] != -1)
return dp[i][j];
ll ret1 = 0, ret2 = 0;
if (w[i] + j <= W)
ret1 = v[i] + solve(i + 1, w[i] + j);
ret2 = solve(i + 1, j);
return dp[i][j] = max(ret1, ret2);
}
int main() {
optimize();
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
mem(dp, -1);
cout << solve(1, 0) << endl;
return 0;
}
| /// *** --- ||| In the name of ALLAH ||| --- *** ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int)x.size()
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))
#define optimize() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define fraction() \
cout.unsetf(ios::floatfield); \
cout.precision(10); \
cout.setf(ios::fixed, ios::floatfield);
#define file() \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define dbg(args...) \
do { \
cerr << #args << " : "; \
faltu(args); \
} while (0)
void faltu() { cerr << endl; }
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
cerr << arg << ' ';
faltu(rest...);
}
ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int mx = 1e5 + 123;
ll dp[102][mx];
int n, w[mx], v[mx], W;
ll solve(int i, int j) {
if (i > n)
return 0;
if (dp[i][j] != -1)
return dp[i][j];
ll ret1 = 0, ret2 = 0;
if (w[i] + j <= W)
ret1 = v[i] + solve(i + 1, w[i] + j);
ret2 = solve(i + 1, j);
return dp[i][j] = max(ret1, ret2);
}
int main() {
optimize();
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
mem(dp, -1);
cout << solve(1, 0) << endl;
return 0;
}
| [] | 967,724 | 967,725 | u724640452 | cpp |
p03163 | /// *** --- ||| In the name of ALLAH ||| --- *** ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int)x.size()
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))
#define optimize() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define fraction() \
cout.unsetf(ios::floatfield); \
cout.precision(10); \
cout.setf(ios::fixed, ios::floatfield);
#define file() \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define dbg(args...) \
do { \
cerr << #args << " : "; \
faltu(args); \
} while (0)
void faltu() { cerr << endl; }
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
cerr << arg << ' ';
faltu(rest...);
}
ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int mx = 1e5 + 123;
ll dp[100][mx];
int n, w[mx], v[mx], W;
int solve(int i, int j) {
if (i > n)
return 0;
if (dp[i][j] != -1)
return dp[i][j];
ll ret1 = 0, ret2 = 0;
if (w[i] + j <= W)
ret1 = v[i] + solve(i + 1, w[i] + j);
ret2 = solve(i + 1, j);
return dp[i][j] = max(ret1, ret2);
}
int main() {
optimize();
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
mem(dp, -1);
cout << solve(1, 0) << endl;
return 0;
}
| /// *** --- ||| In the name of ALLAH ||| --- *** ///
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int)x.size()
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))
#define optimize() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define fraction() \
cout.unsetf(ios::floatfield); \
cout.precision(10); \
cout.setf(ios::fixed, ios::floatfield);
#define file() \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define dbg(args...) \
do { \
cerr << #args << " : "; \
faltu(args); \
} while (0)
void faltu() { cerr << endl; }
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
cerr << arg << ' ';
faltu(rest...);
}
ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int mx = 1e5 + 123;
ll dp[102][mx];
int n, w[mx], v[mx], W;
ll solve(int i, int j) {
if (i > n)
return 0;
if (dp[i][j] != -1)
return dp[i][j];
ll ret1 = 0, ret2 = 0;
if (w[i] + j <= W)
ret1 = v[i] + solve(i + 1, w[i] + j);
ret2 = solve(i + 1, j);
return dp[i][j] = max(ret1, ret2);
}
int main() {
optimize();
cin >> n >> W;
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i];
mem(dp, -1);
cout << solve(1, 0) << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 967,726 | 967,725 | u724640452 | cpp |
p03163 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, k;
cin >> n >> k;
vector<pair<int, int>> v;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
v.push_back({a, b});
}
int dp[n][k + 1];
for (int i = 0; i < n; i++) {
for (int j = 0; j <= k; j++) {
dp[i][j] = 0;
}
}
sort(v.begin(), v.end());
for (int i = 0; i <= k; i++) {
if (i >= v[0].first) {
dp[0][i] = v[0].second;
}
}
for (int i = 1; i < n; i++) {
for (int j = 0; j <= k; j++) {
if (j < v[i].first) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - v[i].first] + v[i].second);
}
}
}
cout << dp[n - 1][k];
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, k;
cin >> n >> k;
vector<pair<ll, ll>> v;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
v.push_back({a, b});
}
ll dp[n][k + 1];
for (int i = 0; i < n; i++) {
for (int j = 0; j <= k; j++) {
dp[i][j] = 0;
}
}
sort(v.begin(), v.end());
for (int i = 0; i <= k; i++) {
if (i >= v[0].first) {
dp[0][i] = v[0].second;
}
}
for (int i = 1; i < n; i++) {
for (int j = 0; j <= k; j++) {
if (j < v[i].first) {
dp[i][j] = dp[i - 1][j];
} else {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - v[i].first] + v[i].second);
}
}
}
cout << dp[n - 1][k];
return 0;
} | [
"variable_declaration.type.change"
] | 967,734 | 967,735 | u990236540 | cpp |
p03163 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
//======================================================
#define for1(i, n) for (int i = 0; i < (int)(n); ++i)
#define for2(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr1(i, n) for (int i = n - 1; i <= 0; --i)
#define forr2(i, n) for (int i = n; i < 0; --i)
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(v, d) memset(v, d, sizeof(v))
#define ull unsigned long long
#define MP(a, b) make_pair(a, b)
#define S second
#define F first
#define PI 3.14159265359
#define ll long long
#define sz(v) v.size()
#define pb push_back
#define pp pop_back
#define bgn begin
#define N 100000 + 5
#define MOD 1e9 + 7
#define inf 1e18
//======================================================
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
while (b--)
ret = (ret * a);
return ret;
}
//======================================================
int weights[100 + 9];
int benefit[100 + 9];
int n, kpWeight;
long long dp[100 + 9][10000 + 9];
long long knapSack(int index, int reminderWeight) {
if (index == n)
return 0;
if (dp[index][reminderWeight] != -1) {
return dp[index][reminderWeight];
}
long long leave = knapSack(index + 1, reminderWeight);
long long take = 0;
if (reminderWeight >= weights[index]) {
take =
benefit[index] + knapSack(index + 1, reminderWeight - weights[index]);
}
return dp[index][reminderWeight] = max(leave, take);
}
int main() {
cin >> n >> kpWeight;
for (int i1 = 0; i1 < 100 + 9; i1++) {
for (int i2 = 0; i2 < 100000 + 9; i2++) {
dp[i1][i2] = -1;
}
}
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
weights[i] = a;
benefit[i] = b;
}
cout << knapSack(0, kpWeight);
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
//======================================================
#define for1(i, n) for (int i = 0; i < (int)(n); ++i)
#define for2(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr1(i, n) for (int i = n - 1; i <= 0; --i)
#define forr2(i, n) for (int i = n; i < 0; --i)
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(v, d) memset(v, d, sizeof(v))
#define ull unsigned long long
#define MP(a, b) make_pair(a, b)
#define S second
#define F first
#define PI 3.14159265359
#define ll long long
#define sz(v) v.size()
#define pb push_back
#define pp pop_back
#define bgn begin
#define N 100000 + 5
#define MOD 1e9 + 7
#define inf 1e18
//======================================================
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
while (b--)
ret = (ret * a);
return ret;
}
//======================================================
int weights[100 + 9];
long long benefit[100 + 9];
int n, kpWeight;
long long dp[100 + 9][100000 + 9];
long long knapSack(int index, int reminderWeight) {
if (index == n)
return 0;
if (dp[index][reminderWeight] != -1) {
return dp[index][reminderWeight];
}
long long leave = knapSack(index + 1, reminderWeight);
long long take = 0;
if (reminderWeight >= weights[index]) {
take =
benefit[index] + knapSack(index + 1, reminderWeight - weights[index]);
}
return dp[index][reminderWeight] = max(leave, take);
}
int main() {
cin >> n >> kpWeight;
for (int i1 = 0; i1 < 100 + 9; i1++) {
for (int i2 = 0; i2 < 100000 + 9; i2++) {
dp[i1][i2] = -1;
}
}
for (int i = 0; i < n; i++) {
int a;
long long b;
cin >> a >> b;
weights[i] = a;
benefit[i] = b;
}
cout << knapSack(0, kpWeight);
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"literal.number.change",
"expression.operation.binary.change"
] | 967,740 | 967,741 | u816631826 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.