Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p03163
#include <bits/stdc++.h> using namespace std; int main() { int n, w; cin >> n >> w; vector<int> dp(w + 1); for (int i = 0; i < n; ++i) { int sz, cst; cin >> sz >> cst; for (int wt = w; wt >= 0; --wt) { dp[wt + sz] = max(dp[wt + sz], dp[wt] + cst); } } cout << *max_element(dp.begin(), dp.end()); }
#include <bits/stdc++.h> using namespace std; int main() { int n, w; cin >> n >> w; vector<long long> dp(w + 1); for (int i = 0; i < n; ++i) { long long sz, cst; cin >> sz >> cst; for (int wt = w - sz; wt >= 0; --wt) { dp[wt + sz] = max(dp[wt + sz], dp[wt] + cst); } } cout << *max_element(dp.begin(), dp.end()); }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "control_flow.loop.for.initializer.change" ]
966,313
966,314
u048764593
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long int ll; #define MOD 1000000007 #define INF 1e18 #include <ctime> #define rep(i, x, n) for (ll i = x; i < n; i++) #define rev(i, n, x) for (ll i = n; i > x; i--) #define endl "\n" #define all(c) (c).begin(), (c).end() #define int long long int #ifdef mishra #define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl; #define print_time() \ cout << setprecision(6) \ << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n'; #else #define debug(x) ; #define print_time() ; #endif clock_t start; void FAST(ll argc) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); start = clock(); if (argc == 2) freopen("std.in", "r", stdin); } /*vector<ll> v; void seive() { v.pb(2); for (int i = 3; i < 100000; i += 2) { for (int j = 0; j < v.size(); j++) { if (i % v[j] == 0) break; if (v[j] * v[j] > i) { v.pb(i); break; } } } } /* void prime_factor(ll x, vector<ll> &r) { ll sqrt_x = sqrt(x); for (ll i : v) { if (i > sqrt_x) break; if (x % i == 0) r.pb(i); while (x % i == 0) { x /= i; } } if (x >= 2) r.pb(x); } */ /* ll power(ll x, ll y) { ll res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } */ /* inline void dfs(ll curr, ll prev) { for (ll i : a[curr]) if (i != prev) dfs(i, curr); } */ /* ll multi(ll a, ll b) { return ((a * b) % MOD); } */ //---------------------CODE STARTS HERE--------------------- signed main(char argc, char *argv[]) { FAST(argc); ll testcase = 1; // cin >> testcase; while (testcase--) { int n, w; cin >> n >> w; pair<int, int> a[n]; rep(i, 0, n) cin >> a[i].first >> a[i].second; sort(a, a + n); // int z[w + 5] = {0}; unordered_map<int, int> m; m[0] = 0; bool ck = 0; int ans = 0; rep(i, 0, n) { int x = a[i].first; int y = a[i].second; // z[x] = max(z[x], y); stack<pair<int, int>> st; for (auto it : m) { if (it.first + x > w) break; st.push(make_pair(it.first + x, max(it.second + y, m[it.first + x]))); } while (st.empty() == 0) { auto z = st.top(); st.pop(); m[z.first] = z.second; if (z.first <= w) ans = max(ans, z.second); } } cout << ans << endl; //--------??--------CLEAR VECTORS--------??-------- m.clear(); } // v.clear(); print_time(); return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long int ll; #define MOD 1000000007 #define INF 1e18 #include <ctime> #define rep(i, x, n) for (ll i = x; i < n; i++) #define rev(i, n, x) for (ll i = n; i > x; i--) #define endl "\n" #define all(c) (c).begin(), (c).end() #define int long long int #ifdef mishra #define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl; #define print_time() \ cout << setprecision(6) \ << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n'; #else #define debug(x) ; #define print_time() ; #endif clock_t start; void FAST(ll argc) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); start = clock(); if (argc == 2) freopen("std.in", "r", stdin); } /*vector<ll> v; void seive() { v.pb(2); for (int i = 3; i < 100000; i += 2) { for (int j = 0; j < v.size(); j++) { if (i % v[j] == 0) break; if (v[j] * v[j] > i) { v.pb(i); break; } } } } /* void prime_factor(ll x, vector<ll> &r) { ll sqrt_x = sqrt(x); for (ll i : v) { if (i > sqrt_x) break; if (x % i == 0) r.pb(i); while (x % i == 0) { x /= i; } } if (x >= 2) r.pb(x); } */ /* ll power(ll x, ll y) { ll res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } */ /* inline void dfs(ll curr, ll prev) { for (ll i : a[curr]) if (i != prev) dfs(i, curr); } */ /* ll multi(ll a, ll b) { return ((a * b) % MOD); } */ //---------------------CODE STARTS HERE--------------------- signed main(char argc, char *argv[]) { FAST(argc); ll testcase = 1; // cin >> testcase; while (testcase--) { int n, w; cin >> n >> w; pair<int, int> a[n]; rep(i, 0, n) cin >> a[i].first >> a[i].second; sort(a, a + n); // int z[w + 5] = {0}; map<int, int> m; m[0] = 0; bool ck = 0; int ans = 0; rep(i, 0, n) { int x = a[i].first; int y = a[i].second; // z[x] = max(z[x], y); stack<pair<int, int>> st; for (auto it : m) { if (it.first + x > w) continue; st.push(make_pair(it.first + x, max(it.second + y, m[it.first + x]))); } while (st.empty() == 0) { auto z = st.top(); st.pop(); m[z.first] = z.second; if (z.first <= w) ans = max(ans, z.second); } } // for(auto it:m) // { // cout << " "; // debug(it.first); // debug(it.second); // } cout << ans << endl; //--------??--------CLEAR VECTORS--------??-------- m.clear(); } // v.clear(); print_time(); return 0; }
[ "variable_declaration.type.change", "control_flow.break.remove", "control_flow.continue.add" ]
966,318
966,317
u868958206
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long int ll; #define MOD 1000000007 #define INF 1e18 #include <ctime> #define rep(i, x, n) for (ll i = x; i < n; i++) #define rev(i, n, x) for (ll i = n; i > x; i--) #define endl "\n" #define all(c) (c).begin(), (c).end() #define int long long int #ifdef mishra #define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl; #define print_time() \ cout << setprecision(6) \ << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n'; #else #define debug(x) ; #define print_time() ; #endif clock_t start; void FAST(ll argc) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); start = clock(); if (argc == 2) freopen("std.in", "r", stdin); } /*vector<ll> v; void seive() { v.pb(2); for (int i = 3; i < 100000; i += 2) { for (int j = 0; j < v.size(); j++) { if (i % v[j] == 0) break; if (v[j] * v[j] > i) { v.pb(i); break; } } } } /* void prime_factor(ll x, vector<ll> &r) { ll sqrt_x = sqrt(x); for (ll i : v) { if (i > sqrt_x) break; if (x % i == 0) r.pb(i); while (x % i == 0) { x /= i; } } if (x >= 2) r.pb(x); } */ /* ll power(ll x, ll y) { ll res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } */ /* inline void dfs(ll curr, ll prev) { for (ll i : a[curr]) if (i != prev) dfs(i, curr); } */ /* ll multi(ll a, ll b) { return ((a * b) % MOD); } */ //---------------------CODE STARTS HERE--------------------- signed main(char argc, char *argv[]) { FAST(argc); ll testcase = 1; // cin >> testcase; while (testcase--) { int n, w; cin >> n >> w; pair<int, int> a[n]; rep(i, 0, n) cin >> a[i].first >> a[i].second; sort(a, a + n); // int z[w + 5] = {0}; map<int, int> m; m[0] = 0; bool ck = 0; int ans = 0; rep(i, 0, n) { int x = a[i].first; int y = a[i].second; // z[x] = max(z[x], y); stack<pair<int, int>> st; for (auto it : m) { if (it.first + x > w) break; st.push(make_pair(it.first + x, max(it.second + y, m[it.first + x]))); } while (st.empty() == 0) { auto z = st.top(); st.pop(); m[z.first] = z.second; if (z.second <= w) ans = max(ans, z.second); } } cout << ans << endl; //--------??--------CLEAR VECTORS--------??-------- m.clear(); } // v.clear(); print_time(); return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long int ll; #define MOD 1000000007 #define INF 1e18 #include <ctime> #define rep(i, x, n) for (ll i = x; i < n; i++) #define rev(i, n, x) for (ll i = n; i > x; i--) #define endl "\n" #define all(c) (c).begin(), (c).end() #define int long long int #ifdef mishra #define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl; #define print_time() \ cout << setprecision(6) \ << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n'; #else #define debug(x) ; #define print_time() ; #endif clock_t start; void FAST(ll argc) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); start = clock(); if (argc == 2) freopen("std.in", "r", stdin); } /*vector<ll> v; void seive() { v.pb(2); for (int i = 3; i < 100000; i += 2) { for (int j = 0; j < v.size(); j++) { if (i % v[j] == 0) break; if (v[j] * v[j] > i) { v.pb(i); break; } } } } /* void prime_factor(ll x, vector<ll> &r) { ll sqrt_x = sqrt(x); for (ll i : v) { if (i > sqrt_x) break; if (x % i == 0) r.pb(i); while (x % i == 0) { x /= i; } } if (x >= 2) r.pb(x); } */ /* ll power(ll x, ll y) { ll res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } */ /* inline void dfs(ll curr, ll prev) { for (ll i : a[curr]) if (i != prev) dfs(i, curr); } */ /* ll multi(ll a, ll b) { return ((a * b) % MOD); } */ //---------------------CODE STARTS HERE--------------------- signed main(char argc, char *argv[]) { FAST(argc); ll testcase = 1; // cin >> testcase; while (testcase--) { int n, w; cin >> n >> w; pair<int, int> a[n]; rep(i, 0, n) cin >> a[i].first >> a[i].second; sort(a, a + n); // int z[w + 5] = {0}; map<int, int> m; m[0] = 0; bool ck = 0; int ans = 0; rep(i, 0, n) { int x = a[i].first; int y = a[i].second; // z[x] = max(z[x], y); stack<pair<int, int>> st; for (auto it : m) { if (it.first + x > w) continue; st.push(make_pair(it.first + x, max(it.second + y, m[it.first + x]))); } while (st.empty() == 0) { auto z = st.top(); st.pop(); m[z.first] = z.second; if (z.first <= w) ans = max(ans, z.second); } } // for(auto it:m) // { // cout << " "; // debug(it.first); // debug(it.second); // } cout << ans << endl; //--------??--------CLEAR VECTORS--------??-------- m.clear(); } // v.clear(); print_time(); return 0; }
[ "control_flow.break.remove", "control_flow.continue.add", "control_flow.branch.if.condition.change" ]
966,319
966,317
u868958206
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long int ll; #define MOD 1000000007 #define INF 1e18 #include <ctime> #define rep(i, x, n) for (ll i = x; i < n; i++) #define rev(i, n, x) for (ll i = n; i > x; i--) #define endl "\n" #define all(c) (c).begin(), (c).end() #define int long long int #ifdef mishra #define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl; #define print_time() \ cout << setprecision(6) \ << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n'; #else #define debug(x) ; #define print_time() ; #endif clock_t start; void FAST(ll argc) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); start = clock(); if (argc == 2) freopen("std.in", "r", stdin); } /*vector<ll> v; void seive() { v.pb(2); for (int i = 3; i < 100000; i += 2) { for (int j = 0; j < v.size(); j++) { if (i % v[j] == 0) break; if (v[j] * v[j] > i) { v.pb(i); break; } } } } /* void prime_factor(ll x, vector<ll> &r) { ll sqrt_x = sqrt(x); for (ll i : v) { if (i > sqrt_x) break; if (x % i == 0) r.pb(i); while (x % i == 0) { x /= i; } } if (x >= 2) r.pb(x); } */ /* ll power(ll x, ll y) { ll res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } */ /* inline void dfs(ll curr, ll prev) { for (ll i : a[curr]) if (i != prev) dfs(i, curr); } */ /* ll multi(ll a, ll b) { return ((a * b) % MOD); } */ //---------------------CODE STARTS HERE--------------------- signed main(char argc, char *argv[]) { FAST(argc); ll testcase = 1; // cin >> testcase; while (testcase--) { int n, w; cin >> n >> w; pair<int, int> a[n]; rep(i, 0, n) cin >> a[i].first >> a[i].second; sort(a, a + n); // int z[w + 5] = {0}; map<int, int> m; m[0] = 0; bool ck = 0; int ans = 0; rep(i, 0, n) { int x = a[i].first; int y = a[i].second; // z[x] = max(z[x], y); stack<pair<int, int>> st; for (auto it : m) { if (it.first + x > w) break; st.push(make_pair(it.first + x, max(it.second + y, m[it.first + x]))); } while (st.empty() == 0) { auto z = st.top(); st.pop(); m[z.first] = z.second; if (z.second <= w) ans = max(ans, z.second); } } cout << ans << endl; //--------??--------CLEAR VECTORS--------??-------- m.clear(); } // v.clear(); print_time(); return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long int ll; #define MOD 1000000007 #define INF 1e18 #include <ctime> #define rep(i, x, n) for (ll i = x; i < n; i++) #define rev(i, n, x) for (ll i = n; i > x; i--) #define endl "\n" #define all(c) (c).begin(), (c).end() #define int long long int #ifdef mishra #define debug(x) cout << ">>" << #x << " is " << x << "<<" << endl; #define print_time() \ cout << setprecision(6) \ << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n'; #else #define debug(x) ; #define print_time() ; #endif clock_t start; void FAST(ll argc) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); start = clock(); if (argc == 2) freopen("std.in", "r", stdin); } /*vector<ll> v; void seive() { v.pb(2); for (int i = 3; i < 100000; i += 2) { for (int j = 0; j < v.size(); j++) { if (i % v[j] == 0) break; if (v[j] * v[j] > i) { v.pb(i); break; } } } } /* void prime_factor(ll x, vector<ll> &r) { ll sqrt_x = sqrt(x); for (ll i : v) { if (i > sqrt_x) break; if (x % i == 0) r.pb(i); while (x % i == 0) { x /= i; } } if (x >= 2) r.pb(x); } */ /* ll power(ll x, ll y) { ll res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } */ /* inline void dfs(ll curr, ll prev) { for (ll i : a[curr]) if (i != prev) dfs(i, curr); } */ /* ll multi(ll a, ll b) { return ((a * b) % MOD); } */ //---------------------CODE STARTS HERE--------------------- signed main(char argc, char *argv[]) { FAST(argc); ll testcase = 1; // cin >> testcase; while (testcase--) { int n, w; cin >> n >> w; pair<int, int> a[n]; rep(i, 0, n) cin >> a[i].first >> a[i].second; sort(a, a + n); // int z[w + 5] = {0}; map<int, int> m; m[0] = 0; bool ck = 0; int ans = 0; rep(i, 0, n) { int x = a[i].first; int y = a[i].second; // z[x] = max(z[x], y); stack<pair<int, int>> st; for (auto it : m) { if (it.first + x > w) break; st.push(make_pair(it.first + x, max(it.second + y, m[it.first + x]))); } while (st.empty() == 0) { auto z = st.top(); st.pop(); m[z.first] = z.second; if (z.first <= w) ans = max(ans, z.second); } } cout << ans << endl; //--------??--------CLEAR VECTORS--------??-------- m.clear(); } // v.clear(); print_time(); return 0; }
[ "control_flow.branch.if.condition.change" ]
966,319
966,320
u868958206
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { long long n, w, j; cin >> n >> w; long long A[n][2]; for (int i = 0; i < n; i++) { cin >> A[i][0] >> A[i][1]; } long long dp[w + 5] = {0}; for (long long i = 0; i < n; i++) { for (j = w - A[i][0]; j >= 0; j--) { dp[j + A[i][0]] = max(dp[j] + A[i][1], dp[j + A[j][0]]); } } cout << dp[w]; // for(int j=W-w;j>=0;--j) dp[j+w]=max(v+dp[j],dp[j+w]); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, w, j; cin >> n >> w; long long A[n][2]; for (int i = 0; i < n; i++) { cin >> A[i][0] >> A[i][1]; } long long dp[w + 5] = {0}; for (long long i = 0; i < n; i++) { for (j = w - A[i][0]; j >= 0; j--) { dp[j + A[i][0]] = max(dp[j] + A[i][1], dp[j + A[i][0]]); } } cout << dp[w]; // for(int j=W-w;j>=0;--j) dp[j+w]=max(v+dp[j],dp[j+w]); return 0; }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
966,321
966,322
u044427591
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { long long n, w, j; cin >> n >> w; int A[n][2]; for (int i = 0; i < n; i++) { cin >> A[i][0] >> A[i][1]; } long long dp[w + 5] = {0}; for (long long i = 0; i < n; i++) { for (j = w - A[i][0]; j >= 0; j--) { dp[j + A[i][0]] = max(dp[j] + A[i][1], dp[j + A[j][0]]); } } cout << dp[w]; // for(int j=W-w;j>=0;--j) dp[j+w]=max(v+dp[j],dp[j+w]); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, w, j; cin >> n >> w; long long A[n][2]; for (int i = 0; i < n; i++) { cin >> A[i][0] >> A[i][1]; } long long dp[w + 5] = {0}; for (long long i = 0; i < n; i++) { for (j = w - A[i][0]; j >= 0; j--) { dp[j + A[i][0]] = max(dp[j] + A[i][1], dp[j + A[i][0]]); } } cout << dp[w]; // for(int j=W-w;j>=0;--j) dp[j+w]=max(v+dp[j],dp[j+w]); return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
966,323
966,322
u044427591
cpp
p03163
#include <bits/stdc++.h> typedef long long ll; using namespace std; template <typename T> void print(T vec) { for (auto d : vec) cout << d << ' '; cout << '\n'; } template <typename T> void print2D(T mat) { for (auto vec : mat) print(vec); } int64_t n, W; vector<ll> weight(n), value(n); ll knapSack(ll W, ll n, vector<vector<int>> &dp) { if (n < 0 || W == 0) return 0; if (dp[n][W] != -1) return dp[n][W]; if (weight[n] > W) dp[n][W] = knapSack(W, n - 1, dp); else dp[n][W] = max(value[n] + knapSack(W - weight[n], n - 1, dp), knapSack(W, n - 1, dp)); return dp[n][W]; } int main() { cin >> n >> W; int temp; weight.resize(n); value.resize(n); vector<vector<int>> dp(n, vector<int>(W + 1, -1)); for (int i = 0; i < n; i++) { cin >> weight[i] >> value[i]; } // cout<<func(W, value, weight, n); cout << knapSack(W, n - 1, dp) << '\n'; return 0; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; template <typename T> void print(T vec) { for (auto d : vec) cout << d << ' '; cout << '\n'; } template <typename T> void print2D(T mat) { for (auto vec : mat) print(vec); } int64_t n, W; vector<ll> weight(n), value(n); ll knapSack(ll W, ll n, vector<vector<ll>> &dp) { if (n < 0 || W == 0) return 0; if (dp[n][W] != -1) return dp[n][W]; if (weight[n] > W) dp[n][W] = knapSack(W, n - 1, dp); else dp[n][W] = max(value[n] + knapSack(W - weight[n], n - 1, dp), knapSack(W, n - 1, dp)); return dp[n][W]; } int main() { cin >> n >> W; int temp; weight.resize(n); value.resize(n); vector<vector<ll>> dp(n, vector<ll>(W + 1, -1)); for (int i = 0; i < n; i++) { cin >> weight[i] >> value[i]; } // cout<<func(W, value, weight, n); cout << knapSack(W, n - 1, dp) << '\n'; // print2D(dp); return 0; }
[ "call.arguments.change" ]
966,336
966,337
u153967106
cpp
p03163
#include <bits/stdc++.h> using namespace std; const int maxn = 110; const int maxv = 1e5 + 10; int w[maxn], c[maxn]; int dp[maxv]; int main() { int n, v; cin >> n >> v; for (int i = 1; i <= n; i++) cin >> w[i] >> c[i]; for (int i = 1; i <= n; i++) { for (int j = v; j >= w[i]; j--) { dp[j] = max(dp[j], dp[j - w[i]] + c[i]); } } cout << dp[v]; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 110; const int maxv = 1e5 + 10; long long w[maxn], c[maxn]; long long dp[maxv]; int main() { int n, v; cin >> n >> v; for (int i = 1; i <= n; i++) cin >> w[i] >> c[i]; for (int i = 1; i <= n; i++) { for (int j = v; j >= w[i]; j--) { dp[j] = max(dp[j], dp[j - w[i]] + c[i]); } } cout << dp[v]; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
966,340
966,341
u775877429
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { int N, W, i, x, y; cin >> N >> W; vector<int> dp(W + 1, 0); for (i = 0; i < N; i++) { cin >> x >> y; // x is weight and y is value for (int weight = W; weight >= x; weight--) { dp[weight] = max(dp[weight], dp[weight - x] + y); } } cout << dp[W]; }
#include <bits/stdc++.h> using namespace std; int main() { int N, W, i, x, y; cin >> N >> W; vector<long long> dp(W + 1, 0); for (i = 0; i < N; i++) { cin >> x >> y; // x is weight and y is value for (int weight = W; weight >= x; weight--) { dp[weight] = max(dp[weight], dp[weight - x] + y); } } cout << dp[W]; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
966,344
966,345
u345094009
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { int N, W; cin >> N >> W; int weight[N], value[N]; for (int i = 0; i < N; i++) { cin >> weight[i] >> value[i]; } long long int dp[N + 1][W + 1] = {0}; for (int i = 0; i < N; i++) { for (int sum_w = 0; sum_w <= W; sum_w++) { if (sum_w - weight[i] >= 0) { dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]); } else { dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]); } } } cout << dp[N][W] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, W; cin >> N >> W; int weight[N], value[N]; for (int i = 0; i < N; i++) { cin >> weight[i] >> value[i]; } long long int dp[N + 1][W + 1] = {}; for (int i = 0; i < N; i++) { for (int sum_w = 0; sum_w <= W; sum_w++) { if (sum_w - weight[i] >= 0) { dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]); } dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]); } } cout << dp[N][W] << endl; }
[]
966,351
966,352
u384300282
cpp
p03163
#include "bits/stdc++.h" using namespace std; int main() { int n, s; cin >> n >> s; int w[n], v[n]; for (auto i = 0; i < n; i++) { cin >> w[i] >> v[i]; } int ans[n + 1][s + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= s; j++) { if (i == 0 || j == 0) { ans[i][j] = 0; } else if (j >= w[i - 1]) { ans[i][j] = max((v[i - 1] + ans[i - 1][j - w[i - 1]]), ans[i - 1][j]); } else { ans[i][j] = ans[i - 1][j]; } } } cout << ans[n][s]; return 0; }
#include "bits/stdc++.h" using namespace std; int main() { long long int n, s; cin >> n >> s; long long int w[n], v[n]; for (auto i = 0; i < n; i++) { cin >> w[i] >> v[i]; } long long int ans[n + 1][s + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= s; j++) { if (i == 0 || j == 0) { ans[i][j] = 0; } else if (j >= w[i - 1]) { ans[i][j] = max((v[i - 1] + ans[i - 1][j - w[i - 1]]), ans[i - 1][j]); } else { ans[i][j] = ans[i - 1][j]; } } } cout << ans[n][s]; return 0; }
[ "variable_declaration.type.widen.change" ]
966,353
966,354
u096449099
cpp
p03163
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int dp[105][100100]; int main() { int n, W; int v[105]; int w[105]; cin >> n >> W; rep(i, n) cin >> w[i] >> v[i]; rep(i, n) { for (int sum_w = 0; sum_w <= W; ++sum_w) { if (sum_w >= w[i]) dp[i + 1][sum_w] = max(dp[i][sum_w - w[i]] + v[i], dp[i][sum_w]); else dp[i + 1][sum_w] = dp[i][sum_w]; } } cout << dp[n][W] << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; ll dp[105][100100]; int main() { int n, W; int v[105]; int w[105]; cin >> n >> W; rep(i, n) cin >> w[i] >> v[i]; rep(i, n) { for (int sum_w = 0; sum_w <= W; ++sum_w) { if (sum_w >= w[i]) dp[i + 1][sum_w] = max(dp[i][sum_w - w[i]] + v[i], dp[i][sum_w]); else dp[i + 1][sum_w] = dp[i][sum_w]; } } cout << dp[n][W] << endl; return 0; }
[ "variable_declaration.type.change" ]
966,355
966,356
u256459711
cpp
p03163
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int dp[105][10010]; int main() { int n, W; int v[105]; int w[105]; cin >> n >> W; rep(i, n) cin >> w[i] >> v[i]; rep(i, n) { for (int sum_w = 0; sum_w <= W; ++sum_w) { if (sum_w >= w[i]) dp[i + 1][sum_w] = max(dp[i][sum_w - w[i]] + v[i], dp[i][sum_w]); else dp[i + 1][sum_w] = dp[i][sum_w]; } } cout << dp[n][W] << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; ll dp[105][100100]; int main() { int n, W; int v[105]; int w[105]; cin >> n >> W; rep(i, n) cin >> w[i] >> v[i]; rep(i, n) { for (int sum_w = 0; sum_w <= W; ++sum_w) { if (sum_w >= w[i]) dp[i + 1][sum_w] = max(dp[i][sum_w - w[i]] + v[i], dp[i][sum_w]); else dp[i + 1][sum_w] = dp[i][sum_w]; } } cout << dp[n][W] << endl; return 0; }
[ "variable_declaration.type.change", "literal.number.change", "variable_declaration.array_dimensions.change" ]
966,357
966,356
u256459711
cpp
p03163
//----AUTHOR:kkdrummer----/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/rope> using namespace __gnu_cxx; using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef complex<int> C; #define X real() #define Y imag() // typedef unordered_set<ll> usll; // typedef unordered_multiset<ll> umsll; typedef multiset<ll> msll; typedef set<ll> sll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pair<ll, ll>> vpll; typedef priority_queue<ll> pqll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; // typedef unordered_multiset<int> umsi; // typedef unordered_set<int> usi; typedef pair<int, int> pi; typedef vector<pair<int, int>> vpi; typedef vector<pair<double, double>> vpd; typedef pair<double, double> pd; typedef priority_queue<int> pqi; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ind_set; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ind_setll; #define in insert #define fi first #define se second #define pb push_back #define mp make_pair #define be begin #define en end #define itr iterator #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define mo 1000000007 #define inf 1000000000000000001 #define ninf -1000000000000000001 #define ima INT_MAX #define imi INT_MIN #define oncnt __builtin_popcount #define zerobegin __builtin_clz #define zeroend __builtin_ctz #define parity __builtin_parity const ld pii = 3.14159265359; inline ll modpow(ll x, ll n) { if (n == 0) return 1; if (n == 1) return (x % mo); ll u = (modpow(x, n / 2)); u = (u * u) % mo; if (n % 2 != 0) u = (u * x % mo) % mo; return u; } inline ll modinv(ll x) { return modpow(x, mo - 2); } inline ll mmul(ll a, ll b) { if (a >= mo) a = a % mo; if (b >= mo) b = b % mo; if (a * b >= mo) return (a * b) % mo; return (a * b); } inline ll madd(ll a, ll b) { if (a >= mo) a = a % mo; if (b >= mo) b = b % mo; if (a + b >= mo) return (a + b) % mo; return (a + b); } inline ll msub(ll a, ll b) { if (a >= mo) a = a % mo; if (b >= mo) b = b % mo; return ((a - b + mo) % mo); } inline ll mdiv(ll a, ll bb) { if (a >= mo) a = a % mo; ll b = modinv(bb); if (b >= mo) b = b % mo; if (a * b >= mo) return (a * b) % mo; return (a * b); } inline ll gcd(ll a, ll b) { return __gcd(a, b); } int main() { io int testcases = 1; // cin>>testcases; while (testcases--) { int n, w; cin >> n >> w; int we[n]; int val[n]; for (int i = 0; i < n; i++) { cin >> we[i]; cin >> val[i]; } int dp[n + 1][w + 1]; for (int i = 0; i < n + 1; i++) { for (int j = 0; j <= w; j++) { if (i == 0 || j == 0) dp[i][j] = 0; else { dp[i][j] = dp[i - 1][j]; if (j >= we[i - 1]) dp[i][j] = max(dp[i][j], val[i - 1] + dp[i - 1][j - we[i - 1]]); } } } cout << dp[n][w]; } return 0; }
//----AUTHOR:kkdrummer----/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/rope> using namespace __gnu_cxx; using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef complex<int> C; #define X real() #define Y imag() // typedef unordered_set<ll> usll; // typedef unordered_multiset<ll> umsll; typedef multiset<ll> msll; typedef set<ll> sll; typedef vector<ll> vll; typedef pair<ll, ll> pll; typedef vector<pair<ll, ll>> vpll; typedef priority_queue<ll> pqll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; // typedef unordered_multiset<int> umsi; // typedef unordered_set<int> usi; typedef pair<int, int> pi; typedef vector<pair<int, int>> vpi; typedef vector<pair<double, double>> vpd; typedef pair<double, double> pd; typedef priority_queue<int> pqi; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ind_set; typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ind_setll; #define in insert #define fi first #define se second #define pb push_back #define mp make_pair #define be begin #define en end #define itr iterator #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define mo 1000000007 #define inf 1000000000000000001 #define ninf -1000000000000000001 #define ima INT_MAX #define imi INT_MIN #define oncnt __builtin_popcount #define zerobegin __builtin_clz #define zeroend __builtin_ctz #define parity __builtin_parity const ld pii = 3.14159265359; inline ll modpow(ll x, ll n) { if (n == 0) return 1; if (n == 1) return (x % mo); ll u = (modpow(x, n / 2)); u = (u * u) % mo; if (n % 2 != 0) u = (u * x % mo) % mo; return u; } inline ll modinv(ll x) { return modpow(x, mo - 2); } inline ll mmul(ll a, ll b) { if (a >= mo) a = a % mo; if (b >= mo) b = b % mo; if (a * b >= mo) return (a * b) % mo; return (a * b); } inline ll madd(ll a, ll b) { if (a >= mo) a = a % mo; if (b >= mo) b = b % mo; if (a + b >= mo) return (a + b) % mo; return (a + b); } inline ll msub(ll a, ll b) { if (a >= mo) a = a % mo; if (b >= mo) b = b % mo; return ((a - b + mo) % mo); } inline ll mdiv(ll a, ll bb) { if (a >= mo) a = a % mo; ll b = modinv(bb); if (b >= mo) b = b % mo; if (a * b >= mo) return (a * b) % mo; return (a * b); } inline ll gcd(ll a, ll b) { return __gcd(a, b); } int main() { io int testcases = 1; // cin>>testcases; while (testcases--) { int n, w; cin >> n >> w; int we[n]; ll val[n]; for (int i = 0; i < n; i++) { cin >> we[i]; cin >> val[i]; } ll dp[n + 1][w + 1]; for (int i = 0; i < n + 1; i++) { for (int j = 0; j <= w; j++) { if (i == 0 || j == 0) dp[i][j] = 0; else { dp[i][j] = dp[i - 1][j]; if (j >= we[i - 1]) dp[i][j] = max(dp[i][j], val[i - 1] + dp[i - 1][j - we[i - 1]]); } } } cout << dp[n][w]; } return 0; }
[ "variable_declaration.type.change" ]
966,358
966,359
u452240501
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define ll long long int find_max_profit_momo(int v[], int w[], int wt, int n) { // cout<<wt<<" "<<n<<endl; // return 1; ll int dp[n + 1][wt + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= wt; j++) { // cout<<i<<" "<<j<<endl; if (i == 0 || j == 0) { if (j == 0) dp[i][j] = 0; else dp[i][j] = 0; } else { if (j >= w[i - 1]) 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[i][j]<<endl; } // cout<<endl; } return dp[n][wt]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // your code goes here int n; cin >> n; int weight; cin >> weight; int w[n], v[n]; for (int i = 0; i < n; i++) cin >> w[i] >> v[i]; // cout<<find_max_profit(v,w,weight,n)<<endl; cout << find_max_profit_momo(v, w, weight, n) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long ll find_max_profit_momo(int v[], int w[], int wt, int n) { // cout<<wt<<" "<<n<<endl; // return 1; ll int dp[n + 1][wt + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= wt; j++) { // cout<<i<<" "<<j<<endl; if (i == 0 || j == 0) { if (j == 0) dp[i][j] = 0; else dp[i][j] = 0; } else { if (j >= w[i - 1]) 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[i][j]<<endl; } // cout<<endl; } return dp[n][wt]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // your code goes here int n; cin >> n; int weight; cin >> weight; int w[n], v[n]; for (int i = 0; i < n; i++) cin >> w[i] >> v[i]; // cout<<find_max_profit(v,w,weight,n)<<endl; cout << find_max_profit_momo(v, w, weight, n) << endl; return 0; }
[]
966,360
966,361
u082850638
cpp
p03163
/* @author: Charan Sai */ #include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define int long long #define ppi pair<int, int> #define INT INT_MAX #define endl "\n" #define nl cout << "\n" #define deb(x) cout << #x << " " << x << endl; const int M = 1e5 + 1; int N, W; int wt[M], val[M]; // Top-Down Solution = Remove read-only arguments and redundant arguments // and cache the results // Time = (Range of possible values of the variable arguments) * (Time Compl of // each function call) O(N * Weight) Time (Pseudo Polynomial) O(N * Weight) // Space int Top_Down(vector<vector<int>> dp, int i, int curr_w = W) { // Base Cases if (i == 0 || curr_w == 0) return 0; if (dp[i][curr_w] != -1) return dp[i][curr_w]; // Choice if (wt[i] > curr_w) return Top_Down(dp, i - 1, curr_w); int incl = Top_Down(dp, i - 1, curr_w - wt[i]) + val[i]; int excl = Top_Down(dp, i - 1, curr_w); return (dp[i][curr_w] = max(incl, excl)); } int Bottom_Up() { vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0)); for (int i = 1; i <= N; ++i) { for (int curr_w = 1; curr_w <= W; ++curr_w) { if (wt[i] > curr_w) dp[i][curr_w] = dp[i - 1][curr_w]; int incl = dp[i - 1][curr_w - wt[i]] + val[i]; int excl = dp[i - 1][curr_w]; dp[i][curr_w] = max(incl, excl); } } return dp[N][W]; } int32_t main() { IOS; cin >> N >> W; // vector<vector<int>> dp(N+1, vector<int>(W+1, -1)); for (int i = 1; i <= N; ++i) { cin >> wt[i]; cin >> val[i]; } cout << Bottom_Up() << endl; }
/* @author: Charan Sai */ #include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define int long long #define ppi pair<int, int> #define INT INT_MAX #define endl "\n" #define nl cout << "\n" #define deb(x) cout << #x << " " << x << endl; const int M = 1e5 + 1; int N, W; int wt[M], val[M]; // Top-Down Solution = Remove read-only arguments and redundant arguments // and cache the results // Time = (Range of possible values of the variable arguments) * (Time Compl of // each function call) O(N * Weight) Time (Pseudo Polynomial) O(N * Weight) // Space int Top_Down(vector<vector<int>> dp, int i, int curr_w = W) { // Base Cases if (i == 0 || curr_w == 0) return 0; if (dp[i][curr_w] != -1) return dp[i][curr_w]; // Choice if (wt[i] > curr_w) return Top_Down(dp, i - 1, curr_w); int incl = Top_Down(dp, i - 1, curr_w - wt[i]) + val[i]; int excl = Top_Down(dp, i - 1, curr_w); return (dp[i][curr_w] = max(incl, excl)); } // O(N * Weight) Time & Space int Bottom_Up() { vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0)); for (int i = 1; i <= N; ++i) { for (int curr_w = 1; curr_w <= W; ++curr_w) { if (wt[i] > curr_w) { dp[i][curr_w] = dp[i - 1][curr_w]; continue; } int incl = dp[i - 1][curr_w - wt[i]] + val[i]; int excl = dp[i - 1][curr_w]; dp[i][curr_w] = max(incl, excl); } } return dp[N][W]; } int32_t main() { IOS; cin >> N >> W; // vector<vector<int>> dp(N+1, vector<int>(W+1, -1)); for (int i = 1; i <= N; ++i) { cin >> wt[i]; cin >> val[i]; } cout << Bottom_Up() << endl; }
[]
966,364
966,365
u895093067
cpp
p03163
#include <bits/stdc++.h> #define ll long long int #define MOD 1000000007 #define MAX 10000000 using namespace std; int main() { ll n, W, w, v; cin >> n >> W; vector<pair<ll, ll>> knap; for (int i = 0; i < n; i++) { cin >> w >> v; knap.push_back({w, v}); } ll k[n + 1][W + 1]; for (int i = 0; i <= n; i++) { for (int s = 0; s <= W; s++) { if (i == 0 || s == 0) { k[i][s] = 0; } else if (knap[i - 1].first <= s) { k[i][s] = max(knap[i].second + k[i - 1][s - knap[i].first], k[i - 1][s]); } else { k[i][s] = k[i - 1][s]; } } } cout << k[n][W] << endl; return 0; }
#include <bits/stdc++.h> #define ll long long int #define MOD 1000000007 #define MAX 10000000 using namespace std; int main() { ll n, W, w, v; cin >> n >> W; vector<pair<ll, ll>> knap; for (int i = 0; i < n; i++) { cin >> w >> v; knap.push_back({w, v}); } ll k[n + 1][W + 1]; for (int i = 0; i <= n; i++) { for (int s = 0; s <= W; s++) { if (i == 0 || s == 0) { k[i][s] = 0; } else if (knap[i - 1].first <= s) { k[i][s] = max(knap[i - 1].second + k[i - 1][s - knap[i - 1].first], k[i - 1][s]); } else { k[i][s] = k[i - 1][s]; } } } cout << k[n][W] << endl; return 0; }
[ "assignment.change" ]
966,366
966,367
u768421127
cpp
p03163
#include <bits/stdc++.h> using namespace std; vector<vector<int>> dp(2005, vector<int>(2005, -1)); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t, s; cin >> t >> s; vector<pair<int, int>> vec; for (int i = 0; i < t; i++) { int a, b; cin >> a >> b; vec.push_back(make_pair(a, b)); } vector<int> dp(s + 1, 0); dp[0] = 1; for (int i = 0; i < vec.size(); i++) { for (int j = dp.size() - 1; j >= 0; j--) { if (dp[j] && j + vec[i].first <= s) dp[j + vec[i].first] = max(dp[j + vec[i].first], dp[j] + vec[i].second); } } int ans = 0; for (int i = 0; i < dp.size(); i++) { ans = max(ans, dp[i]); } cout << ans - 1; return 0; }
#include <bits/stdc++.h> using namespace std; vector<vector<int>> dp(2005, vector<int>(2005, -1)); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t, s; cin >> t >> s; vector<pair<int, int>> vec; for (int i = 0; i < t; i++) { int a, b; cin >> a >> b; vec.push_back(make_pair(a, b)); } vector<long long> dp(s + 1, 0); dp[0] = 1; for (int i = 0; i < vec.size(); i++) { for (int j = dp.size() - 1; j >= 0; j--) { if (dp[j] && j + vec[i].first <= s) dp[j + vec[i].first] = max(dp[j + vec[i].first], dp[j] + vec[i].second); } } long long ans = 0; for (int i = 0; i < dp.size(); i++) { ans = max(ans, dp[i]); } cout << ans - 1; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
966,371
966,372
u990110497
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { int n, w; cin >> n >> w; int wt[n + 1], v[n + 1]; wt[0] = 0, v[0] = 0; for (int i = 1; i <= n; i++) { cin >> wt[i] >> v[i]; } int mat[n + 1][w + 1]; for (int i = 0; i <= n; i++) { mat[i][0] = 0; } for (int i = 0; i <= w; i++) { mat[0][i] = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= w; j++) { if (wt[i] > j) mat[i][j] = mat[i - 1][j]; else mat[i][j] = max(mat[i - 1][j], mat[i - 1][j - wt[i]] + v[i]); } } cout << mat[n][w]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, w; cin >> n >> w; int wt[n + 1], v[n + 1]; wt[0] = 0, v[0] = 0; for (int i = 1; i <= n; i++) { cin >> wt[i] >> v[i]; } long long int mat[n + 1][w + 1]; for (int i = 0; i <= n; i++) { mat[i][0] = 0; } for (int i = 0; i <= w; i++) { mat[0][i] = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= w; j++) { if (wt[i] > j) mat[i][j] = mat[i - 1][j]; else mat[i][j] = max(mat[i - 1][j], mat[i - 1][j - wt[i]] + v[i]); } } cout << mat[n][w]; return 0; }
[ "variable_declaration.type.widen.change" ]
966,373
966,374
u426221901
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, W; cin >> n >> W; int w[n]; int val[n]; // cout<<"\n"; for (int i = 0; i < n; i++) { cin >> w[i] >> val[i]; } int dp[n + 1][W + 1]; 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 (w[i - 1] <= j) { dp[i][j] = max(val[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]); // check 2nd term } 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::sync_with_stdio(0); cin.tie(0); int n, W; cin >> n >> W; int w[n]; int val[n]; // cout<<"\n"; for (int i = 0; i < n; i++) { cin >> w[i] >> val[i]; } long long int dp[n + 1][W + 1]; 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 (w[i - 1] <= j) { dp[i][j] = max(val[i - 1] + dp[i - 1][j - w[i - 1]], dp[i - 1][j]); // check 2nd term } else { dp[i][j] = dp[i - 1][j]; } } } cout << dp[n][W] << " \n"; return 0; }
[ "variable_declaration.type.widen.change" ]
966,379
966,380
u604419417
cpp
p03163
/* _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | | | author : thanos1399 Language : C ++ | | college : MSIT | | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | */ #include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define TEST \ int t; \ cin >> t; \ while (t--) #define line cout << endl; #define loop(i, a, b) for (long long int i = a; i < b; i++) #define loopIn(i, a, b) for (long long int i = a; i <= b; i++) #define MAX_SIZE 1000000 #define ff first #define ss second #define pb push_back #define ll long long int #define mp make_pair #define vt vector<tup> #define vtt vector<vt> #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; void Sieve(int *prime, int n) { for (int i = 0; i < n; i++) { prime[i] = 0; } for (int i = 2; i < n; i++) { prime[i] = 1; } for (int i = 4; i < n; i += 2) { prime[i] = 0; } for (int i = 3; i < n; i++) { if (prime[i] == 1) { for (int j = i * i; j < n; j += i) { prime[j] = 0; } } } return; } void input() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("/home/yash/Desktop/CPP/input.txt", "r", stdin); freopen("/home/yash/Desktop/CPP/output.txt", "w", stdout); #endif } ll inp; int parent[101]; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } /*int find(int a) { while(parent[a] > 0) a = parent[a]; return a; } */ class item { public: ll val, wt; }; void Union(int a, int b) { parent[a] += parent[b]; // adding size of set b to set a parent[b] = a; // making a , parent of new set } int find(int node) { if (parent[node] < 0) return node; parent[node] = find(parent[node]); return parent[node]; } // Solution 1 ll solve(vector<item> arr, ll n, ll W) { ll dp[n + 1][W + 1]; for (ll w = 0; w <= W; w++) { dp[1][w] = 0; } dp[1][arr[1].wt] = arr[1].val; for (ll i = 2; i <= n; i++) { for (ll w = 0; w <= W; w++) { dp[i][w] = dp[i - 1][w]; if (arr[i].wt > w) continue; dp[i][w] = max(dp[i][w], arr[i].val + dp[i - 1][w - arr[i].wt]); } } // return dp[n][W]; return *max_element(dp[n], dp[n] + W + 1); } int solve1(vector<item> arr, ll n, ll W) { 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 (arr[i - 1].wt <= w) K[i][w] = max(arr[i - 1].val + K[i - 1][w - arr[i - 1].wt], K[i - 1][w]); else K[i][w] = K[i - 1][w]; } } return K[n][W]; } int main() { input(); ll n, W; cin >> n >> W; vector<item> arr(n + 1); for (ll i = 1; i <= n; i++) { cin >> arr[i].wt >> arr[i].val; } ll ans = solve(arr, n, W); // ll ans2 = solve1( arr , n , W) ; cout << ans << endl; return 0; }
/* _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | | | author : thanos1399 Language : C ++ | | college : MSIT | | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | */ #include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define TEST \ int t; \ cin >> t; \ while (t--) #define line cout << endl; #define loop(i, a, b) for (long long int i = a; i < b; i++) #define loopIn(i, a, b) for (long long int i = a; i <= b; i++) #define MAX_SIZE 1000000 #define ff first #define ss second #define pb push_back #define ll long long int #define mp make_pair #define vt vector<tup> #define vtt vector<vt> #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; void Sieve(int *prime, int n) { for (int i = 0; i < n; i++) { prime[i] = 0; } for (int i = 2; i < n; i++) { prime[i] = 1; } for (int i = 4; i < n; i += 2) { prime[i] = 0; } for (int i = 3; i < n; i++) { if (prime[i] == 1) { for (int j = i * i; j < n; j += i) { prime[j] = 0; } } } return; } void input() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("/home/yash/Desktop/CPP/input.txt", "r", stdin); freopen("/home/yash/Desktop/CPP/output.txt", "w", stdout); #endif } ll inp; int parent[101]; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } /*int find(int a) { while(parent[a] > 0) a = parent[a]; return a; } */ class item { public: ll val, wt; }; void Union(int a, int b) { parent[a] += parent[b]; // adding size of set b to set a parent[b] = a; // making a , parent of new set } int find(int node) { if (parent[node] < 0) return node; parent[node] = find(parent[node]); return parent[node]; } // Solution 1 ll solve(vector<item> arr, ll n, ll W) { ll dp[n + 1][W + 1]; for (ll w = 0; w <= W; w++) { dp[1][w] = 0; } dp[1][arr[1].wt] = arr[1].val; for (ll i = 2; i <= n; i++) { for (ll w = 0; w <= W; w++) { dp[i][w] = dp[i - 1][w]; if (arr[i].wt > w) continue; dp[i][w] = max(dp[i][w], arr[i].val + dp[i - 1][w - arr[i].wt]); } } // return dp[n][W]; return *max_element(dp[n], dp[n] + W + 1); } int solve1(vector<item> arr, ll n, ll W) { 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 (arr[i - 1].wt <= w) K[i][w] = max(arr[i - 1].val + K[i - 1][w - arr[i - 1].wt], K[i - 1][w]); else K[i][w] = K[i - 1][w]; } } return K[n][W]; } int main() { // input(); ll n, W; cin >> n >> W; vector<item> arr(n + 1); for (ll i = 1; i <= n; i++) { cin >> arr[i].wt >> arr[i].val; } ll ans = solve(arr, n, W); // ll ans2 = solve1( arr , n , W) ; cout << ans << endl; return 0; }
[ "call.remove" ]
966,393
966,394
u332867154
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { int w, n, ans = 0; cin >> n >> w; vector<int> weight(w + 1); for (int item = 0; item < n; item++) { int ni, wi; cin >> ni >> wi; for (int i = w - ni; i >= 0; i--) { weight[i + ni] = max(weight[i + ni], weight[i] + wi); } } for (int x = 0; x <= w; x++) { ans = max(ans, weight[x]); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long w, n, ans = 0; cin >> n >> w; vector<long long> weight(w + 1); for (int item = 0; item < n; item++) { int ni, wi; cin >> ni >> wi; for (int i = w - ni; i >= 0; i--) { weight[i + ni] = max(weight[i + ni], weight[i] + wi); } } for (int x = 0; x <= w; x++) { ans = max(ans, weight[x]); } cout << ans << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
966,395
966,396
u436793326
cpp
p03163
#include <bits/stdc++.h> using namespace std; long long int dp[101][100001]; int knapSack(int wt[], int val[], int W, int n) { if (n == 0 || W == 0) return 0; if (dp[n][W] != -1) return dp[n][W]; if (wt[n - 1] <= W) { dp[n][W] = max(val[n - 1] + knapSack(wt, val, W - wt[n - 1], n - 1), knapSack(wt, val, W, n - 1)); return dp[n][W]; } else if (wt[n - 1] > W) { dp[n][W] = knapSack(wt, val, W, n - 1); return dp[n][W]; } } int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif memset(dp, -1, sizeof(dp)); int n, W; cin >> n >> W; int wt[n], val[n]; for (int i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } cout << knapSack(wt, val, W, n); }
#include <bits/stdc++.h> using namespace std; long long int dp[101][100001]; long long int knapSack(int wt[], int val[], int W, int n) { if (n == 0 || W == 0) return 0; if (dp[n][W] != -1) return dp[n][W]; if (wt[n - 1] <= W) { dp[n][W] = max(val[n - 1] + knapSack(wt, val, W - wt[n - 1], n - 1), knapSack(wt, val, W, n - 1)); return dp[n][W]; } else if (wt[n - 1] > W) { dp[n][W] = knapSack(wt, val, W, n - 1); return dp[n][W]; } } int main() { //#ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); //#endif memset(dp, -1, sizeof(dp)); int n, W; cin >> n >> W; int wt[n], val[n]; for (int i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } cout << knapSack(wt, val, W, n); }
[ "variable_declaration.type.widen.change" ]
966,400
966,401
u545355464
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define fo(i, n) for (ll i = 0; i < n; i++) #define endl "\n" #define of(i, n) for (ll i = n - 1; i >= 0; i--) #define ll long long #define vec vector<ll> #define fio \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define tr(container, it) \ for (typeof(container.begin()) it = container.begin(); \ it != container.end(); it++) ll mod = 1e9 + 7; #define umap unordered_map string t; ll sub(string s) { ll l = 0, h = s.length(); ll j = 0; for (int i = 0; i < s.length() && j < t.length(); i++) if (t[j] == s[i]) j++; return (j == t.length()); } ll check(ll n, string s) { ll l, h; l = 0; h = n - 1; while (h < s.length()) { if (sub(s.substr(l, h))) return 1; l++; h++; } return 0; } ll ab(ll x) { if (x < 0) x *= -1; return x; } int main() { fio; ll n, w; cin >> n >> w; ll dp[n][w]; int wt[n], v[n]; fo(i, n) cin >> wt[i] >> v[i]; fo(i, n + 1) { fo(j, w + 1) { if (i == 0 || j == 0) dp[i][j] = 0; else if (wt[i - 1] <= j) { dp[i][j] = max(v[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]); } else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w] << endl; }
#include <bits/stdc++.h> using namespace std; #define fo(i, n) for (ll i = 0; i < n; i++) #define endl "\n" #define of(i, n) for (ll i = n - 1; i >= 0; i--) #define ll long long #define vec vector<ll> #define fio \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define tr(container, it) \ for (typeof(container.begin()) it = container.begin(); \ it != container.end(); it++) ll mod = 1e9 + 7; #define umap unordered_map string t; ll sub(string s) { ll l = 0, h = s.length(); ll j = 0; for (int i = 0; i < s.length() && j < t.length(); i++) if (t[j] == s[i]) j++; return (j == t.length()); } ll check(ll n, string s) { ll l, h; l = 0; h = n - 1; while (h < s.length()) { if (sub(s.substr(l, h))) return 1; l++; h++; } return 0; } ll ab(ll x) { if (x < 0) x *= -1; return x; } int main() { fio; ll n, w; cin >> n >> w; ll dp[n + 1][w + 1]; int wt[n], v[n]; fo(i, n) cin >> wt[i] >> v[i]; fo(i, n + 1) { fo(j, w + 1) { if (i == 0 || j == 0) dp[i][j] = 0; else if (wt[i - 1] <= j) { dp[i][j] = max(v[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]); } else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w] << endl; }
[ "variable_declaration.array_dimensions.change", "expression.operation.binary.add" ]
966,409
966,410
u744956225
cpp
p03163
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const long long INF = 1LL << 60; int N; long long W, weight[110], value[110]; long long dp[110][100100] = {}; int main() { cin >> N >> W; for (long long i = 0; i < W; i++) { cin >> weight[i] >> value[i]; } for (long long i = 0; i < N; i++) { for (long long wsum = 0; wsum <= W; wsum++) { if (wsum >= weight[i]) chmax(dp[i + 1][wsum], dp[i][wsum - weight[i]] + value[i]); else chmax(dp[i + 1][wsum], dp[i][wsum]); } } cout << dp[N][W] << endl; }
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const long long INF = 1LL << 60; int N; long long W, weight[110], value[110]; long long dp[110][100100] = {}; int main() { cin >> N >> W; for (long long i = 0; i < W; i++) { cin >> weight[i] >> value[i]; } for (long long i = 0; i < N; i++) { for (long long wsum = 0; wsum <= W; wsum++) { if (wsum >= weight[i]) chmax(dp[i + 1][wsum], dp[i][wsum - weight[i]] + value[i]); chmax(dp[i + 1][wsum], dp[i][wsum]); } } cout << dp[N][W] << endl; }
[ "control_flow.branch.else.remove" ]
966,426
966,427
u731665172
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define ll long long #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define endl '\n' #define mod 998244353 #define inf 1000000000000000000 const int sz = 200006; ll n, k; vector<ll> h, dp; int main() { io cin >> n >> k; vector<int> w(n), v(n); for (int i = 0; i < n; i++) cin >> w[i] >> v[i]; vector<vector<int>> dp(n + 1, vector<int>(k + 1)); for (int i = 0; i <= n; i++) { for (int j = 0; j <= k; j++) { if (i == 0 || j == 0) dp[i][j] = 0; else if (w[i - 1] <= j) { dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]); } else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][k]; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define endl '\n' #define mod 998244353 #define inf 1000000000000000000 const int sz = 200006; ll n, k; vector<ll> h, dp; int main() { io cin >> n >> k; vector<ll> w(n), v(n); for (int i = 0; i < n; i++) cin >> w[i] >> v[i]; vector<vector<ll>> dp(n + 1, vector<ll>(k + 1)); for (int i = 0; i <= n; i++) { for (int j = 0; j <= k; j++) { if (i == 0 || j == 0) dp[i][j] = 0; else if (w[i - 1] <= j) { dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]); } else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][k]; }
[ "call.arguments.change" ]
966,428
966,429
u083831049
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define frst first #define sec second #define fast cin.tie(0), ios_base ::sync_with_stdio(0) #define db double #define mod 1000000007 void online_judge() { #ifndef ONLINE_JUDGE freopen("Input.txt", "r", stdin); freopen("Output.txt", "w", stdout); #endif } ll dp[101][100001]; ll solve1(ll wt[], ll p[], ll n, ll w) { for (int i = 0; i <= n; ++i) { for (int j = 0; j <= w; ++j) { if (i == 0 || j == 0) { dp[i][j] == 0; continue; } dp[i][j] = dp[i - 1][j]; if (j >= wt[i - 1]) { dp[i][j] = max(dp[i][j], dp[i - 1][j - wt[i - 1]] + p[i - 1]); } } } ////cout << dp[n][w] << endl; return dp[n][w]; } void go() { ll n, w; cin >> n >> w; ll wt[n], p[n]; for (int i = 0; i < n; ++i) cin >> wt[i] >> p[i]; // memset(dp , -1 , sizeof dp); cout << solve1(wt, p, n, w); } int main() { fast; online_judge(); // cout << 2332; go(); }
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define frst first #define sec second #define fast cin.tie(0), ios_base ::sync_with_stdio(0) #define db double #define mod 1000000007 void online_judge() { #ifndef ONLINE_JUDGE freopen("Input.txt", "r", stdin); freopen("Output.txt", "w", stdout); #endif } ll dp[101][100001]; ll solve1(ll wt[], ll p[], ll n, ll w) { for (int i = 0; i <= n; ++i) { for (int j = 0; j <= w; ++j) { if (i == 0 || j == 0) { dp[i][j] == 0; continue; } dp[i][j] = dp[i - 1][j]; if (j >= wt[i - 1]) { dp[i][j] = max(dp[i][j], dp[i - 1][j - wt[i - 1]] + p[i - 1]); } } } ////cout << dp[n][w] << endl; return dp[n][w]; } void go() { ll n, w; cin >> n >> w; ll wt[n], p[n]; for (int i = 0; i < n; ++i) cin >> wt[i] >> p[i]; // memset(dp , -1 , sizeof dp); cout << solve1(wt, p, n, w); } int main() { fast; /// online_judge(); // cout << 2332; go(); }
[ "call.remove" ]
966,435
966,436
u723601567
cpp
p03163
/* ╔═══╦═══╦═══╗ ║╔═╗║╔══╩╗╔╗║ ║║░║║╚══╗║║║║ ║║░║║╔══╝║║║║ ║╚═╝║╚══╦╝╚╝║ ╚══╗╠═══╩═══╝ ░░░╚╝░░░░░░░░ */ #include <bits/stdc++.h> #define ll long long #define MOD 1000000007 #define MAX 1e9 #define MIN -1e9 #define PI acos(-1.0) #define vi vector<int> #define vii vector<vi> #define vll vector<ll> #define mid(s, e) (s + (e - s) / 2) using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } template <typename T> void printVec(const T &v, char sep = ' ') { for (auto &i : v) cout << i << sep; } template <typename T> void printVecPair(const T &v, char sep = ' ') { for (auto &i : v) cout << i.first << " " << i.second << sep; } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); int N, W; cin >> N >> W; vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0)); int w[110], v[110]; for (int i = 0; i < N; i++) { cin >> w[i] >> v[i]; } ll ans = 0; for (int i = 1; i <= N; i++) { unsigned ll itemW = w[i]; ll value = v[i]; for (int j = 1; j <= W; j++) { if (itemW > j) dp[i][j] = dp[i - 1][j]; else { dp[i][j] = max(dp[i - 1][j], value + dp[i - 1][j - itemW]); ans = dp[i][j]; } } } cout << dp[N][W]; return 0; }
/* ╔═══╦═══╦═══╗ ║╔═╗║╔══╩╗╔╗║ ║║░║║╚══╗║║║║ ║║░║║╔══╝║║║║ ║╚═╝║╚══╦╝╚╝║ ╚══╗╠═══╩═══╝ ░░░╚╝░░░░░░░░ */ #include <bits/stdc++.h> #define ll long long #define MOD 1000000007 #define MAX 1e9 #define MIN -1e9 #define PI acos(-1.0) #define vi vector<int> #define vii vector<vi> #define vll vector<ll> #define mid(s, e) (s + (e - s) / 2) using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } template <typename T> void printVec(const T &v, char sep = ' ') { for (auto &i : v) cout << i << sep; } template <typename T> void printVecPair(const T &v, char sep = ' ') { for (auto &i : v) cout << i.first << " " << i.second << sep; } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); int N, W; cin >> N >> W; vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0)); int w[110], v[110]; for (int i = 0; i < N; i++) { cin >> w[i] >> v[i]; } ll ans = 0; for (int i = 1; i <= N; i++) { unsigned ll itemW = w[i - 1]; ll value = v[i - 1]; for (int j = 0; j <= W; j++) { if (itemW > j) dp[i][j] = dp[i - 1][j]; else { dp[i][j] = max(dp[i - 1][j], value + dp[i - 1][j - itemW]); ans = dp[i][j]; } } } // debug(dp); cout << dp[N][W]; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
966,437
966,438
u288568295
cpp
p03163
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; using vi = vector<int>; using vll = vector<ll>; ll fast_exp(ll base, ll e) { ll r = 1; while (e > 0) { if (e % 2) r = (r * base); base = base * base; e /= 2; } return r; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, W; cin >> n >> W; vll w(n), v(n); for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } vector<vll> dp(n + 1, vll(W + 1, 0)); for (int i = 0; i <= n; i++) { for (int j = 0; j <= W; j++) { if (i > 0 && j > 0) { if (w[i - 1] <= j) { dp[i][j] = max(v[i - 1] + dp[i][j - w[i - 1]], dp[i - 1][j]); } else dp[i][j] = dp[i - 1][j]; } } } cout << dp[n][W]; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; using vi = vector<int>; using vll = vector<ll>; ll fast_exp(ll base, ll e) { ll r = 1; while (e > 0) { if (e % 2) r = (r * base); base = base * base; e /= 2; } return r; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, W; cin >> n >> W; vll w(n), v(n); for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } vector<vll> dp(n + 1, vll(W + 1, 0)); for (int i = 0; i <= n; i++) { for (int j = 0; j <= W; j++) { if (i > 0 && j > 0) { 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][W]; }
[ "assignment.change" ]
966,439
966,440
u338222575
cpp
p03163
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; using vi = vector<int>; using vll = vector<ll>; ll fast_exp(ll base, ll e) { ll r = 1; while (e > 0) { if (e % 2) r = (r * base); base = base * base; e /= 2; } return r; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, W; cin >> n >> W; vll w(n), v(n); for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } vector<vll> dp(n + 1, vll(W + 1, 0)); for (int i = 0; i <= n; i++) { for (int j = 0; j <= W; j++) { if (i > 0 && j > 0) { if (w[i - 1] <= j) { dp[i][j] = max(v[i - 1] + dp[i][j - w[i - 1]], dp[i][j]); } else dp[i][j] = dp[i - 1][j]; } } } cout << dp[n][W]; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; using vi = vector<int>; using vll = vector<ll>; ll fast_exp(ll base, ll e) { ll r = 1; while (e > 0) { if (e % 2) r = (r * base); base = base * base; e /= 2; } return r; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, W; cin >> n >> W; vll w(n), v(n); for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } vector<vll> dp(n + 1, vll(W + 1, 0)); for (int i = 0; i <= n; i++) { for (int j = 0; j <= W; j++) { if (i > 0 && j > 0) { 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][W]; }
[ "assignment.change" ]
966,441
966,440
u338222575
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { int n, mx = 0, m; cin >> n; cin >> m; int a[n], b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; cin >> b[i]; } int dp[n + 1][m + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (i == 0 || j == 0) dp[i][j] = 0; else if (j < a[i - 1]) dp[i][j] = dp[i - 1][j]; else if (j >= a[i - 1]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a[i - 1]] + b[i - 1]); } } cout << dp[n][m] << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, mx = 0, m; cin >> n; cin >> m; long long int a[n], b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; cin >> b[i]; } long long int dp[n + 1][m + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (i == 0 || j == 0) dp[i][j] = 0; else if (j < a[i - 1]) dp[i][j] = dp[i - 1][j]; else if (j >= a[i - 1]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a[i - 1]] + b[i - 1]); } } cout << dp[n][m] << "\n"; return 0; }
[ "variable_declaration.type.widen.change" ]
966,442
966,443
u561103039
cpp
p03163
#include <bits/stdc++.h> using namespace std; long long int mat[101][100001]; int main() { #ifdef EVAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int N, W; cin >> N >> W; int val[N]; int p[N]; for (int i = 0; i < N; i++) { cin >> p[i] >> val[i]; } for (int i = p[0]; i <= W; i++) { mat[0][i] = val[0]; } for (int i = 1; i < N; i++) { for (int j = 0; j <= W; j++) { mat[i][j] = max(mat[i][j], mat[i - 1][j]); if (j + p[i] <= W) mat[i][j + p[i]] = max(mat[i][j + p[i]], mat[i - 1][j] + val[i]); } } cout << mat[N - 1][W - 1]; }
#include <bits/stdc++.h> using namespace std; long long int mat[101][100001]; int main() { #ifdef EVAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int N, W; cin >> N >> W; int val[N]; int p[N]; for (int i = 0; i < N; i++) { cin >> p[i] >> val[i]; } for (int i = p[0]; i <= W; i++) { mat[0][i] = val[0]; } for (int i = 1; i < N; i++) { for (int j = 0; j <= W; j++) { mat[i][j] = max(mat[i][j], mat[i - 1][j]); if (j + p[i] <= W) mat[i][j + p[i]] = max(mat[i][j + p[i]], mat[i - 1][j] + val[i]); } } cout << mat[N - 1][W]; }
[ "expression.operation.binary.remove" ]
966,451
966,452
u101297813
cpp
p03163
#define ll long long int #define fr(i, x, n) for (ll i = (ll)(x); i < (ll)(n); ++i) #include <bits/stdc++.h> // https://atcoder.jp/contests/dp/submissions/12796237 using namespace std; int main() { int N, W; cin >> N; cin >> W; int arr1[N][2]; fr(i, 0, N) { cin >> arr1[i][0]; cin >> arr1[i][1]; } int Wt[N]; int val[N]; fr(i, 0, N) { Wt[i] = arr1[i][0]; val[i] = arr1[i][1]; } int dp[N + 1][W + 1]; fr(i, 0, N + 1) { dp[i][0] = 0; } fr(i, 0, W + 1) dp[0][i] = 0; fr(i, 1, N + 1) fr(j, 1, W + 1) { if (Wt[i - 1] <= j) dp[i][j] = max(val[i - 1] + dp[i - 1][j - Wt[i - 1]], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } cout << dp[N][W]; }
#define ll long long int #define fr(i, x, n) for (ll i = (ll)(x); i < (ll)(n); ++i) #include <bits/stdc++.h> // https://atcoder.jp/contests/dp/submissions/12796237 using namespace std; int main() { ll N, W; cin >> N; cin >> W; int arr1[N][2]; fr(i, 0, N) { cin >> arr1[i][0]; cin >> arr1[i][1]; } ll Wt[N]; ll val[N]; fr(i, 0, N) { Wt[i] = arr1[i][0]; val[i] = arr1[i][1]; } ll dp[N + 1][W + 1]; fr(i, 0, N + 1) { dp[i][0] = 0; } fr(i, 0, W + 1) dp[0][i] = 0; fr(i, 1, N + 1) fr(j, 1, W + 1) { if (Wt[i - 1] <= j) dp[i][j] = max(val[i - 1] + dp[i - 1][j - Wt[i - 1]], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } cout << dp[N][W]; }
[ "variable_declaration.type.change" ]
966,453
966,454
u174584859
cpp
p03163
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) #define For(i, a, b) for (int i = a; i < b; i++) typedef long long ll; double PI = 3.14159265; using namespace std; using Graph = vector<vector<int>>; using Field = vector<string>; using DGraph = vector<vector<pair<int, int>>>; const long long INF = 1LL << 60; //---// int w[110], v[110], dp[100010][110]; int main() { int N, W; cin >> N >> W; rep(i, N) cin >> w[i] >> v[i]; memset(dp, 0, sizeof(dp)); rep(i, N) { For(j, 0, W + 1) { if (j >= w[i]) dp[j][i + 1] = max(dp[j - w[i]][i] + v[i], dp[j][i]); else dp[j][i + 1] = dp[j][i]; } } cout << dp[W][N] << endl; return 0; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) #define For(i, a, b) for (int i = a; i < b; i++) typedef long long ll; double PI = 3.14159265; using namespace std; using Graph = vector<vector<int>>; using Field = vector<string>; using DGraph = vector<vector<pair<int, int>>>; const long long INF = 1LL << 60; //---// int w[110], v[110]; ll dp[100010][110]; int main() { int N, W; cin >> N >> W; rep(i, N) cin >> w[i] >> v[i]; memset(dp, 0, sizeof(dp)); rep(i, N) { For(j, 0, W + 1) { if (j >= w[i]) dp[j][i + 1] = max(dp[j - w[i]][i] + v[i], dp[j][i]); else dp[j][i + 1] = dp[j][i]; } } cout << dp[W][N] << endl; return 0; }
[]
966,455
966,456
u116995735
cpp
p03163
#include <iostream> using namespace std; int main() { long n, W; cin >> n; cin >> W; long val[n], wt[n], dp[n][W + 1]; for (long i = 0; i < n; i++) { cin >> wt[i]; cin >> val[i]; } for (long i = 0; i < n; i++) { for (long w = 0; w <= W; w++) { if (w == 0) dp[i][w] = 0; else if (i == 0) { if (wt[0] < w) dp[i][w] = val[i]; else dp[i][w] = 0; } else { dp[i][w] = (wt[i] < w) ? max(dp[i - 1][w], val[i] + dp[i - 1][W - wt[i]]) : dp[i - 1][w]; } } } cout << dp[n - 1][W]; }
#include <iostream> using namespace std; int main() { long n, W; cin >> n; cin >> W; long val[n], wt[n], dp[n][W + 1]; for (long i = 0; i < n; i++) { cin >> wt[i]; cin >> val[i]; } for (long i = 0; i < n; i++) { for (long w = 0; w <= W; w++) { if (w == 0) dp[i][w] = 0; else if (i == 0) { if (wt[0] <= w) dp[i][w] = val[i]; else dp[i][w] = 0; } else { dp[i][w] = (wt[i] <= w) ? max(dp[i - 1][w], val[i] + dp[i - 1][w - wt[i]]) : dp[i - 1][w]; } } } cout << dp[n - 1][W]; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.value.change", "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
966,457
966,458
u519699168
cpp
p03163
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long int ll; vector<vector<ll>> adjlist; ll max(ll x, ll y) { return (x > y) ? x : y; } ll min(ll x, ll y) { return (x > y) ? y : x; } #define sfor(a, n, i) for (ll i = a; i < n; i++) #define rfor(n, a, i) for (ll i = n; i >= a; i--) #define mod 1000000007 #define pb push_back #define in insert #define mp make_pair #define inf mod #define bg begin() #define ed end() #define sz size() #define vi vector<ll> #define vc vector<char> #define vinv vector<vector<ll, ll>> #define imap map<ll, ll> #define cmap map<char, ll> #define smap map<string, ll> #define iset set<ll> #define bit(x, i) (x & (1 << i)) int main() { int n, w; cin >> n >> w; pair<int, int> vw[n + 1]; vw[0] = {0, 0}; sfor(01, n + 1, i) cin >> vw[i].first >> vw[i].second; // sfor(01, n + 1, i) // { // cout << vw[i].first << " " << vw[i].second; // cout << endl; // } vector<vector<int>> dp(n + 1, vector<int>(w + 1, 0)); sfor(1, w + 1, i) { sfor(1, n + 1, j) { if (vw[j].first <= i) { int temp = max(dp[j - 1][i], vw[j].second + dp[j - 1][i - vw[j].first]); dp[j][i] = temp; } else { dp[j][i] = dp[j - 1][i]; } } } // sfor(0, n + 1, i) // { // sfor(0, w + 1, j) // { // cout << dp[i][j] << " "; //= max(dp[j - 1][i], vw[j].second + dp[j // - 1][i - vw[j].first]); // } // cout << endl; // } cout << dp[n][w] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long int ll; vector<vector<ll>> adjlist; ll max(ll x, ll y) { return (x > y) ? x : y; } ll min(ll x, ll y) { return (x > y) ? y : x; } #define sfor(a, n, i) for (ll i = a; i < n; i++) #define rfor(n, a, i) for (ll i = n; i >= a; i--) #define mod 1000000007 #define pb push_back #define in insert #define mp make_pair #define inf mod #define bg begin() #define ed end() #define sz size() #define vi vector<ll> #define vc vector<char> #define vinv vector<vector<ll, ll>> #define imap map<ll, ll> #define cmap map<char, ll> #define smap map<string, ll> #define iset set<ll> #define bit(x, i) (x & (1 << i)) int main() { ll n, w; cin >> n >> w; pair<ll, ll> vw[n + 1]; vw[0] = {0, 0}; sfor(01, n + 1, i) cin >> vw[i].first >> vw[i].second; // sfor(01, n + 1, i) // { // cout << vw[i].first << " " << vw[i].second; // cout << endl; // } vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0)); sfor(1, w + 1, i) { sfor(1, n + 1, j) { if (vw[j].first <= i) { ll temp = max(dp[j - 1][i], vw[j].second + dp[j - 1][i - vw[j].first]); dp[j][i] = temp; } else { dp[j][i] = dp[j - 1][i]; } } } // sfor(0, n + 1, i) // { // sfor(0, w + 1, j) // { // cout << dp[i][j] << " "; //= max(dp[j - 1][i], vw[j].second + dp[j // - 1][i - vw[j].first]); // } // cout << endl; // } cout << dp[n][w] << endl; return 0; }
[ "variable_declaration.type.change", "call.arguments.change" ]
966,462
966,463
u448528861
cpp
p03163
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef pair<int, int> P; typedef long long ll; const int INF = 1e9; const int MOD = 1e9 + 7; int N, W; int v[110], w[110]; int dp[110][110000]; 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 = 0; j <= W; j++) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef pair<int, int> P; typedef long long ll; const int INF = 1e9; const int MOD = 1e9 + 7; int N, W; int v[110], w[110]; ll dp[110][110000]; 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 = 0; j <= W; j++) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; }
[ "variable_declaration.type.change" ]
966,464
966,465
u503228842
cpp
p03163
#include <bits/stdc++.h> #define ll long long int using namespace std; // ll dp[100001]; void knapsack(int n, ll *w, ll *v, int W) { ll dp[n][W + 1]; for (int i = 0; i <= W; i++) { if (i >= w[i]) { dp[0][i] = v[0]; } else dp[0][i] = 0; // cout<<i<<dp[0][i]<<endl; } for (int i = 1; i < n; i++) { for (int j = 0; j <= W; j++) { // int max=0; 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]; } } /*for(int i=0;i<n;i++) { for(int j=0;j<=W;j++) { cout<<dp[i][j]<<" "; } cout<<endl; }*/ cout << dp[n - 1][W]; } int main() { int n, W; cin >> n >> W; ll w[n], v[n]; for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } knapsack(n, w, v, W); }
#include <bits/stdc++.h> #define ll long long int using namespace std; // ll dp[100001]; void knapsack(int n, ll *w, ll *v, int W) { ll dp[n][W + 1]; for (int i = 0; i <= W; i++) { if (i >= w[0]) { dp[0][i] = v[0]; } else dp[0][i] = 0; // cout<<i<<dp[0][i]<<endl; } for (int i = 1; i < n; i++) { for (int j = 0; j <= W; j++) { // int max=0; 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]; } } /*for(int i=0;i<n;i++) { for(int j=0;j<=W;j++) { cout<<dp[i][j]<<" "; } cout<<endl; }*/ cout << dp[n - 1][W] << endl; } int main() { int n, W; cin >> n >> W; ll w[n], v[n]; for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } knapsack(n, w, v, W); }
[ "identifier.replace.remove", "literal.replace.add", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "io.output.newline.add" ]
966,468
966,469
u539406723
cpp
p03163
#include <iostream> using namespace std; const int mxN = 1e5 + 5, mxM = 105; int dp[mxM][mxN], w[mxM], v[mxM]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> w[i] >> v[i]; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (j >= w[i]) dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][m]; }
#include <iostream> using namespace std; const int mxN = 1e5 + 5, mxM = 105; long long dp[mxM][mxN], w[mxM], v[mxM]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> w[i] >> v[i]; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (j >= w[i]) dp[i][j] = max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][m]; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
966,474
966,475
u106978087
cpp
p03163
#include <iostream> #include <string> #include <vector> #define ll long long using namespace std; int main() { ll n, W; cin >> n >> W; vector<ll> w(n), v(n); vector<vector<ll>> dp(n, vector<ll>(W + 1, 0)); for (ll i = 0; i < n; i++) cin >> w.at(i) >> v.at(i); for (ll i = w.at(0); i < n; i++) dp.at(0).at(i) = v.at(0); for (ll i = 1; i < n; i++) { for (ll j = 0; j < W + 1; j++) { dp.at(i).at(j) = dp.at(i - 1).at(j); if ((j - w.at(i) >= 0) && (dp.at(i - 1).at(j - w.at(i)) + v.at(i) > dp.at(i).at(j))) dp.at(i).at(j) = dp.at(i - 1).at(j - w.at(i)) + v.at(i); } } cout << dp.at(n - 1).at(W) << endl; }
#include <iostream> #include <string> #include <vector> #define ll long long using namespace std; int main() { ll n, W; cin >> n >> W; vector<ll> w(n), v(n); vector<vector<ll>> dp(n, vector<ll>(W + 1, 0)); for (ll i = 0; i < n; i++) cin >> w.at(i) >> v.at(i); for (ll i = w.at(0); i < W + 1; i++) dp.at(0).at(i) = v.at(0); for (ll i = 1; i < n; i++) { for (ll j = 0; j < W + 1; j++) { dp.at(i).at(j) = dp.at(i - 1).at(j); if ((j - w.at(i) >= 0) && (dp.at(i - 1).at(j - w.at(i)) + v.at(i) > dp.at(i).at(j))) dp.at(i).at(j) = dp.at(i - 1).at(j - w.at(i)) + v.at(i); } } cout << dp.at(n - 1).at(W) << endl; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "misc.off_by_one" ]
966,478
966,479
u415370212
cpp
p03163
#include <algorithm> #include <iostream> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> using V = vector<T>; template <class T> using VV = vector<vector<T>>; int main() { int n, w; cin >> n >> w; VV<int> dp(n + 1, V<int>(w + 1, 0)); V<int> vw(n); V<int> vv(n); rep(i, n) { cin >> vw[i] >> vv[i]; } rep(i, n) { for (int sum_w = 0; sum_w <= w; ++sum_w) { chmax(dp[i + 1][sum_w], dp[i][sum_w]); if (sum_w - vw[i] < 0) continue; chmax(dp[i + 1][sum_w], dp[i][sum_w - vw[i]] + vv[i]); } } cout << dp[n][w] << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> using V = vector<T>; template <class T> using VV = vector<vector<T>>; int main() { int n, w; cin >> n >> w; VV<ll> dp(n + 1, V<ll>(w + 1, 0)); V<int> vw(n); V<int> vv(n); rep(i, n) { cin >> vw[i] >> vv[i]; } rep(i, n) { for (int sum_w = 0; sum_w <= w; ++sum_w) { chmax(dp[i + 1][sum_w], dp[i][sum_w]); if (sum_w - vw[i] < 0) continue; chmax(dp[i + 1][sum_w], dp[i][sum_w - vw[i]] + vv[i]); } } cout << dp[n][w] << endl; return 0; }
[ "call.arguments.change" ]
966,481
966,482
u809212443
cpp
p03163
#include <bits/stdc++.h> using namespace std; int N, W, weight[101], v[101], dp[101][100001]; int main() { cin >> N >> W; for (int i = 1; i <= N; i++) { cin >> weight[i] >> v[i]; } for (int w = 0; w <= W; w++) dp[0][w] = 0; for (int i = 0; i <= N; i++) dp[i][0] = 0; for (int i = 1; i <= N; i++) { for (int w = 0; w <= W; w++) { if (weight[i] <= w) { dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight[i]] + v[i]); } else { dp[i][w] = dp[i - 1][w]; } } } cout << dp[N][W]; }
#include <bits/stdc++.h> using namespace std; int N, W, weight[101]; long long v[101], dp[101][100001]; int main() { cin >> N >> W; for (int i = 1; i <= N; i++) { cin >> weight[i] >> v[i]; } for (int w = 0; w <= W; w++) dp[0][w] = 0; for (int i = 0; i <= N; i++) dp[i][0] = 0; for (int i = 1; i <= N; i++) { for (int w = 0; w <= W; w++) { if (weight[i] <= w) { dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight[i]] + v[i]); } else { dp[i][w] = dp[i - 1][w]; } } } cout << dp[N][W] << endl; }
[ "io.output.newline.add" ]
966,487
966,488
u052165189
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define ll long long #define max(a, b) ((a > b) ? a : b) int main() { int n, w; cin >> n >> w; int cost, val; vector<int> dp(w + 1, 0); for (int i = 0; i < n; i++) { cin >> cost >> val; for (int cost_i = w; cost_i >= cost; cost_i--) dp[cost_i] = max(dp[cost_i], dp[cost_i - cost] + val); } cout << *max_element(dp.begin(), dp.end()); }
#include <bits/stdc++.h> using namespace std; #define ll long long #define max(a, b) ((a > b) ? a : b) int main() { int n, w; cin >> n >> w; int cost, val; vector<ll> dp(w + 1, 0); for (int i = 0; i < n; i++) { cin >> cost >> val; for (int cost_i = w; cost_i >= cost; cost_i--) dp[cost_i] = max(dp[cost_i], dp[cost_i - cost] + val); } cout << *max_element(dp.begin(), dp.end()); }
[]
966,494
966,495
u157193081
cpp
p03163
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <vector> typedef long long int lld; typedef unsigned long long int llu; using namespace std; const int m = 1e9; int main() { int n, w, i; cin >> n >> w; int wt[n], v[n]; for (i = 0; i < n; i++) cin >> wt[i] >> v[i]; int k[n + 1][w + 1], j; for (i = 0; i <= n; i++) { for (j = 0; j <= w; j++) { if (i == 0 || j == 0) k[i][j] = 0; else if (wt[i - 1] <= j) { k[i][j] = max(k[i - 1][j], v[i - 1] + k[i - 1][j - wt[i - 1]]); } else k[i][j] = k[i - 1][j]; } } cout << k[n][w]; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <vector> typedef long long int lld; typedef unsigned long long int llu; using namespace std; const int m = 1e9; int main() { llu n, w, i; cin >> n >> w; llu wt[n], v[n]; for (i = 0; i < n; i++) cin >> wt[i] >> v[i]; llu k[n + 1][w + 1], j; for (i = 0; i <= n; i++) { for (j = 0; j <= w; j++) { if (i == 0 || j == 0) k[i][j] = 0; else if (wt[i - 1] <= j) { k[i][j] = max(k[i - 1][j], v[i - 1] + k[i - 1][j - wt[i - 1]]); } else k[i][j] = k[i - 1][j]; } } cout << k[n][w]; }
[ "variable_declaration.type.change" ]
966,496
966,497
u408298796
cpp
p03163
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <vector> typedef long long int lld; typedef unsigned long long int llu; using namespace std; const int m = 1e9; int main() { int n, w, i; cin >> n >> w; int wt[n], v[n]; for (i = 0; i < n; i++) cin >> wt[i] >> v[i]; int k[n + 1][w + 1], j; for (i = 0; i <= n; i++) { for (j = 0; j <= w; j++) { if (i == 0 || j == 0) k[i][j] = 0; else if (wt[i - 1] <= j) { k[i][j] = max(k[i - 1][j], v[i - 1] + k[i - 1][j - wt[i - 1]]); } else k[i][j] = k[i - 1][j]; } } cout << k[n][w]; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <vector> typedef long long int lld; typedef unsigned long long int llu; using namespace std; const int m = 1e9; int main() { int n, w, i; cin >> n >> w; int wt[n], v[n]; for (i = 0; i < n; i++) cin >> wt[i] >> v[i]; lld k[n + 1][w + 1], j; for (i = 0; i <= n; i++) { for (j = 0; j <= w; j++) { if (i == 0 || j == 0) k[i][j] = 0; else if (wt[i - 1] <= j) { k[i][j] = max(k[i - 1][j], v[i - 1] + k[i - 1][j - wt[i - 1]]); } else k[i][j] = k[i - 1][j]; } } cout << k[n][w]; }
[ "variable_declaration.type.change" ]
966,496
966,498
u408298796
cpp
p03163
#include <algorithm> #include <iostream> #include <vector> using namespace std; long long a[1000 + 100][2], b[10 + 10000][10010] = {0}; long long sol(int n, int i, int j) { if (i == n - 1) { long long m = -8; for (int t = 0; t < 3; t++) { if (t != j) m = max(m, a[i][t]); } return m; } long long m = -8, s = 0; for (int t = 0; t < 3; t++) { if (t != j) { if (m < a[i][t]) s = t; m = max(m, a[i][t]); } } if (b[i][s] == -1) b[i][s] = m + sol(n, i + 1, s); return b[i][s]; } int main() { int n, w; cin >> n >> w; for (int i = 1; i <= n; i++) for (int j = 0; j < 2; j++) { cin >> a[i][j]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= w; j++) { if (j - a[i][0] > -1) { b[i][j] = max(a[i][1] + b[i - 1][j - a[i][0]], b[i - 1][j]); } else b[i][j] = b[i - 1][j]; } } cout << b[n][w] << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; long long a[1000 + 100][2], b[10 + 100][100000 + 100] = {0}; long long sol(int n, int i, int j) { if (i == n - 1) { long long m = -8; for (int t = 0; t < 3; t++) { if (t != j) m = max(m, a[i][t]); } return m; } long long m = -8, s = 0; for (int t = 0; t < 3; t++) { if (t != j) { if (m < a[i][t]) s = t; m = max(m, a[i][t]); } } if (b[i][s] == -1) b[i][s] = m + sol(n, i + 1, s); return b[i][s]; } int main() { int n, w; cin >> n >> w; for (int i = 1; i <= n; i++) for (int j = 0; j < 2; j++) { cin >> a[i][j]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= w; j++) { if (j - a[i][0] > -1) { b[i][j] = max(a[i][1] + b[i - 1][j - a[i][0]], b[i - 1][j]); } else b[i][j] = b[i - 1][j]; } } cout << b[n][w] << endl; return 0; }
[ "literal.number.change", "expression.operation.binary.change" ]
966,504
966,505
u543080241
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define int long long int #define ld long double #define F first #define S second #define P pair<int, int> #define pb push_back const int N = 100005; void solve() { int i, j, k, n, m, ans = 0, cnt = 0, sum = 0; cin >> n >> m; int w[n + 1], v[n + 1]; w[0] = v[0] = 0; for (i = 1; i <= n; i++) { cin >> w[i] >> v[i]; } int dp[n + 1][m + 1]; memset(dp, 0, sizeof(dp)); for (i = 1; i <= n; i++) { for (j = 0; j <= m; j++) { if (j - w[i] >= 0) { dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } dp[i][j] = max({dp[i][j], dp[i][j - 1], dp[i - 1][j]}); } } cout << dp[n][m]; return; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // int t; cin >> t; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long int #define ld long double #define F first #define S second #define P pair<int, int> #define pb push_back const int N = 100005; void solve() { int i, j, k, n, m, ans = 0, cnt = 0, sum = 0; cin >> n >> m; int w[n + 1], v[n + 1]; w[0] = v[0] = 0; for (i = 1; i <= n; i++) { cin >> w[i] >> v[i]; } int dp[n + 1][m + 1]; memset(dp, 0, sizeof(dp)); for (i = 1; i <= n; i++) { for (j = 0; j <= m; j++) { if (j - w[i] >= 0) { dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } if (j) dp[i][j] = max({dp[i][j], dp[i][j - 1], dp[i - 1][j]}); } } cout << dp[n][m]; return; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // int t; cin >> t; while (t--) solve(); return 0; }
[ "control_flow.branch.if.add" ]
966,522
966,523
u064488844
cpp
p03163
#include <iostream> #include <vector> using namespace std; long long dp[105][100005] = {}; int main() { int n, weight; cin >> n >> weight; vector<int> W(n), V(n); for (int i = 0; i < n; ++i) cin >> W[i] >> V[i]; for (int i = 1; i <= n; ++i) { for (int w = 1; w <= weight; ++w) { if (w >= W[i]) dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - W[i]] + V[i]); else dp[i][w] = dp[i - 1][w]; } } cout << dp[n][weight] << endl; }
#include <iostream> #include <vector> using namespace std; long long dp[105][100005] = {}; int main() { int n, weight; cin >> n >> weight; vector<int> W(n + 1), V(n + 1); for (int i = 1; i <= n; ++i) cin >> W[i] >> V[i]; for (int i = 1; i <= n; ++i) { for (int w = 1; w <= weight; ++w) { if (w >= W[i]) dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - W[i]] + V[i]); else dp[i][w] = dp[i - 1][w]; } } cout << dp[n][weight] << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
966,526
966,527
u706786134
cpp
p03163
/** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. */ #include <bits/stdc++.h> #define ll long long using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long primechk[10000]; void preprocess(long long N) { long long i, j; for (i = 2; i <= N; i++) { primechk[i] = 1; } for (i = 2; i <= N; i++) { if (primechk[i] == 1) { for (j = 2; i * j <= N; j++) { primechk[i * j] = 0; } } } } bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } long long Binexpo(long long a, long long b) { if (b == 0) return 1; long long res = Binexpo(a, b / 2); if (b % 2) { return res * res * a; } else { return res * res; } } long long Pwr(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b % 2) { res = res * a % m; } a = a * a % m; b >>= 1; } return res; } long long dp[1000000]; int main() { long long wt, q, b, c, d, e, f, g, h, i, j, k, x, y, z, sum = 0, cnt = 0, n, l, r, hi, lo, t, val = 1; cin >> n >> wt; long long w[n], v[n]; for (i = 0; i < n; i++) { cin >> w[i] >> v[i]; } for (i = 0; i < n; i++) { for (j = wt; j >= w[i]; j--) { dp[j] = max(dp[j - w[i]] + v[i], dp[j]); } } for (i = 0; i < wt; i++) { val = max(val, dp[i]); } cout << val; return 0; }
/** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. */ #include <bits/stdc++.h> #define ll long long using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long primechk[10000]; void preprocess(long long N) { long long i, j; for (i = 2; i <= N; i++) { primechk[i] = 1; } for (i = 2; i <= N; i++) { if (primechk[i] == 1) { for (j = 2; i * j <= N; j++) { primechk[i * j] = 0; } } } } bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } long long Binexpo(long long a, long long b) { if (b == 0) return 1; long long res = Binexpo(a, b / 2); if (b % 2) { return res * res * a; } else { return res * res; } } long long Pwr(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b % 2) { res = res * a % m; } a = a * a % m; b >>= 1; } return res; } long long dp[1000000]; int main() { long long wt, q, b, c, d, e, f, g, h, i, j, k, x, y, z, sum = 0, cnt = 0, n, l, r, hi, lo, t, val = 1; cin >> n >> wt; long long w[n], v[n]; for (i = 0; i < n; i++) { cin >> w[i] >> v[i]; } for (i = 0; i < n; i++) { for (j = wt; j >= w[i]; j--) { dp[j] = max(dp[j - w[i]] + v[i], dp[j]); } } for (i = 0; i <= wt; i++) { val = max(val, dp[i]); } cout << val; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
966,542
966,543
u220730975
cpp
p03163
#include <iostream> using namespace std; typedef long long ll; int main() { int n, w; cin >> n >> w; ll weight[n], value[n]; for (int i = 0; i < n; i++) { cin >> weight[i] >> value[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 (weight[i - 1] <= w) dp[i][j] = max(dp[i - 1][j], value[i - 1] + dp[i - 1][j - weight[i - 1]]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w]; }
#include <iostream> using namespace std; typedef long long ll; int main() { int n, w; cin >> n >> w; ll weight[n], value[n]; for (int i = 0; i < n; i++) { cin >> weight[i] >> value[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 (weight[i - 1] <= j) dp[i][j] = max(dp[i - 1][j], value[i - 1] + dp[i - 1][j - weight[i - 1]]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w]; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
966,561
966,562
u051114039
cpp
p03163
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <queue> #include <set> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { int n, cap; cin >> n >> cap; int w[n], v[n]; for (int i = 0; i < n; i++) cin >> w[i] >> v[i]; int dp[n + 1][cap + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= cap; 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][cap]; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <queue> #include <set> #include <utility> #include <vector> using namespace std; typedef long long ll; int main() { ll n, cap; cin >> n >> cap; int w[n], v[n]; for (ll i = 0; i < n; i++) cin >> w[i] >> v[i]; ll dp[n + 1][cap + 1]; for (ll i = 0; i <= n; i++) { for (int j = 0; j <= cap; 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][cap]; }
[ "variable_declaration.type.change", "control_flow.loop.for.initializer.change" ]
966,563
966,564
u051114039
cpp
p03163
#include <bits/stdc++.h> using namespace std; int main() { int n, w; cin >> n >> w; vector<int> weight(n); vector<int> value(n); for (int i = 0; i < n; i++) cin >> weight[i] >> value[i]; vector<vector<int>> value_sum(n, vector<int>(w + 1)); for (int i = 0; i < n; i++) { for (int j = 0; j <= w; j++) { if (i == 0) { if (weight[i] > j) value_sum[i][j] = 0; else value_sum[i][j] = value[i]; } else { if (weight[i] > j) value_sum[i][j] = value_sum[i - 1][j]; else value_sum[i][j] = max(value_sum[i - 1][j], value_sum[i - 1][j - weight[i]] + value[i]); } } } cout << value_sum[n - 1][w] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, w; cin >> n >> w; vector<int> weight(n); vector<int> value(n); for (int i = 0; i < n; i++) cin >> weight[i] >> value[i]; vector<vector<int64_t>> value_sum(n, vector<int64_t>(w + 1)); for (int i = 0; i < n; i++) { for (int j = 0; j <= w; j++) { if (i == 0) { if (weight[i] > j) value_sum[i][j] = 0; else value_sum[i][j] = value[i]; } else { if (weight[i] > j) value_sum[i][j] = value_sum[i - 1][j]; else value_sum[i][j] = max(value_sum[i - 1][j], value_sum[i - 1][j - weight[i]] + value[i]); } } } cout << value_sum[n - 1][w] << endl; }
[ "variable_declaration.type.primitive.change" ]
966,565
966,566
u592961584
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define ll long long main() { ll N; ll W; cin >> N >> W; ll wt[N]; ll val[N]; for (ll i = 0; i < N; i++) { cin >> wt[i] >> val[i]; } ll dp[N + 1][W + 1]; for (ll i = 0; i < W; i++) dp[0][i] = 0; for (ll i = 0; i < N; i++) { for (ll j = 0; j <= W; j++) { if (j >= wt[i]) dp[i + 1][j] = max(dp[i][j], dp[i][j - wt[i]] + val[i]); else { dp[i + 1][j] = dp[i][j]; } } } cout << dp[N][W] << "\n"; }
#include <bits/stdc++.h> using namespace std; #define ll long long main() { ll N; ll W; cin >> N >> W; ll wt[N]; ll val[N]; for (ll i = 0; i < N; i++) { cin >> wt[i] >> val[i]; } ll dp[N + 1][W + 1]; for (ll i = 0; i <= W; i++) dp[0][i] = 0; for (ll i = 0; i < N; i++) { for (ll j = 0; j <= W; j++) { if (j >= wt[i]) dp[i + 1][j] = max(dp[i][j], dp[i][j - wt[i]] + val[i]); else { dp[i + 1][j] = dp[i][j]; } } } cout << dp[N][W] << "\n"; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
966,581
966,582
u934544507
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 100005 #define m 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 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, W, i, j; cin >> n >> W; int w[n], v[n]; for (i = 0; i < n; ++i) cin >> w[i] >> v[i]; int dp[n + 1][W + 1]; for (i = 0; i <= n; ++i) for (j = 0; j <= W; ++j) { if (i == 0 || j == 0) dp[i][j] = 0; else 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]; } cout << dp[n][W]; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 100005 #define m 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 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, W, i, j; cin >> n >> W; ll w[n], v[n]; for (i = 0; i < n; ++i) cin >> w[i] >> v[i]; ll dp[n + 1][W + 1]; for (i = 0; i <= n; ++i) for (j = 0; j <= W; ++j) { if (i == 0 || j == 0) dp[i][j] = 0; else 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]; } cout << dp[n][W]; }
[ "variable_declaration.type.change" ]
966,583
966,584
u987273922
cpp
p03163
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep2(i, n, m) for (int i = n; i < m; ++i) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1001001001; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, w; cin >> n >> w; vector<vector<int>> dp(n + 1, vector<int>(w + 1)); vector<int> value(n); vector<int> weight(n); rep(i, n) { cin >> weight.at(i) >> value.at(i); } rep(i, n) { for (int j = 0; j <= w; ++j) { if (j - weight.at(i) >= 0) { chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]); } chmax(dp[i + 1][j], dp[i][j]); } } cout << dp[n][w] << endl; cout << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep2(i, n, m) for (int i = n; i < m; ++i) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1001001001; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, w; cin >> n >> w; vector<vector<ll>> dp(n + 1, vector<ll>(w + 1)); vector<ll> value(n); vector<ll> weight(n); rep(i, n) { cin >> weight.at(i) >> value.at(i); } rep(i, n) { for (int j = 0; j <= w; ++j) { if (j - weight.at(i) >= 0) { chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]); } chmax(dp[i + 1][j], dp[i][j]); } } cout << dp[n][w] << endl; cout << endl; return 0; }
[ "variable_declaration.type.change", "call.arguments.change" ]
966,588
966,589
u154148649
cpp
p03163
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) 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 a[100010][3]; // ll dp[110][100010]; // [品物][重さ] としたときの価値の最大値 // ll weight[110], value[110]; const int MAX_N = 100; const int MAX_W = 100000; int N, W; int w[MAX_N], v[MAX_N]; // dp[i][w] i時点における、重さがwを超えないように頑張ったときの、価値の最大値 int dp[MAX_N + 1][MAX_W + 1]; int main() { cin >> N >> W; REP(i, N) { cin >> w[i] >> v[i]; } for (int i = 0; i < N; i++) { for (int sum_w = 0; sum_w <= W; sum_w++) { // i番目を選ぶ場合 if (sum_w - w[i] >= 0) { chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i] + v[i]]); } // i番目を選ばない場合 chmax(dp[i + 1][sum_w], dp[i][sum_w]); } } cout << dp[N][W] << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) 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 a[100010][3]; // ll dp[110][100010]; // [品物][重さ] としたときの価値の最大値 // ll weight[110], value[110]; const int MAX_N = 100; const int MAX_W = 100000; ll N, W; ll w[MAX_N], v[MAX_N]; // dp[i][w] i時点における、重さがwを超えないように頑張ったときの、価値の最大値 ll dp[MAX_N + 1][MAX_W + 1]; int main() { cin >> N >> W; REP(i, N) { cin >> w[i] >> v[i]; } for (int i = 0; i < N; i++) { for (int sum_w = 0; sum_w <= W; sum_w++) { // i番目を選ぶ場合→i+1番目を更新 if (sum_w - w[i] >= 0) { // そもそも選べるか? chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]); } // i番目を選ばない場合 chmax(dp[i + 1][sum_w], dp[i][sum_w]); } } cout << dp[N][W] << endl; }
[ "variable_declaration.type.change", "call.arguments.change" ]
966,592
966,593
u989306199
cpp
p03163
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<ll>> dp(200, vector<ll>(1000000, -1)); ll ans(ll a[][2], ll w, ll i) { if (dp[i][w] != -1) return dp[i][w]; if (i == 0 || w == 0) { dp[i][w] = 0; return dp[i][w]; } if (w - a[i - 1][0] >= 0) { dp[i][w] = max(ans(a, w - a[i - 1][0], i - 1) + a[i - 1][1], ans(a, w, i - 1)); return dp[i][w]; } else { dp[i][w] = ans(a, w, i - 1); return dp[i][w]; } } int main() { ll n, w; cin >> n >> w; ll a[n][2]; ll sum = 0; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; } ll x = ans(a, w, n); cout << x << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<ll>> dp(108, vector<ll>(100009, -1)); ll ans(ll a[][2], ll w, ll i) { if (dp[i][w] != -1) return dp[i][w]; if (i == 0 || w == 0) { dp[i][w] = 0; return dp[i][w]; } if (w - a[i - 1][0] >= 0) { dp[i][w] = max(ans(a, w - a[i - 1][0], i - 1) + a[i - 1][1], ans(a, w, i - 1)); return dp[i][w]; } else { dp[i][w] = ans(a, w, i - 1); return dp[i][w]; } } int main() { ll n, w; cin >> n >> w; ll a[n][2]; ll sum = 0; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; } ll x = ans(a, w, n); cout << x << endl; }
[ "literal.number.change", "call.arguments.change" ]
966,596
966,597
u951060638
cpp
p03163
#include <climits> #include <iostream> #include <math.h> #include <vector> using namespace std; int dp[101][100005] = {0}; int main() { int n, W; cin >> n >> W; long long arr[n + 1][2]; for (int i = 1; i <= n; ++i) { cin >> arr[i][0] >> arr[i][1]; } for (int item = 1; item <= n; ++item) { for (int weight = 1; weight <= W; ++weight) { if (weight - arr[item][0] >= 0) dp[item][weight] = max((long long)dp[item - 1][weight], dp[item - 1][weight - arr[item][0]] + arr[item][1]); else dp[item][weight] = dp[item - 1][weight]; } } cout << dp[n][W] << endl; }
#include <climits> #include <iostream> #include <math.h> #include <vector> using namespace std; long long dp[101][100005] = {0}; int main() { int n, W; cin >> n >> W; long long arr[n + 1][2]; for (int i = 1; i <= n; ++i) { cin >> arr[i][0] >> arr[i][1]; } for (int item = 1; item <= n; ++item) { for (int weight = 1; weight <= W; ++weight) { if (weight - arr[item][0] >= 0) dp[item][weight] = max((long long)dp[item - 1][weight], dp[item - 1][weight - arr[item][0]] + arr[item][1]); else dp[item][weight] = dp[item - 1][weight]; } } cout << dp[n][W] << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
966,607
966,608
u794871368
cpp
p03163
#include <bits/stdc++.h> using namespace std; template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int inf = 1ll << 30; int main() { int n, w; cin >> n >> w; vector<int64_t> weight(n); vector<int64_t> value(n); vector<vector<int64_t>> dp(101, vector<int64_t>(1000000001)); for (int i = 0; i < n; i++) cin >> weight.at(i) >> value.at(i); for (int j = 0; j < w + 1; j++) if (j - weight.at(0) >= 0) dp.at(0).at(j) = value.at(0); for (int i = 1; i < n; i++) { for (int j = 0; j < w + 1; j++) { if (j - weight.at(i) >= 0) chmax(dp.at(i).at(j), dp.at(i - 1).at(j - weight.at(i)) + value.at(i)); chmax(dp.at(i).at(j), dp.at(i - 1).at(j)); } } /*for(int i=0;i<n;i++){ for(int j=1;j<w+1;j++)cout<<dp.at(i).at(j)<<" "; cout<<endl; }*/ cout << dp.at(n - 1).at(w) << endl; }
#include <bits/stdc++.h> using namespace std; template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int inf = 1ll << 30; int main() { int n, w; cin >> n >> w; vector<int64_t> weight(n); vector<int64_t> value(n); vector<vector<int64_t>> dp(110, vector<int64_t>(100001)); for (int i = 0; i < n; i++) cin >> weight.at(i) >> value.at(i); for (int j = 0; j < w + 1; j++) if (j - weight.at(0) >= 0) dp.at(0).at(j) = value.at(0); for (int i = 1; i < n; i++) { for (int j = 0; j < w + 1; j++) { if (j - weight.at(i) >= 0) chmax(dp.at(i).at(j), dp.at(i - 1).at(j - weight.at(i)) + value.at(i)); chmax(dp.at(i).at(j), dp.at(i - 1).at(j)); //   ポイント! } } /*for(int i=0;i<n;i++){ for(int j=1;j<w+1;j++)cout<<dp.at(i).at(j)<<" "; cout<<endl; }*/ cout << dp.at(n - 1).at(w) << endl; }
[ "literal.number.change", "call.arguments.change" ]
966,611
966,612
u529089914
cpp
p03163
#include <bits/stdc++.h> using namespace std; template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int inf = 1ll << 30; int main() { int n, w; cin >> n >> w; vector<int64_t> weight(n); vector<int64_t> value(n); vector<vector<int64_t>> dp(n, vector<int64_t>(w)); for (int i = 0; i < n; i++) cin >> weight.at(i) >> value.at(i); for (int j = 0; j < w + 1; j++) if (j - weight.at(0) >= 0) dp.at(0).at(j) = value.at(0); for (int i = 1; i < n; i++) { for (int j = 0; j < w + 1; j++) { if (j - weight.at(i) >= 0) chmax(dp.at(i).at(j), dp.at(i - 1).at(j - weight.at(i)) + value.at(i)); chmax(dp.at(i).at(j), dp.at(i - 1).at(j)); } } /*for(int i=0;i<n;i++){ for(int j=1;j<w+1;j++)cout<<dp.at(i).at(j)<<" "; cout<<endl; }*/ cout << dp.at(n - 1).at(w) << endl; }
#include <bits/stdc++.h> using namespace std; template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int inf = 1ll << 30; int main() { int n, w; cin >> n >> w; vector<int64_t> weight(n); vector<int64_t> value(n); vector<vector<int64_t>> dp(110, vector<int64_t>(100001)); for (int i = 0; i < n; i++) cin >> weight.at(i) >> value.at(i); for (int j = 0; j < w + 1; j++) if (j - weight.at(0) >= 0) dp.at(0).at(j) = value.at(0); for (int i = 1; i < n; i++) { for (int j = 0; j < w + 1; j++) { if (j - weight.at(i) >= 0) chmax(dp.at(i).at(j), dp.at(i - 1).at(j - weight.at(i)) + value.at(i)); chmax(dp.at(i).at(j), dp.at(i - 1).at(j)); //   ポイント! } } /*for(int i=0;i<n;i++){ for(int j=1;j<w+1;j++)cout<<dp.at(i).at(j)<<" "; cout<<endl; }*/ cout << dp.at(n - 1).at(w) << endl; }
[]
966,613
966,612
u529089914
cpp
p03163
#include <bits/stdc++.h> using namespace std; int dp[101][100010]; int w[101], v[101]; int main() { int n, W; cin >> n >> W; for (int i = 1; i <= n; i++) { cin >> w[i] >> v[i]; for (int j = 0; j <= W; j++) { //容量不够 if (j < w[i]) { dp[i][j] = dp[i - 1][j]; //容量足够 } else { dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j]); } } cout << dp[n][W]; } }
#include <bits/stdc++.h> using namespace std; long dp[101][100010]; int w[101], v[101]; int main() { int n, W; cin >> n >> W; for (int i = 1; i <= n; i++) { cin >> w[i] >> v[i]; for (int j = 0; j <= W; j++) { //容量不够 if (j < w[i]) { dp[i][j] = dp[i - 1][j]; //容量足够 } else { dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j]); } } } cout << dp[n][W]; }
[ "variable_declaration.type.primitive.change" ]
966,614
966,615
u337802798
cpp
p03163
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long int #define endl "\n" #define f(i, a, b) for (ll i = a; i < b; i++) #define fb(i, a, b) for (ll i = a; i >= b; i--) #define pb push_back #define mp make_pair #define fi first #define se second #define vi vector<int> #define vl vector<long long> #define pi pair<int, int> #define sz(x) (int)x.size() #define M 100005 #define mod 1000000007 using namespace std; void solve() { ll n, W, ans = 0; cin >> n >> W; ll w[n + 1], v[n + 1], dp[W + 1][n + 1]; f(i, 1, n + 1) cin >> w[i] >> v[i]; f(i, 0, W + 1) dp[i][0] = 0; f(i, 0, n) dp[0][i] = 0; f(i, 1, W + 1) { f(j, 1, n + 1) { ll x = 0, y = 0; if (i - w[j] >= 0) x = dp[i - w[j]][j - 1] + v[j]; y = dp[i][j - 1]; dp[i][j] = max(x, y); } } f(i, 0, W + 1) ans = max(ans, dp[i][n]); cout << ans; } int main() { IOS int t = 1; // cin>>t; f(tno, 1, t + 1) { solve(); } return 0; }
#include <bits/stdc++.h> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long int #define endl "\n" #define f(i, a, b) for (ll i = a; i < b; i++) #define fb(i, a, b) for (ll i = a; i >= b; i--) #define pb push_back #define mp make_pair #define fi first #define se second #define vi vector<int> #define vl vector<long long> #define pi pair<int, int> #define sz(x) (int)x.size() #define M 100005 #define mod 1000000007 using namespace std; void solve() { ll n, W, ans = 0; cin >> n >> W; ll w[n + 1], v[n + 1], dp[W + 1][n + 1] = {}; f(i, 1, n + 1) cin >> w[i] >> v[i]; f(i, 0, W + 1) dp[i][0] = 0; f(i, 0, n) dp[0][i] = 0; f(i, 1, W + 1) { f(j, 1, n + 1) { ll x = 0, y = 0; if (i - w[j] >= 0) x = dp[i - w[j]][j - 1] + v[j]; y = dp[i][j - 1]; dp[i][j] = max(x, y); } } f(i, 0, W + 1) ans = max(ans, dp[i][n]); cout << ans; } int main() { IOS int t = 1; // cin>>t; f(tno, 1, t + 1) { solve(); } return 0; }
[ "variable_declaration.value.change" ]
966,616
966,617
u021844224
cpp
p03163
// Author: Fuadul Hasan(fuadul202@gmail.com) // BSMRSTU,Gopalganj #include <bits/stdc++.h> using namespace std; int tc = 1; #define happy ios::sync_with_stdio(false); #define coding cin.tie(0); #define pb push_back #define mp make_pair #define ll long long #define pr pair<int, int> #define vpr vector<pr> #define vi std::vector<int> #define vll std::vector<ll> #define all(n) n.begin(), n.end() #define Test printf("Case %d: ", tc++); #define YES printf("YES\n"); #define NO printf("NO\n"); #define Yes printf("Yes\n"); #define No printf("No\n"); const int mod = 1e9 + 7; const ll Inf = (ll)2e18 + 5; const int N = 2e5 + 5; int solve() { // happy coding int n, m; cin >> n >> m; int wt[n + 1], val[n + 1]; for (int i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } int dp[n + 1][m + 1]; memset(dp, 0, sizeof dp); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (j >= wt[i - 1]) { // dp[i][j] = max(dp[i-1][j-wt[i-1]]+val[i-1],dp[i-1][j]); dp[i][j] = max(dp[i - 1][j - wt[i - 1]] + val[i - 1], dp[i - 1][j]); } else { dp[i][j] = dp[i - 1][j]; } // cout<<dp[i][j]<<" "; } // cout<<endl; } cout << dp[n][m] << endl; // cout<<cnt<<endl; return 0; } int main() { int test = 1; // scanf("%d", &test); while (test--) solve(); return 0; }
// Author: Fuadul Hasan(fuadul202@gmail.com) // BSMRSTU,Gopalganj #include <bits/stdc++.h> using namespace std; int tc = 1; #define happy ios::sync_with_stdio(false); #define coding cin.tie(0); #define pb push_back #define mp make_pair #define ll long long #define pr pair<int, int> #define vpr vector<pr> #define vi std::vector<int> #define vll std::vector<ll> #define all(n) n.begin(), n.end() #define Test printf("Case %d: ", tc++); #define YES printf("YES\n"); #define NO printf("NO\n"); #define Yes printf("Yes\n"); #define No printf("No\n"); const int mod = 1e9 + 7; const ll Inf = (ll)2e18 + 5; const int N = 2e5 + 5; int solve() { // happy coding ll n, m; cin >> n >> m; ll wt[n + 1], val[n + 1]; for (ll i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } ll dp[n + 1][m + 1]; memset(dp, 0, sizeof dp); for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { if (j >= wt[i - 1]) { // dp[i][j] = max(dp[i-1][j-wt[i-1]]+val[i-1],dp[i-1][j]); dp[i][j] = max(dp[i - 1][j - wt[i - 1]] + val[i - 1], dp[i - 1][j]); } else { dp[i][j] = dp[i - 1][j]; } // cout<<dp[i][j]<<" "; } // cout<<endl; } cout << dp[n][m] << endl; // cout<<cnt<<endl; return 0; } int main() { int test = 1; // scanf("%d", &test); while (test--) solve(); return 0; }
[ "variable_declaration.type.change", "control_flow.loop.for.initializer.change" ]
966,618
966,619
u526278960
cpp
p03163
// Author: Fuadul Hasan(fuadul202@gmail.com) // BSMRSTU,Gopalganj #include <bits/stdc++.h> using namespace std; #define ll long long const int mod = 1e9 + 7; const int Inf = (int)2e9 + 5; const ll Lnf = (ll)2e18 + 5; const int N = 4e5 + 5; int solve() { int n, w; cin >> n >> w; int val[n + 1], wt[n + 1]; /*for(int i=0;i<n;i++) cin>>val[i]; for(int i=0;i<n;i++) cin>>wt[i];*/ for (int i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } int dp[n + 1][w + 1]; memset(dp, 0, sizeof dp); for (int i = 1; i <= n; i++) { for (int j = 1; j <= w; j++) { if (j >= wt[i - 1]) { dp[i][j] = max(dp[i - 1][j - wt[i - 1]] + val[i - 1], dp[i - 1][j]); } else { dp[i][j] = dp[i - 1][j]; } } } cout << dp[n][w] << endl; return 0; } int main() { int test = 1; // scanf("%d", &test); while (test--) solve(); return 0; }
// Author: Fuadul Hasan(fuadul202@gmail.com) // BSMRSTU,Gopalganj #include <bits/stdc++.h> using namespace std; #define ll long long const int mod = 1e9 + 7; const int Inf = (int)2e9 + 5; const ll Lnf = (ll)2e18 + 5; const int N = 4e5 + 5; int solve() { ll n, w; cin >> n >> w; ll val[n + 1], wt[n + 1]; /*for(int i=0;i<n;i++) cin>>val[i]; for(int i=0;i<n;i++) cin>>wt[i];*/ for (ll i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } ll dp[n + 1][w + 1]; memset(dp, 0, sizeof dp); for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= w; j++) { if (j >= wt[i - 1]) { dp[i][j] = max(dp[i - 1][j - wt[i - 1]] + val[i - 1], dp[i - 1][j]); } else { dp[i][j] = dp[i - 1][j]; } } } cout << dp[n][w] << endl; return 0; } int main() { int test = 1; // scanf("%d", &test); while (test--) solve(); return 0; }
[ "variable_declaration.type.change", "control_flow.loop.for.initializer.change" ]
966,620
966,621
u526278960
cpp
p03163
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, w; cin >> n >> w; ll wt[n]; ll val[n]; for (int i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } ll dp[n + 1][w + 1]; for (int i = 0; i < n + 1; i++) { dp[i][0] = 0; } for (int j = 0; j < w + 1; j++) { dp[0][j] = 0; } for (int i = 1; i < n + 1; i++) { for (int j = 1; j < w + 1; j++) { if (j >= wt[i]) { dp[i][j] = max(dp[i - 1][j], val[i] + dp[i - 1][j - wt[i]]); } else { dp[i][j] = dp[i - 1][j]; } } } cout << dp[n][w]; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, w; cin >> n >> w; ll wt[n]; ll val[n]; for (int i = 0; i < n; i++) { cin >> wt[i] >> val[i]; } ll dp[n + 1][w + 1]; for (int i = 0; i < n + 1; i++) { dp[i][0] = 0; } for (int j = 0; j < w + 1; j++) { dp[0][j] = 0; } for (int i = 1; i < n + 1; i++) { for (int j = 1; j < w + 1; j++) { if (j >= wt[i - 1]) { dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - wt[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" ]
966,624
966,625
u507641224
cpp
p03163
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using P = pair<int, int>; using G = vector<vector<int>>; const long long INF = 1LL << 60; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int n, w; cin >> n >> w; vector<int> weight(n, 0); vector<int> value(n, 0); vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, -1)); rep(i, n) cin >> weight[i] >> value[i]; dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= w; j++) { //ある時点での上限 if (j - weight[i] >= 0) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i]] + value[i]); } chmax(dp[i + 1][j], dp[i][j]); } } cout << dp[n][w] << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using P = pair<int, int>; using G = vector<vector<int>>; const long long INF = 1LL << 60; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int n, w; cin >> n >> w; vector<int> weight(n, 0); vector<int> value(n, 0); vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0)); rep(i, n) cin >> weight[i] >> value[i]; dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= w; j++) { //ある時点での上限 if (j - weight[i] >= 0) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i]] + value[i]); } chmax(dp[i + 1][j], dp[i][j]); } } cout << dp[n][w] << endl; }
[ "literal.number.change", "call.arguments.change" ]
966,633
966,634
u106635407
cpp
p03163
#include <bits/stdc++.h> using namespace std; const int Maxn = 1e2 + 10, Maxw = 1e5 + 10; int N, W; int w[Maxn], v[Maxn]; int Dp[Maxn][Maxw]; 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 = 0; j <= W; j++) { Dp[i][j] = Dp[i - 1][j]; if (w[i] <= j) Dp[i][j] = max(Dp[i][j], Dp[i - 1][j - w[i]] + v[i]); } cout << Dp[N][W] << endl; return 0; }
#include <bits/stdc++.h> #define int long long using namespace std; const int Maxn = 1e2 + 10, Maxw = 1e5 + 10; int N, W; int w[Maxn], v[Maxn]; int Dp[Maxn][Maxw]; signed 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 = 0; j <= W; j++) { Dp[i][j] = Dp[i - 1][j]; if (w[i] <= j) Dp[i][j] = max(Dp[i][j], Dp[i - 1][j - w[i]] + v[i]); } cout << Dp[N][W] << endl; return 0; }
[ "variable_declaration.type.primitive.change" ]
966,643
966,644
u701136990
cpp
p03163
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, W; cin >> N >> W; vector<int> w(N), v(N); vector<vector<int>> dp(N + 1, vector<int>(W + 1)); for (int i = 0; i < N; i++) { cin >> w.at(i) >> v.at(i); } dp[0][0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j <= W; j++) { if (j >= w[i]) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]); } dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]); } } cout << dp[N][W] << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, W; cin >> N >> W; vector<int> w(N), v(N); vector<vector<long long int>> dp(N + 1, vector<long long int>(W + 1, 0)); for (int i = 0; i < N; i++) { cin >> w.at(i) >> v.at(i); } dp[0][0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j <= W; j++) { if (j >= w[i]) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]); } dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]); } } cout << dp[N][W] << endl; return 0; }
[ "call.arguments.add" ]
966,645
966,646
u113960459
cpp
p03163
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int n, W; cin >> n >> W; vector<int> w(n), v(n); for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } vector<vector<long>> M(W, vector<long>(n)); for (int i = 0; i < W; i++) { if (i > w[0]) { M[i][0] = v[0]; } else { M[i][0] = 0; } } for (int i = 0; i < W; i++) { for (int j = 1; j < n; j++) { if (i - w[j] < 0) { M[i][j] = M[i][j - 1]; } else { M[i][j] = max(M[i][j - 1], M[i - w[j]][j - 1] + v[j]); } } } cout << M[W - 1][n - 1] << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int n, W; cin >> n >> W; vector<int> w(n), v(n); for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } vector<vector<long>> M(W, vector<long>(n)); for (int i = 0; i < W; i++) { if (i + 1 >= w[0]) { M[i][0] = v[0]; } else { M[i][0] = 0; } } for (int i = 0; i < W; i++) { for (int j = 1; j < n; j++) { if (i - w[j] < 0) { M[i][j] = M[i][j - 1]; } else { M[i][j] = max(M[i][j - 1], M[i - w[j]][j - 1] + v[j]); } } } cout << M[W - 1][n - 1] << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
966,647
966,648
u806417535
cpp
p03163
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; #define vl vector<ll> #define vll vector<vector<ll>> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i < (int)(n); i++) int N, W; int w[110], v[110]; int dp[110][110000]; int main() { cin >> N >> W; rep1(i, N + 1) cin >> w[i] >> v[i]; rep1(i, N + 1) { rep(j, W + 1) { chmax(dp[i][j], dp[i - 1][j]); if (j - w[i] >= 0) chmax(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; }
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; #define vl vector<ll> #define vll vector<vector<ll>> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i < (int)(n); i++) int N, W; ll w[110], v[110]; ll dp[110][110000]; int main() { cin >> N >> W; rep1(i, N + 1) cin >> w[i] >> v[i]; rep1(i, N + 1) { rep(j, W + 1) { chmax(dp[i][j], dp[i - 1][j]); if (j - w[i] >= 0) chmax(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; }
[ "variable_declaration.type.change" ]
966,655
966,656
u614875193
cpp
p03163
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a, n) for (int i = (a); i < (n); i++) #define ll long long #define llint long long int #define reverse(v) reverse(v.begin(), v.end()); #define Yes(ans) \ if (ans) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define YES(ans) \ if (ans) \ cout << "YES" << endl; \ else \ cout << "NO" << endl; #define hei(a) vector<a> #define whei(a) vector<vector<a>> #define UF UnionFind #define Pint pair<int, int> #define keta(a) fixed << setprecision(a) constexpr auto INF = 1000000000; constexpr auto mod = 1000000007; //辞書順はnext_permutation( begin( v ), end( v ) );やで! llint gcd(llint a, llint b) { if (b > a) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } llint Tow(int n) { // 2のn乗 if (n == 0) return 1; llint x = Tow(n / 2); x %= mod; x *= x; x %= mod; if (n % 2 == 1) x *= 10; x %= mod; return x; } int main() { int N, W; cin >> N >> W; hei(llint) w(N), v(N); rep(i, 0, N) cin >> w[i] >> v[i]; whei(llint) dp(N + 1, hei(llint)(W + 1, 0)); rep(i, 0, N) { rep(j, 0, W + 1) { if (j >= w[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]); else dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); } } cout << dp[N][W] << endl; return 0; }
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a, n) for (int i = (a); i < (n); i++) #define ll long long #define llint long long int #define reverse(v) reverse(v.begin(), v.end()); #define Yes(ans) \ if (ans) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define YES(ans) \ if (ans) \ cout << "YES" << endl; \ else \ cout << "NO" << endl; #define hei(a) vector<a> #define whei(a) vector<vector<a>> #define UF UnionFind #define Pint pair<int, int> #define keta(a) fixed << setprecision(a) constexpr auto INF = 1000000000; constexpr auto mod = 1000000007; //辞書順はnext_permutation( begin( v ), end( v ) );やで! llint gcd(llint a, llint b) { if (b > a) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } llint Tow(int n) { // 2のn乗 if (n == 0) return 1; llint x = Tow(n / 2); x %= mod; x *= x; x %= mod; if (n % 2 == 1) x *= 10; x %= mod; return x; } int main() { int N, W; cin >> N >> W; hei(llint) w(N), v(N); rep(i, 0, N) cin >> w[i] >> v[i]; whei(llint) dp(N + 1, hei(llint)(W + 1, 0)); rep(i, 0, N) { rep(j, 0, W + 1) { if (j >= w[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]); dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); } } cout << dp[N][W] << endl; return 0; }
[ "control_flow.branch.else.remove" ]
966,657
966,658
u407213771
cpp
p03163
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a, n) for (int i = (a); i < (n); i++) #define ll long long #define llint long long int #define reverse(v) reverse(v.begin(), v.end()); #define Yes(ans) \ if (ans) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define YES(ans) \ if (ans) \ cout << "YES" << endl; \ else \ cout << "NO" << endl; #define hei(a) vector<a> #define whei(a) vector<vector<a>> #define UF UnionFind #define Pint pair<int, int> #define keta(a) fixed << setprecision(a) constexpr auto INF = 1000000000; constexpr auto mod = 1000000007; //辞書順はnext_permutation( begin( v ), end( v ) );やで! llint gcd(llint a, llint b) { if (b > a) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } llint Tow(int n) { // 2のn乗 if (n == 0) return 1; llint x = Tow(n / 2); x %= mod; x *= x; x %= mod; if (n % 2 == 1) x *= 10; x %= mod; return x; } int main() { int N, W; cin >> N >> W; hei(int) w(N), v(N); rep(i, 0, N) cin >> w[i] >> v[i]; whei(int) dp(N + 1, hei(int)(W + 1, 0)); rep(i, 0, N) { rep(j, 0, W + 1) { if (j >= w[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]); else dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); } } cout << dp[N][W] << endl; return 0; }
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a, n) for (int i = (a); i < (n); i++) #define ll long long #define llint long long int #define reverse(v) reverse(v.begin(), v.end()); #define Yes(ans) \ if (ans) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define YES(ans) \ if (ans) \ cout << "YES" << endl; \ else \ cout << "NO" << endl; #define hei(a) vector<a> #define whei(a) vector<vector<a>> #define UF UnionFind #define Pint pair<int, int> #define keta(a) fixed << setprecision(a) constexpr auto INF = 1000000000; constexpr auto mod = 1000000007; //辞書順はnext_permutation( begin( v ), end( v ) );やで! llint gcd(llint a, llint b) { if (b > a) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } llint Tow(int n) { // 2のn乗 if (n == 0) return 1; llint x = Tow(n / 2); x %= mod; x *= x; x %= mod; if (n % 2 == 1) x *= 10; x %= mod; return x; } int main() { int N, W; cin >> N >> W; hei(llint) w(N), v(N); rep(i, 0, N) cin >> w[i] >> v[i]; whei(llint) dp(N + 1, hei(llint)(W + 1, 0)); rep(i, 0, N) { rep(j, 0, W + 1) { if (j >= w[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]); dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); } } cout << dp[N][W] << endl; return 0; }
[ "call.arguments.change", "control_flow.branch.else.remove" ]
966,659
966,658
u407213771
cpp
p03163
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <string> #include <utility> //swapでaとbの値を入れ替える #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define ll long long #define sort(s) sort(s.begin(), s.end()) #define Yes(a) \ if (a) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define please return constexpr auto AC = 0; using namespace std; int main() { int a, b; cin >> a >> b; vector<int> g(a), m(a); vector<vector<int>> dp(a + 1, vector<int>(b + 1, 0)); rep(i, a) cin >> g[i] >> m[i]; rep(i, a) { rep(j, b + 1) { if (j >= g[i]) dp[i + 1][j] = max(dp[i][j - g[i]] + m[i], dp[i + 1][j]); dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]); } } cout << dp[a][b] << endl; please AC; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <string> #include <utility> //swapでaとbの値を入れ替える #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define ll long long #define sort(s) sort(s.begin(), s.end()) #define Yes(a) \ if (a) \ cout << "Yes" << endl; \ else \ cout << "No" << endl; #define please return constexpr auto AC = 0; using namespace std; int main() { ll a, b; cin >> a >> b; vector<ll> g(a), m(a); vector<vector<ll>> dp(a + 1, vector<ll>(b + 1, 0)); rep(i, a) cin >> g[i] >> m[i]; rep(i, a) { rep(j, b + 1) { if (j >= g[i]) dp[i + 1][j] = max(dp[i][j - g[i]] + m[i], dp[i + 1][j]); dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]); } } cout << dp[a][b] << endl; please AC; }
[ "variable_declaration.type.change", "call.arguments.change" ]
966,660
966,661
u407213771
cpp
p03163
#include <bits/stdc++.h> #define ll long long #define rep(i, N) for (int i = 0; i < N; i++) using namespace std; const int INF = 1001001001; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, W; cin >> n >> W; vector<int> w(n + 1), v(n + 1); rep(i, n) cin >> w[i + 1] >> v[i + 1]; vector<vector<int>> dp(n + 1, vector<int>(W + 1)); // rep(i,n+1) dp[i][0] = 0; rep(i, n + 1) if (i != 0) { rep(j, W + 1) if (j != 0) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } } // rep(i,n+1) cout << i << ":" << dp[i][W] << endl; cout << dp[n][W] << endl; return 0; }
#include <bits/stdc++.h> #define ll long long #define rep(i, N) for (int i = 0; i < N; i++) using namespace std; const int INF = 1001001001; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, W; cin >> n >> W; vector<int> w(n + 1), v(n + 1); rep(i, n) cin >> w[i + 1] >> v[i + 1]; vector<vector<ll>> dp(n + 1, vector<ll>(W + 1)); // rep(i,n+1) dp[i][0] = 0; rep(i, n + 1) if (i != 0) { rep(j, W + 1) if (j != 0) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]); } } // rep(i,n+1) cout << i << ":" << dp[i][W] << endl; cout << dp[n][W] << endl; return 0; }
[ "call.arguments.change" ]
966,662
966,663
u026421211
cpp
p03163
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define PB push_back struct edge { int to; }; using graph = vector<vector<edge>>; auto maxx(auto &a, auto b) { a = max(a, b); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N, W; cin >> N >> W; vi w(N), b(N); rep(i, 0, N) { cin >> w[i] >> b[i]; } auto dp = vector<ll>(W + 1, -1); dp[0] = 0; rep(i, 0, N) { for (int weight = W; weight >= 0; weight--) { if (weight >= w[i]) maxx(dp[weight], dp[weight - w[i]] + b[i]); } } cout << dp[W] << '\n'; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define PB push_back struct edge { int to; }; using graph = vector<vector<edge>>; auto maxx(auto &a, auto b) { a = max(a, b); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N, W; cin >> N >> W; vi w(N), b(N); rep(i, 0, N) { cin >> w[i] >> b[i]; } auto dp = vector<ll>(W + 1, 0); dp[0] = 0; rep(i, 0, N) { for (int weight = W; weight >= 0; weight--) { if (weight >= w[i]) maxx(dp[weight], dp[weight - w[i]] + b[i]); } } cout << dp[W] << '\n'; }
[ "literal.number.change", "call.arguments.change" ]
966,664
966,665
u092269433
cpp
p03163
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define PB push_back struct edge { int to; }; using graph = vector<vector<edge>>; auto maxx(auto &a, auto b) { a = max(a, b); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N, W; cin >> N >> W; vi w(N), b(N); rep(i, 0, N) { cin >> w[i] >> b[i]; } auto dp = vi(W + 1, -1); dp[0] = 0; rep(i, 0, N) { for (int weight = W; weight >= 0; weight--) { if (weight >= w[i]) maxx(dp[weight], dp[weight - w[i]] + b[i]); } } cout << dp[W] << '\n'; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define PB push_back struct edge { int to; }; using graph = vector<vector<edge>>; auto maxx(auto &a, auto b) { a = max(a, b); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N, W; cin >> N >> W; vi w(N), b(N); rep(i, 0, N) { cin >> w[i] >> b[i]; } auto dp = vector<ll>(W + 1, 0); dp[0] = 0; rep(i, 0, N) { for (int weight = W; weight >= 0; weight--) { if (weight >= w[i]) maxx(dp[weight], dp[weight - w[i]] + b[i]); } } cout << dp[W] << '\n'; }
[ "literal.number.change", "call.arguments.change" ]
966,666
966,665
u092269433
cpp
p03163
// Om Sree Sai Ram #include <bits/stdc++.h> #include <fstream> #include <iostream> using namespace std; vector<int> dp; int main() { int n, W; cin >> n >> W; vector<int> dp(W + 1); // dp[i] represents maximum value obtained with exactly i amount of weight // j means weight already there in the knapsack dp[0] = 0; for (int i = 0; i < n; i++) { int weight, value; cin >> weight >> value; for (int j = W - weight; j >= 0; j--) { dp[j + weight] = max(dp[j + weight], dp[j] + value); } } cout << *max_element(dp.begin(), dp.end()) << endl; }
// Om Sree Sai Ram #include <bits/stdc++.h> #include <fstream> #include <iostream> using namespace std; vector<int> dp; int main() { int n, W; cin >> n >> W; vector<long long> dp(W + 1); // dp[i] represents maximum value obtained with exactly i amount of weight // j means weight already there in the knapsack dp[0] = 0; for (int i = 0; i < n; i++) { int weight, value; cin >> weight >> value; for (int j = W - weight; j >= 0; j--) { dp[j + weight] = max(dp[j + weight], dp[j] + value); } } cout << *max_element(dp.begin(), dp.end()) << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
966,673
966,674
u279912110
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define fastt \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define enl "\n" #define ll long long #define pb push_back #define fi first #define se second #define vvl vector<vector<ll>> #define vl vector<ll> #define vpll vector<pair<ll, ll>> #define pll pair<ll, ll> #define all(x) x.begin(), x.end() #define mtc \ ll t; \ cin >> t; \ while (t--) #define rep(i, s, n) for (ll i = s; i < n; ++i) #define sz(a) (ll) a.size() #define PI 3.14159265 ll mod = 1e9 + 7; ll k; ll findMax(vl &W, vl &v, vvl &dp, ll i, ll w) { if (i >= sz(W)) { return 0; } if (dp[i][w] != -1) return dp[i][w]; ll ans = findMax(W, v, dp, i + 1, w); if (w + W[i] <= k) { ans = max(ans, findMax(W, v, dp, i + 1, w + W[i]) + v[i]); } return dp[i][w] = ans; } int main() { fastt; ll i, j; ll n, W; cin >> n >> W; k = W; vl w(n); vl v(n); rep(i, 0, n) { cin >> w[i] >> v[i]; } vvl dp(n, vl(W, -1)); cout << findMax(w, v, dp, 0, 0) << enl; }
#include <bits/stdc++.h> using namespace std; #define fastt \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define enl "\n" #define ll long long #define pb push_back #define fi first #define se second #define vvl vector<vector<ll>> #define vl vector<ll> #define vpll vector<pair<ll, ll>> #define pll pair<ll, ll> #define all(x) x.begin(), x.end() #define mtc \ ll t; \ cin >> t; \ while (t--) #define rep(i, s, n) for (ll i = s; i < n; ++i) #define sz(a) (ll) a.size() #define PI 3.14159265 ll mod = 1e9 + 7; ll k; ll findMax(vl &W, vl &v, vvl &dp, ll i, ll w) { if (i >= sz(W)) { return 0; } if (dp[i][w] != -1) return dp[i][w]; ll ans = findMax(W, v, dp, i + 1, w); if (w + W[i] <= k) { ans = max(ans, findMax(W, v, dp, i + 1, w + W[i]) + v[i]); } return dp[i][w] = ans; } int main() { fastt; ll i, j; ll n, W; cin >> n >> W; k = W; vl w(n); vl v(n); rep(i, 0, n) { cin >> w[i] >> v[i]; } vvl dp(n, vl(W + 1, -1)); cout << findMax(w, v, dp, 0, 0) << enl; }
[ "assignment.change" ]
966,679
966,680
u064688560
cpp
p03163
#include <bits/stdc++.h> using namespace std; int my_max(int a, int b) { return a > b ? a : b; } int my_abs(int x) { return x < 0 ? -x : x; } unsigned long long dp[110][100010]; int main() { int n, w; int datas[100][2]; cin >> n >> w; for (int i = 0; i < n; i++) { cin >> datas[i][0] >> datas[i][1]; } for (int i = 0; i <= w; i++) { if (datas[0][0] <= i) { dp[0][i] = datas[0][1]; } else { dp[0][i] = 0; } } for (int i = 1; i < n; i++) { for (int j = 0; j <= w; j++) { if (j - datas[i][0] >= 0) { dp[i][j] = max(dp[i - 1][j], datas[i][1] + dp[i - 1][j - datas[i][0]]); } else { dp[i][j] = dp[i - 1][j]; } } } cout << dp[n - 1][w - 1] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int my_max(int a, int b) { return a > b ? a : b; } int my_abs(int x) { return x < 0 ? -x : x; } unsigned long long dp[110][100010]; int main() { int n, w; int datas[100][2]; cin >> n >> w; for (int i = 0; i < n; i++) { cin >> datas[i][0] >> datas[i][1]; } for (int i = 0; i <= w; i++) { if (datas[0][0] <= i) { dp[0][i] = datas[0][1]; } else { dp[0][i] = 0; } } for (int i = 1; i < n; i++) { for (int j = 0; j <= w; j++) { if (j - datas[i][0] >= 0) { dp[i][j] = max(dp[i - 1][j], datas[i][1] + dp[i - 1][j - datas[i][0]]); } else { dp[i][j] = dp[i - 1][j]; } } } cout << dp[n - 1][w] << endl; return 0; }
[ "expression.operation.binary.remove" ]
966,681
966,682
u341846697
cpp
p03163
#include <bits/stdc++.h> #define INP (a << 50) using namespace std; int main() { int a, b, c, i, j; cin >> a >> b; int s[a + 5], ss[a + 5]; long long int sss[a + 5][a + 5]; for (i = 1; i <= a; i++) { cin >> s[i] >> ss[i]; } memset(sss, 0, sizeof(sss)); for (i = 1; i <= a; i++) { for (j = 1; j <= b; j++) { if (s[i] <= j) { sss[i][j] = max(sss[i - 1][j], sss[i - 1][j - s[i]] + ss[i]); } else sss[i][j] = sss[i - 1][j]; } } cout << sss[a][b] << endl; return 0; }
#include <bits/stdc++.h> #define INP (a << 50) using namespace std; int main() { int a, b, c, i, j; cin >> a >> b; int s[a + 5], ss[b + 5]; long long int sss[a + 5][b + 5]; for (i = 1; i <= a; i++) { cin >> s[i] >> ss[i]; } memset(sss, 0, sizeof(sss)); for (i = 1; i <= a; i++) { for (j = 1; j <= b; j++) { if (s[i] <= j) { sss[i][j] = max(sss[i - 1][j], sss[i - 1][j - s[i]] + ss[i]); } else sss[i][j] = sss[i - 1][j]; } } cout << sss[a][b] << endl; return 0; }
[ "identifier.change", "expression.operation.binary.change" ]
966,683
966,684
u711204934
cpp
p03163
#include <bits/stdc++.h> #define INP (a << 50) using namespace std; int main() { int a, b, c, i, j; cin >> a >> b; int s[a + 5], ss[b + 5]; long long int sss[a + 5][a + 5]; for (i = 1; i <= a; i++) { cin >> s[i] >> ss[i]; } memset(sss, 0, sizeof(sss)); for (i = 1; i <= a; i++) { for (j = 1; j <= b; j++) { if (s[i] <= j) { sss[i][j] = max(sss[i - 1][j], sss[i - 1][j - s[i]] + ss[i]); } else sss[i][j] = sss[i - 1][j]; } } cout << sss[a][b] << endl; return 0; }
#include <bits/stdc++.h> #define INP (a << 50) using namespace std; int main() { int a, b, c, i, j; cin >> a >> b; int s[a + 5], ss[b + 5]; long long int sss[a + 5][b + 5]; for (i = 1; i <= a; i++) { cin >> s[i] >> ss[i]; } memset(sss, 0, sizeof(sss)); for (i = 1; i <= a; i++) { for (j = 1; j <= b; j++) { if (s[i] <= j) { sss[i][j] = max(sss[i - 1][j], sss[i - 1][j - s[i]] + ss[i]); } else sss[i][j] = sss[i - 1][j]; } } cout << sss[a][b] << endl; return 0; }
[ "identifier.change", "expression.operation.binary.change" ]
966,685
966,684
u711204934
cpp
p03163
#include <bits/stdc++.h> #define INP (a << 50) using namespace std; int main() { int a, b, c, i, j; cin >> a >> b; int s[a + 1], ss[b + 1]; long long int sss[a + 5][a + 5]; for (i = 1; i <= a; i++) { cin >> s[i] >> ss[i]; } memset(sss, 0, sizeof(sss)); for (i = 1; i <= a; i++) { for (j = 1; j <= b; j++) { if (s[i] <= j) { sss[i][j] = max(sss[i - 1][j], sss[i - 1][j - s[i]] + ss[i]); } else sss[i][j] = sss[i - 1][j]; } } cout << sss[a][b] << endl; return 0; }
#include <bits/stdc++.h> #define INP (a << 50) using namespace std; int main() { int a, b, c, i, j; cin >> a >> b; int s[a + 5], ss[b + 5]; long long int sss[a + 5][b + 5]; for (i = 1; i <= a; i++) { cin >> s[i] >> ss[i]; } memset(sss, 0, sizeof(sss)); for (i = 1; i <= a; i++) { for (j = 1; j <= b; j++) { if (s[i] <= j) { sss[i][j] = max(sss[i - 1][j], sss[i - 1][j - s[i]] + ss[i]); } else sss[i][j] = sss[i - 1][j]; } } cout << sss[a][b] << endl; return 0; }
[ "literal.number.change", "expression.operation.binary.change", "identifier.change" ]
966,686
966,684
u711204934
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define pb push_back using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; int main() { int N, W; cin >> N >> W; vector<int> w(N); vector<int> v(W); rep(i, N) 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 (j - w[i] < 0) 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; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define pb push_back using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; int main() { int N, W; cin >> N >> W; vector<int> w(N); vector<int> v(W); rep(i, N) cin >> w[i] >> v[i]; vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0)); for (int i = 0; i < N; i++) { for (int j = 0; j <= W; j++) { if (j - w[i] < 0) 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; }
[ "call.arguments.change" ]
966,689
966,690
u455067221
cpp
p03163
#include <bits/stdc++.h> #define pb push_back #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define uy q.front() #define SIZE (ll)(1e6) #define mod (ll)(1e9 + 7) using namespace std; typedef long long ll; int main() { int n, w; cin >> n >> w; int ar[n], we[n], dp[n + 1][w + 1]; for (int i = 0; i < n; i++) { cin >> we[i] >> ar[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 (we[i - 1] <= j) { dp[i][j] = max(dp[i - 1][j], (ar[i - 1] + dp[i - 1][j - we[i - 1]])); } else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w]; return 0; }
#include <bits/stdc++.h> #define pb push_back #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define uy q.front() #define SIZE (ll)(1e6) #define mod (ll)(1e9 + 7) using namespace std; typedef long long ll; int main() { int n, w; cin >> n >> w; ll ar[n], we[n], dp[n + 1][w + 1]; for (int i = 0; i < n; i++) { cin >> we[i] >> ar[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 (we[i - 1] <= j) { dp[i][j] = max(dp[i - 1][j], (ar[i - 1] + dp[i - 1][j - we[i - 1]])); } else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w]; return 0; }
[ "variable_declaration.type.change" ]
966,695
966,696
u850140043
cpp
p03163
#include <bits/stdc++.h> using namespace std; //#define ll long long long long int dp[10005][10005]; // int val[100005]; // int wt[100005]; long long int fun(long long int w, long long int n, long long int val[], long long int wt[]) { if (w == 0 || n == 0) return 0; if (wt[n - 1] > w) return dp[w][n] = fun(w, n - 1, val, wt); if (dp[w][n] != -1) return dp[w][n]; return dp[w][n] = max(fun(w - wt[n - 1], n - 1, val, wt) + val[n - 1], fun(w, n - 1, val, wt)); } int main() { long long int n, w; cin >> n >> w; memset(dp, -1, sizeof(dp)); long long int val[n + 1]; long long int wt[n + 1]; for (long long int i = 0; i < n; i++) { cin >> wt[i]; cin >> val[i]; } cout << fun(w, n, val, wt); }
#include <bits/stdc++.h> using namespace std; //#define ll long long long long int dp[100005][105]; // int val[100005]; // int wt[100005]; long long int fun(long long int w, long long int n, long long int val[], long long int wt[]) { if (w == 0 || n == 0) return 0; if (wt[n - 1] > w) return dp[w][n] = fun(w, n - 1, val, wt); if (dp[w][n] != -1) return dp[w][n]; return dp[w][n] = max(fun(w - wt[n - 1], n - 1, val, wt) + val[n - 1], fun(w, n - 1, val, wt)); } int main() { long long int n, w; cin >> n >> w; memset(dp, -1, sizeof(dp)); long long int val[n + 1]; long long int wt[n + 1]; for (long long int i = 0; i < n; i++) { cin >> wt[i]; cin >> val[i]; } cout << fun(w, n, val, wt); }
[ "literal.number.change", "variable_declaration.array_dimensions.change" ]
966,702
966,703
u901562101
cpp
p03163
// // Created by 13783 on 2020/4/2. // #include <iostream> using namespace std; const int MAX_N = 101; const int MAX_W = 1e5 + 2; int N, W; int w[MAX_N]; int v[MAX_N]; int dp[MAX_N][MAX_W]; void solve() { for (int i = 1; i <= N; i++) { for (int j = 1; 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]; } int main() { cin >> N >> W; for (int i = 1; i <= N; i++) { cin >> w[i] >> v[i]; } solve(); return 0; }
// // Created by 13783 on 2020/4/2. // #include <iostream> using namespace std; const int MAX_N = 101; const int MAX_W = 1e5 + 2; typedef long long ll; int N, W; int w[MAX_N]; int v[MAX_N]; ll dp[MAX_N][MAX_W]; void solve() { // dp[i][j]为前i种物品,总总量为j的最大价值 for (int i = 1; i <= N; i++) { for (int j = 1; 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]; } int main() { cin >> N >> W; for (int i = 1; i <= N; i++) { cin >> w[i] >> v[i]; } solve(); return 0; }
[ "variable_declaration.type.change" ]
966,704
966,705
u524496896
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define lli long long int #define endl "\n" int main() { int n, w; cin >> n >> w; vector<int> val(n), wt(n); for (int i = 0; i < n; i++) cin >> wt[i] >> val[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 (wt[i - 1] <= j) dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w] << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long int #define endl "\n" int32_t main() { int n, w; cin >> n >> w; vector<int> val(n), wt(n); for (int i = 0; i < n; i++) cin >> wt[i] >> val[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 (wt[i - 1] <= j) dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w] << endl; }
[ "identifier.change", "function.return_type.change" ]
966,711
966,712
u453089097
cpp
p03163
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using ti = tuple<int, int, int>; #define REP(i, m, n) for (int i = (m); i < (n); i++) #define RREP(i, n, m) for (int i = (n); i >= (m); i--) #define pb push_back #define mp make_pair #define debug(x) cerr << #x << ": " << x << endl // #define int long long const double eps = 1e-14; const int mod = 1e9 + 7; const int inf = ((1 << 30) - 1); const ll linf = (1LL << 60); const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } ll dp[110][110000]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, W; cin >> N >> W; int w[N + 1], v[N + 1]; REP(i, 1, N + 1) cin >> v[i] >> w[i]; REP(i, 1, N + 1) { REP(j, 1, W + 1) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using ti = tuple<int, int, int>; #define REP(i, m, n) for (int i = (m); i < (n); i++) #define RREP(i, n, m) for (int i = (n); i >= (m); i--) #define pb push_back #define mp make_pair #define debug(x) cerr << #x << ": " << x << endl // #define int long long const double eps = 1e-14; const int mod = 1e9 + 7; const int inf = ((1 << 30) - 1); const ll linf = (1LL << 60); const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } ll dp[110][110000]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, W; cin >> N >> W; int w[N + 1], v[N + 1]; REP(i, 1, N + 1) cin >> w[i] >> v[i]; REP(i, 1, N + 1) { REP(j, 1, W + 1) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; return 0; }
[ "identifier.change", "expression.operation.binary.change" ]
966,715
966,716
u018713014
cpp
p03163
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using ti = tuple<int, int, int>; #define REP(i, m, n) for (int i = (m); i < (n); i++) #define RREP(i, n, m) for (int i = (n); i >= (m); i--) #define pb push_back #define mp make_pair #define debug(x) cerr << #x << ": " << x << endl // #define int long long const double eps = 1e-14; const int mod = 1e9 + 7; const int inf = ((1 << 30) - 1); const ll linf = (1LL << 60); const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } ll dp[110][110000]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, W; cin >> N >> W; int w[N + 1], v[N + 1]; REP(i, 1, N + 1) cin >> v[i] >> w[i]; REP(i, 1, N + 1) { REP(j, 1, N + 1) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <ctime> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using ti = tuple<int, int, int>; #define REP(i, m, n) for (int i = (m); i < (n); i++) #define RREP(i, n, m) for (int i = (n); i >= (m); i--) #define pb push_back #define mp make_pair #define debug(x) cerr << #x << ": " << x << endl // #define int long long const double eps = 1e-14; const int mod = 1e9 + 7; const int inf = ((1 << 30) - 1); const ll linf = (1LL << 60); const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; struct mint { ll x; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } ll dp[110][110000]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, W; cin >> N >> W; int w[N + 1], v[N + 1]; REP(i, 1, N + 1) cin >> w[i] >> v[i]; REP(i, 1, N + 1) { REP(j, 1, W + 1) { dp[i][j] = dp[i - 1][j]; if (j - w[i] >= 0) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]); } } cout << dp[N][W] << endl; return 0; }
[ "identifier.change", "expression.operation.binary.change", "call.arguments.change" ]
966,717
966,716
u018713014
cpp
p03163
#include <bits/stdc++.h> using namespace std; using ll = long long; ll vs[10010][2]; ll dp[10010][10010]; void solve() { int N, W; cin >> N >> W; for (ll i = 1; i <= N; ++i) cin >> vs[i][0] >> vs[i][1]; for (ll i = 0; i <= W; ++i) dp[0][i] = 0; for (ll i = 0; i <= N; ++i) dp[i][0] = 0; for (ll i = 1; i <= N; ++i) { ll *vi = vs[i]; for (ll w = 1; w <= W; ++w) { if (w < vi[0]) dp[i][w] = dp[i - 1][w]; else dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - vi[0]] + vi[1]); } } cout << dp[N][W] << endl; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; ll vs[110][2]; ll dp[110][100100]; void solve() { int N, W; cin >> N >> W; for (ll i = 1; i <= N; ++i) cin >> vs[i][0] >> vs[i][1]; for (ll i = 0; i <= W; ++i) dp[0][i] = 0; for (ll i = 0; i <= N; ++i) dp[i][0] = 0; for (ll i = 1; i <= N; ++i) { ll *vi = vs[i]; for (ll w = 1; w <= W; ++w) { if (w < vi[0]) dp[i][w] = dp[i - 1][w]; else dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - vi[0]] + vi[1]); } } cout << dp[N][W] << endl; } int main() { solve(); return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change" ]
966,718
966,719
u740626584
cpp
p03163
#include <bits/stdc++.h> using namespace std; long long int dp[109][100009]; int ansd(long long int value[], int wts[], int n, int max_wt) { for (int i = 1; i < n + 1; i++) { for (int j = 0; j < max_wt + 1; j++) { if (j >= wts[i - 1]) dp[i][j] = max(dp[i - 1][j - wts[i - 1]] + value[i - 1], dp[i - 1][j]); else { dp[i][j] = dp[i - 1][j]; } } } return dp[n][max_wt]; // for (int o = 0; o < max_wt+1; o++) // { // for (int j = 0; j < n+1; j++) // { // cout<<dp[o][j]<<" "; // } // cout<<'\n'; // } } int main() { int n, w; cin >> n >> w; long long int val[n]; int wts[n]; for (int i = 0; i < n; i++) { cin >> wts[i]; cin >> val[i]; } cout << ansd(val, wts, n, w); }
//#FINALLY its gonna be A.C> #include <bits/stdc++.h> using namespace std; long long int dp[109][100009]; long long int ansd(long long int value[], int wts[], int n, int max_wt) { for (int i = 1; i < n + 1; i++) { for (int j = 0; j < max_wt + 1; j++) { if (j >= wts[i - 1]) dp[i][j] = max(dp[i - 1][j - wts[i - 1]] + value[i - 1], dp[i - 1][j]); else { dp[i][j] = dp[i - 1][j]; } } } return dp[n][max_wt]; // for (int o = 0; o < max_wt+1; o++) // { // for (int j = 0; j < n+1; j++) // { // cout<<dp[o][j]<<" "; // } // cout<<'\n'; // } } int main() { int n, w; cin >> n >> w; long long int val[n]; int wts[n]; for (int i = 0; i < n; i++) { cin >> wts[i]; cin >> val[i]; } cout << ansd(val, wts, n, w); }
[ "variable_declaration.type.widen.change" ]
966,723
966,724
u697345261
cpp
p03163
#include <bits/stdc++.h> using namespace std; long long int dp[109][100009]; int ansd(long long int value[], int wts[], int n, int max_wt) { for (int i = 1; i < n + 1; i++) { for (int j = 1; j < max_wt + 1; j++) { if (j >= wts[i - 1]) dp[i][j] = max(dp[i - 1][j - wts[i - 1]] + value[i - 1], dp[i - 1][j]); else { dp[i][j] = dp[i - 1][j]; } } } return dp[n][max_wt]; // for (int o = 0; o < max_wt+1; o++) // { // for (int j = 0; j < n+1; j++) // { // cout<<dp[o][j]<<" "; // } // cout<<'\n'; // } } int main() { int n, w; cin >> n >> w; long long int val[n]; int wts[n]; for (int i = 0; i < n; i++) { cin >> wts[i]; cin >> val[i]; } cout << ansd(val, wts, n, w); }
//#FINALLY its gonna be A.C> #include <bits/stdc++.h> using namespace std; long long int dp[109][100009]; long long int ansd(long long int value[], int wts[], int n, int max_wt) { for (int i = 1; i < n + 1; i++) { for (int j = 0; j < max_wt + 1; j++) { if (j >= wts[i - 1]) dp[i][j] = max(dp[i - 1][j - wts[i - 1]] + value[i - 1], dp[i - 1][j]); else { dp[i][j] = dp[i - 1][j]; } } } return dp[n][max_wt]; // for (int o = 0; o < max_wt+1; o++) // { // for (int j = 0; j < n+1; j++) // { // cout<<dp[o][j]<<" "; // } // cout<<'\n'; // } } int main() { int n, w; cin >> n >> w; long long int val[n]; int wts[n]; for (int i = 0; i < n; i++) { cin >> wts[i]; cin >> val[i]; } cout << ansd(val, wts, n, w); }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
966,725
966,724
u697345261
cpp
p03163
#include <algorithm> #include <climits> #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <vector> using namespace std; #define ll long long ll dp[101][100000]; int solve(int i, int W, int *w, int *v, int n) { if (W < 0) return INT_MIN; if (i == n) return 0; if (dp[i][W] == -1) dp[i][W] = max(solve(i + 1, W, w, v, n), solve(i + 1, W - w[i], w, v, n) + v[i]); return dp[i][W]; } int main() { int n, W; cin >> n >> W; int v[n], w[n]; for (int i = 0; i < n; ++i) cin >> w[i] >> v[i]; memset(dp, -1, sizeof(dp)); cout << solve(0, W, w, v, n); return 0; }
#include <algorithm> #include <climits> #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <vector> using namespace std; #define ll long long ll dp[101][100000]; ll solve(int i, int W, ll int *w, ll int *v, int n) { if (W < 0) return INT_MIN; if (i == n) return 0; if (dp[i][W] == -1) dp[i][W] = max(solve(i + 1, W, w, v, n), solve(i + 1, W - w[i], w, v, n) + v[i]); return dp[i][W]; } int main() { int n, W; cin >> n >> W; ll v[n], w[n]; for (int i = 0; i < n; ++i) cin >> w[i] >> v[i]; memset(dp, -1, sizeof(dp)); cout << solve(0, W, w, v, n); return 0; }
[ "function.parameters.parameter.add", "variable_declaration.type.change" ]
966,730
966,731
u634851584
cpp
p03163
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 101; const int maxw = 1e5 + 1; ll w[maxn], v[maxn], dp[4][9]; int main() { #ifdef LOCAL freopen("data.txt", "r", stdin); #endif ll n, W; scanf("%lld%lld", &n, &W); for (int i = 1; i <= n; ++i) scanf("%lld%lld", &w[i], &v[i]); for (int i = 1; i <= n; ++i) for (int j = 1; j <= W; ++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]); printf("%lld\n", dp[n][W]); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 101; const int maxw = 1e5 + 1; ll w[maxn], v[maxn], dp[maxn][maxw]; int main() { #ifdef LOCAL freopen("data.txt", "r", stdin); #endif ll n, W; scanf("%lld%lld", &n, &W); for (int i = 1; i <= n; ++i) scanf("%lld%lld", &w[i], &v[i]); for (int i = 1; i <= n; ++i) for (int j = 1; j <= W; ++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]); printf("%lld\n", dp[n][W]); }
[ "identifier.replace.add", "literal.replace.remove", "variable_declaration.array_dimensions.change" ]
966,747
966,748
u822306583
cpp
p03163
#include <algorithm> #include <chrono> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using LL = long long; using ULL = unsigned long long; using PII = pair<int, int>; using PIL = pair<int, LL>; using PLL = pair<LL, LL>; // const int mod = 1e9 + 7; // const int mod = 998244353; inline void quickread() { ios::sync_with_stdio(false); cin.tie(nullptr); } LL f[100010]; int n, w, x, y; inline void work() { cin >> n >> w; for (int i = 0; i < n; ++i) { cin >> x >> y; for (int i = w; i >= x; --i) { f[i] = max(f[i], f[i - x] + y); } } cout << *max_element(f, f + w) << "\n"; } int main() { // freopen("input.txt", "r", stdin); quickread(); work(); return 0; }
#include <algorithm> #include <chrono> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using LL = long long; using ULL = unsigned long long; using PII = pair<int, int>; using PIL = pair<int, LL>; using PLL = pair<LL, LL>; // const int mod = 1e9 + 7; // const int mod = 998244353; inline void quickread() { ios::sync_with_stdio(false); cin.tie(nullptr); } LL f[100010]; int n, w, x, y; inline void work() { cin >> n >> w; for (int i = 0; i < n; ++i) { cin >> x >> y; for (int i = w; i >= x; --i) { f[i] = max(f[i], f[i - x] + y); } } cout << *max_element(f, f + w + 1) << "\n"; } int main() { // freopen("input.txt", "r", stdin); quickread(); work(); return 0; }
[ "expression.operation.binary.add" ]
966,749
966,750
u878735274
cpp
p03163
#include <bits/stdc++.h> #define pb push_back #define f first #define s second #define ll long long using namespace std; int dp[100002][3]; int main() { int n, m; cin >> n >> m; int val[n], wt[n]; for (int i = 0; i < n; i++) cin >> wt[i] >> val[i]; int i, w; int K[n + 1][m + 1]; // Build table K[][] in bottom up manner for (i = 0; i <= n; i++) { for (w = 0; w <= m; 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]; } } cout << K[n][m]; return 0; }
#include <bits/stdc++.h> #define pb push_back #define f first #define s second #define ll long long using namespace std; int dp[100002][3]; int main() { int n, m; cin >> n >> m; ll val[n], wt[n]; for (int i = 0; i < n; i++) cin >> wt[i] >> val[i]; int i, w; ll K[n + 1][m + 1]; // Build table K[][] in bottom up manner for (i = 0; i <= n; i++) { for (w = 0; w <= m; 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]; } } cout << K[n][m]; return 0; }
[ "variable_declaration.type.change" ]
966,751
966,752
u537150014
cpp
p03163
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define fi first #define se second #define si size() #define bk back() #define popb pop_back() #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define endl "\n" #define lb lower_bound #define ub upper_bound #define emp empty() #define beg begin() #define en end() #define ump unordered_map #define forl(i, a, n) for (int i = a; i < n; i++) #define rfor(i, n, a) for (int i = n; i >= a; i--) #define fore(i, a, n) for (int i = a; i <= n; i++) #define mod 1000000007 #define len length() double doINF = 1.0 / 0.0; ostream_iterator<int> outp(cout, " "); // copy(v.beg,v.en,outp); inline ll modadd(ll n, ll m) { ll sum = ((n + m) % mod + mod) % mod; return sum; } inline ll modsub(ll n, ll m) { ll diff = ((n - m + mod) % mod + mod) % mod; return diff; } inline ll modpro(ll n, ll m) { ll pro = ((n * m) % mod + mod) % mod; return pro; } inline ll pow(int x, int y) { ll res = 1; while (y > 0) { if (y & 1) res = res * x; y = y >> 1; x = x * x; } return res; } inline ll powmod(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = modpro(res, x); y = y >> 1; x = modpro(x, x); } return res; } ll min(ll a, ll b) { if (a > b) { return b; } return a; } bool pairdec(const pair<int, int> &a, const pair<int, int> &b) { if (a.fi != b.fi) return (a.fi > b.fi); else return a.se > b.se; } int main() { int n, w; cin >> n >> w; int arr[n][2]; forl(i, 0, n) { forl(j, 0, 2) cin >> arr[i][j]; } int dp[n + 1][w + 1] = {}; forl(i, 0, n + 1) { forl(j, 0, w + 1) { if (i == 0 || j == 0) { dp[i][j] = 0; } else if (j >= arr[i - 1][0]) dp[i][j] = max(dp[i - 1][j - arr[i - 1][0]] + arr[i - 1][1], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w] << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define fi first #define se second #define si size() #define bk back() #define popb pop_back() #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define endl "\n" #define lb lower_bound #define ub upper_bound #define emp empty() #define beg begin() #define en end() #define ump unordered_map #define forl(i, a, n) for (int i = a; i < n; i++) #define rfor(i, n, a) for (int i = n; i >= a; i--) #define fore(i, a, n) for (int i = a; i <= n; i++) #define mod 1000000007 #define len length() double doINF = 1.0 / 0.0; ostream_iterator<int> outp(cout, " "); // copy(v.beg,v.en,outp); inline ll modadd(ll n, ll m) { ll sum = ((n + m) % mod + mod) % mod; return sum; } inline ll modsub(ll n, ll m) { ll diff = ((n - m + mod) % mod + mod) % mod; return diff; } inline ll modpro(ll n, ll m) { ll pro = ((n * m) % mod + mod) % mod; return pro; } inline ll pow(int x, int y) { ll res = 1; while (y > 0) { if (y & 1) res = res * x; y = y >> 1; x = x * x; } return res; } inline ll powmod(ll x, ll y) { ll res = 1; while (y > 0) { if (y & 1) res = modpro(res, x); y = y >> 1; x = modpro(x, x); } return res; } ll min(ll a, ll b) { if (a > b) { return b; } return a; } bool pairdec(const pair<int, int> &a, const pair<int, int> &b) { if (a.fi != b.fi) return (a.fi > b.fi); else return a.se > b.se; } int main() { ll n, w; cin >> n >> w; ll arr[n][2]; forl(i, 0, n) { forl(j, 0, 2) cin >> arr[i][j]; } ll dp[n + 1][w + 1] = {}; forl(i, 0, n + 1) { forl(j, 0, w + 1) { if (i == 0 || j == 0) { dp[i][j] = 0; } else if (j >= arr[i - 1][0]) dp[i][j] = max(dp[i - 1][j - arr[i - 1][0]] + arr[i - 1][1], dp[i - 1][j]); else dp[i][j] = dp[i - 1][j]; } } cout << dp[n][w] << endl; }
[ "variable_declaration.type.change" ]
966,753
966,754
u397955542
cpp
p03163
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int abs(int i, int j) { if (i - j > 0) { return i - j; } else { return j - i; } } int main() { int N, W; cin >> N >> W; vector<int> dp(W + 1); rep(i, N) { int weight, value; cin >> weight >> value; for (int j = W - weight; j >= 0; --j) { dp.at(j + weight) = max(dp.at(j + weight), dp.at(j) + value); } } cout << dp.at(W) << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int abs(int i, int j) { if (i - j > 0) { return i - j; } else { return j - i; } } int main() { int N, W; cin >> N >> W; vector<ll> dp(W + 1); rep(i, N) { int weight, value; cin >> weight >> value; for (int j = W - weight; j >= 0; --j) { dp.at(j + weight) = max(dp.at(j + weight), dp.at(j) + value); } } cout << dp.at(W) << endl; }
[]
966,763
966,764
u065715253
cpp
p03163
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int N, W; cin >> N >> W; vector<int> w(N); vector<long long> v(N); for (int i = 0; i < N; i++) { cin >> w[i] >> v[i]; } vector<vector<long long>> dp(N + 1, vector<long long>(W, 0)); for (int i = 0; i < N; i++) { for (int j = 0; j <= W; j++) { dp[i + 1][j] = w[i] <= j ? max(dp[i][j - w[i]] + v[i], dp[i][j]) : dp[i][j]; } } cout << dp[N][W - 1] << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { int N, W; cin >> N >> W; vector<long long> w(N); vector<long long> v(N); for (int i = 0; i < N; i++) { cin >> w[i] >> v[i]; } vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0)); for (int i = 0; i < N; i++) { for (int j = 0; j <= W; j++) { dp[i + 1][j] = w[i] <= j ? max(dp[i][j - w[i]] + v[i], dp[i][j]) : dp[i][j]; } } cout << dp[N][W] << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "expression.operation.binary.remove" ]
966,765
966,766
u213532807
cpp
p03163
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int n, W; cin >> n >> W; ll dp[W + 1]; rep(i, n) { ll w, v; cin >> w >> v; for (int j = W; j >= w; j--) { dp[j] = max(dp[j - w] + v, dp[j]); } } cout << dp[W] << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int n, W; cin >> n >> W; ll dp[200005]; rep(i, n) { ll w, v; cin >> w >> v; for (int j = W; j >= w; j--) { dp[j] = max(dp[j - w] + v, dp[j]); } } cout << dp[W] << endl; }
[ "identifier.replace.remove", "literal.replace.add", "expression.operation.binary.change", "expression.operation.binary.remove" ]
966,780
966,781
u314917898
cpp