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
p03008
#include <algorithm> #include <cfloat> #include <complex> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <unordered_map> #include <vector> #define fs first #define sc second using namespace std; typedef long long ll; typedef pair<ll, ll> P; ll ret_sub(P x) { return max(x.sc - x.fs, x.fs - x.sc); } int main() { ll N; ll g[2][3]; cin >> N; for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { cin >> g[i][j]; } } vector<P> x, y; for (int i = 0; i < 3; i++) { if (g[0][i] > g[1][i]) { y.emplace_back(P(g[0][i], g[1][i])); } else if (g[0][i] < g[1][i]) { x.emplace_back(P(g[0][i], g[1][i])); } } if (x.size() == 1) { P p = x[0]; N += (N / p.fs) * ret_sub(p); } else if (x.size() == 2) { ll ma = 0; for (ll i = 0; i <= N / x[0].fs; i++) { ll v1 = i * ret_sub(x[0]); ll v2 = (N - i * x[0].fs) / x[1].fs * (x[1].sc - x[1].fs); ma = max(v1 + v2, ma); } N += ma; } else if (x.size() == 3) { ll ma = 0; for (ll i = 0; i * x[0].fs <= N; i++) { for (ll j = 0; i * x[0].fs + j * x[1].fs <= N; j++) { ll v1 = i * ret_sub(x[0]); ll v2 = j * ret_sub(x[1]); ll v3 = (N - i * x[0].fs + j * x[1].fs) / x[2].fs * ret_sub(x[2]); ma = max(v1 + v2 + v3, ma); } } N += ma; } if (y.size() == 1) { N += (N / y[0].fs) * ret_sub(y[0]); } else if (y.size() == 2) { ll ma = 0; for (ll i = 0; i <= N / y[0].fs; i++) { ll v1 = i * ret_sub(y[0]); ll v2 = (N - i * y[0].fs) / y[1].fs * ret_sub(y[1]); ma = max(v1 + v2, ma); } N += ma; } else if (y.size() == 3) { ll ma = 0; for (ll i = 0; i * y[0].fs <= N; i++) { for (ll j = 0; i * y[0].fs + j * y[1].fs <= N; j++) { ll v1 = i * ret_sub(y[0]); ll v2 = j * ret_sub(y[1]); ll v3 = (N - i * y[0].fs + j * y[1].fs) / y[2].fs * ret_sub(y[2]); ma = max(v1 + v2 + v3, ma); } } N += ma; } cout << N << endl; return 0; }
#include <algorithm> #include <cfloat> #include <complex> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <unordered_map> #include <vector> #define fs first #define sc second using namespace std; typedef long long ll; typedef pair<ll, ll> P; ll ret_sub(P x) { return max(x.sc - x.fs, x.fs - x.sc); } int main() { ll N; ll g[2][3]; cin >> N; for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { cin >> g[i][j]; } } vector<P> x, y; for (int i = 0; i < 3; i++) { if (g[0][i] > g[1][i]) { y.emplace_back(P(g[1][i], g[0][i])); } else if (g[0][i] < g[1][i]) { x.emplace_back(P(g[0][i], g[1][i])); } } if (x.size() == 1) { P p = x[0]; N += (N / p.fs) * ret_sub(p); } else if (x.size() == 2) { ll ma = 0; for (ll i = 0; i <= N / x[0].fs; i++) { ll v1 = i * ret_sub(x[0]); ll v2 = (N - i * x[0].fs) / x[1].fs * (x[1].sc - x[1].fs); ma = max(v1 + v2, ma); } N += ma; } else if (x.size() == 3) { ll ma = 0; for (ll i = 0; i * x[0].fs <= N; i++) { for (ll j = 0; i * x[0].fs + j * x[1].fs <= N; j++) { ll v1 = i * ret_sub(x[0]); ll v2 = j * ret_sub(x[1]); ll v3 = (N - i * x[0].fs - j * x[1].fs) / x[2].fs * ret_sub(x[2]); ma = max(v1 + v2 + v3, ma); } } N += ma; } if (y.size() == 1) { N += (N / y[0].fs) * ret_sub(y[0]); } else if (y.size() == 2) { ll ma = 0; for (ll i = 0; i <= N / y[0].fs; i++) { ll v1 = i * ret_sub(y[0]); ll v2 = (N - i * y[0].fs) / y[1].fs * ret_sub(y[1]); ma = max(v1 + v2, ma); } N += ma; } else if (y.size() == 3) { ll ma = 0; for (ll i = 0; i * y[0].fs <= N; i++) { for (ll j = 0; i * y[0].fs + j * y[1].fs <= N; j++) { ll v1 = i * ret_sub(y[0]); ll v2 = j * ret_sub(y[1]); ll v3 = (N - i * y[0].fs - j * y[1].fs) / y[2].fs * ret_sub(y[2]); ma = max(v1 + v2 + v3, ma); } } N += ma; } cout << N << endl; return 0; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "misc.opposites", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
822,228
822,229
u852158538
cpp
p03008
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long int INF = 3e18; double Pi = 3.1415926535897932384626; vector<ll> G[500005]; // vector<P> tree[500010]; priority_queue<ll> pql; priority_queue<P> pqp; // big priority queue priority_queue<ll, vector<ll>, greater<ll>> pqls; priority_queue<P, vector<P>, greater<P>> pqps; // small priority queue // top pop int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; char dir[] = "DRUL"; // ll bit[500005]; //↓,→,↑,← #define p(x) cout << x << endl; #define el cout << endl; #define pe(x) cout << (x) << " "; #define ps(x) cout << fixed << setprecision(25) << x << endl; #define pu(x) cout << (x); #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout << #x << " = " << x << endl ll mod = 1000000007; ll rui(ll number1, ll number2) { if (number2 == 0) { return 1; } else { ll number3 = rui(number1, number2 / 2); number3 *= number3; number3 %= mod; if (number2 % 2 == 1) { number3 *= number1; number3 %= mod; } return number3; } } ll gcd(ll number1, ll number2) { if (number1 > number2) { swap(number1, number2); } if (number1 == 0 || number1 == number2) { return number2; } else { return gcd(number2 % number1, number1); } } void YES(bool condition) { if (condition) { p("YES"); } else { p("NO"); } return; } void Yes(bool condition) { if (condition) { p("Yes"); } else { p("No"); } return; } void Yay(bool condition) { if (condition) { p("Yay!"); } else { p(":("); } return; } // ll fact[800005],rfact[800005]; /* void c3_init(){ fact[0] = rfact[0] = 1; for(ll i=1; i<=800000; i++){ fact[i] = (fact[i-1]*i) % mod; } rfact[800000] = rui(fact[800000],mod - 2); for(ll i=800000; i>=1; i--){ rfact[i-1] = rfact[i] * i; rfact[i-1] %= mod; } return;} ll c3(ll n,ll r){ return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;} */ ll n, m, num, sum, ans, a, b, c, d, e, g, h, w, i, j, k, q; ll x[500005], y[500005], z[500005]; ll l[500005], r[500005]; ll check[500005]; ll dp[40000000]; char s[500005], t[500005]; ll ga, sa, ba, gb, sb, bb; bool flag, dame; void solve1() { dp[0] = 0; for (i = 1; i <= n; i++) { dp[i] = 0; for (j = 0; j < 3; j++) { if (i >= x[j]) { dp[i] = max(dp[i], dp[i - x[j]] + y[j]); } } } n = dp[n]; } void solve2() { for (i = 0; i < 3; i++) { swap(x[i], y[i]); } solve1(); } int main() { cin >> n; for (i = 0; i < 3; i++) { cin >> x[i]; } for (i = 0; i < 3; i++) { cin >> y[i]; } solve1(); // p(n); solve2(); p(n); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long int INF = 3e18; double Pi = 3.1415926535897932384626; vector<ll> G[500005]; // vector<P> tree[500010]; priority_queue<ll> pql; priority_queue<P> pqp; // big priority queue priority_queue<ll, vector<ll>, greater<ll>> pqls; priority_queue<P, vector<P>, greater<P>> pqps; // small priority queue // top pop int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; char dir[] = "DRUL"; // ll bit[500005]; //↓,→,↑,← #define p(x) cout << x << endl; #define el cout << endl; #define pe(x) cout << (x) << " "; #define ps(x) cout << fixed << setprecision(25) << x << endl; #define pu(x) cout << (x); #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout << #x << " = " << x << endl ll mod = 1000000007; ll rui(ll number1, ll number2) { if (number2 == 0) { return 1; } else { ll number3 = rui(number1, number2 / 2); number3 *= number3; number3 %= mod; if (number2 % 2 == 1) { number3 *= number1; number3 %= mod; } return number3; } } ll gcd(ll number1, ll number2) { if (number1 > number2) { swap(number1, number2); } if (number1 == 0 || number1 == number2) { return number2; } else { return gcd(number2 % number1, number1); } } void YES(bool condition) { if (condition) { p("YES"); } else { p("NO"); } return; } void Yes(bool condition) { if (condition) { p("Yes"); } else { p("No"); } return; } void Yay(bool condition) { if (condition) { p("Yay!"); } else { p(":("); } return; } // ll fact[800005],rfact[800005]; /* void c3_init(){ fact[0] = rfact[0] = 1; for(ll i=1; i<=800000; i++){ fact[i] = (fact[i-1]*i) % mod; } rfact[800000] = rui(fact[800000],mod - 2); for(ll i=800000; i>=1; i--){ rfact[i-1] = rfact[i] * i; rfact[i-1] %= mod; } return;} ll c3(ll n,ll r){ return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;} */ ll n, m, num, sum, ans, a, b, c, d, e, g, h, w, i, j, k, q; ll x[500005], y[500005], z[500005]; ll l[500005], r[500005]; ll check[500005]; ll dp[40000000]; char s[500005], t[500005]; ll ga, sa, ba, gb, sb, bb; bool flag, dame; void solve1() { dp[0] = 0; for (i = 1; i <= n; i++) { dp[i] = i; for (j = 0; j < 3; j++) { if (i >= x[j]) { dp[i] = max(dp[i], dp[i - x[j]] + y[j]); } } } n = dp[n]; } void solve2() { for (i = 0; i < 3; i++) { swap(x[i], y[i]); } solve1(); } int main() { cin >> n; for (i = 0; i < 3; i++) { cin >> x[i]; } for (i = 0; i < 3; i++) { cin >> y[i]; } solve1(); // p(n); solve2(); p(n); return 0; }
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
822,234
822,235
u399527088
cpp
p03008
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long int INF = 3e18; double Pi = 3.1415926535897932384626; vector<ll> G[500005]; // vector<P> tree[500010]; priority_queue<ll> pql; priority_queue<P> pqp; // big priority queue priority_queue<ll, vector<ll>, greater<ll>> pqls; priority_queue<P, vector<P>, greater<P>> pqps; // small priority queue // top pop int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; char dir[] = "DRUL"; // ll bit[500005]; //↓,→,↑,← #define p(x) cout << x << endl; #define el cout << endl; #define pe(x) cout << (x) << " "; #define ps(x) cout << fixed << setprecision(25) << x << endl; #define pu(x) cout << (x); #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout << #x << " = " << x << endl ll mod = 1000000007; ll rui(ll number1, ll number2) { if (number2 == 0) { return 1; } else { ll number3 = rui(number1, number2 / 2); number3 *= number3; number3 %= mod; if (number2 % 2 == 1) { number3 *= number1; number3 %= mod; } return number3; } } ll gcd(ll number1, ll number2) { if (number1 > number2) { swap(number1, number2); } if (number1 == 0 || number1 == number2) { return number2; } else { return gcd(number2 % number1, number1); } } void YES(bool condition) { if (condition) { p("YES"); } else { p("NO"); } return; } void Yes(bool condition) { if (condition) { p("Yes"); } else { p("No"); } return; } void Yay(bool condition) { if (condition) { p("Yay!"); } else { p(":("); } return; } // ll fact[800005],rfact[800005]; /* void c3_init(){ fact[0] = rfact[0] = 1; for(ll i=1; i<=800000; i++){ fact[i] = (fact[i-1]*i) % mod; } rfact[800000] = rui(fact[800000],mod - 2); for(ll i=800000; i>=1; i--){ rfact[i-1] = rfact[i] * i; rfact[i-1] %= mod; } return;} ll c3(ll n,ll r){ return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;} */ ll n, m, num, sum, ans, a, b, c, d, e, g, h, w, i, j, k, q; ll x[500005], y[500005], z[500005]; ll l[500005], r[500005]; ll check[500005]; ll dp[500005]; char s[500005], t[500005]; ll ga, sa, ba, gb, sb, bb; bool flag, dame; void solve1() { dp[0] = 0; for (i = 1; i <= n; i++) { dp[i] = 0; for (j = 0; j < 3; j++) { if (i >= x[j]) { dp[i] = max(dp[i], dp[i - x[j]] + y[j]); } } } n = dp[n]; } void solve2() { for (i = 0; i < 3; i++) { swap(x[i], y[i]); } solve1(); } int main() { cin >> n; for (i = 0; i < 3; i++) { cin >> x[i]; } for (i = 0; i < 3; i++) { cin >> y[i]; } solve1(); // p(n); solve2(); p(n); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string.h> #include <string> #include <time.h> #include <tuple> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long int INF = 3e18; double Pi = 3.1415926535897932384626; vector<ll> G[500005]; // vector<P> tree[500010]; priority_queue<ll> pql; priority_queue<P> pqp; // big priority queue priority_queue<ll, vector<ll>, greater<ll>> pqls; priority_queue<P, vector<P>, greater<P>> pqps; // small priority queue // top pop int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; char dir[] = "DRUL"; // ll bit[500005]; //↓,→,↑,← #define p(x) cout << x << endl; #define el cout << endl; #define pe(x) cout << (x) << " "; #define ps(x) cout << fixed << setprecision(25) << x << endl; #define pu(x) cout << (x); #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout << #x << " = " << x << endl ll mod = 1000000007; ll rui(ll number1, ll number2) { if (number2 == 0) { return 1; } else { ll number3 = rui(number1, number2 / 2); number3 *= number3; number3 %= mod; if (number2 % 2 == 1) { number3 *= number1; number3 %= mod; } return number3; } } ll gcd(ll number1, ll number2) { if (number1 > number2) { swap(number1, number2); } if (number1 == 0 || number1 == number2) { return number2; } else { return gcd(number2 % number1, number1); } } void YES(bool condition) { if (condition) { p("YES"); } else { p("NO"); } return; } void Yes(bool condition) { if (condition) { p("Yes"); } else { p("No"); } return; } void Yay(bool condition) { if (condition) { p("Yay!"); } else { p(":("); } return; } // ll fact[800005],rfact[800005]; /* void c3_init(){ fact[0] = rfact[0] = 1; for(ll i=1; i<=800000; i++){ fact[i] = (fact[i-1]*i) % mod; } rfact[800000] = rui(fact[800000],mod - 2); for(ll i=800000; i>=1; i--){ rfact[i-1] = rfact[i] * i; rfact[i-1] %= mod; } return;} ll c3(ll n,ll r){ return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;} */ ll n, m, num, sum, ans, a, b, c, d, e, g, h, w, i, j, k, q; ll x[500005], y[500005], z[500005]; ll l[500005], r[500005]; ll check[500005]; ll dp[40000000]; char s[500005], t[500005]; ll ga, sa, ba, gb, sb, bb; bool flag, dame; void solve1() { dp[0] = 0; for (i = 1; i <= n; i++) { dp[i] = i; for (j = 0; j < 3; j++) { if (i >= x[j]) { dp[i] = max(dp[i], dp[i - x[j]] + y[j]); } } } n = dp[n]; } void solve2() { for (i = 0; i < 3; i++) { swap(x[i], y[i]); } solve1(); } int main() { cin >> n; for (i = 0; i < 3; i++) { cin >> x[i]; } for (i = 0; i < 3; i++) { cin >> y[i]; } solve1(); // p(n); solve2(); p(n); return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
822,236
822,235
u399527088
cpp
p03008
//#pragma comment(linker, "/STACK:134217728") #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <vector> using namespace std; typedef long long Int; typedef pair<int, int> PII; typedef vector<int> VInt; #define FOR(i, a, b) for (i = (a); i < (b); ++i) #define RFOR(i, a, b) for (i = (a)-1; i >= (b); --i) #define CLEAR(a, b) memset(a, b, sizeof(a)) #define SIZE(a) int((a).size()) #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair Int f(Int m, VInt v, VInt w) { int i, j; FOR(i, 0, 2) FOR(j, i + 1, 2) if (w[i] * v[j] < w[j] * v[i]) { swap(v[i], v[j]); swap(w[i], w[j]); } Int res = m; FOR(i, 0, v[0]) FOR(j, 0, v[0]) { Int left = m - v[1] * i - v[2] * j; if (left < 0) continue; res = max(res, left + w[1] * i + w[2] * j); Int k = left / v[0]; left -= k * v[0]; res = max(res, left + w[1] * i + w[2] * j + w[0] * k); } return res; } void solve(int test) { int n; cin >> n; VInt v[] = {VInt(3), VInt(3)}; int i, j; FOR(i, 0, 2) FOR(j, 0, 3) scanf("%d", &v[i][j]); Int r1 = f(n, v[0], v[1]); Int r2 = f(r1, v[1], v[0]); cout << r2 << endl; } int main() { int t, T; T = 1; // scanf("%d", &T); FOR(t, 0, T) solve(t); return 0; };
//#pragma comment(linker, "/STACK:134217728") #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <vector> using namespace std; typedef long long Int; typedef pair<int, int> PII; typedef vector<int> VInt; #define FOR(i, a, b) for (i = (a); i < (b); ++i) #define RFOR(i, a, b) for (i = (a)-1; i >= (b); --i) #define CLEAR(a, b) memset(a, b, sizeof(a)) #define SIZE(a) int((a).size()) #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair Int f(Int m, VInt v, VInt w) { int i, j; FOR(i, 0, 3) FOR(j, i + 1, 3) if (w[i] * v[j] < w[j] * v[i]) { swap(v[i], v[j]); swap(w[i], w[j]); } Int res = m; FOR(i, 0, v[0]) FOR(j, 0, v[0]) { Int left = m - v[1] * i - v[2] * j; if (left < 0) continue; res = max(res, left + w[1] * i + w[2] * j); Int k = left / v[0]; left -= k * v[0]; res = max(res, left + w[1] * i + w[2] * j + w[0] * k); } return res; } void solve(int test) { int n; cin >> n; VInt v[] = {VInt(3), VInt(3)}; int i, j; FOR(i, 0, 2) FOR(j, 0, 3) scanf("%d", &v[i][j]); Int r1 = f(n, v[0], v[1]); Int r2 = f(r1, v[1], v[0]); cout << r2 << endl; } int main() { int t, T; T = 1; // scanf("%d", &T); FOR(t, 0, T) solve(t); return 0; };
[ "literal.number.change", "call.arguments.change" ]
822,239
822,240
u115089744
cpp
p03008
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define PPC(x) __builtin_popcount((x)) #define ALL(x) (x).begin(), (x).end() #define pb push_back using namespace std; vector<pair<int, int>> p; long long res; int limit; void go(int d, int prev, long long sum) { if (d == p.size() or prev == limit) { res = max(res, sum); return; } int i = (d == p.size() - 1 ? limit : prev + 1); for (; i <= limit; i++) go(d + 1, i, sum + 1ll * (i - prev) / p[d].first * p[d].second + (i - prev) % p[d].first); } int main() { long long n; scanf("%lld", &n); pair<int, int> T[3]; FOR(i, 0, 3) scanf("%d", &T[i].first); FOR(i, 0, 3) scanf("%d", &T[i].second); FOR(i, 0, 3) if (T[i].first < T[i].second) p.pb(T[i]); limit = n; go(0, 0, 0); n = max(n, res); p.resize(0); FOR(i, 0, 3) if (T[i].second < T[i].first) p.pb({T[i].second, T[i].first}); res = 0; limit = n; go(0, 0, 0); n = max(n, res); printf("%lld\n", n); return 0; }
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define PPC(x) __builtin_popcount((x)) #define ALL(x) (x).begin(), (x).end() #define pb push_back using namespace std; vector<pair<int, int>> p; long long res; int limit; void go(int d, int prev, long long sum) { if (d == p.size() or prev == limit) { res = max(res, sum); return; } int i = (d == p.size() - 1 ? limit : prev); for (; i <= limit; i++) go(d + 1, i, sum + 1ll * (i - prev) / p[d].first * p[d].second + (i - prev) % p[d].first); } int main() { long long n; scanf("%lld", &n); pair<int, int> T[3]; FOR(i, 0, 3) scanf("%d", &T[i].first); FOR(i, 0, 3) scanf("%d", &T[i].second); FOR(i, 0, 3) if (T[i].first < T[i].second) p.pb(T[i]); limit = n; go(0, 0, 0); n = max(n, res); p.resize(0); FOR(i, 0, 3) if (T[i].second < T[i].first) p.pb({T[i].second, T[i].first}); res = 0; limit = n; go(0, 0, 0); n = max(n, res); printf("%lld\n", n); return 0; }
[ "expression.operation.binary.remove" ]
822,247
822,248
u716895502
cpp
p03008
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <complex> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <time.h> #include <tuple> #include <unistd.h> #include <vector> #define _USE_MATH_DEFINES #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> plglg; typedef pair<double, ll> pdlg; typedef tuple<int, int, int> tiii; typedef tuple<ll, ll, ll> tlglglg; typedef tuple<double, double, double> tddd; typedef complex<double> xy_t; typedef vector<ll> vll; typedef vector<vector<ll>> matrix; #define REP(i, x, y) for (ll i = (ll)x; i < (ll)y; i++) #define DREP(i, x, y, d) for (ll i = (ll)x; i < (ll)y; i += (ll)d) #define PER(i, x, y) for (ll i = (ll)x; i > (ll)y; i--) #define DPER(i, x, y, d) for (ll i = (ll)x; i > (ll)y; i -= (ll)d) int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; double pi = 3.141592653589793; ll mod = 1000000007; int intmax = 2147483647; int intmin = -2147483648; ll llmax = 9223372036854775807; ll llmin = -9223372036854775807; int iinf = intmax / 8; ll inf = llmax / 8; double eps = 1e-12; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; ll ga, sa, ba, gb, sb, bb; cin >> ga >> sa >> ba >> gb >> sb >> bb; ll g = false, s = false, b = false; if (ga > gb) { g = true; } if (sa > sb) { s = true; } if (ba > bb) { b = true; } ll ans = N; if ((g && s && b) || (!g && !s && !b)) { REP(i, 0, 5010) { REP(j, 0, 5010) { if (i * ga + j * sa > N) { continue; } ll rem = N - (i * ga + j * sa); ll br = rem / ba; ll tmp = rem; tmp += i * gb; tmp += j * sb; if (bb > ba) { tmp += br * (bb - ba); } ans = max(tmp, ans); } } REP(i, 0, 5010) { REP(j, 0, 5010) { if (i * gb + j * sb > N) { continue; } ll rem = N - (i * gb + j * sb); ll br = rem / bb; ll tmp = rem; tmp += i * ga; tmp += j * sa; if (ba > bb) { tmp += br * (ba - bb); } ans = max(tmp, ans); } } } else { tlglglg dif[3]; dif[0] = tlglglg(ga - gb, ga, gb); dif[1] = tlglglg(sa - sb, sa, sb); dif[2] = tlglglg(ba - bb, ba, bb); sort(dif, dif + 3); ll cnt = 0; if (g) { cnt++; } if (s) { cnt++; } if (b) { cnt++; } if (cnt == 1) { REP(i, 0, 5010) { tlglglg t = dif[0]; if (i * get<1>(t) > N) { continue; } ll rem = N - i * get<1>(t); tlglglg tt = dif[1]; ll two = rem / get<1>(tt); ll tmp = rem; tmp += i * get<2>(t); tmp += two * (get<2>(tt) - get<1>(tt)); tlglglg ttt = dif[2]; ll three = tmp / get<2>(ttt); tmp += three * get<0>(ttt); ans = max(tmp, ans); } } else { tlglglg t = dif[0]; ll one = N / get<1>(t); ll tmp = N + one * (-get<0>(t)); REP(i, 0, 5010 * 5010) { tlglglg tt = dif[1]; if (i * get<2>(tt) > tmp) { continue; } ll rem = tmp - i * get<2>(tt); tlglglg ttt = dif[2]; ll three = rem / get<2>(ttt); tmp += i * get<0>(tt); tmp += three * get<0>(ttt); ans = max(tmp, ans); } } } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <complex> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <time.h> #include <tuple> #include <unistd.h> #include <vector> #define _USE_MATH_DEFINES #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> plglg; typedef pair<double, ll> pdlg; typedef tuple<int, int, int> tiii; typedef tuple<ll, ll, ll> tlglglg; typedef tuple<double, double, double> tddd; typedef complex<double> xy_t; typedef vector<ll> vll; typedef vector<vector<ll>> matrix; #define REP(i, x, y) for (ll i = (ll)x; i < (ll)y; i++) #define DREP(i, x, y, d) for (ll i = (ll)x; i < (ll)y; i += (ll)d) #define PER(i, x, y) for (ll i = (ll)x; i > (ll)y; i--) #define DPER(i, x, y, d) for (ll i = (ll)x; i > (ll)y; i -= (ll)d) int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; double pi = 3.141592653589793; ll mod = 1000000007; int intmax = 2147483647; int intmin = -2147483648; ll llmax = 9223372036854775807; ll llmin = -9223372036854775807; int iinf = intmax / 8; ll inf = llmax / 8; double eps = 1e-12; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; ll ga, sa, ba, gb, sb, bb; cin >> ga >> sa >> ba >> gb >> sb >> bb; ll g = false, s = false, b = false; if (ga > gb) { g = true; } if (sa > sb) { s = true; } if (ba > bb) { b = true; } ll ans = N; if ((g && s && b) || (!g && !s && !b)) { REP(i, 0, 5010) { REP(j, 0, 5010) { if (i * ga + j * sa > N) { continue; } ll rem = N - (i * ga + j * sa); ll br = rem / ba; ll tmp = rem; tmp += i * gb; tmp += j * sb; if (bb > ba) { tmp += br * (bb - ba); } ans = max(tmp, ans); } } REP(i, 0, 5010) { REP(j, 0, 5010) { if (i * gb + j * sb > N) { continue; } ll rem = N - (i * gb + j * sb); ll br = rem / bb; ll tmp = rem; tmp += i * ga; tmp += j * sa; if (ba > bb) { tmp += br * (ba - bb); } ans = max(tmp, ans); } } } else { tlglglg dif[3]; dif[0] = tlglglg(ga - gb, ga, gb); dif[1] = tlglglg(sa - sb, sa, sb); dif[2] = tlglglg(ba - bb, ba, bb); sort(dif, dif + 3); ll cnt = 0; if (g) { cnt++; } if (s) { cnt++; } if (b) { cnt++; } if (cnt == 1) { REP(i, 0, 5010) { tlglglg t = dif[0]; if (i * get<1>(t) > N) { continue; } ll rem = N - i * get<1>(t); tlglglg tt = dif[1]; ll two = rem / get<1>(tt); ll tmp = rem; tmp += i * get<2>(t); tmp += two * (get<2>(tt) - get<1>(tt)); tlglglg ttt = dif[2]; ll three = tmp / get<2>(ttt); tmp += three * get<0>(ttt); ans = max(tmp, ans); } } else { tlglglg t = dif[0]; ll one = N / get<1>(t); ll tmpbase = N + one * (-get<0>(t)); REP(i, 0, 5010 * 5010) { ll tmp = tmpbase; tlglglg tt = dif[1]; if (i * get<2>(tt) > tmp) { continue; } ll rem = tmp - i * get<2>(tt); tlglglg ttt = dif[2]; ll three = rem / get<2>(ttt); tmp += i * get<0>(tt); tmp += three * get<0>(ttt); ans = max(tmp, ans); } } } cout << ans << endl; }
[ "variable_declaration.name.change", "identifier.change", "variable_declaration.add" ]
822,249
822,250
u006204672
cpp
p03008
#include <bits/stdc++.h> #include <unistd.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cerr << " " << v[i]; \ cerr << endl #define DEBUG_MAT(v) \ cerr << #v << endl; \ for (int i = 0; i < v.size(); i++) { \ for (int j = 0; j < v[i].size(); j++) { \ cerr << v[i][j] << " "; \ } \ cerr << endl; \ } typedef long long ll; #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> template <class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); } template <class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep1(i, n) for (int i = (n); i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) #define in(x, a, b) (a <= x && x < b) #define all(c) c.begin(), c.end() template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const ll MOD = 1000000007; // const ll MOD = 998244353; const double pi = 3.14159265358979323846; #define Sp(p) cout << setprecision(15) << fixed << p << endl; int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1}; #define fio() \ cin.tie(0); \ ios::sync_with_stdio(false); // #define mp make_pair //#define endl '\n' ll solve(int n, vl a, vl b) { ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; rep(s, n + 1) { if (a[0] * g + a[1] * s > n) break; ll nokori = n - a[0] * g - a[1] * s; ll d = nokori / a[2]; nokori -= d * a[2]; nokori += g * b[0]; nokori += s * b[1]; nokori += d * b[2]; chmax(ans, nokori); } } return ans; } bool cmp(pll a, pll b) { return a.first - a.second < b.first - b.second; } ll solve2(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; ll nokori = n - a[0] * g; ll s = nokori / a[1]; nokori -= s * a[1]; nokori += g * b[0]; nokori += s * b[1]; ll d = nokori / b[2]; nokori -= d * b[2]; nokori += d * b[2]; chmax(ans, nokori); } return ans; } ll solve1(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll g = n / a[0]; ll nokori = n - a[0] * g; nokori += b[0] * g; ll ans = n; rep(s, nokori + 1) { ll temp = nokori - s * b[1]; if (temp < 0) break; ll d = temp / b[2]; temp -= d * b[2]; temp += d * a[2]; temp += s * a[1]; chmax(ans, temp); } return ans; } int main() { int n; cin >> n; vl a(3), b(3); rep(i, 3) { cin >> a[i]; } rep(i, 3) { cin >> b[i]; } bool up = true, down = true; rep(i, 3) { if (a[i] > b[i]) down = false; if (a[i] < b[i]) up = false; } if (up and down) { cout << n << endl; return 0; } if (up) { cout << solve(n, b, a) << endl; return 0; } if (down) { cout << solve(n, a, b) << endl; return 0; } vector<pll> ab(3); rep(i, 3) { ab[i] = pll(a[i], b[i]); } sort(all(ab), cmp); int cnt = 0; rep(i, 3) { if (ab[i].first <= ab[i].second) cnt++; } if (cnt == 2) { cout << solve2(n, ab) << endl; } else { cout << solve1(n, ab) << endl; } }
#include <bits/stdc++.h> #include <unistd.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cerr << " " << v[i]; \ cerr << endl #define DEBUG_MAT(v) \ cerr << #v << endl; \ for (int i = 0; i < v.size(); i++) { \ for (int j = 0; j < v[i].size(); j++) { \ cerr << v[i][j] << " "; \ } \ cerr << endl; \ } typedef long long ll; #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> template <class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); } template <class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep1(i, n) for (int i = (n); i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) #define in(x, a, b) (a <= x && x < b) #define all(c) c.begin(), c.end() template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const ll MOD = 1000000007; // const ll MOD = 998244353; const double pi = 3.14159265358979323846; #define Sp(p) cout << setprecision(15) << fixed << p << endl; int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1}; #define fio() \ cin.tie(0); \ ios::sync_with_stdio(false); // #define mp make_pair //#define endl '\n' ll solve(int n, vl a, vl b) { ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; rep(s, n + 1) { if (a[0] * g + a[1] * s > n) break; ll nokori = n - a[0] * g - a[1] * s; ll d = nokori / a[2]; nokori -= d * a[2]; nokori += g * b[0]; nokori += s * b[1]; nokori += d * b[2]; chmax(ans, nokori); } } return ans; } bool cmp(pll a, pll b) { return a.first - a.second < b.first - b.second; } ll solve2(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; ll nokori = n - a[0] * g; ll s = nokori / a[1]; nokori -= s * a[1]; nokori += g * b[0]; nokori += s * b[1]; ll d = nokori / b[2]; nokori -= d * b[2]; nokori += d * a[2]; chmax(ans, nokori); } return ans; } ll solve1(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll g = n / a[0]; ll nokori = n - a[0] * g; nokori += b[0] * g; ll ans = n; rep(s, nokori + 1) { ll temp = nokori - s * b[1]; if (temp < 0) break; ll d = temp / b[2]; temp -= d * b[2]; temp += d * a[2]; temp += s * a[1]; chmax(ans, temp); } return ans; } int main() { int n; cin >> n; vl a(3), b(3); rep(i, 3) { cin >> a[i]; } rep(i, 3) { cin >> b[i]; } bool up = true, down = true; rep(i, 3) { if (a[i] > b[i]) down = false; if (a[i] < b[i]) up = false; } if (up and down) { cout << n << endl; return 0; } if (up) { cout << solve(n, b, a) << endl; return 0; } if (down) { cout << solve(n, a, b) << endl; return 0; } vector<pll> ab(3); rep(i, 3) { ab[i] = pll(a[i], b[i]); } sort(all(ab), cmp); int cnt = 0; rep(i, 3) { if (ab[i].first <= ab[i].second) cnt++; } if (cnt == 2) { cout << solve2(n, ab) << endl; } else { cout << solve1(n, ab) << endl; } }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
822,251
822,252
u579152247
cpp
p03008
#include <bits/stdc++.h> #include <unistd.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cerr << " " << v[i]; \ cerr << endl #define DEBUG_MAT(v) \ cerr << #v << endl; \ for (int i = 0; i < v.size(); i++) { \ for (int j = 0; j < v[i].size(); j++) { \ cerr << v[i][j] << " "; \ } \ cerr << endl; \ } typedef long long ll; #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> template <class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); } template <class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep1(i, n) for (int i = (n); i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) #define in(x, a, b) (a <= x && x < b) #define all(c) c.begin(), c.end() template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const ll MOD = 1000000007; // const ll MOD = 998244353; const double pi = 3.14159265358979323846; #define Sp(p) cout << setprecision(15) << fixed << p << endl; int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1}; #define fio() \ cin.tie(0); \ ios::sync_with_stdio(false); // #define mp make_pair //#define endl '\n' ll solve(int n, vl a, vl b) { ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; rep(s, n + 1) { if (a[0] * g + a[1] * s > n) break; ll nokori = n - a[0] * g - a[1] * s; ll d = nokori / a[2]; nokori -= d * a[2]; nokori += g * b[0]; nokori += s * b[1]; nokori += d * b[1]; chmax(ans, nokori); } } return ans; } bool cmp(pll a, pll b) { return a.first - a.second < b.first - b.second; } ll solve2(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; ll nokori = n - a[0] * g; ll s = nokori / a[1]; nokori -= s * a[1]; nokori += g * b[0]; nokori += s * b[1]; ll d = nokori / b[2]; nokori -= d * b[2]; nokori += d * b[1]; chmax(ans, nokori); } return ans; } ll solve1(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll g = n / a[0]; ll nokori = n - a[0] * g; nokori += b[0] * g; ll ans = n; rep(s, nokori + 1) { ll temp = nokori - s * b[1]; if (temp < 0) break; ll d = temp / b[2]; temp -= d * b[2]; temp += d * a[2]; temp += s * a[1]; chmax(ans, temp); } return ans; } int main() { int n; cin >> n; vl a(3), b(3); rep(i, 3) { cin >> a[i]; } rep(i, 3) { cin >> b[i]; } bool up = true, down = true; rep(i, 3) { if (a[i] > b[i]) down = false; if (a[i] < b[i]) up = false; } if (up and down) { cout << n << endl; return 0; } if (up) { cout << solve(n, b, a) << endl; return 0; } if (down) { cout << solve(n, a, b) << endl; return 0; } vector<pll> ab(3); rep(i, 3) { ab[i] = pll(a[i], b[i]); } sort(all(ab), cmp); int cnt = 0; rep(i, 3) { if (ab[i].first <= ab[i].second) cnt++; } if (cnt == 2) { cout << solve2(n, ab) << endl; } else { cout << solve1(n, ab) << endl; } }
#include <bits/stdc++.h> #include <unistd.h> using namespace std; #define DEBUG(x) cerr << #x << ": " << x << endl; #define DEBUG_VEC(v) \ cerr << #v << ":"; \ for (int i = 0; i < v.size(); i++) \ cerr << " " << v[i]; \ cerr << endl #define DEBUG_MAT(v) \ cerr << #v << endl; \ for (int i = 0; i < v.size(); i++) { \ for (int j = 0; j < v[i].size(); j++) { \ cerr << v[i][j] << " "; \ } \ cerr << endl; \ } typedef long long ll; #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define vs vector<string> #define pii pair<int, int> #define pis pair<int, string> #define psi pair<string, int> #define pll pair<ll, ll> template <class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); } template <class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep1(i, n) for (int i = (n); i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) #define in(x, a, b) (a <= x && x < b) #define all(c) c.begin(), c.end() template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const ll MOD = 1000000007; // const ll MOD = 998244353; const double pi = 3.14159265358979323846; #define Sp(p) cout << setprecision(15) << fixed << p << endl; int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1}; #define fio() \ cin.tie(0); \ ios::sync_with_stdio(false); // #define mp make_pair //#define endl '\n' ll solve(int n, vl a, vl b) { ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; rep(s, n + 1) { if (a[0] * g + a[1] * s > n) break; ll nokori = n - a[0] * g - a[1] * s; ll d = nokori / a[2]; nokori -= d * a[2]; nokori += g * b[0]; nokori += s * b[1]; nokori += d * b[2]; chmax(ans, nokori); } } return ans; } bool cmp(pll a, pll b) { return a.first - a.second < b.first - b.second; } ll solve2(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll ans = n; rep(g, n + 1) { if (a[0] * g > n) break; ll nokori = n - a[0] * g; ll s = nokori / a[1]; nokori -= s * a[1]; nokori += g * b[0]; nokori += s * b[1]; ll d = nokori / b[2]; nokori -= d * b[2]; nokori += d * a[2]; chmax(ans, nokori); } return ans; } ll solve1(int n, vector<pll> ab) { vl a(3), b(3); rep(i, 3) { a[i] = ab[i].first; b[i] = ab[i].second; } ll g = n / a[0]; ll nokori = n - a[0] * g; nokori += b[0] * g; ll ans = n; rep(s, nokori + 1) { ll temp = nokori - s * b[1]; if (temp < 0) break; ll d = temp / b[2]; temp -= d * b[2]; temp += d * a[2]; temp += s * a[1]; chmax(ans, temp); } return ans; } int main() { int n; cin >> n; vl a(3), b(3); rep(i, 3) { cin >> a[i]; } rep(i, 3) { cin >> b[i]; } bool up = true, down = true; rep(i, 3) { if (a[i] > b[i]) down = false; if (a[i] < b[i]) up = false; } if (up and down) { cout << n << endl; return 0; } if (up) { cout << solve(n, b, a) << endl; return 0; } if (down) { cout << solve(n, a, b) << endl; return 0; } vector<pll> ab(3); rep(i, 3) { ab[i] = pll(a[i], b[i]); } sort(all(ab), cmp); int cnt = 0; rep(i, 3) { if (ab[i].first <= ab[i].second) cnt++; } if (cnt == 2) { cout << solve2(n, ab) << endl; } else { cout << solve1(n, ab) << endl; } }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change", "identifier.change" ]
822,253
822,252
u579152247
cpp
p03008
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } long long g[2], s[2], b[2]; int main() { int n = ri(); for (int i = 0; i < 2; i++) { g[i] = ri(); s[i] = ri(); b[i] = ri(); } long long res = n; { long long dp[res + 1]; dp[res] = 0; for (int i = 0; i < res; i++) dp[i] = -10000000000000000LL; for (int i = res; i >= 0; i--) { if (i >= g[0]) dp[i - g[0]] = std::max(dp[i - g[0]], dp[i] + g[1]); if (i >= s[0]) dp[i - s[0]] = std::max(dp[i - s[0]], dp[i] + s[1]); if (i >= b[0]) dp[i - b[0]] = std::max(dp[i - b[0]], dp[i] + b[1]); } long long next = res; for (int i = 0; i <= res; i++) next = std::max(next, dp[i]); res = next; } { long long dp[res + 1]; dp[res] = 0; for (int i = 0; i < res; i++) dp[i] = -10000000000000000LL; for (int i = res; i >= 0; i--) { if (i >= g[1]) dp[i - g[1]] = std::max(dp[i - g[1]], dp[i] + g[0]); if (i >= s[1]) dp[i - s[1]] = std::max(dp[i - s[1]], dp[i] + s[0]); if (i >= b[1]) dp[i - b[1]] = std::max(dp[i - b[1]], dp[i] + b[0]); } long long next = res; for (int i = 0; i <= res; i++) next = std::max(next, dp[i]); res = next; } std::cout << res << std::endl; return 0; }
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } long long g[2], s[2], b[2]; int main() { int n = ri(); for (int i = 0; i < 2; i++) { g[i] = ri(); s[i] = ri(); b[i] = ri(); } long long res = n; { long long dp[res + 1]; dp[res] = 0; for (int i = 0; i < res; i++) dp[i] = -10000000000000000LL; for (int i = res; i >= 0; i--) { if (i >= g[0]) dp[i - g[0]] = std::max(dp[i - g[0]], dp[i] + g[1]); if (i >= s[0]) dp[i - s[0]] = std::max(dp[i - s[0]], dp[i] + s[1]); if (i >= b[0]) dp[i - b[0]] = std::max(dp[i - b[0]], dp[i] + b[1]); } long long next = res; for (int i = 0; i <= res; i++) next = std::max(next, i + dp[i]); res = next; } { long long dp[res + 1]; dp[res] = 0; for (int i = 0; i < res; i++) dp[i] = -10000000000000000LL; for (int i = res; i >= 0; i--) { if (i >= g[1]) dp[i - g[1]] = std::max(dp[i - g[1]], dp[i] + g[0]); if (i >= s[1]) dp[i - s[1]] = std::max(dp[i - s[1]], dp[i] + s[0]); if (i >= b[1]) dp[i - b[1]] = std::max(dp[i - b[1]], dp[i] + b[0]); } long long next = res; for (int i = 0; i <= res; i++) next = std::max(next, i + dp[i]); res = next; } std::cout << res << std::endl; return 0; }
[ "assignment.change" ]
822,254
822,255
u040490988
cpp
p03008
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <unordered_map> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) using namespace std; typedef unsigned long long ul; typedef long long ll; typedef pair<int, int> PAIR; int main() { ll N, ga, gb, sa, sb, ba, bb; cin >> N; cin >> ga >> sa >> ba >> gb >> sb >> bb; ll gA = gb - ga; ll sA = sb - sa; ll bA = bb - ba; vector<ll> vals; vals.resize(N + 1); vals[0] = 0; FOR(i, 1, N + 1) { ll valA = i >= ga ? vals[i - ga] + gA : 0; ll valB = i >= sa ? vals[i - ba] + sA : 0; ll valC = i >= ba ? vals[i - ba] + bA : 0; ll val0 = vals[i - 1]; vals[i] = max(valA, max(valB, max(valC, val0))); } N = vals[N] + N; vals.clear(); vals[0] = 0; vals.resize(N + 1); FOR(i, 1, N + 1) { ll valA = i >= gb ? vals[i - gb] - gA : 0; ll valB = i >= sb ? vals[i - sb] - sA : 0; ll valC = i >= bb ? vals[i - bb] - bA : 0; ll val0 = vals[i - 1]; vals[i] = max(valA, max(valB, max(valC, val0))); } N = vals[N] + N; cout << N; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <unordered_map> #include <vector> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) using namespace std; typedef unsigned long long ul; typedef long long ll; typedef pair<int, int> PAIR; int main() { ll N, ga, gb, sa, sb, ba, bb; cin >> N; cin >> ga >> sa >> ba >> gb >> sb >> bb; ll gA = gb - ga; ll sA = sb - sa; ll bA = bb - ba; vector<ll> vals; vals.resize(N + 1); vals[0] = 0; FOR(i, 1, N + 1) { ll valA = i >= ga ? vals[i - ga] + gA : 0; ll valB = i >= sa ? vals[i - sa] + sA : 0; ll valC = i >= ba ? vals[i - ba] + bA : 0; ll val0 = vals[i - 1]; vals[i] = max(valA, max(valB, max(valC, val0))); } N = vals[N] + N; vals.clear(); vals[0] = 0; vals.resize(N + 1); FOR(i, 1, N + 1) { ll valA = i >= gb ? vals[i - gb] - gA : 0; ll valB = i >= sb ? vals[i - sb] - sA : 0; ll valC = i >= bb ? vals[i - bb] - bA : 0; ll val0 = vals[i - 1]; vals[i] = max(valA, max(valB, max(valC, val0))); } N = vals[N] + N; cout << N; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
822,256
822,257
u211490974
cpp
p03008
#include "bits/stdc++.h" using namespace std; #define ll long long #define ii pair<ll, ll> ll n, g[2], s[2], b[2]; ll ans[10000], finalAns = 0; bool visited[10000]; ll dp(ll num, ll ma, ll sa, ll mb, ll sb, ll mc, ll sc) { if (visited[num]) return ans[num]; visited[num] = true; ans[num] = num; if (num >= ma) ans[num] = max(ans[num], dp(num - ma, ma, sa, mb, sb, mc, sc) + sa + ma); if (num >= mb) ans[num] = max(ans[num], dp(num - mb, ma, sa, mb, sb, mc, sc) + sb + mb); if (num >= mc) ans[num] = max(ans[num], dp(num - mc, ma, sa, mb, sb, mc, sc) + sc + mc); return ans[num]; } int main() { scanf("%lld", &n); scanf("%lld %lld %lld", &g[0], &s[0], &b[0]); scanf("%lld %lld %lld", &g[1], &s[1], &b[1]); int back = (g[0] - g[1] > 0) + (s[0] - s[1] > 0) + (b[0] - b[1] > 0); // A -> B, then B -> A ll midAns = dp(n, g[0], g[1] - g[0], s[0], s[1] - s[0], b[0], b[1] - b[0]); // Find final ans if (back == 3) { // Use dp memset(visited, 0, sizeof visited); finalAns = dp(midAns, g[1], g[0] - g[1], s[1], s[0] - s[1], b[1], b[0] - b[1]); } else if (back > 0) { // Find sulprus trade vector<ii> trade; if (g[1] - g[0] > 0) trade.push_back(ii(g[1], g[0])); if (s[1] - s[0] > 0) trade.push_back(ii(s[1], s[0])); if (b[1] - b[0] > 0) trade.push_back(ii(b[1], b[0])); // Use brute force for (ll i = 0; i <= midAns; ++i) { if (i * trade[0].first > midAns) break; // Try trading trade1 i times ll tmpFinal = midAns + i * (trade[0].second - trade[0].first); // Trade the rest witn trade2 if (trade.size() > 1) { ll rem = midAns - i * (trade[0].first); ll numTrade = rem / trade[1].first; tmpFinal += numTrade * (trade[1].second - trade[1].first); } finalAns = max(finalAns, tmpFinal); } } else { finalAns = midAns; } printf("%lld\n", finalAns); }
#include "bits/stdc++.h" using namespace std; #define ll long long #define ii pair<ll, ll> ll n, g[2], s[2], b[2]; ll ans[10000], finalAns = 0; bool visited[10000]; ll dp(ll num, ll ma, ll sa, ll mb, ll sb, ll mc, ll sc) { if (visited[num]) return ans[num]; visited[num] = true; ans[num] = num; if (num >= ma) ans[num] = max(ans[num], dp(num - ma, ma, sa, mb, sb, mc, sc) + sa + ma); if (num >= mb) ans[num] = max(ans[num], dp(num - mb, ma, sa, mb, sb, mc, sc) + sb + mb); if (num >= mc) ans[num] = max(ans[num], dp(num - mc, ma, sa, mb, sb, mc, sc) + sc + mc); return ans[num]; } int main() { scanf("%lld", &n); scanf("%lld %lld %lld", &g[0], &s[0], &b[0]); scanf("%lld %lld %lld", &g[1], &s[1], &b[1]); int back = (g[0] - g[1] > 0) + (s[0] - s[1] > 0) + (b[0] - b[1] > 0); // A -> B, then B -> A ll midAns = dp(n, g[0], g[1] - g[0], s[0], s[1] - s[0], b[0], b[1] - b[0]); // printf("mid = %lld, back = %d\n", midAns, back); // Find final ans if (back == 3) { // Use dp memset(visited, 0, sizeof visited); finalAns = dp(midAns, g[1], g[0] - g[1], s[1], s[0] - s[1], b[1], b[0] - b[1]); } else if (back > 0) { // Find sulprus trade vector<ii> trade; if (g[0] - g[1] > 0) trade.push_back(ii(g[1], g[0])); if (s[0] - s[1] > 0) trade.push_back(ii(s[1], s[0])); if (b[0] - b[1] > 0) trade.push_back(ii(b[1], b[0])); // Use brute force for (ll i = 0; i <= midAns; ++i) { if (i * trade[0].first > midAns) break; // Try trading trade1 i times ll tmpFinal = midAns + i * (trade[0].second - trade[0].first); // Trade the rest witn trade2 if (trade.size() > 1) { ll rem = midAns - i * (trade[0].first); ll numTrade = rem / trade[1].first; tmpFinal += numTrade * (trade[1].second - trade[1].first); } // printf("tmpFinal = %lld, %lld\n", tmpFinal, i); finalAns = max(finalAns, tmpFinal); } } else { finalAns = midAns; } printf("%lld\n", finalAns); }
[ "literal.number.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
822,260
822,261
u198150045
cpp
p03008
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ll long long #define pb push_back #define sz(x) (int)(x).size() #define mp make_pair #define f first #define s second #define all(x) x.begin(), x.end() #define D(x) cerr << #x << " is " << (x) << "\n"; using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /// find_by_order(),order_of_key() template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { os << '{' << a.f << ", " << a.s << '}'; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &a) { os << '{'; for (int i = 0; i < sz(a); i++) { if (i > 0 && i < sz(a)) os << ", "; os << a[i]; } os << '}'; return os; } template <class T> ostream &operator<<(ostream &os, const set<T> &a) { os << '{'; int i = 0; for (auto p : a) { if (i > 0 && i < sz(a)) os << ", "; os << p; i++; } os << '}'; return os; } template <class T> ostream &operator<<(ostream &os, const multiset<T> &a) { os << '{'; int i = 0; for (auto p : a) { if (i > 0 && i < sz(a)) os << ", "; os << p; i++; } os << '}'; return os; } template <class T1, class T2> ostream &operator<<(ostream &os, const map<T1, T2> &a) { os << '{'; int i = 0; for (auto p : a) { if (i > 0 && i < sz(a)) os << ", "; os << p; i++; } os << '}'; return os; } vector<pair<int, int>> AB, BA; int dp1[3][5001]; vector<vector<ll>> dp2; int calc1(int tr, int money) { if (tr == AB.size()) return money; if (dp1[tr][money] != -1) return dp1[tr][money]; int m = money; int profit = 0; dp1[tr][money] = calc1(tr + 1, m); while (m >= AB[tr].s) { m -= AB[tr].s; profit += AB[tr].f; dp1[tr][money] = max(dp1[tr][money], profit + calc1(tr + 1, m)); } return dp1[tr][money]; } ll calc2(int tr, int money) { if (tr == BA.size()) return money; if (dp2[tr][money] != -1) return dp2[tr][money]; int m = money; ll profit = 0; if (tr == BA.size() - 1) { int puta = m / BA[tr].s; dp2[tr][money] = (ll)puta * BA[tr].s + m - BA[tr].s * puta; return dp2[tr][money]; } dp2[tr][money] = calc2(tr + 1, m); while (m >= BA[tr].s) { m -= BA[tr].s; profit += BA[tr].f; dp2[tr][money] = max(dp2[tr][money], profit + calc2(tr + 1, m)); } return dp2[tr][money]; } int main() { memset(dp1, -1, sizeof(dp1)); int n; scanf("%i", &n); int ga, sa, ba, gb, sb, bb; scanf("%i %i %i %i %i %i", &ga, &sa, &ba, &gb, &sb, &bb); if (ga > gb) BA.pb({ga, gb}); if (ga < gb) AB.pb({gb, ga}); if (sa > sb) BA.pb({sa, sb}); if (sa < sb) AB.pb({sb, sa}); if (ba > bb) BA.pb({ba, bb}); if (ba < bb) AB.pb({bb, ba}); int novo = calc1(0, n); dp2.resize((int)BA.size(), vector<ll>(novo + 1, -1)); printf("%lld\n", calc2(0, novo)); return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ll long long #define pb push_back #define sz(x) (int)(x).size() #define mp make_pair #define f first #define s second #define all(x) x.begin(), x.end() #define D(x) cerr << #x << " is " << (x) << "\n"; using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /// find_by_order(),order_of_key() template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { os << '{' << a.f << ", " << a.s << '}'; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &a) { os << '{'; for (int i = 0; i < sz(a); i++) { if (i > 0 && i < sz(a)) os << ", "; os << a[i]; } os << '}'; return os; } template <class T> ostream &operator<<(ostream &os, const set<T> &a) { os << '{'; int i = 0; for (auto p : a) { if (i > 0 && i < sz(a)) os << ", "; os << p; i++; } os << '}'; return os; } template <class T> ostream &operator<<(ostream &os, const multiset<T> &a) { os << '{'; int i = 0; for (auto p : a) { if (i > 0 && i < sz(a)) os << ", "; os << p; i++; } os << '}'; return os; } template <class T1, class T2> ostream &operator<<(ostream &os, const map<T1, T2> &a) { os << '{'; int i = 0; for (auto p : a) { if (i > 0 && i < sz(a)) os << ", "; os << p; i++; } os << '}'; return os; } vector<pair<int, int>> AB, BA; int dp1[3][5001]; vector<vector<ll>> dp2; int calc1(int tr, int money) { if (tr == AB.size()) return money; if (dp1[tr][money] != -1) return dp1[tr][money]; int m = money; int profit = 0; dp1[tr][money] = calc1(tr + 1, m); while (m >= AB[tr].s) { m -= AB[tr].s; profit += AB[tr].f; dp1[tr][money] = max(dp1[tr][money], profit + calc1(tr + 1, m)); } return dp1[tr][money]; } ll calc2(int tr, int money) { if (tr == BA.size()) return money; if (dp2[tr][money] != -1) return dp2[tr][money]; int m = money; ll profit = 0; if (tr == BA.size() - 1) { int puta = m / BA[tr].s; dp2[tr][money] = (ll)puta * BA[tr].f + m - BA[tr].s * puta; return dp2[tr][money]; } dp2[tr][money] = calc2(tr + 1, m); while (m >= BA[tr].s) { m -= BA[tr].s; profit += BA[tr].f; dp2[tr][money] = max(dp2[tr][money], profit + calc2(tr + 1, m)); } return dp2[tr][money]; } int main() { memset(dp1, -1, sizeof(dp1)); int n; scanf("%i", &n); int ga, sa, ba, gb, sb, bb; scanf("%i %i %i %i %i %i", &ga, &sa, &ba, &gb, &sb, &bb); if (ga > gb) BA.pb({ga, gb}); if (ga < gb) AB.pb({gb, ga}); if (sa > sb) BA.pb({sa, sb}); if (sa < sb) AB.pb({sb, sa}); if (ba > bb) BA.pb({ba, bb}); if (ba < bb) AB.pb({bb, ba}); int novo = calc1(0, n); dp2.resize((int)BA.size(), vector<ll>(novo + 1, -1)); printf("%lld\n", calc2(0, novo)); return 0; }
[ "assignment.value.change", "expression.operation.binary.change" ]
822,262
822,263
u013064880
cpp
p03008
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(3), b(3); for (int i = 0; i < 3; i++) cin >> a[i]; for (int i = 0; i < 3; i++) cin >> b[i]; vector<ll> dp(n + 1, -1); dp[0] = 0; for (int i = 0; i < 3; i++) { if (a[i] >= b[i]) continue; for (int j = 0; j <= n - a[i]; j++) { if (dp[j] < 0) continue; dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]); } } ll n2 = n; for (int i = 0; i <= n; i++) { n2 = max(n2, dp[i] + n - i); } vector<ll> dp2(n2 + 1, -1); dp2[0] = 0; for (int i = 0; i < 3; i++) { if (a[i] <= b[i]) continue; for (int j = 0; j <= n - b[i]; j++) { if (dp2[j] < 0) continue; dp2[j + b[i]] = max(dp2[j + b[i]], dp2[j] + a[i]); } } ll ans = n2; for (int i = 0; i <= n2; i++) { ans = max(ans, dp2[i] + n2 - i); } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(3), b(3); for (int i = 0; i < 3; i++) cin >> a[i]; for (int i = 0; i < 3; i++) cin >> b[i]; vector<ll> dp(n + 1, -1); dp[0] = 0; for (int i = 0; i < 3; i++) { if (a[i] >= b[i]) continue; for (ll j = 0; j <= n - a[i]; j++) { if (dp[j] < 0) continue; dp[j + a[i]] = max(dp[j + a[i]], dp[j] + b[i]); } } ll n2 = n; for (ll i = 0; i <= n; i++) { n2 = max(n2, dp[i] + n - i); } vector<ll> dp2(n2 + 1, -1); dp2[0] = 0; for (int i = 0; i < 3; i++) { if (a[i] <= b[i]) continue; for (ll j = 0; j <= n2 - b[i]; j++) { if (dp2[j] < 0) continue; dp2[j + b[i]] = max(dp2[j + b[i]], dp2[j] + a[i]); } } ll ans = n2; for (ll i = 0; i <= n2; i++) { ans = max(ans, dp2[i] + n2 - i); } cout << ans << "\n"; return 0; }
[ "control_flow.loop.for.initializer.change", "variable_declaration.type.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
822,474
822,475
u553623615
cpp
p03008
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, n) repl(i, 0, n) #define all(x) (x).begin(), (x).end() #define dbg(x) cout << #x "=" << x << endl #define mmax(x, y) (x > y ? x : y) #define mmin(x, y) (x < y ? x : y) #define maxch(x, y) x = mmax(x, y) #define minch(x, y) x = mmin(x, y) #define uni(x) x.erase(unique(all(x)), x.end()) #define exist(x, y) (find(all(x), y) != x.end()) #define bcnt __builtin_popcountll #define INF 1e16 #define mod 1000000007 ll n; ll g[2], s[2], b[2]; ll dp[30000000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; rep(i, 2) cin >> g[i] >> s[i] >> b[i]; rep(i, 2) { ll j = 1 - i; rep(k, n + 1) dp[k] = -INF; dp[0] = 0; rep(k, n + 1) { if (k - g[i] >= 0) maxch(dp[k], dp[k - g[i]] + max(g[i], g[j])); if (k - s[i] >= 0) maxch(dp[k], dp[k - s[i]] + max(s[i], s[j])); if (k - b[i] >= 0) maxch(dp[k], dp[k - b[i]] + max(b[i], b[j])); } ll nxt = dp[n]; n = nxt; } cout << n << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, n) repl(i, 0, n) #define all(x) (x).begin(), (x).end() #define dbg(x) cout << #x "=" << x << endl #define mmax(x, y) (x > y ? x : y) #define mmin(x, y) (x < y ? x : y) #define maxch(x, y) x = mmax(x, y) #define minch(x, y) x = mmin(x, y) #define uni(x) x.erase(unique(all(x)), x.end()) #define exist(x, y) (find(all(x), y) != x.end()) #define bcnt __builtin_popcountll #define INF 1e16 #define mod 1000000007 ll n; ll g[2], s[2], b[2]; ll dp[30000000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; rep(i, 2) cin >> g[i] >> s[i] >> b[i]; rep(i, 2) { ll j = 1 - i; rep(k, n + 1) dp[k] = k; dp[0] = 0; rep(k, n + 1) { if (k - g[i] >= 0) maxch(dp[k], dp[k - g[i]] + max(g[i], g[j])); if (k - s[i] >= 0) maxch(dp[k], dp[k - s[i]] + max(s[i], s[j])); if (k - b[i] >= 0) maxch(dp[k], dp[k - b[i]] + max(b[i], b[j])); } ll nxt = dp[n]; n = nxt; } cout << n << endl; return 0; }
[ "assignment.value.change", "expression.operation.unary.remove" ]
822,483
822,484
u762921614
cpp
p03008
#pragma GCC optimize(3) #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/priority_queue.hpp> #include <ext/pb_ds/tree_policy.hpp> #define MAXN 5005 #define INF 1000000000 #define MOD 1000000007 #define F first #define S second using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> P; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef __gnu_pbds::priority_queue<int, greater<int>, pairing_heap_tag> pq; ll n, dp[MAXN * MAXN]; int w[3][2]; vector<P> v1, v2; ll solve(ll n, vector<P> &v) { memset(dp, -1, sizeof(dp)); dp[n] = 0; for (int i = 0; i < (int)v.size(); i++) for (int j = n; j >= 0; j--) { if (dp[j] == -1) continue; if (j >= v[i].F) dp[j - v[i].F] = max(dp[j - v[i].F], dp[j] + v[i].S); } ll ans = 0; for (int i = 0; i <= n; i++) ans = max(ans, dp[i]); return n + ans; } int main() { scanf("%lld", &n); for (int i = 0; i < 3; i++) for (int j = 0; j < 2; j++) scanf("%d", &w[i][j]); for (int i = 0; i < 3; i++) { if (w[i][0] < w[i][1]) v1.push_back(P(w[i][0], w[i][1] - w[i][0])); else v2.push_back(P(w[i][1], w[i][0] - w[i][1])); } n = solve(n, v1); n = solve(n, v2); printf("%lld\n", n); return 0; }
#pragma GCC optimize(3) #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/priority_queue.hpp> #include <ext/pb_ds/tree_policy.hpp> #define MAXN 5005 #define INF 1000000000 #define MOD 1000000007 #define F first #define S second using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> P; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef __gnu_pbds::priority_queue<int, greater<int>, pairing_heap_tag> pq; ll n, dp[MAXN * MAXN]; int w[3][2]; vector<P> v1, v2; ll solve(ll n, vector<P> &v) { memset(dp, -1, sizeof(dp)); dp[n] = 0; for (int i = 0; i < (int)v.size(); i++) for (int j = n; j >= 0; j--) { if (dp[j] == -1) continue; if (j >= v[i].F) dp[j - v[i].F] = max(dp[j - v[i].F], dp[j] + v[i].S); } ll ans = 0; for (int i = 0; i <= n; i++) ans = max(ans, dp[i]); return n + ans; } int main() { scanf("%lld", &n); for (int i = 0; i < 2; i++) for (int j = 0; j < 3; j++) scanf("%d", &w[j][i]); for (int i = 0; i < 3; i++) { if (w[i][0] < w[i][1]) v1.push_back(P(w[i][0], w[i][1] - w[i][0])); else v2.push_back(P(w[i][1], w[i][0] - w[i][1])); } n = solve(n, v1); n = solve(n, v2); printf("%lld\n", n); return 0; }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "identifier.change", "variable_access.subscript.index.change", "call.arguments.change" ]
822,491
822,492
u237254894
cpp
p03008
#include <bits/stdc++.h> #define pa pair<int, int> #define CLR(a, x) memset(a, x, sizeof(a)) #define MP make_pair #define fi first #define se second using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef long double ld; const int maxn = 25e6 + 10; inline char gc() { return getchar(); static const int maxs = 1 << 16; static char buf[maxs], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, maxs, stdin), p1 == p2) ? EOF : *p1++; } inline ll rd() { ll x = 0; char c = gc(); bool neg = 0; while (c < '0' || c > '9') { if (c == '-') neg = 1; c = gc(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = gc(); return neg ? (~x + 1) : x; } int N, a[2][3]; int f[maxn]; int main() { // freopen("","r",stdin); N = rd(); for (int i = 0; i <= 1; i++) for (int j = 0; j <= 2; j++) a[i][j] = rd(); for (int i = 1; i <= N; i++) { f[i] = f[i - 1] + 1; for (int j = 0; j <= 2; j++) { if (i >= a[0][j]) f[i] = max(f[i], f[i - a[0][j]] + a[1][j]); } } int now = f[N]; CLR(f, 0); for (int i = 1; i <= now; i++) { f[i] = f[i - 1] + 1; for (int j = 0; j <= 2; j++) { if (i >= a[0][j]) f[i] = max(f[i], f[i - a[1][j]] + a[0][j]); } } printf("%d\n", f[now]); return 0; }
#include <bits/stdc++.h> #define pa pair<int, int> #define CLR(a, x) memset(a, x, sizeof(a)) #define MP make_pair #define fi first #define se second using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef long double ld; const int maxn = 25e6 + 10; inline char gc() { return getchar(); static const int maxs = 1 << 16; static char buf[maxs], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, maxs, stdin), p1 == p2) ? EOF : *p1++; } inline ll rd() { ll x = 0; char c = gc(); bool neg = 0; while (c < '0' || c > '9') { if (c == '-') neg = 1; c = gc(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = gc(); return neg ? (~x + 1) : x; } int N, a[2][3]; ll f[maxn]; int main() { // freopen("","r",stdin); N = rd(); for (int i = 0; i <= 1; i++) for (int j = 0; j <= 2; j++) a[i][j] = rd(); for (int i = 1; i <= N; i++) { f[i] = f[i - 1] + 1; for (int j = 0; j <= 2; j++) { if (i >= a[0][j]) f[i] = max(f[i], f[i - a[0][j]] + a[1][j]); } } int now = f[N]; CLR(f, 0); for (int i = 1; i <= now; i++) { f[i] = f[i - 1] + 1; for (int j = 0; j <= 2; j++) { if (i >= a[1][j]) f[i] = max(f[i], f[i - a[1][j]] + a[0][j]); } } printf("%lld\n", f[now]); return 0; }
[ "variable_declaration.type.change", "literal.number.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
822,493
822,494
u371295315
cpp
p03008
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; long long n, ga, sa, ba, gb, sb, bb, w, id[4], dp[25555555]; long long trans(long long n, int ga, int sa, int ba, int gb, int sb, int bb) { memset(dp, 0, sizeof(dp)); for (int i = 1; i <= n; i++) { if (i >= ga) dp[i] = max(dp[i], dp[i - ga] + gb); if (i >= sa) dp[i] = max(dp[i], dp[i - sa] + sb); if (i >= ba) dp[i] = max(dp[i], dp[i - ba] + bb); } long long ans = 0; for (int i = 1; i <= n; i++) ans = max(ans, n - i + dp[i]); return ans; } int main() { cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; w = trans(n, ga, sa, ba, gb, sb, bb); n = trans(w, gb, sb, bb, ga, sa, ba); printf("%lld\n", n); return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; long long n, ga, sa, ba, gb, sb, bb, w, id[4], dp[25555555]; long long trans(long long n, int ga, int sa, int ba, int gb, int sb, int bb) { memset(dp, 0, sizeof(dp)); for (int i = 1; i <= n; i++) { if (i >= ga) dp[i] = max(dp[i], dp[i - ga] + gb); if (i >= sa) dp[i] = max(dp[i], dp[i - sa] + sb); if (i >= ba) dp[i] = max(dp[i], dp[i - ba] + bb); } long long ans = 0; for (int i = 0; i <= n; i++) ans = max(ans, n - i + dp[i]); return ans; } int main() { cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; w = trans(n, ga, sa, ba, gb, sb, bb); n = trans(w, gb, sb, bb, ga, sa, ba); printf("%lld\n", n); return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
822,499
822,500
u900309151
cpp
p03008
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; long long n, ga, sa, ba, gb, sb, bb, w, id[4], dp[25555555]; long long trans(long long n, int ga, int sa, int ba, int gb, int sb, int bb) { memset(dp, 0, sizeof(dp)); for (int i = 1; i <= n; i++) { if (i >= ga) dp[i] = max(dp[i], dp[i - ga] + gb); if (i >= sa) dp[i] = max(dp[i], dp[i - sa] + sb); if (i >= ba) dp[i] = max(dp[i], dp[i - ba] + bb); } long long ans = 0; for (int i = 1; i <= n; i++) ans = max(ans, n - i + dp[i]); } int main() { cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; w = trans(n, ga, sa, ba, gb, sb, bb); n = trans(w, gb, sb, bb, ga, sa, ba); printf("%lld\n", n); return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; long long n, ga, sa, ba, gb, sb, bb, w, id[4], dp[25555555]; long long trans(long long n, int ga, int sa, int ba, int gb, int sb, int bb) { memset(dp, 0, sizeof(dp)); for (int i = 1; i <= n; i++) { if (i >= ga) dp[i] = max(dp[i], dp[i - ga] + gb); if (i >= sa) dp[i] = max(dp[i], dp[i - sa] + sb); if (i >= ba) dp[i] = max(dp[i], dp[i - ba] + bb); } long long ans = 0; for (int i = 0; i <= n; i++) ans = max(ans, n - i + dp[i]); return ans; } int main() { cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; w = trans(n, ga, sa, ba, gb, sb, bb); n = trans(w, gb, sb, bb, ga, sa, ba); printf("%lld\n", n); return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "control_flow.return.add" ]
822,501
822,500
u900309151
cpp
p03008
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() typedef pair<ll, ll> P; const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; // priority_queue<ll> max;//大きい順 // priority_queue<ll, Array, greater<ll>> min;//小さい順 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; } // substr 文字列取り出し // upper_bound // ある値より大きい一番左のイテレータを返す、lowerは以上(setに対して使うとO(N)なので、setのメンバ関数を使う // stoi struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag) G[to].push_back(Edge( from, revCap, (ll)G[from].size() - 1)); //最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } //二分グラフの最大マッチングを求めたりも出来る また二部グラフの最大独立集合は頂点数-最大マッチングのサイズ ll max_flow(Graph &G, ll s, ll t) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } void BellmanFord(Graph &G, ll s, Array &d, Array &negative) { // O(|E||V|) d.resize(G.size()); negative.resize(G.size()); REP(i, d.size()) d[i] = INF; REP(i, d.size()) negative[i] = false; d[s] = 0; REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; } } } } REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; negative[G[i][j].to] = true; } if (negative[i] == true) negative[G[i][j].to] = true; } } } } void Dijkstra(Graph &G, ll s, Array &d) { // O(|E|log|V|) d.resize(G.size()); REP(i, d.size()) d[i] = INF; d[s] = 0; priority_queue<P, vector<P>, greater<P>> q; q.push(make_pair(0, s)); while (!q.empty()) { P a = q.top(); q.pop(); if (d[a.second] < a.first) continue; REP(i, G[a.second].size()) { Edge e = G[a.second][i]; if (d[e.to] > d[a.second] + e.cap) { d[e.to] = d[a.second] + e.cap; q.push(make_pair(d[e.to], e.to)); } } } } void WarshallFloyd(Graph &G, Matrix &d) { // O(V^3) d.resize(G.size()); REP(i, d.size()) d[i].resize(G.size()); REP(i, d.size()) { REP(j, d[i].size()) { d[i][j] = INF; } } REP(i, G.size()) { REP(j, G[i].size()) { d[i][G[i][j].to] = G[i][j].cap; } } REP(i, G.size()) { REP(j, G.size()) { REP(k, G.size()) { chmin(d[j][k], d[j][i] + d[i][k]); } } } } class UnionFind { vector<int> data; ll num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(int x, int y) { // xとyの集合を統合する x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } num -= (x != y); return x != y; } bool findSet(int x, int y) { // xとyが同じ集合か返す return root(x) == root(y); } int root(int x) { // xのルートを返す return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { // xの集合のサイズを返す return -data[root(x)]; } int numSet() { //集合の数を返す return num; } }; class SumSegTree { private: int _sum(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return 0; // 交差しない if (a <= l && r <= b) return dat[k]; // a,l,r,bの順で完全に含まれる else { int s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 int s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return s1 + s2; } } public: int n, height; vector<int> dat; // 初期化(_nは最大要素数) SumSegTree(int _n) { n = 1; height = 1; while (n < _n) { n *= 2; height++; } dat = vector<int>(2 * n - 1); } // 場所i(0-indexed)にxを足す void add(int i, int x) { i += n - 1; // i番目の葉ノードへ dat[i] += x; while (i > 0) { // 下から上がっていく i = (i - 1) / 2; dat[i] += x; } } // 区間[a,b)の総和。ノードk=[l,r)に着目している。 int sum(int a, int b) { return _sum(a, b, 0, 0, n); } }; //約数求める //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); } vector<ll> lis_fast(const vector<ll> &a) { //最長部分増加列 const ll n = a.size(); vector<ll> A(n, INT_MAX); vector<ll> id(n); for (int i = 0; i < n; ++i) { id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i])); A[id[i]] = a[i]; } ll m = *max_element(id.begin(), id.end()); vector<ll> b(m + 1); for (int i = n - 1; i >= 0; --i) if (id[i] == m) b[m--] = a[i]; return b; } ll ModPow(ll x, ll n) { ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } // nCrとか class Combination { public: Array fact; Array inv; ll mod; ll mod_inv(ll x) { ll n = mod - 2LL; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } }; bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) { //降順second if (a.second != b.second) { return a.second < b.second; } else { return a.first > b.first; } } bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) { //降順first if (a.first != b.first) { return a.first > b.first; } else { return a.second > b.second; } } ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } Matrix mIdentity(ll n) { Matrix A(n, Array(n)); for (int i = 0; i < n; ++i) A[i][i] = 1; return A; } Matrix mMul(const Matrix &A, const Matrix &B) { Matrix C(A.size(), Array(B[0].size())); for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[i].size(); ++j) for (int k = 0; k < A[i].size(); ++k) (C[i][j] += (A[i][k] % MOD) * (B[k][j] % MOD)) %= MOD; return C; } // O( n^3 log e ) Matrix mPow(const Matrix &A, ll e) { return e == 0 ? mIdentity(A.size()) : e % 2 == 0 ? mPow(mMul(A, A), e / 2) : mMul(A, mPow(A, e - 1)); } ll dp1[5001]; ll dp2[25000001]; int main() { ll n; cin >> n; ll ga, sa, ba; cin >> ga >> sa >> ba; ll gb, sb, bb; cin >> gb >> sb >> bb; REP(i, n + 1) { if (i - ga >= 0) { chmax(dp1[i], dp1[i - ga] + gb - ga); } if (i - sa >= 0) { chmax(dp1[i], dp1[i - sa] + sb - sa); } if (i - ba >= 0) { chmax(dp1[i], dp1[i - ba] + bb - ba); } } REP(i, dp1[n] + n + 1) { if (i - gb >= 0) { chmax(dp2[i], dp2[i - gb] + ga - gb); } if (i - sb >= 0) { chmax(dp2[i], dp2[i - sb] + sa - sb); } if (i - ba >= 0) { chmax(dp2[i], dp2[i - ba] + ba - bb); } } cout << dp2[dp1[n] + n] + dp1[n] + n; return 0; }
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() typedef pair<ll, ll> P; const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; // priority_queue<ll> max;//大きい順 // priority_queue<ll, Array, greater<ll>> min;//小さい順 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; } // substr 文字列取り出し // upper_bound // ある値より大きい一番左のイテレータを返す、lowerは以上(setに対して使うとO(N)なので、setのメンバ関数を使う // stoi struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag) G[to].push_back(Edge( from, revCap, (ll)G[from].size() - 1)); //最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } //二分グラフの最大マッチングを求めたりも出来る また二部グラフの最大独立集合は頂点数-最大マッチングのサイズ ll max_flow(Graph &G, ll s, ll t) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } void BellmanFord(Graph &G, ll s, Array &d, Array &negative) { // O(|E||V|) d.resize(G.size()); negative.resize(G.size()); REP(i, d.size()) d[i] = INF; REP(i, d.size()) negative[i] = false; d[s] = 0; REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; } } } } REP(k, G.size() - 2) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; negative[G[i][j].to] = true; } if (negative[i] == true) negative[G[i][j].to] = true; } } } } void Dijkstra(Graph &G, ll s, Array &d) { // O(|E|log|V|) d.resize(G.size()); REP(i, d.size()) d[i] = INF; d[s] = 0; priority_queue<P, vector<P>, greater<P>> q; q.push(make_pair(0, s)); while (!q.empty()) { P a = q.top(); q.pop(); if (d[a.second] < a.first) continue; REP(i, G[a.second].size()) { Edge e = G[a.second][i]; if (d[e.to] > d[a.second] + e.cap) { d[e.to] = d[a.second] + e.cap; q.push(make_pair(d[e.to], e.to)); } } } } void WarshallFloyd(Graph &G, Matrix &d) { // O(V^3) d.resize(G.size()); REP(i, d.size()) d[i].resize(G.size()); REP(i, d.size()) { REP(j, d[i].size()) { d[i][j] = INF; } } REP(i, G.size()) { REP(j, G[i].size()) { d[i][G[i][j].to] = G[i][j].cap; } } REP(i, G.size()) { REP(j, G.size()) { REP(k, G.size()) { chmin(d[j][k], d[j][i] + d[i][k]); } } } } class UnionFind { vector<int> data; ll num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(int x, int y) { // xとyの集合を統合する x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } num -= (x != y); return x != y; } bool findSet(int x, int y) { // xとyが同じ集合か返す return root(x) == root(y); } int root(int x) { // xのルートを返す return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { // xの集合のサイズを返す return -data[root(x)]; } int numSet() { //集合の数を返す return num; } }; class SumSegTree { private: int _sum(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return 0; // 交差しない if (a <= l && r <= b) return dat[k]; // a,l,r,bの順で完全に含まれる else { int s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 int s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 return s1 + s2; } } public: int n, height; vector<int> dat; // 初期化(_nは最大要素数) SumSegTree(int _n) { n = 1; height = 1; while (n < _n) { n *= 2; height++; } dat = vector<int>(2 * n - 1); } // 場所i(0-indexed)にxを足す void add(int i, int x) { i += n - 1; // i番目の葉ノードへ dat[i] += x; while (i > 0) { // 下から上がっていく i = (i - 1) / 2; dat[i] += x; } } // 区間[a,b)の総和。ノードk=[l,r)に着目している。 int sum(int a, int b) { return _sum(a, b, 0, 0, n); } }; //約数求める //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); } vector<ll> lis_fast(const vector<ll> &a) { //最長部分増加列 const ll n = a.size(); vector<ll> A(n, INT_MAX); vector<ll> id(n); for (int i = 0; i < n; ++i) { id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i])); A[id[i]] = a[i]; } ll m = *max_element(id.begin(), id.end()); vector<ll> b(m + 1); for (int i = n - 1; i >= 0; --i) if (id[i] == m) b[m--] = a[i]; return b; } ll ModPow(ll x, ll n) { ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1; } return res; } // nCrとか class Combination { public: Array fact; Array inv; ll mod; ll mod_inv(ll x) { ll n = mod - 2LL; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } }; bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) { //降順second if (a.second != b.second) { return a.second < b.second; } else { return a.first > b.first; } } bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) { //降順first if (a.first != b.first) { return a.first > b.first; } else { return a.second > b.second; } } ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } Matrix mIdentity(ll n) { Matrix A(n, Array(n)); for (int i = 0; i < n; ++i) A[i][i] = 1; return A; } Matrix mMul(const Matrix &A, const Matrix &B) { Matrix C(A.size(), Array(B[0].size())); for (int i = 0; i < C.size(); ++i) for (int j = 0; j < C[i].size(); ++j) for (int k = 0; k < A[i].size(); ++k) (C[i][j] += (A[i][k] % MOD) * (B[k][j] % MOD)) %= MOD; return C; } // O( n^3 log e ) Matrix mPow(const Matrix &A, ll e) { return e == 0 ? mIdentity(A.size()) : e % 2 == 0 ? mPow(mMul(A, A), e / 2) : mMul(A, mPow(A, e - 1)); } ll dp1[5001]; ll dp2[25000001]; int main() { ll n; cin >> n; ll ga, sa, ba; cin >> ga >> sa >> ba; ll gb, sb, bb; cin >> gb >> sb >> bb; REP(i, n + 1) { if (i - ga >= 0) { chmax(dp1[i], dp1[i - ga] + gb - ga); } if (i - sa >= 0) { chmax(dp1[i], dp1[i - sa] + sb - sa); } if (i - ba >= 0) { chmax(dp1[i], dp1[i - ba] + bb - ba); } } REP(i, dp1[n] + n + 1) { if (i - gb >= 0) { chmax(dp2[i], dp2[i - gb] + ga - gb); } if (i - sb >= 0) { chmax(dp2[i], dp2[i - sb] + sa - sb); } if (i - bb >= 0) { chmax(dp2[i], dp2[i - bb] + ba - bb); } } cout << dp2[dp1[n] + n] + dp1[n] + n; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
822,506
822,507
u051493691
cpp
p03008
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using ld = double; using P = pair<ll, ll>; using T = tuple<ll, ll, ll, ll>; const ll INF = 1e17; const ld eps = 1e-10; const ll MOD = 1e9 + 7; const double pi = acos(-1.0); int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<ll> a(3); vector<ll> b(3); for (int i = 0; i < 3; i++) cin >> a[i]; for (int i = 0; i < 3; i++) cin >> b[i]; vector<P> v; for (int i = 0; i < 3; i++) { if (a[i] < b[i]) v.push_back(P(a[i], b[i])); } ll big = N; if (v.size() > 0) { vector<ll> num; ll rest = N; if (v.size() == 1) { num.push_back(N / v[0].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int i = 0; i * v[0].first < N; i++) { num.push_back(i); rest = N - i * v[0].first; if (v.size() == 2) { num.push_back(rest / v[1].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int j = 0; j * v[1].first < N - i * v[0].first; j++) { num.push_back(j); rest = N - i * v[0].first - j * v[1].first; num.push_back(rest / v[2].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); num.pop_back(); } } num.pop_back(); } } } N = big; v.clear(); for (int i = 0; i < 3; i++) { if (a[i] > b[i]) v.push_back(P(b[i], a[i])); } if (v.size() > 0) { vector<ll> num; ll rest = N; if (v.size() == 1) { num.push_back(N / v[0].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int i = 0; i * v[0].first < N; i++) { num.push_back(i); rest = N - i * v[0].first; if (v.size() == 2) { num.push_back(rest / v[1].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int j = 0; j * v[1].first < N - i * v[0].first; j++) { num.push_back(j); rest = N - i * v[0].first - j * v[1].first; num.push_back(rest / v[2].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); num.pop_back(); } } num.pop_back(); } } } cout << big << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using ld = double; using P = pair<ll, ll>; using T = tuple<ll, ll, ll, ll>; const ll INF = 1e17; const ld eps = 1e-10; const ll MOD = 1e9 + 7; const double pi = acos(-1.0); int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; vector<ll> a(3); vector<ll> b(3); for (int i = 0; i < 3; i++) cin >> a[i]; for (int i = 0; i < 3; i++) cin >> b[i]; vector<P> v; for (int i = 0; i < 3; i++) { if (a[i] < b[i]) v.push_back(P(a[i], b[i])); } ll big = N; if (v.size() > 0) { vector<ll> num; ll rest = N; if (v.size() == 1) { num.push_back(N / v[0].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int i = 0; i * v[0].first <= N; i++) { num.push_back(i); rest = N - i * v[0].first; if (v.size() == 2) { num.push_back(rest / v[1].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int j = 0; j * v[1].first <= N - i * v[0].first; j++) { num.push_back(j); rest = N - i * v[0].first - j * v[1].first; num.push_back(rest / v[2].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); num.pop_back(); } } num.pop_back(); } } } N = big; v.clear(); for (int i = 0; i < 3; i++) { if (a[i] > b[i]) v.push_back(P(b[i], a[i])); } if (v.size() > 0) { vector<ll> num; ll rest = N; if (v.size() == 1) { num.push_back(N / v[0].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int i = 0; i * v[0].first <= N; i++) { num.push_back(i); rest = N - i * v[0].first; if (v.size() == 2) { num.push_back(rest / v[1].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); } else { for (int j = 0; j * v[1].first <= N - i * v[0].first; j++) { num.push_back(j); rest = N - i * v[0].first - j * v[1].first; num.push_back(rest / v[2].first); ll tmp = N; for (int k = 0; k < num.size(); k++) tmp += num[k] * (v[k].second - v[k].first); big = max(big, tmp); num.pop_back(); num.pop_back(); } } num.pop_back(); } } } cout << big << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,508
822,509
u287305727
cpp
p03008
#include <algorithm> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define int long long #define vel vector<long long> #define vvel vector<vel> #define rep(i, n) for (long long i = 0; i < n; i++) #define rp(i, n) for (long long i = 1; i < n; i++) #define sor(v) sort(v.begin(), v.end()) #define mmax(a, b) a = max(a, b) #define mmin(a, b) a = min(a, b) #define mkp make_pair #define pin pair<int, int> #define V vector long long p = 1000000007; vel rui(19, 1); vel kai(1000007, 1); vel ink(1000007, 1); vel par; int root(int ser) { if (par[ser] == -1) { return ser; } int ans = root(par[ser]); par[ser] = ans; return ans; } bool marge(pin a) { int x = root(a.first); int y = root(a.second); if (x != y) { par[x] = y; } return x != y; } int gcd(int a, int b) { if (a < b) { swap(a, b); } if (b == 0) { return a; } return gcd(b, a % b); } int ru(int a, int r) { if (r == 0) { return 1; } int ans = ru(a, r / 2); ans *= ans; ans %= p; if (r % 2 == 1) { ans *= a; ans %= p; } return ans; } int inv(int a) { return ru(a, p - 2); } void make_kai() { rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; } rep(i, 1000007) { ink[i] = inv(kai[i]); } } int com(int n, int r) { int ans = kai[n] * ink[r]; ans %= p; return ans; } int nap(int n, vel napw, vel napv) { if (napw.size() == 0) { return 0; } if (napw.size() == 1) { return (n / napw[0]) * napv[0]; } if (napw.size() == 2) { int ans = 0; int lim = n / napw[0]; rep(c0, lim) { int c1 = (n - c0 * napw[0]) / napw[1]; mmax(ans, c0 * napv[0] + c1 * napv[1]); } return ans; } int ans = 0; int ex; int lim = n / napw[0]; int nlim; rep(c0, lim) { ex = n - c0 * napw[0]; nlim = ex / napw[1]; rep(c1, nlim) { int c2 = (ex - c1 * napw[1]) / napw[2]; mmax(ans, c0 * napv[0] + c1 * napv[1] + c2 * napv[2]); } } return ans; } signed main() { int n; cin >> n; vvel w(2, vel(3)); rep(i, 3) { cin >> w[0][i]; } rep(i, 3) { cin >> w[1][i]; } rep(i, 2) { vel napv(0), napw(0); rep(j, 3) { int now_w = w[i][j]; int pre_w = w[(i + 1) % 2][j]; if (now_w < pre_w) { napw.push_back(now_w); napv.push_back(pre_w - now_w); } } n += nap(n, napw, napv); } cout << n << endl; return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define int long long #define vel vector<long long> #define vvel vector<vel> #define rep(i, n) for (long long i = 0; i < n; i++) #define rp(i, n) for (long long i = 1; i < n; i++) #define sor(v) sort(v.begin(), v.end()) #define mmax(a, b) a = max(a, b) #define mmin(a, b) a = min(a, b) #define mkp make_pair #define pin pair<int, int> #define V vector long long p = 1000000007; vel rui(19, 1); vel kai(1000007, 1); vel ink(1000007, 1); vel par; int root(int ser) { if (par[ser] == -1) { return ser; } int ans = root(par[ser]); par[ser] = ans; return ans; } bool marge(pin a) { int x = root(a.first); int y = root(a.second); if (x != y) { par[x] = y; } return x != y; } int gcd(int a, int b) { if (a < b) { swap(a, b); } if (b == 0) { return a; } return gcd(b, a % b); } int ru(int a, int r) { if (r == 0) { return 1; } int ans = ru(a, r / 2); ans *= ans; ans %= p; if (r % 2 == 1) { ans *= a; ans %= p; } return ans; } int inv(int a) { return ru(a, p - 2); } void make_kai() { rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; } rep(i, 1000007) { ink[i] = inv(kai[i]); } } int com(int n, int r) { int ans = kai[n] * ink[r]; ans %= p; return ans; } int nap(int n, vel napw, vel napv) { if (napw.size() == 0) { return 0; } if (napw.size() == 1) { return (n / napw[0]) * napv[0]; } if (napw.size() == 2) { int ans = 0; int lim = n / napw[0]; rep(c0, lim + 1) { int c1 = (n - c0 * napw[0]) / napw[1]; mmax(ans, c0 * napv[0] + c1 * napv[1]); } return ans; } int ans = 0; int ex; int lim = n / napw[0]; int nlim; rep(c0, lim + 1) { ex = n - c0 * napw[0]; nlim = ex / napw[1]; rep(c1, nlim + 1) { int c2 = (ex - c1 * napw[1]) / napw[2]; mmax(ans, c0 * napv[0] + c1 * napv[1] + c2 * napv[2]); } } return ans; } signed main() { int n; cin >> n; vvel w(2, vel(3)); rep(i, 3) { cin >> w[0][i]; } rep(i, 3) { cin >> w[1][i]; } rep(i, 2) { vel napv(0), napw(0); rep(j, 3) { int now_w = w[i][j]; int pre_w = w[(i + 1) % 2][j]; if (now_w < pre_w) { napw.push_back(now_w); napv.push_back(pre_w - now_w); } } n += nap(n, napw, napv); } cout << n << endl; return 0; }
[ "expression.operation.binary.add" ]
822,514
822,515
u021034020
cpp
p03008
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1); #define FOR(i, a, b) for (ll i = (a), __last_##i = (b); i < __last_##i; i++) #define RFOR(i, a, b) for (ll i = (b)-1, __last_##i = (a); i >= __last_##i; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME #define each(i, a) for (auto &&i : a) #define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__) #define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__) #define pb push_back #define eb emplace_back #define all(a) begin(a), end(a) #define chmin(x, v) x = min(x, v) #define chmax(x, v) x = max(x, v) template <typename T> ll min(ll a, const T &&b) { return a < b ? a : b; } template <typename T> ll min(const T &&a, ll b) { return a < b ? a : b; } template <typename T> ll max(ll a, const T &&b) { return a > b ? a : b; } template <typename T> ll max(const T &&a, ll b) { return a > b ? a : b; } template <typename Head> void out(Head h) { cout << h << endl; } template <typename Head, typename... Tail> void out(Head h, Tail... t) { cout << h << " "; out(t...); } template <typename T> istream &operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << " "; os << v[i]; } return os; } ostream &operator<<(ostream &os, const vector<string> &v) { rep(i, v.size()) { if (i) os << endl; os << v[i]; } return os; } template <typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { rep(i, v.size()) { if (i) os << endl; os << v[i]; } return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << "(" << p.first << ", " << p.second << ")"; } struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } }; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha; solve(); } // ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^ ll f(ll x, P &p) { ll use = x / p.first; return x + use * p.second; } ll solve(ll x, const vector<ll> &a, const vector<ll> &b) { vector<P> v; rep(i, 3) if (a[i] < b[i]) { v.eb(a[i], b[i] - a[i]); } if (v.size() == 0) { return x; } else if (v.size() == 1) { return f(x, v[0]); } else if (v.size() == 2) { ll res = x; rep(i, x + 1) { ll rest = x - i * v[0].first; if (rest < 0) break; chmax(res, (x - rest) + i * v[0].first + f(rest, v[1])); } return res; } else if (v.size() == 3) { ll res = x; rep(i, x + 1) rep(j, x + 1) { ll rest = x - i * v[0].first - j * v[1].first; if (rest < 0) break; chmax(res, (x - rest) + i * v[0].second + j * v[1].second + f(rest, v[2])); } return res; } assert(false); } void solve() { ll n; cin >> n; vector<vector<ll>> a(2, vector<ll>(3)); cin >> a; n = solve(n, a[0], a[1]); n = solve(n, a[1], a[0]); cout << n << endl; }
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1); #define FOR(i, a, b) for (ll i = (a), __last_##i = (b); i < __last_##i; i++) #define RFOR(i, a, b) for (ll i = (b)-1, __last_##i = (a); i >= __last_##i; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME #define each(i, a) for (auto &&i : a) #define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__) #define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__) #define pb push_back #define eb emplace_back #define all(a) begin(a), end(a) #define chmin(x, v) x = min(x, v) #define chmax(x, v) x = max(x, v) template <typename T> ll min(ll a, const T &&b) { return a < b ? a : b; } template <typename T> ll min(const T &&a, ll b) { return a < b ? a : b; } template <typename T> ll max(ll a, const T &&b) { return a > b ? a : b; } template <typename T> ll max(const T &&a, ll b) { return a > b ? a : b; } template <typename Head> void out(Head h) { cout << h << endl; } template <typename Head, typename... Tail> void out(Head h, Tail... t) { cout << h << " "; out(t...); } template <typename T> istream &operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << " "; os << v[i]; } return os; } ostream &operator<<(ostream &os, const vector<string> &v) { rep(i, v.size()) { if (i) os << endl; os << v[i]; } return os; } template <typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { rep(i, v.size()) { if (i) os << endl; os << v[i]; } return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << "(" << p.first << ", " << p.second << ")"; } struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } }; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha; solve(); } // ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^ ll f(ll x, P &p) { ll use = x / p.first; return x + use * p.second; } ll solve(ll x, const vector<ll> &a, const vector<ll> &b) { vector<P> v; rep(i, 3) if (a[i] < b[i]) { v.eb(a[i], b[i] - a[i]); } if (v.size() == 0) { return x; } else if (v.size() == 1) { return f(x, v[0]); } else if (v.size() == 2) { ll res = x; rep(i, x + 1) { ll rest = x - i * v[0].first; if (rest < 0) break; chmax(res, (x - rest) + i * v[0].second + f(rest, v[1])); } return res; } else if (v.size() == 3) { ll res = x; rep(i, x + 1) rep(j, x + 1) { ll rest = x - i * v[0].first - j * v[1].first; if (rest < 0) break; chmax(res, (x - rest) + i * v[0].second + j * v[1].second + f(rest, v[2])); } return res; } assert(false); } void solve() { ll n; cin >> n; vector<vector<ll>> a(2, vector<ll>(3)); cin >> a; n = solve(n, a[0], a[1]); // cout << n << endl; n = solve(n, a[1], a[0]); cout << n << endl; }
[ "call.arguments.change", "expression.operation.binary.change" ]
822,517
822,518
u518019145
cpp
p03008
// https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_d /*<head>*/ // #include "Template.hpp" /*</head>*/ /*<body>*/ /* #region header */ /* #region 1*/ /** * @file Template.hpp * @brief 競技プログラミング用テンプレート * @author btk15049 * @date 2019/05/02 */ #include <bits/stdc++.h> using namespace std; /* #region macro */ #ifdef BTK #define DEBUG if (1) #define CIN_ONLY if (0) #else #define DEBUG if (0) #define CIN_ONLY if (1) #endif /** @def * ALLマクロ */ #define ALL(v) (v).begin(), (v).end() /** @def * 再帰ラムダをするためのマクロ */ #define REC(ret, ...) std::function<ret(__VA_ARGS__)> /* #endregion */ namespace _Template_ { /** * @brief cin高速化処理を行うための構造体 * @details CIN_ONLYマクロで動作が変わる */ struct cww { cww() { CIN_ONLY { ios::sync_with_stdio(false); cin.tie(0); } } } star; /** * @brief change min * @tparam T 型 * @param l 参照 * @param r 非参照 * @return 更新があればtrue */ template <typename T> inline bool chmin(T &l, T r) { bool a = l > r; if (a) l = r; return a; } /** * @brief chminのmax版 * @see chmin */ template <typename T> inline bool chmax(T &l, T r) { bool a = l < r; if (a) l = r; return a; } /** * @brief * vectorに直接cin流すためのやつ * @tparam T * @param is * @param v * @return istream& */ template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &it : v) is >> it; return is; } /** * @brief * rangeを逆向きに操作したいとき用 * @details * ループの範囲は[bg,ed)なので注意 * @see range */ class reverse_range { private: struct I { int x; int operator*() { return x - 1; } bool operator!=(I &lhs) { return x > lhs.x; } void operator++() { --x; } }; I i, n; public: reverse_range(int n) : i({0}), n({n}) {} reverse_range(int i, int n) : i({i}), n({n}) {} I &begin() { return n; } I &end() { return i; } }; /** * @brief * python みたいな range-based for を実現 * @details * ループの範囲は[bg,ed)なので注意 * !つけると逆向きにループが回る (reverse_range) * 空間計算量はO(1) * 使わない変数ができて警告が出がちなので,unused_varとかを使って警告消しするとよい */ class range { private: struct I { int x; int operator*() { return x; } bool operator!=(I &lhs) { return x < lhs.x; } void operator++() { ++x; } }; I i, n; public: range(int n) : i({0}), n({n}) {} range(int i, int n) : i({i}), n({n}) {} I &begin() { return i; } I &end() { return n; } reverse_range operator!() { return reverse_range(*i, *n); } }; /** * @brief * rangeで生まれる使わない変数を消す用(警告消し) */ template <typename T> inline T &unused_var(T &v) { return v; } using LL = long long; } // namespace _Template_ using namespace _Template_; /* #endregion */ /* #endregion */ /*</body>*/ constexpr int sz = 5123 * 5123; LL dp[sz]; int main() { LL N; cin >> N; vector<LL> A(3), B(3); cin >> A >> B; { for (int i : range(3)) { for (int j : range(A[i], N + 1)) { chmax(dp[j], dp[j - A[i]] + B[i]); } } LL NN = N; for (int i : range(N + 1)) chmax(NN, dp[i] + (N - i)); N = NN; } swap(A, B); fill(dp, dp + N + 1, 0ll); { for (int i : range(3)) { for (int j : range(A[i], N + 1)) { chmax(dp[j], dp[j - A[i]] + B[i]); } } LL NN = N; for (int i : range(N + 1)) chmax(N, dp[i] + (N - i)); N = NN; } cout << N << endl; return 0; }
// https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_d /*<head>*/ // #include "Template.hpp" /*</head>*/ /*<body>*/ /* #region header */ /* #region 1*/ /** * @file Template.hpp * @brief 競技プログラミング用テンプレート * @author btk15049 * @date 2019/05/02 */ #include <bits/stdc++.h> using namespace std; /* #region macro */ #ifdef BTK #define DEBUG if (1) #define CIN_ONLY if (0) #else #define DEBUG if (0) #define CIN_ONLY if (1) #endif /** @def * ALLマクロ */ #define ALL(v) (v).begin(), (v).end() /** @def * 再帰ラムダをするためのマクロ */ #define REC(ret, ...) std::function<ret(__VA_ARGS__)> /* #endregion */ namespace _Template_ { /** * @brief cin高速化処理を行うための構造体 * @details CIN_ONLYマクロで動作が変わる */ struct cww { cww() { CIN_ONLY { ios::sync_with_stdio(false); cin.tie(0); } } } star; /** * @brief change min * @tparam T 型 * @param l 参照 * @param r 非参照 * @return 更新があればtrue */ template <typename T> inline bool chmin(T &l, T r) { bool a = l > r; if (a) l = r; return a; } /** * @brief chminのmax版 * @see chmin */ template <typename T> inline bool chmax(T &l, T r) { bool a = l < r; if (a) l = r; return a; } /** * @brief * vectorに直接cin流すためのやつ * @tparam T * @param is * @param v * @return istream& */ template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &it : v) is >> it; return is; } /** * @brief * rangeを逆向きに操作したいとき用 * @details * ループの範囲は[bg,ed)なので注意 * @see range */ class reverse_range { private: struct I { int x; int operator*() { return x - 1; } bool operator!=(I &lhs) { return x > lhs.x; } void operator++() { --x; } }; I i, n; public: reverse_range(int n) : i({0}), n({n}) {} reverse_range(int i, int n) : i({i}), n({n}) {} I &begin() { return n; } I &end() { return i; } }; /** * @brief * python みたいな range-based for を実現 * @details * ループの範囲は[bg,ed)なので注意 * !つけると逆向きにループが回る (reverse_range) * 空間計算量はO(1) * 使わない変数ができて警告が出がちなので,unused_varとかを使って警告消しするとよい */ class range { private: struct I { int x; int operator*() { return x; } bool operator!=(I &lhs) { return x < lhs.x; } void operator++() { ++x; } }; I i, n; public: range(int n) : i({0}), n({n}) {} range(int i, int n) : i({i}), n({n}) {} I &begin() { return i; } I &end() { return n; } reverse_range operator!() { return reverse_range(*i, *n); } }; /** * @brief * rangeで生まれる使わない変数を消す用(警告消し) */ template <typename T> inline T &unused_var(T &v) { return v; } using LL = long long; } // namespace _Template_ using namespace _Template_; /* #endregion */ /* #endregion */ /*</body>*/ constexpr int sz = 5123 * 5123; LL dp[sz]; int main() { LL N; cin >> N; vector<LL> A(3), B(3); cin >> A >> B; { for (int i : range(3)) { for (int j : range(A[i], N + 1)) { chmax(dp[j], dp[j - A[i]] + B[i]); } } LL NN = N; for (int i : range(N + 1)) chmax(NN, dp[i] + (N - i)); N = NN; } swap(A, B); fill(dp, dp + N + 1, 0ll); { for (int i : range(3)) { for (int j : range(A[i], N + 1)) { chmax(dp[j], dp[j - A[i]] + B[i]); } } LL NN = N; for (int i : range(N + 1)) chmax(NN, dp[i] + (N - i)); N = NN; } cout << N << endl; return 0; }
[ "identifier.change", "call.arguments.change" ]
822,527
822,528
u613658617
cpp
p03008
#include <iostream> #include <vector> using namespace std; using ll = long long; ll knapsack(const vector<pair<ll, ll>> &items, ll max_w) { vector<ll> res(max_w + 1, 0); for (auto pr : items) { ll val = pr.first; ll wei = pr.second; for (int j = 0; j + wei <= max_w; ++j) { res[j + wei] = max(res[j + wei], res[j] + val); } } ll ans = 0; for (int i = 1; i <= max_w; ++i) ans = max(ans, res[i]); return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; vector<ll> vals1(3, 1); vector<ll> vals2(3, 1); for (int i = 0; i < 3; ++i) cin >> vals1[i]; for (int i = 0; i < 3; ++i) cin >> vals2[i]; // Really it's two instances of knapsack // Item value is its buy price - its sell price // Item weight is its buy price vector<pair<ll, ll>> items1(3); vector<pair<ll, ll>> items2(3); for (int i = 0; i < 3; ++i) { items1[i] = {vals2[i] - vals1[i], vals1[i]}; items2[i] = {vals1[i] - vals2[i], vals1[i]}; } ll cur = n; cur += knapsack(items1, cur); cur += knapsack(items2, cur); cout << cur << '\n'; }
#include <iostream> #include <vector> using namespace std; using ll = long long; ll knapsack(const vector<pair<ll, ll>> &items, ll max_w) { vector<ll> res(max_w + 1, 0); for (auto pr : items) { ll val = pr.first; ll wei = pr.second; for (int j = 0; j + wei <= max_w; ++j) { res[j + wei] = max(res[j + wei], res[j] + val); } } ll ans = 0; for (int i = 1; i <= max_w; ++i) ans = max(ans, res[i]); return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; vector<ll> vals1(3); vector<ll> vals2(3); for (int i = 0; i < 3; ++i) cin >> vals1[i]; for (int i = 0; i < 3; ++i) cin >> vals2[i]; // Really it's two instances of knapsack // Item value is its buy price - its sell price // Item weight is its buy price vector<pair<ll, ll>> items1(3); vector<pair<ll, ll>> items2(3); for (int i = 0; i < 3; ++i) { items1[i] = {vals2[i] - vals1[i], vals1[i]}; items2[i] = {vals1[i] - vals2[i], vals2[i]}; } ll cur = n; cur += knapsack(items1, cur); cur += knapsack(items2, cur); cout << cur << '\n'; }
[ "call.arguments.change", "identifier.change" ]
822,529
822,530
u347328826
cpp
p03008
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math") #pragma GCC target("popcnt") #include <bits/stdc++.h> #define maxn 25000010 #define ll long long #define ull unsigned long long #define ld long double #define fi first #define se second #define pb push_back #define eb emplace_back #define pob pop_back #define pf push_front #define pof pop_front #define pii pair<int, int> #define pil pair<int, ll> #define pll pair<ll, ll> #define IL inline #define ss system using namespace std; int a[3], b[3]; ll f[maxn], n; template <class T> void read(T &x) { char ch = x = 0; bool fl = false; while (!isdigit(ch)) fl |= ch == '-', ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x = fl ? -x : x; } int main() { cin >> n; for (int i = 0; i < 3; i++) { cin >> a[i]; } for (int i = 0; i < 3; i++) { cin >> b[i]; } for (int i = 0; i < 3; i++) { if (a[i] < b[i]) { for (int j = a[i]; j <= n; j++) { f[j] = max(f[j], f[j - a[i]] + b[i]); } } } ll tmp = n; for (int i = n; i; i--) { n = max(n, tmp - i + f[i]); } memset(f, 0, sizeof(f)); for (int i = 0; i < 3; i++) { if (b[i] < a[i]) { for (int j = a[i]; j <= n; j++) { f[j] = max(f[j], f[j - b[i]] + a[i]); } } } tmp = n; for (int i = n; i; i--) { n = max(n, tmp - i + f[i]); } cout << n << endl; return 0; }
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math") #pragma GCC target("popcnt") #include <bits/stdc++.h> #define maxn 25000010 #define ll long long #define ull unsigned long long #define ld long double #define fi first #define se second #define pb push_back #define eb emplace_back #define pob pop_back #define pf push_front #define pof pop_front #define pii pair<int, int> #define pil pair<int, ll> #define pll pair<ll, ll> #define IL inline #define ss system using namespace std; int a[3], b[3]; ll f[maxn], n; template <class T> void read(T &x) { char ch = x = 0; bool fl = false; while (!isdigit(ch)) fl |= ch == '-', ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x = fl ? -x : x; } int main() { cin >> n; for (int i = 0; i < 3; i++) { cin >> a[i]; } for (int i = 0; i < 3; i++) { cin >> b[i]; } for (int i = 0; i < 3; i++) { if (a[i] < b[i]) { for (int j = a[i]; j <= n; j++) { f[j] = max(f[j], f[j - a[i]] + b[i]); } } } ll tmp = n; for (int i = n; i; i--) { n = max(n, tmp - i + f[i]); } memset(f, 0, sizeof(f)); for (int i = 0; i < 3; i++) { if (b[i] < a[i]) { for (int j = b[i]; j <= n; j++) { f[j] = max(f[j], f[j - b[i]] + a[i]); } } } tmp = n; for (int i = n; i; i--) { n = max(n, tmp - i + f[i]); } cout << n << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.initializer.change" ]
822,542
822,543
u086813340
cpp
p03009
#include <algorithm> #include <array> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define M_PI 3.141592653589793238 using namespace std; long long p9 = 998244353; long long p1 = 1000000007; #define upperbound(v, val) upper_bound(v.begin(), v.end(), val) - v.begin() #define lowerbound(v, val) lower_bound(v.begin(), v.end(), val) - v.begin() #define int long long #define vel vector<long long> #define vvel vector<vel> #define rep(i, n) for (int i = 0; i < n; i++) #define sor(v) sort(v.begin(), v.end()) #define mmax(a, b) a = max(a, b) #define mmin(a, b) a = min(a, b) #define mkp(a, b) make_pair(a, b) #define pin pair<int, int> #define qin pair<pin, int> #define V vector #define Endl endl #define veb vector<bool> #define fcout cout << fixed << setprecision(15) #define rev(s) reverse(s.begin(), s.end()) #define lower(h, val) (lower_bound(h.begin(), h.end(), val) - h.begin()) #define upper(h, val) (upper_bound(h.begin(), h.end(), val) - h.begin()) #define vveb V<veb> #define omajinai \ cin.tie(0); \ ios::sync_with_stdio(false); #define endl "\n" #define pb push_back vel kai; vel inv_kai; vel inv; int root(int x, vel &pa) { if (pa[x] == -1) { return x; } int ans = root(pa[x], pa); pa[x] = ans; return ans; } bool mar(int x, int y, vel &pa) { x = root(x, pa); y = root(y, pa); if (x != y) { pa[x] = y; } return (x != y); } int gcd(int x, int y) { if (x < y) { return gcd(y, x); } if (y == 0) { return x; } return gcd(y, x % y); } int lcm(int x, int y) { x = abs(x); y = abs(y); return x * (y / gcd(x, y)); } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } void make_inv(int max_inv, int p) { inv = vel(max_inv + 1, 1); for (int i = 2; i <= max_inv; i++) { inv[i] = p - ((p / i) * inv[p % i]) % p; } } void make_kai(int max_kai, int p) { kai = vel(max_kai + 1, 1); inv_kai = kai; make_inv(max_kai, p); rep(i, max_kai) { kai[i + 1] = kai[i] * (i + 1); kai[i + 1] %= p; inv_kai[i + 1] = inv_kai[i] * inv[i + 1]; inv_kai[i + 1] %= p; } } int com(int n, int r, int p) { if ((n < 0) || (r < 0) || (r > n)) { return 0; } int ans = (kai[n] * inv_kai[r]) % p; return (ans * inv_kai[n - r]) % p; } int per(int n, int r, int p) { if ((n < 0) || (r < 0) || (r > n)) { return 0; } return (kai[n] * inv_kai[n - r]) % p; } vel dijk(V<V<pin>> &way, int st, int inf) { int n = way.size(); vel dist(n, inf); dist[st] = 0; priority_queue<pin, vector<pin>, greater<pin>> pq; pq.push(mkp(0, st)); veb is_checked(n, false); while (!pq.empty()) { pin x = pq.top(); pq.pop(); int pot = x.second; if (!is_checked[pot]) { is_checked[pot] = true; for (auto y : way[pot]) { int nex_dist = x.first + y.second; int nex_pot = y.first; if (dist[nex_pot] > nex_dist) { dist[nex_pot] = nex_dist; pq.push(mkp(nex_dist, y.first)); } } } } return dist; } V<V<pin>> make_w(vvel v) { int n = v.size(); V<V<pin>> ret(n); rep(i, n) { for (int x : v[i]) { ret[i].push_back(mkp(x, 1)); } } return ret; } void make_tree(vvel &chi, vel &par, int n) { V<V<pin>> way(n); rep(i, n - 1) { int a, b; cin >> a >> b; a--; b--; way[a].push_back(mkp(b, 1)); way[b].push_back(mkp(a, 1)); } vel dist = dijk(way, 0, n + 1); par = vel(n, -1); chi = vvel(n); rep(i, n) { for (auto nex : way[i]) { int pot = nex.first; if (dist[pot] > dist[i]) { chi[i].push_back(pot); } else { par[i] = pot; } } } } void pri(vel &v) { if (v.size() == 0) { return; } cout << v[0]; rep(i, v.size() - 1) { cout << " " << v[i + 1]; } cout << endl; return; } int modpow(int a, int n, int p) { if (n == 0) { return 1; } int m = n / 2; int x = modpow(a, n / 2, p); x *= x; x %= p; if (n % 2 == 1) { x *= a; x %= p; } return x; } #define ui long long vvel disj_min(vel &v) { int n = v.size(); vvel ret(22, vel(n)); ret[0] = v; rep(i, 21) { rep(j, n) { int nex = j + (1 << i); if (nex < n) { ret[i + 1][j] = min(ret[i][j], ret[i][nex]); } else { ret[i + 1][j] = ret[i][j]; } } } return ret; } int find_min(vvel &dv, int l, int r) { int i = 21; while (l + (1 << i) > r) { i--; } while (i >= 0) { if (dv[i][l] > dv[i][r - (1 << i)]) { l = r - (1 << i); } else { r = l + (1 << i); } i--; } return l; } V<V<pin>> dbl(V<pin> &v) { V<V<pin>> ans(20, V<pin>(v)); int n = v.size(); rep(i, 19) { rep(j, n) { ans[i + 1][j].first = ans[i][ans[i][j].first].first; ans[i + 1][j].second = max(ans[i][j].second, ans[i][ans[i][j].first].second); } } return ans; } int lca(int s, int t, int diff, V<V<pin>> &pa) { if (diff < 0) { return lca(t, s, -diff, pa); } int ans = 0; rep(i, 19) { if ((diff & (1 << i)) != 0) { mmax(ans, pa[i][s].second); s = pa[i][s].first; } } for (int i = 19; i >= 0; i--) { if (pa[i][s] != pa[i][t]) { mmax(ans, pa[i][s].second); s = pa[i][s].first; mmax(ans, pa[i][t].second); t = pa[i][t].first; } } if (s != t) { mmax(ans, pa[0][s].second); mmax(ans, pa[0][t].second); } return ans; } void alp(int n, vel &pr) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) { pr.push_back(i); while (n % i == 0) { n /= i; } } } if (n != 1) { pr.push_back(n); } } vel dx = {0, 0, -1, 1}; vel dy = {1, -1, 0, 0}; void sol(int i, int st, int dir, vel &cnt, vvel &nex, vvel &use) { if (use[i].size() == 0 || use[i].back() != st) { use[i].push_back(st); if (cnt[i] >= 1) { rep(nd, 2) { int ne = nex[nd][i]; if (ne != -1) { sol(ne, st, nd, cnt, nex, use); } } } else { int ne = nex[dir][i]; if (ne != -1) { sol(ne, st, dir, cnt, nex, use); } } } } signed main() { omajinai; int n, h, d; cin >> n >> h >> d; int M = 0; int ka = 1; rep(i, n) { ka *= (i + 1); M += ka; M %= p1; } vel dp(h); dp[0] = 1; for (int i = 1; i < h; i++) { dp[i] = (M + 1) * dp[i - 1]; if (i >= d + 1) { dp[i] -= M * dp[i - d - 1]; } dp[i] %= p1; dp[i] += p1; dp[i] %= p1; } int ans = dp.back(); if (h >= d + 1) { ans += p1 - dp[h - d - 1]; } ans *= ka; cout << ans % p1 << endl; return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define M_PI 3.141592653589793238 using namespace std; long long p9 = 998244353; long long p1 = 1000000007; #define upperbound(v, val) upper_bound(v.begin(), v.end(), val) - v.begin() #define lowerbound(v, val) lower_bound(v.begin(), v.end(), val) - v.begin() #define int long long #define vel vector<long long> #define vvel vector<vel> #define rep(i, n) for (int i = 0; i < n; i++) #define sor(v) sort(v.begin(), v.end()) #define mmax(a, b) a = max(a, b) #define mmin(a, b) a = min(a, b) #define mkp(a, b) make_pair(a, b) #define pin pair<int, int> #define qin pair<pin, int> #define V vector #define Endl endl #define veb vector<bool> #define fcout cout << fixed << setprecision(15) #define rev(s) reverse(s.begin(), s.end()) #define lower(h, val) (lower_bound(h.begin(), h.end(), val) - h.begin()) #define upper(h, val) (upper_bound(h.begin(), h.end(), val) - h.begin()) #define vveb V<veb> #define omajinai \ cin.tie(0); \ ios::sync_with_stdio(false); #define endl "\n" #define pb push_back vel kai; vel inv_kai; vel inv; int root(int x, vel &pa) { if (pa[x] == -1) { return x; } int ans = root(pa[x], pa); pa[x] = ans; return ans; } bool mar(int x, int y, vel &pa) { x = root(x, pa); y = root(y, pa); if (x != y) { pa[x] = y; } return (x != y); } int gcd(int x, int y) { if (x < y) { return gcd(y, x); } if (y == 0) { return x; } return gcd(y, x % y); } int lcm(int x, int y) { x = abs(x); y = abs(y); return x * (y / gcd(x, y)); } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } void make_inv(int max_inv, int p) { inv = vel(max_inv + 1, 1); for (int i = 2; i <= max_inv; i++) { inv[i] = p - ((p / i) * inv[p % i]) % p; } } void make_kai(int max_kai, int p) { kai = vel(max_kai + 1, 1); inv_kai = kai; make_inv(max_kai, p); rep(i, max_kai) { kai[i + 1] = kai[i] * (i + 1); kai[i + 1] %= p; inv_kai[i + 1] = inv_kai[i] * inv[i + 1]; inv_kai[i + 1] %= p; } } int com(int n, int r, int p) { if ((n < 0) || (r < 0) || (r > n)) { return 0; } int ans = (kai[n] * inv_kai[r]) % p; return (ans * inv_kai[n - r]) % p; } int per(int n, int r, int p) { if ((n < 0) || (r < 0) || (r > n)) { return 0; } return (kai[n] * inv_kai[n - r]) % p; } vel dijk(V<V<pin>> &way, int st, int inf) { int n = way.size(); vel dist(n, inf); dist[st] = 0; priority_queue<pin, vector<pin>, greater<pin>> pq; pq.push(mkp(0, st)); veb is_checked(n, false); while (!pq.empty()) { pin x = pq.top(); pq.pop(); int pot = x.second; if (!is_checked[pot]) { is_checked[pot] = true; for (auto y : way[pot]) { int nex_dist = x.first + y.second; int nex_pot = y.first; if (dist[nex_pot] > nex_dist) { dist[nex_pot] = nex_dist; pq.push(mkp(nex_dist, y.first)); } } } } return dist; } V<V<pin>> make_w(vvel v) { int n = v.size(); V<V<pin>> ret(n); rep(i, n) { for (int x : v[i]) { ret[i].push_back(mkp(x, 1)); } } return ret; } void make_tree(vvel &chi, vel &par, int n) { V<V<pin>> way(n); rep(i, n - 1) { int a, b; cin >> a >> b; a--; b--; way[a].push_back(mkp(b, 1)); way[b].push_back(mkp(a, 1)); } vel dist = dijk(way, 0, n + 1); par = vel(n, -1); chi = vvel(n); rep(i, n) { for (auto nex : way[i]) { int pot = nex.first; if (dist[pot] > dist[i]) { chi[i].push_back(pot); } else { par[i] = pot; } } } } void pri(vel &v) { if (v.size() == 0) { return; } cout << v[0]; rep(i, v.size() - 1) { cout << " " << v[i + 1]; } cout << endl; return; } int modpow(int a, int n, int p) { if (n == 0) { return 1; } int m = n / 2; int x = modpow(a, n / 2, p); x *= x; x %= p; if (n % 2 == 1) { x *= a; x %= p; } return x; } #define ui long long vvel disj_min(vel &v) { int n = v.size(); vvel ret(22, vel(n)); ret[0] = v; rep(i, 21) { rep(j, n) { int nex = j + (1 << i); if (nex < n) { ret[i + 1][j] = min(ret[i][j], ret[i][nex]); } else { ret[i + 1][j] = ret[i][j]; } } } return ret; } int find_min(vvel &dv, int l, int r) { int i = 21; while (l + (1 << i) > r) { i--; } while (i >= 0) { if (dv[i][l] > dv[i][r - (1 << i)]) { l = r - (1 << i); } else { r = l + (1 << i); } i--; } return l; } V<V<pin>> dbl(V<pin> &v) { V<V<pin>> ans(20, V<pin>(v)); int n = v.size(); rep(i, 19) { rep(j, n) { ans[i + 1][j].first = ans[i][ans[i][j].first].first; ans[i + 1][j].second = max(ans[i][j].second, ans[i][ans[i][j].first].second); } } return ans; } int lca(int s, int t, int diff, V<V<pin>> &pa) { if (diff < 0) { return lca(t, s, -diff, pa); } int ans = 0; rep(i, 19) { if ((diff & (1 << i)) != 0) { mmax(ans, pa[i][s].second); s = pa[i][s].first; } } for (int i = 19; i >= 0; i--) { if (pa[i][s] != pa[i][t]) { mmax(ans, pa[i][s].second); s = pa[i][s].first; mmax(ans, pa[i][t].second); t = pa[i][t].first; } } if (s != t) { mmax(ans, pa[0][s].second); mmax(ans, pa[0][t].second); } return ans; } void alp(int n, vel &pr) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) { pr.push_back(i); while (n % i == 0) { n /= i; } } } if (n != 1) { pr.push_back(n); } } vel dx = {0, 0, -1, 1}; vel dy = {1, -1, 0, 0}; void sol(int i, int st, int dir, vel &cnt, vvel &nex, vvel &use) { if (use[i].size() == 0 || use[i].back() != st) { use[i].push_back(st); if (cnt[i] >= 1) { rep(nd, 2) { int ne = nex[nd][i]; if (ne != -1) { sol(ne, st, nd, cnt, nex, use); } } } else { int ne = nex[dir][i]; if (ne != -1) { sol(ne, st, dir, cnt, nex, use); } } } } signed main() { omajinai; int n, h, d; cin >> n >> h >> d; int M = 0; int ka = 1; rep(i, n) { ka *= (i + 1); ka %= p1; M += ka; M %= p1; } vel dp(h); dp[0] = 1; for (int i = 1; i < h; i++) { dp[i] = (M + 1) * dp[i - 1]; if (i >= d + 1) { dp[i] -= M * dp[i - d - 1]; } dp[i] %= p1; dp[i] += p1; dp[i] %= p1; } int ans = dp.back(); if (h >= d + 1) { ans += p1 - dp[h - d - 1]; } ans *= ka; cout << ans % p1 << endl; return 0; }
[ "assignment.add" ]
822,548
822,549
u021034020
cpp
p03009
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9 + 7, N = 1e6 + 5; ll n, h, d, f[N], sum[N], s; int main() { scanf("%lld%lld%lld", &n, &h, &d); f[0] = 1; for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod, s = (s + f[i]) % mod; sum[1] = 1; for (int i = 2; i <= h; i++) sum[i] = (sum[i - 1] + (sum[i - 1] - sum[max(0ll, i - d - 1)]) * s) % mod; printf("%lld\n", (sum[h] - sum[h - d]) * f[n] % mod); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9 + 7, N = 1e6 + 5; ll n, h, d, f[N], sum[N], s; int main() { scanf("%lld%lld%lld", &n, &h, &d); f[0] = 1; for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mod, s = (s + f[i]) % mod; sum[1] = 1; for (int i = 2; i <= h; i++) sum[i] = (sum[i - 1] + (sum[i - 1] - sum[max(0ll, i - d - 1)]) * s) % mod; printf("%lld\n", ((sum[h] - sum[h - d]) * f[n] % mod + mod) % mod); }
[ "call.arguments.change" ]
822,552
822,553
u676323984
cpp
p03009
#include <bits/stdc++.h> using namespace std; using ll = long long; // queue を考えて, 同じ数字は入れるときに順番を決めて, 出てきた順に値を更新する #define mod 1000000007 #define MAX_N 1000001 // = MAX_H ll fact[MAX_N]; // iの階乗 ll fact_sum[MAX_N]; // i>0での累積和 // 最大値がi個の時の場合の数 ll dp[MAX_N]; int main() { int N, H, D; cin >> N >> H >> D; // 階乗計算 fact[0] = 1; for (int i = 1; i < MAX_N; ++i) { fact[i] = fact[i - 1] * i % mod; fact_sum[i] = (fact_sum[i - 1] + fact[i]) % mod; } dp[0] = fact[N]; // 0をN個queueに入れる ll sum = 0; // Dの幅でしゃくとり for (int i = 1; i <= H; ++i) { sum += dp[i - 1]; // dp[i-D] から dp[i-1] まで if (i > D) sum -= dp[i - D - 1]; sum %= mod; dp[i] = sum * fact_sum[N] % mod; // i個の塔の個数が1からNまで } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; // queue を考えて, 同じ数字は入れるときに順番を決めて, 出てきた順に値を更新する #define mod 1000000007 #define MAX_N 1000001 // = MAX_H ll fact[MAX_N]; // iの階乗 ll fact_sum[MAX_N]; // i>0での累積和 // 最大値がi個の時の場合の数 ll dp[MAX_N]; int main() { int N, H, D; cin >> N >> H >> D; // 階乗計算 fact[0] = 1; for (int i = 1; i < MAX_N; ++i) { fact[i] = fact[i - 1] * i % mod; fact_sum[i] = (fact_sum[i - 1] + fact[i]) % mod; } dp[0] = fact[N]; // 0をN個queueに入れる ll sum = 0; // Dの幅でしゃくとり for (int i = 1; i <= H; ++i) { sum += dp[i - 1]; // dp[i-D] から dp[i-1] まで if (i > D) sum = sum + mod - dp[i - D - 1]; sum %= mod; dp[i] = sum * fact_sum[N] % mod; // i個の塔の個数が1からNまで } cout << sum; return 0; }
[ "assignment.value.change", "assignment.change" ]
822,554
822,555
u590088474
cpp
p03009
#include <bits/stdc++.h> #define ll long long #define fornum(A, B, C) for (A = B; A < C; A++) #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// #define MOD ((ll)1e9 + 7) ll moddiv(ll a, ll b) { a %= MOD; b %= MOD; for (ll m = MOD - 2; m > 0; m /= 2) { if (m & 1) { a = a * b % MOD; } b = b * b % MOD; } return a; } ll N, H, D; ll dp[2020202], mk[2020202]; ll i, j, k, ans; ll fa[1010101]; int main() { scanf("%lld%lld%lld", &N, &H, &D); fa[0] = 1; fornum(i, 0, 1010101) { fa[i + 1] = fa[i] * (i + 1) % MOD; } ll aDd = 0; fornum(i, 0, N) { aDd = (aDd + fa[i + 1]) % MOD; } k = fa[N]; mk[D] = k; fornum(i, 0, H - 1) { mk[i + 1 + D] = k * aDd; k = (k + k * aDd + MOD - mk[i + 1]) % MOD; } printf("%lld", k); return 0; }
#include <bits/stdc++.h> #define ll long long #define fornum(A, B, C) for (A = B; A < C; A++) #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// #define MOD ((ll)1e9 + 7) ll moddiv(ll a, ll b) { a %= MOD; b %= MOD; for (ll m = MOD - 2; m > 0; m /= 2) { if (m & 1) { a = a * b % MOD; } b = b * b % MOD; } return a; } ll N, H, D; ll dp[2020202], mk[2020202]; ll i, j, k, ans; ll fa[1010101]; int main() { scanf("%lld%lld%lld", &N, &H, &D); fa[0] = 1; fornum(i, 0, 1010101) { fa[i + 1] = fa[i] * (i + 1) % MOD; } ll aDd = 0; fornum(i, 0, N) { aDd = (aDd + fa[i + 1]) % MOD; } k = fa[N]; mk[D] = k; fornum(i, 0, H - 1) { mk[i + 1 + D] = k * aDd % MOD; k = (k + k * aDd + MOD - mk[i + 1]) % MOD; } printf("%lld", k); return 0; }
[ "assignment.change" ]
822,558
822,559
u259396003
cpp
p03009
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> // 変数名にy1が使えなくなるかも…。 #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> typedef __int128_t int128_t; std::istream & operator>>(std::istream &input, int128_t &value) { // int128_tの入力。入力が64bitに収まる前提。 long long tmp; input >> tmp; value = tmp; return input; } std::ostream & operator<<(std::ostream &output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。 output << (long long)value; return output; } int128_t cal_mod(const int128_t n, const int128_t mod) { // n % modを計算する。ただしmod <= 0 // ならば何もしない。nが負の場合、正にして補正する。 if (mod <= 0) { return n; } else if (0 <= n) { return n % mod; } else { int128_t tmp = (-n) / mod + 1; return (n + tmp * mod) % mod; } } int128_t pow_mod(int128_t x, int128_t n, const int128_t mod) { // 累乗の計算。mod <= 0ならば余りの計算は行わない。 int128_t ret = 1; while (n > 0) { if (n & 1) { ret = cal_mod(ret * x, mod); } x = cal_mod(x * x, mod); n = (n >> 1); } return ret; } class Combi_Num { // 「組み合わせ数 % // 素数」を、前処理を行ったうえでO(1)で求める。modは32bitに収まることが前提。 public: int128_t mod; std::vector<int128_t> factorial, factorial_inv, inv; Combi_Num() {} Combi_Num(const int n, const int128_t mod_in) { mod = mod_in; factorial.resize(n + 1, 0); factorial_inv.resize(n + 1, 0); inv.resize(n + 1, 0); factorial[0] = 1; factorial_inv[0] = 1; inv[0] = 1; for (int i = 1; i <= n; i++) { factorial[i] = (factorial[i - 1] * i) % mod; inv[i] = pow_mod(i, mod - 2, mod); factorial_inv[i] = (factorial_inv[i - 1] * inv[i]) % mod; } } int128_t combi(const int n, const int r) { return (factorial[n] * ((factorial_inv[r] * factorial_inv[n - r]) % mod)) % mod; } int128_t perm(const int n, const int r) { return (factorial[n] * factorial_inv[n - r]) % mod; } }; const int MOD = 1e9 + 7; const int MAX_N = 1000010; int128_t N, H, D; Combi_Num cn = Combi_Num(MAX_N, MOD); int128_t dp[MAX_N], dp_ac[MAX_N]; int main(int argc, char **argv) { std::cin >> N >> H >> D; int128_t coeff = 0; for (int i = 1; i <= N; i++) { coeff = (coeff + cn.factorial[i]) % MOD; } dp[0] = cn.factorial[N]; dp_ac[0] = dp[0]; // std::cout << dp[0] << " " << dp_ac[0] << std::endl; for (int i = 1; i <= H; i++) { int128_t tmp = dp_ac[i - 1]; if (0 < i - D) { tmp = cal_mod(tmp - dp_ac[i - D - 1], MOD); } if (i == H) { dp[i] = tmp; } else { dp[i] = (tmp * coeff) % MOD; } dp_ac[i] = dp_ac[i - 1] + dp[i]; } std::cout << dp[H] << std::endl; return 0; }
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> // 変数名にy1が使えなくなるかも…。 #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> typedef __int128_t int128_t; std::istream & operator>>(std::istream &input, int128_t &value) { // int128_tの入力。入力が64bitに収まる前提。 long long tmp; input >> tmp; value = tmp; return input; } std::ostream & operator<<(std::ostream &output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。 output << (long long)value; return output; } int128_t cal_mod(const int128_t n, const int128_t mod) { // n % modを計算する。ただしmod <= 0 // ならば何もしない。nが負の場合、正にして補正する。 if (mod <= 0) { return n; } else if (0 <= n) { return n % mod; } else { int128_t tmp = (-n) / mod + 1; return (n + tmp * mod) % mod; } } int128_t pow_mod(int128_t x, int128_t n, const int128_t mod) { // 累乗の計算。mod <= 0ならば余りの計算は行わない。 int128_t ret = 1; while (n > 0) { if (n & 1) { ret = cal_mod(ret * x, mod); } x = cal_mod(x * x, mod); n = (n >> 1); } return ret; } class Combi_Num { // 「組み合わせ数 % // 素数」を、前処理を行ったうえでO(1)で求める。modは32bitに収まることが前提。 public: int128_t mod; std::vector<int128_t> factorial, factorial_inv, inv; Combi_Num() {} Combi_Num(const int n, const int128_t mod_in) { mod = mod_in; factorial.resize(n + 1, 0); factorial_inv.resize(n + 1, 0); inv.resize(n + 1, 0); factorial[0] = 1; factorial_inv[0] = 1; inv[0] = 1; for (int i = 1; i <= n; i++) { factorial[i] = (factorial[i - 1] * i) % mod; inv[i] = pow_mod(i, mod - 2, mod); factorial_inv[i] = (factorial_inv[i - 1] * inv[i]) % mod; } } int128_t combi(const int n, const int r) { return (factorial[n] * ((factorial_inv[r] * factorial_inv[n - r]) % mod)) % mod; } int128_t perm(const int n, const int r) { return (factorial[n] * factorial_inv[n - r]) % mod; } }; const int MOD = 1e9 + 7; const int MAX_N = 1000010; int128_t N, H, D; Combi_Num cn = Combi_Num(MAX_N, MOD); int128_t dp[MAX_N], dp_ac[MAX_N]; int main(int argc, char **argv) { std::cin >> N >> H >> D; int128_t coeff = 0; for (int i = 1; i <= N; i++) { coeff = (coeff + cn.factorial[i]) % MOD; } dp[0] = cn.factorial[N]; dp_ac[0] = dp[0]; // std::cout << dp[0] << " " << dp_ac[0] << std::endl; for (int i = 1; i <= H; i++) { int128_t tmp = dp_ac[i - 1]; if (0 < i - D) { tmp = cal_mod(tmp - dp_ac[i - D - 1], MOD); } if (i == H) { dp[i] = tmp; } else { dp[i] = (tmp * coeff) % MOD; } dp_ac[i] = (dp_ac[i - 1] + dp[i]) % MOD; } std::cout << dp[H] << std::endl; return 0; }
[ "assignment.change" ]
822,562
822,563
u370768058
cpp
p03009
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #define LL long long using namespace std; const LL mod = 1e9 + 7; LL n, h, d, fac[1000010], f[1000010], s[1000010]; int main() { scanf("%lld %lld %lld", &n, &h, &d); fac[0] = fac[1] = 1; for (LL i = 2; i <= n; i++) fac[i] = fac[i - 1] * i % mod; f[1] = s[1] = fac[n]; LL p = 0; for (LL i = 0; i <= n; i++) (p += fac[i]) %= mod; for (LL i = 2; i <= d; i++) s[i] = (s[i - 1] + (f[i] = f[i - 1] * p % mod)) % mod; for (LL i = d + 1; i <= n; i++) { f[i] = (s[i - 1] - s[i - d - 1]) % mod * (p - 1) % mod; s[i] = (s[i - 1] + s[i]) % mod; } printf("%lld", (f[n] + mod) % mod); }
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #define LL long long using namespace std; const LL mod = 1e9 + 7; LL n, h, d, fac[1000010], f[1000010], s[1000010]; int main() { scanf("%lld %lld %lld", &n, &h, &d); fac[0] = fac[1] = 1; for (LL i = 2; i <= n; i++) fac[i] = fac[i - 1] * i % mod; f[1] = s[1] = fac[n]; LL p = 0; for (LL i = 0; i <= n; i++) (p += fac[i]) %= mod; for (LL i = 2; i <= d; i++) s[i] = (s[i - 1] + (f[i] = f[i - 1] * p % mod)) % mod; for (LL i = d + 1; i <= h; i++) { f[i] = (s[i - 1] - s[i - d - 1]) % mod * (p - 1) % mod; s[i] = (s[i - 1] + f[i]) % mod; } printf("%lld", (f[h] + mod) % mod); }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "io.output.change" ]
822,566
822,567
u038798747
cpp
p03009
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> #define M_PI 3.14159265358979323846 using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define MT make_tuple #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define FILL(a, x) memset(a, x, sizeof(a)) // repetition //------------------------------------------ #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) const int N = 1010000; const LL MOD = 1000000007; LL fac[N]; LL sfac[N]; LL dp[N]; int main() { LL n, h, d; cin >> n >> h >> d; fac[0] = fac[1] = 1; FOR(i, 1, n + 1) { fac[i] = (fac[i - 1] * i) % MOD; sfac[i] = (sfac[i - 1] + fac[i]) % MOD; } dp[0] = fac[n]; LL s = dp[0]; FOR(i, 1, h) { dp[i] = s * sfac[n]; s = (s + dp[i]) % MOD; if (i >= d) s = (s - dp[i - d] + MOD) % MOD; } cout << s << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> #define M_PI 3.14159265358979323846 using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define MT make_tuple #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define FILL(a, x) memset(a, x, sizeof(a)) // repetition //------------------------------------------ #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) const int N = 1010000; const LL MOD = 1000000007; LL fac[N]; LL sfac[N]; LL dp[N]; int main() { LL n, h, d; cin >> n >> h >> d; fac[0] = fac[1] = 1; FOR(i, 1, n + 1) { fac[i] = (fac[i - 1] * i) % MOD; sfac[i] = (sfac[i - 1] + fac[i]) % MOD; } dp[0] = fac[n]; LL s = dp[0]; FOR(i, 1, h) { dp[i] = (s * sfac[n]) % MOD; s = (s + dp[i]) % MOD; if (i >= d) s = (s - dp[i - d] + MOD) % MOD; } cout << s << endl; return 0; }
[ "assignment.change" ]
822,572
822,573
u614497125
cpp
p03009
#include <cstdio> typedef long long ll; const int mod = 1000000007; int f[1000050], g[1000050], s[1000050]; int main() { int n, h, d, p, i; scanf("%d%d%d", &n, &h, &d); f[0] = f[1] = 1; for (i = 2; i <= n; ++i) f[i] = (ll)f[i - 1] * i % mod; p = 2; for (i = 2; i <= n; ++i) p = (p + f[i]) % mod; s[1] = g[1] = f[n]; for (i = 2; i <= d; ++i) s[i] = (s[i - 1] + (g[i] = (ll)g[i - 1] * p % mod)) % mod; for (i = d + 1; i <= h; ++i) { g[i] = (ll)(s[i - 1] - s[i - d - 1]) * (p - 1) % mod; s[i] = (s[i - 1] + g[i]) % mod; } printf("%d\n", g[h]); return 0; }
#include <cstdio> typedef long long ll; const int mod = 1000000007; int f[1000050], g[1000050], s[1000050]; int main() { int n, h, d, p, i; scanf("%d%d%d", &n, &h, &d); f[0] = f[1] = 1; for (i = 2; i <= n; ++i) f[i] = (ll)f[i - 1] * i % mod; p = 2; for (i = 2; i <= n; ++i) p = (p + f[i]) % mod; s[1] = g[1] = f[n]; for (i = 2; i <= d; ++i) s[i] = (s[i - 1] + (g[i] = (ll)g[i - 1] * p % mod)) % mod; for (i = d + 1; i <= h; ++i) { g[i] = (ll)(s[i - 1] - s[i - d - 1] + mod) * (p - 1 + mod) % mod; s[i] = (s[i - 1] + g[i]) % mod; } printf("%d\n", g[h]); return 0; }
[ "assignment.change" ]
822,574
822,575
u070422134
cpp
p03007
#include <bits/stdc++.h> using namespace std; using ll = long long; using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using pll = pair<ll, ll>; using tll = tuple<ll, ll>; using tlll = tuple<ll, ll, ll>; using vs = vector<string>; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define rep(i, n) range(i, 0, n) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define range(i, a, n) for (ll i = (a); i < (n); i++) #define LINF ((ll)1ll << 60) #define INF ((int)1 << 30) #define EPS (1e-9) #define MOD (1000000007ll) #define fcout(a) cout << setprecision(a) << fixed #define fs first #define sc second #define PI (3.1415926535897932384) int dx[] = {1, 0, -1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class S> S sum(vector<S> &a) { return accumulate(all(a), S()); } template <class S> S max(vector<S> &a) { return *max_element(all(a)); } template <class S> S min(vector<S> &a) { return *min_element(all(a)); } ll max(int a, ll b) { return max((ll)a, b); } ll max(ll a, int b) { return max(a, (ll)b); } template <class T> void puta(T &&t) { cout << t << "\n"; } template <class H, class... T> void puta(H &&h, T &&...t) { cout << h << ' '; puta(t...); } template <class S, class T> void tf(bool b, S t, T f) { if (b) puta(t); else puta(f); } void YN(bool b) { tf(b, "YES", "NO"); } void Yn(bool b) { tf(b, "Yes", "No"); } void yn(bool b) { tf(b, "yes", "no"); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "[" << p.first << ", " << p.second << "]"; return os; }; template <class S> auto &operator<<(ostream &os, vector<S> t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; } template <class S> auto &operator>>(istream &is, vector<S> &t) { for (S &a : t) cin >> a; return is; } /*他のライブラリを入れる場所*/ int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vl a(n); cin >> a; sort(rall(a)); vector<pll> ap; range(i, 1, n - 1) { if (a[i] >= 0) { ap.emplace_back(a.back(), a[i]); a.back() -= a[i]; } else { ap.emplace_back(a.front(), a[i]); a.back() -= a[i]; } } ap.emplace_back(a.front(), a.back()); a.front() -= a.back(); puta(a.front()); for (auto &p : ap) puta(p.fs, p.sc); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using pll = pair<ll, ll>; using tll = tuple<ll, ll>; using tlll = tuple<ll, ll, ll>; using vs = vector<string>; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define rep(i, n) range(i, 0, n) #define rrep(i, n) for (ll i = (n)-1; i >= 0; i--) #define range(i, a, n) for (ll i = (a); i < (n); i++) #define LINF ((ll)1ll << 60) #define INF ((int)1 << 30) #define EPS (1e-9) #define MOD (1000000007ll) #define fcout(a) cout << setprecision(a) << fixed #define fs first #define sc second #define PI (3.1415926535897932384) int dx[] = {1, 0, -1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class S> S sum(vector<S> &a) { return accumulate(all(a), S()); } template <class S> S max(vector<S> &a) { return *max_element(all(a)); } template <class S> S min(vector<S> &a) { return *min_element(all(a)); } ll max(int a, ll b) { return max((ll)a, b); } ll max(ll a, int b) { return max(a, (ll)b); } template <class T> void puta(T &&t) { cout << t << "\n"; } template <class H, class... T> void puta(H &&h, T &&...t) { cout << h << ' '; puta(t...); } template <class S, class T> void tf(bool b, S t, T f) { if (b) puta(t); else puta(f); } void YN(bool b) { tf(b, "YES", "NO"); } void Yn(bool b) { tf(b, "Yes", "No"); } void yn(bool b) { tf(b, "yes", "no"); } template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) { os << "[" << p.first << ", " << p.second << "]"; return os; }; template <class S> auto &operator<<(ostream &os, vector<S> t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; } template <class S> auto &operator>>(istream &is, vector<S> &t) { for (S &a : t) cin >> a; return is; } /*他のライブラリを入れる場所*/ int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vl a(n); cin >> a; sort(rall(a)); vector<pll> ap; range(i, 1, n - 1) { if (a[i] >= 0) { ap.emplace_back(a.back(), a[i]); a.back() -= a[i]; } else { ap.emplace_back(a.front(), a[i]); a.front() -= a[i]; } } ap.emplace_back(a.front(), a.back()); a.front() -= a.back(); puta(a.front()); for (auto &p : ap) puta(p.fs, p.sc); return 0; }
[ "assignment.variable.change", "call.function.change" ]
822,278
822,279
u364618491
cpp
p03007
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9 + 7; ll a[100000]; vector<P> te; int main() { int n; ll ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); ll m = a[0]; //最小 ll s = a[n - 1]; //最大 //最大を増やす for (int i = 1; i < n; i++) { if (a[i] >= 0) break; te.push_back(P(s, a[i])); s -= a[i]; } //最小を減らす for (int i = n - 2; i > -1; i--) { if (a[i] < 0) break; te.push_back(P(m, a[i])); m -= a[i]; } te.push_back(P(s, m)); ans = s - m; cout << ans << endl; for (int i = 0; i < te.size(); i++) cout << te[i].first << " " << te[i].second << endl; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1e9 + 7; ll a[100000]; vector<P> te; int main() { int n; ll ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); ll m = a[0]; //最小 ll s = a[n - 1]; //最大 //最大を増やす for (int i = 1; i < n - 1; i++) { if (a[i] >= 0) break; te.push_back(P(s, a[i])); s -= a[i]; } //最小を減らす for (int i = n - 2; i > 0; i--) { if (a[i] < 0) break; te.push_back(P(m, a[i])); m -= a[i]; } te.push_back(P(s, m)); ans = s - m; cout << ans << endl; for (int i = 0; i < te.size(); i++) cout << te[i].first << " " << te[i].second << endl; return 0; }
[ "control_flow.loop.for.condition.change", "misc.off_by_one", "literal.number.change", "expression.operation.binary.change" ]
822,292
822,293
u863507492
cpp
p03007
#include <bits/stdc++.h> using namespace std; #define LL long long #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<LL, LL> #define x first #define y second #define pi acos(-1) #define sqr(x) ((x) * (x)) #define pdd pair<double, double> #define MEMS(x) memset(x, -1, sizeof(x)) #define MEM(x) memset(x, 0, sizeof(x)) #define N 200005 #define rank Rank #define index Index int main() { int n; scanf("%d", &n); int a[100005]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); int ans = 0; for (int i = 1; i < n - 1; i++) ans += abs(a[i]); ans += a[n - 1]; ans -= a[0]; printf("%d\n", ans); vector<int> v; int now = a[0]; for (int i = 1; i < n - 1; i++) { if (a[i] > 0) { printf("%d %d\n", now, a[i]); now -= a[i]; } } printf("%d %d\n", a[n - 1], now); now = a[n - 1] - now; for (int i = 1; i < n - 1; i++) { if (a[i] < 0) { printf("%d %d\n", now, a[i]); now -= a[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define LL long long #define mp make_pair #define pb push_back #define pii pair<int, int> #define pll pair<LL, LL> #define x first #define y second #define pi acos(-1) #define sqr(x) ((x) * (x)) #define pdd pair<double, double> #define MEMS(x) memset(x, -1, sizeof(x)) #define MEM(x) memset(x, 0, sizeof(x)) #define N 200005 #define rank Rank #define index Index int main() { int n; scanf("%d", &n); int a[100005]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); int ans = 0; for (int i = 1; i < n - 1; i++) ans += abs(a[i]); ans += a[n - 1]; ans -= a[0]; printf("%d\n", ans); vector<int> v; int now = a[0]; for (int i = 1; i < n - 1; i++) { if (a[i] > 0) { printf("%d %d\n", now, a[i]); now -= a[i]; } } printf("%d %d\n", a[n - 1], now); now = a[n - 1] - now; for (int i = 1; i < n - 1; i++) { if (a[i] <= 0) { printf("%d %d\n", now, a[i]); now -= a[i]; } } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,294
822,295
u682550266
cpp
p03007
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x, to) for (x = 0; x < (to); x++) #define FORR(x, arr) for (auto &x : arr) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) //------------------------------------------------------- int N; int A[101010]; pair<int, int> P[101010]; int mi[101010]; vector<pair<int, int>> D; void solve() { int i, j, k, l, r, x, y; string s; cin >> N; FOR(i, N) { cin >> A[i]; P[i] = {A[i], i}; } sort(P, P + N); int C[2] = {}; FOR(i, N) { if (P[i].first < 0) mi[P[i].second] = 1; C[mi[P[i].second]]++; } if (C[0] == N) { mi[P[0].second] = 1; } if (C[1] == N) { mi[P[N - 1].second] = 0; } multiset<ll> S[2]; FOR(i, N) S[mi[i]].insert(A[i]); vector<pair<ll, ll>> V; while (S[0].size() > 1) { auto it = S[0].begin(); auto it2 = S[1].begin(); ll a = *it; ll b = *it2; S[0].erase(it); S[1].erase(it2); V.push_back({b, a}); S[1].insert(b - a); } while (S[1].size()) { auto it = S[0].begin(); auto it2 = S[1].begin(); ll a = *it; ll b = *it2; S[0].erase(it); S[1].erase(it2); V.push_back({b, a}); S[0].insert(a - b); } cout << *S[0].begin() << endl; FORR(d, V) cout << d.first << " " << d.second << endl; } int main(int argc, char **argv) { string s; int i; if (argc == 1) ios::sync_with_stdio(false), cin.tie(0); FOR(i, argc - 1) s += argv[i + 1], s += '\n'; FOR(i, s.size()) ungetc(s[s.size() - 1 - i], stdin); cout.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x, to) for (x = 0; x < (to); x++) #define FORR(x, arr) for (auto &x : arr) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) //------------------------------------------------------- int N; int A[101010]; pair<int, int> P[101010]; int mi[101010]; vector<pair<int, int>> D; void solve() { int i, j, k, l, r, x, y; string s; cin >> N; FOR(i, N) { cin >> A[i]; P[i] = {A[i], i}; } sort(P, P + N); int C[2] = {}; FOR(i, N) { if (P[i].first < 0) mi[P[i].second] = 1; C[mi[P[i].second]]++; } if (C[0] == N) { mi[P[0].second] = 1; } if (C[1] == N) { mi[P[N - 1].second] = 0; } multiset<ll> S[2]; FOR(i, N) S[mi[i]].insert(A[i]); vector<pair<ll, ll>> V; while (S[0].size() > 1) { auto it = S[0].begin(); auto it2 = S[1].begin(); ll a = *it; ll b = *it2; S[0].erase(it); S[1].erase(it2); V.push_back({b, a}); S[1].insert(b - a); } while (S[1].size()) { auto it = S[0].begin(); auto it2 = S[1].begin(); ll a = *it; ll b = *it2; S[0].erase(it); S[1].erase(it2); V.push_back({a, b}); S[0].insert(a - b); } cout << *S[0].begin() << endl; FORR(d, V) cout << d.first << " " << d.second << endl; } int main(int argc, char **argv) { string s; int i; if (argc == 1) ios::sync_with_stdio(false), cin.tie(0); FOR(i, argc - 1) s += argv[i + 1], s += '\n'; FOR(i, s.size()) ungetc(s[s.size() - 1 - i], stdin); cout.tie(0); solve(); return 0; }
[]
822,296
822,297
u452725238
cpp
p03007
#include <algorithm> #include <iostream> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; #define mod 1000000007 #define mad(a, b) a = (a + b) % mod; #define N 100010 typedef pair<ll, ll> P; vector<P> v; ll n, a[N]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (int i = 1; i < n - 1; i++) { if (a[i] < 0) continue; v.push_back(make_pair(a[0], a[i])); a[0] = a[0] - a[i]; } for (int i = 1; i < n - 1; i++) { if (a[i] >= 0) continue; v.push_back(make_pair(a[i], a[n - 1])); a[n - 1] = a[n - 1] - a[i]; } v.push_back(make_pair(a[n - 1], a[0])); cout << a[n - 1] - a[0] << endl; for (int i = 0; i < n - 1; i++) { cout << v[i].first << " " << v[i].second << endl; } return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; #define mod 1000000007 #define mad(a, b) a = (a + b) % mod; #define N 100010 typedef pair<ll, ll> P; vector<P> v; ll n, a[N]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (int i = 1; i < n - 1; i++) { if (a[i] < 0) continue; v.push_back(make_pair(a[0], a[i])); a[0] = a[0] - a[i]; } for (int i = 1; i < n - 1; i++) { if (a[i] >= 0) continue; v.push_back(make_pair(a[n - 1], a[i])); a[n - 1] = a[n - 1] - a[i]; } v.push_back(make_pair(a[n - 1], a[0])); cout << a[n - 1] - a[0] << endl; for (int i = 0; i < n - 1; i++) { cout << v[i].first << " " << v[i].second << endl; } return 0; }
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
822,300
822,301
u924885571
cpp
p03008
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #include "_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template <class T, class V> typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) { t = v; } template <class T, class V> typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) { for (auto &e : t) fill(e, v); } // auto v = make_vec<int>(h, w); // fill(v, 0); signed main() { int n; cin >> n; auto v = make_vec<int>(2, 3); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { cin >> v[i][j]; } } int N = n; for (int i = 0; i < 2; i++) { vector<int> dp(N + 1); iota(dp.begin(), dp.end(), 0); for (int j = 0; j < 3; j++) { int add = v[i ^ 1][j], cost = v[i][j]; for (int k = 0; k + add <= N; k++) { dp[k + add] = max(dp[k + add], dp[k] + cost); } } N = dp[N]; } cout << N << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #ifdef _DEBUG #include "_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template <class T, class V> typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) { t = v; } template <class T, class V> typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) { for (auto &e : t) fill(e, v); } // auto v = make_vec<int>(h, w); // fill(v, 0); signed main() { int n; cin >> n; auto v = make_vec<int>(2, 3); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { cin >> v[i][j]; } } int N = n; for (int i = 0; i < 2; i++) { vector<int> dp(N + 1); iota(dp.begin(), dp.end(), 0); for (int j = 0; j < 3; j++) { int add = v[i][j], cost = v[i ^ 1][j]; for (int k = 0; k + add <= N; k++) { dp[k + add] = max(dp[k + add], dp[k] + cost); } } N = dp[N]; } cout << N << endl; return 0; }
[ "expression.operation.binary.remove" ]
822,314
822,315
u344122377
cpp
p03008
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using P = pair<int, int>; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template <class T> inline bool chmax(T &x, T y) { if (x < y) { x = y; return true; } return false; } template <class T> inline bool chmin(T &x, T y) { if (x > y) { x = y; return true; } return false; } int dp[25000005], dp2[25000005]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; vector<vector<int>> X(2, vector<int>(3)); cin >> N; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 3; ++j) { cin >> X[i][j]; } } int bound = 0; for (int i = 0; i <= N; ++i) { dp[i] = i; for (int j = 0; j < 3; ++j) { if (i >= X[0][j]) chmax(dp[i], dp[i - X[0][j]] + X[1][j]); } chmax(bound, dp[i]); } int ans = 0; for (int i = 0; i <= bound; ++i) { dp2[i] = i; for (int j = 0; j < 3; ++j) { if (i >= X[1][j]) chmax(dp2[i], dp2[i - X[1][j]] + X[0][j]); } chmax(ans, dp[i]); } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; using ll = long long; using P = pair<int, int>; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template <class T> inline bool chmax(T &x, T y) { if (x < y) { x = y; return true; } return false; } template <class T> inline bool chmin(T &x, T y) { if (x > y) { x = y; return true; } return false; } int dp[25000005]; ll dp2[25000005]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; vector<vector<int>> X(2, vector<int>(3)); cin >> N; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 3; ++j) { cin >> X[i][j]; } } int bound = 0; for (int i = 0; i <= N; ++i) { dp[i] = i; for (int j = 0; j < 3; ++j) { if (i >= X[0][j]) chmax(dp[i], dp[i - X[0][j]] + X[1][j]); } chmax(bound, dp[i]); } ll ans = 0; for (int i = 0; i <= bound; ++i) { dp2[i] = i; for (int j = 0; j < 3; ++j) { if (i >= X[1][j]) chmax(dp2[i], dp2[i - X[1][j]] + X[0][j]); } chmax(ans, dp2[i]); } cout << ans << endl; }
[ "variable_declaration.type.change", "identifier.change", "call.arguments.change" ]
822,322
822,321
u190018920
cpp
p03008
// Template #include <bits/stdc++.h> #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i = 0; i < (n); ++i) #define rep3(i, l, r) for (int i = (l); i < (r); ++i) #define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; using ll = long long; constexpr int inf = 1001001001; constexpr ll INF = 3003003003003003003; template <typename T> inline bool chmin(T &x, const T &y) { if (x > y) { x = y; return 1; } return 0; } template <typename T> inline bool chmax(T &x, const T &y) { if (x < y) { x = y; return 1; } return 0; } struct IOSET { IOSET() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); } } ioset; // Main Code int main() { int n, ga, sa, ba, gb, sb, bb; cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; int w[] = {ga, sa, ba, gb, gb, bb}, v[] = {gb - ga, sb - sa, bb - ba, ga - gb, sa - sb, ba - bb}; vector<vector<ll>> dp1(4, vector<ll>(n + 1, -INF)); dp1[0][0] = 0; rep(i, 3) rep(j, n + 1) { if (dp1[i][j] == -INF) continue; chmax(dp1[i + 1][j], dp1[i][j]); if (j < n) chmax(dp1[i][j + 1], dp1[i][j]); if (j + w[i] <= n) chmax(dp1[i][j + w[i]], dp1[i][j] + v[i]); } n += dp1[3][n]; vector<vector<ll>> dp2(4, vector<ll>(n + 1, -INF)); dp2[0][0] = 0; rep(i, 3) rep(j, n + 1) { if (dp2[i][j] == -INF) continue; chmax(dp2[i + 1][j], dp2[i][j]); if (j < n) chmax(dp2[i][j + 1], dp2[i][j]); if (j + w[i + 3] <= n) chmax(dp2[i][j + w[i + 3]], dp2[i][j] + v[i + 3]); } n += dp2[3][n]; cout << n << "\n"; return 0; }
// Template #include <bits/stdc++.h> #define rep_override(x, y, z, name, ...) name #define rep2(i, n) for (int i = 0; i < (n); ++i) #define rep3(i, l, r) for (int i = (l); i < (r); ++i) #define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; using ll = long long; constexpr int inf = 1001001001; constexpr ll INF = 3003003003003003003; template <typename T> inline bool chmin(T &x, const T &y) { if (x > y) { x = y; return 1; } return 0; } template <typename T> inline bool chmax(T &x, const T &y) { if (x < y) { x = y; return 1; } return 0; } struct IOSET { IOSET() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); } } ioset; // Main Code int main() { ll n; int ga, sa, ba, gb, sb, bb; cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; int w[] = {ga, sa, ba, gb, sb, bb}, v[] = {gb - ga, sb - sa, bb - ba, ga - gb, sa - sb, ba - bb}; vector<vector<ll>> dp1(4, vector<ll>(n + 1, -INF)); dp1[0][0] = 0; rep(i, 3) rep(j, n + 1) { if (dp1[i][j] == -INF) continue; chmax(dp1[i + 1][j], dp1[i][j]); if (j < n) chmax(dp1[i][j + 1], dp1[i][j]); if (j + w[i] <= n) chmax(dp1[i][j + w[i]], dp1[i][j] + v[i]); } n += dp1[3][n]; vector<vector<ll>> dp2(4, vector<ll>(n + 1, -INF)); dp2[0][0] = 0; rep(i, 3) rep(j, n + 1) { if (dp2[i][j] == -INF) continue; chmax(dp2[i + 1][j], dp2[i][j]); if (j < n) chmax(dp2[i][j + 1], dp2[i][j]); if (j + w[i + 3] <= n) chmax(dp2[i][j + w[i + 3]], dp2[i][j] + v[i + 3]); } n += dp2[3][n]; cout << n << "\n"; return 0; }
[ "variable_declaration.type.change", "identifier.change" ]
822,327
822,326
u826189900
cpp
p03008
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; using ll = long long; unsigned euclidean_gcd(unsigned a, unsigned b) { if (a < b) return euclidean_gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll ll_gcd(ll a, ll b) { if (a < b) return ll_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } struct UnionFind { vector<ll> par; vector<ll> siz; UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (ll i = 0; i < sz_; ++i) par[i] = i; } ll root(ll x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { return root(x) == root(y); } ll size(ll x) { return siz[root(x)]; } }; long long modpow(long long a, long long n, long long mod) { if (n < 0) return 0; long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } vector<int> tpsort(vector<vector<int>> &G) { int V = G.size(); vector<int> sorted_vertices; queue<int> que; vector<int> indegree(V); for (int i = 0; i < V; i++) { for (int j = 0; j < G[i].size(); j++) { indegree[G[i][j]]++; } } for (int i = 0; i < V; i++) { if (indegree[i] == 0) { que.push(i); } } while (que.empty() == false) { int v = que.front(); que.pop(); for (int i = 0; i < G[v].size(); i++) { int u = G[v][i]; indegree[u] -= 1; if (indegree[u] == 0) que.push(u); } sorted_vertices.push_back(v); } return sorted_vertices; } struct Point { double x; double y; }; struct LineSegment { Point start; Point end; }; double tenkyori(const LineSegment &line, const Point &point) { double x0 = point.x, y0 = point.y; double x1 = line.start.x, y1 = line.start.y; double x2 = line.end.x, y2 = line.end.y; double a = x2 - x1; double b = y2 - y1; double a2 = a * a; double b2 = b * b; double r2 = a2 + b2; double tt = -(a * (x1 - x0) + b * (y1 - y0)); if (tt < 0) return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); else if (tt > r2) return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0)); double f1 = a * (y1 - y0) - b * (x1 - x0); return sqrt((f1 * f1) / r2); } void dfs1(vector<vector<ll>> &z, ll k, ll oya, ll &ans, vector<ll> &b) { for (auto m : z[k]) { if (m != oya) dfs1(z, m, k, ans, b); } vector<ll> s; for (auto m : z[k]) { if (m != oya) s.push_back(b[m]); } ll m = b.size() - 1; for (auto d : s) { m -= d; } b[k] = b.size() - m; if (m != 0) s.push_back(m); ll a = modinv(2, 1000000007); for (auto d : s) { a += 1000000007 - modinv(modpow(2, b.size() - d, 1000000007), 1000000007); } a += modinv(modpow(2, b.size(), 1000000007), 1000000007) * (z[k].size() - 1); ans += a; ans %= 1000000007; return; } ll merge_cnt(vector<int> &a) { int n = a.size(); if (n <= 1) { return 0; } ll cnt = 0; vector<int> b(a.begin(), a.begin() + n / 2); vector<int> c(a.begin() + n / 2, a.end()); cnt += merge_cnt(b); cnt += merge_cnt(c); int ai = 0, bi = 0, ci = 0; while (ai < n) { if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) { a[ai++] = b[bi++]; } else { cnt += n / 2 - bi; a[ai++] = c[ci++]; } } return cnt; } int main() { ll n; vector<ll> a(3); vector<ll> b(3); cin >> n >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2]; ll mx = n; vector<ll> z(n + 1); for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; if (a[i] >= b[i]) break; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + a[i] * k > n) break; nz[j + a[i] * k] = max(nz[j + a[i] * k], z[j] + (b[i] - a[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx += z[n]; ll u = mx; if (a[0] <= b[0]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[2] * (a[2] - b[2]))); } } else if (a[1] <= b[1]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[2] > u) break; mx = max(mx, u + (a[2] - b[2]) * i + max((ll)0, (u - i * b[2]) / b[0] * (a[0] - b[0]))); } } else if (a[2] <= b[2]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[0] * (a[0] - b[0]))); } } else { for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + b[i] * k > n) break; nz[j + b[i] * k] = max(nz[j + b[i] * k], z[j] + (a[i] - b[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx = z[n] + u; } cout << mx << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; using ll = long long; unsigned euclidean_gcd(unsigned a, unsigned b) { if (a < b) return euclidean_gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll ll_gcd(ll a, ll b) { if (a < b) return ll_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } struct UnionFind { vector<ll> par; vector<ll> siz; UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (ll i = 0; i < sz_; ++i) par[i] = i; } ll root(ll x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { return root(x) == root(y); } ll size(ll x) { return siz[root(x)]; } }; long long modpow(long long a, long long n, long long mod) { if (n < 0) return 0; long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } vector<int> tpsort(vector<vector<int>> &G) { int V = G.size(); vector<int> sorted_vertices; queue<int> que; vector<int> indegree(V); for (int i = 0; i < V; i++) { for (int j = 0; j < G[i].size(); j++) { indegree[G[i][j]]++; } } for (int i = 0; i < V; i++) { if (indegree[i] == 0) { que.push(i); } } while (que.empty() == false) { int v = que.front(); que.pop(); for (int i = 0; i < G[v].size(); i++) { int u = G[v][i]; indegree[u] -= 1; if (indegree[u] == 0) que.push(u); } sorted_vertices.push_back(v); } return sorted_vertices; } struct Point { double x; double y; }; struct LineSegment { Point start; Point end; }; double tenkyori(const LineSegment &line, const Point &point) { double x0 = point.x, y0 = point.y; double x1 = line.start.x, y1 = line.start.y; double x2 = line.end.x, y2 = line.end.y; double a = x2 - x1; double b = y2 - y1; double a2 = a * a; double b2 = b * b; double r2 = a2 + b2; double tt = -(a * (x1 - x0) + b * (y1 - y0)); if (tt < 0) return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); else if (tt > r2) return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0)); double f1 = a * (y1 - y0) - b * (x1 - x0); return sqrt((f1 * f1) / r2); } void dfs1(vector<vector<ll>> &z, ll k, ll oya, ll &ans, vector<ll> &b) { for (auto m : z[k]) { if (m != oya) dfs1(z, m, k, ans, b); } vector<ll> s; for (auto m : z[k]) { if (m != oya) s.push_back(b[m]); } ll m = b.size() - 1; for (auto d : s) { m -= d; } b[k] = b.size() - m; if (m != 0) s.push_back(m); ll a = modinv(2, 1000000007); for (auto d : s) { a += 1000000007 - modinv(modpow(2, b.size() - d, 1000000007), 1000000007); } a += modinv(modpow(2, b.size(), 1000000007), 1000000007) * (z[k].size() - 1); ans += a; ans %= 1000000007; return; } ll merge_cnt(vector<int> &a) { int n = a.size(); if (n <= 1) { return 0; } ll cnt = 0; vector<int> b(a.begin(), a.begin() + n / 2); vector<int> c(a.begin() + n / 2, a.end()); cnt += merge_cnt(b); cnt += merge_cnt(c); int ai = 0, bi = 0, ci = 0; while (ai < n) { if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) { a[ai++] = b[bi++]; } else { cnt += n / 2 - bi; a[ai++] = c[ci++]; } } return cnt; } int main() { ll n; vector<ll> a(3); vector<ll> b(3); cin >> n >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2]; ll mx = n; vector<ll> z(n + 1); for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; if (a[i] >= b[i]) continue; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + a[i] * k > n) break; nz[j + a[i] * k] = max(nz[j + a[i] * k], z[j] + (b[i] - a[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx += z[n]; ll u = mx; if (a[0] <= b[0]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[2] * (a[2] - b[2]))); } } else if (a[1] <= b[1]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[2] > u) break; mx = max(mx, u + (a[2] - b[2]) * i + max((ll)0, (u - i * b[2]) / b[0] * (a[0] - b[0]))); } } else if (a[2] <= b[2]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[0] * (a[0] - b[0]))); } } else { for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + b[i] * k > n) break; nz[j + b[i] * k] = max(nz[j + b[i] * k], z[j] + (a[i] - b[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx = z[n] + u; } cout << mx << endl; }
[ "control_flow.break.remove", "control_flow.continue.add" ]
822,328
822,329
u577774192
cpp
p03008
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; using ll = long long; unsigned euclidean_gcd(unsigned a, unsigned b) { if (a < b) return euclidean_gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll ll_gcd(ll a, ll b) { if (a < b) return ll_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } struct UnionFind { vector<ll> par; vector<ll> siz; UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (ll i = 0; i < sz_; ++i) par[i] = i; } ll root(ll x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { return root(x) == root(y); } ll size(ll x) { return siz[root(x)]; } }; long long modpow(long long a, long long n, long long mod) { if (n < 0) return 0; long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } vector<int> tpsort(vector<vector<int>> &G) { int V = G.size(); vector<int> sorted_vertices; queue<int> que; vector<int> indegree(V); for (int i = 0; i < V; i++) { for (int j = 0; j < G[i].size(); j++) { indegree[G[i][j]]++; } } for (int i = 0; i < V; i++) { if (indegree[i] == 0) { que.push(i); } } while (que.empty() == false) { int v = que.front(); que.pop(); for (int i = 0; i < G[v].size(); i++) { int u = G[v][i]; indegree[u] -= 1; if (indegree[u] == 0) que.push(u); } sorted_vertices.push_back(v); } return sorted_vertices; } struct Point { double x; double y; }; struct LineSegment { Point start; Point end; }; double tenkyori(const LineSegment &line, const Point &point) { double x0 = point.x, y0 = point.y; double x1 = line.start.x, y1 = line.start.y; double x2 = line.end.x, y2 = line.end.y; double a = x2 - x1; double b = y2 - y1; double a2 = a * a; double b2 = b * b; double r2 = a2 + b2; double tt = -(a * (x1 - x0) + b * (y1 - y0)); if (tt < 0) return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); else if (tt > r2) return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0)); double f1 = a * (y1 - y0) - b * (x1 - x0); return sqrt((f1 * f1) / r2); } void dfs1(vector<vector<ll>> &z, ll k, ll oya, ll &ans, vector<ll> &b) { for (auto m : z[k]) { if (m != oya) dfs1(z, m, k, ans, b); } vector<ll> s; for (auto m : z[k]) { if (m != oya) s.push_back(b[m]); } ll m = b.size() - 1; for (auto d : s) { m -= d; } b[k] = b.size() - m; if (m != 0) s.push_back(m); ll a = modinv(2, 1000000007); for (auto d : s) { a += 1000000007 - modinv(modpow(2, b.size() - d, 1000000007), 1000000007); } a += modinv(modpow(2, b.size(), 1000000007), 1000000007) * (z[k].size() - 1); ans += a; ans %= 1000000007; return; } ll merge_cnt(vector<int> &a) { int n = a.size(); if (n <= 1) { return 0; } ll cnt = 0; vector<int> b(a.begin(), a.begin() + n / 2); vector<int> c(a.begin() + n / 2, a.end()); cnt += merge_cnt(b); cnt += merge_cnt(c); int ai = 0, bi = 0, ci = 0; while (ai < n) { if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) { a[ai++] = b[bi++]; } else { cnt += n / 2 - bi; a[ai++] = c[ci++]; } } return cnt; } int main() { ll n; vector<ll> a(3); vector<ll> b(3); cin >> n >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2]; ll mx = n; vector<ll> z(n + 1); for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; if (a[i] >= b[i]) break; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + a[i] * k > n) break; nz[j + a[i] * k] = max(nz[j + a[i] * k], z[j] + (b[i] - a[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx += z[n]; ll u = mx; if (a[0] <= b[0]) { for (ll i = 0; i < n * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[2] * (a[2] - b[2]))); } } else if (a[1] <= b[1]) { for (ll i = 0; i < n * 5000 + 5; i++) { if (i * b[2] > u) break; mx = max(mx, u + (a[2] - b[2]) * i + max((ll)0, (u - i * b[2]) / b[0] * (a[0] - b[0]))); } } else if (a[2] <= b[2]) { for (ll i = 0; i < n * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[0] * (a[0] - b[0]))); } } else { for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + b[i] * k > n) break; nz[j + b[i] * k] = max(nz[j + b[i] * k], z[j] + (a[i] - b[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx = z[n] + u; } cout << mx << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #pragma warning(disable : 4996) using namespace std; using ll = long long; unsigned euclidean_gcd(unsigned a, unsigned b) { if (a < b) return euclidean_gcd(b, a); unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll ll_gcd(ll a, ll b) { if (a < b) return ll_gcd(b, a); ll r; while ((r = a % b)) { a = b; b = r; } return b; } struct UnionFind { vector<ll> par; vector<ll> siz; UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) { for (ll i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (ll i = 0; i < sz_; ++i) par[i] = i; } ll root(ll x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(ll x, ll y) { return root(x) == root(y); } ll size(ll x) { return siz[root(x)]; } }; long long modpow(long long a, long long n, long long mod) { if (n < 0) return 0; long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } vector<int> tpsort(vector<vector<int>> &G) { int V = G.size(); vector<int> sorted_vertices; queue<int> que; vector<int> indegree(V); for (int i = 0; i < V; i++) { for (int j = 0; j < G[i].size(); j++) { indegree[G[i][j]]++; } } for (int i = 0; i < V; i++) { if (indegree[i] == 0) { que.push(i); } } while (que.empty() == false) { int v = que.front(); que.pop(); for (int i = 0; i < G[v].size(); i++) { int u = G[v][i]; indegree[u] -= 1; if (indegree[u] == 0) que.push(u); } sorted_vertices.push_back(v); } return sorted_vertices; } struct Point { double x; double y; }; struct LineSegment { Point start; Point end; }; double tenkyori(const LineSegment &line, const Point &point) { double x0 = point.x, y0 = point.y; double x1 = line.start.x, y1 = line.start.y; double x2 = line.end.x, y2 = line.end.y; double a = x2 - x1; double b = y2 - y1; double a2 = a * a; double b2 = b * b; double r2 = a2 + b2; double tt = -(a * (x1 - x0) + b * (y1 - y0)); if (tt < 0) return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)); else if (tt > r2) return sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0)); double f1 = a * (y1 - y0) - b * (x1 - x0); return sqrt((f1 * f1) / r2); } void dfs1(vector<vector<ll>> &z, ll k, ll oya, ll &ans, vector<ll> &b) { for (auto m : z[k]) { if (m != oya) dfs1(z, m, k, ans, b); } vector<ll> s; for (auto m : z[k]) { if (m != oya) s.push_back(b[m]); } ll m = b.size() - 1; for (auto d : s) { m -= d; } b[k] = b.size() - m; if (m != 0) s.push_back(m); ll a = modinv(2, 1000000007); for (auto d : s) { a += 1000000007 - modinv(modpow(2, b.size() - d, 1000000007), 1000000007); } a += modinv(modpow(2, b.size(), 1000000007), 1000000007) * (z[k].size() - 1); ans += a; ans %= 1000000007; return; } ll merge_cnt(vector<int> &a) { int n = a.size(); if (n <= 1) { return 0; } ll cnt = 0; vector<int> b(a.begin(), a.begin() + n / 2); vector<int> c(a.begin() + n / 2, a.end()); cnt += merge_cnt(b); cnt += merge_cnt(c); int ai = 0, bi = 0, ci = 0; while (ai < n) { if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) { a[ai++] = b[bi++]; } else { cnt += n / 2 - bi; a[ai++] = c[ci++]; } } return cnt; } int main() { ll n; vector<ll> a(3); vector<ll> b(3); cin >> n >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2]; ll mx = n; vector<ll> z(n + 1); for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; if (a[i] >= b[i]) continue; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + a[i] * k > n) break; nz[j + a[i] * k] = max(nz[j + a[i] * k], z[j] + (b[i] - a[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx += z[n]; ll u = mx; if (a[0] <= b[0]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[2] * (a[2] - b[2]))); } } else if (a[1] <= b[1]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[2] > u) break; mx = max(mx, u + (a[2] - b[2]) * i + max((ll)0, (u - i * b[2]) / b[0] * (a[0] - b[0]))); } } else if (a[2] <= b[2]) { for (ll i = 0; i < 5000 * 5000 + 5; i++) { if (i * b[1] > u) break; mx = max(mx, u + (a[1] - b[1]) * i + max((ll)0, (u - i * b[1]) / b[0] * (a[0] - b[0]))); } } else { for (int i = 0; i < 3; i++) { vector<ll> nz(n + 1); nz = z; for (int j = 0; j < n + 1; j++) { for (int k = 1; k < n + 1; k++) { if (j + b[i] * k > n) break; nz[j + b[i] * k] = max(nz[j + b[i] * k], z[j] + (a[i] - b[i]) * k); } } for (int i = 0; i < n; i++) { nz[i + 1] = max(nz[i], nz[i + 1]); } z = nz; } mx = z[n] + u; } cout << mx << endl; }
[ "control_flow.break.remove", "control_flow.continue.add", "identifier.replace.remove", "literal.replace.add", "control_flow.branch.if.condition.change" ]
822,330
822,329
u577774192
cpp
p03008
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; const int MOD = 1000000007; /* const int MOD = 998244353; */ const int INF = 1e18; const double PI = acos(-1); using namespace std; struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } INIT; int f(int N, int a[], int b[]) { vector<int> dp(N + 1, -INF); dp[0] = 0; REP(i, N) REP(j, 3) { if (i != 0) chmax(dp[i], dp[i - 1]); if (i + a[j] <= N) chmax(dp[i + a[j]], dp[i] + b[j] - a[j]); } return dp[N] + N; } signed main() { int N; cin >> N; int a[3], b[3]; REP(i, 3) cin >> a[i]; REP(i, 3) cin >> b[i]; int ret = f(N, a, b); cout << f(ret, b, a) << "\n"; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; const int MOD = 1000000007; /* const int MOD = 998244353; */ const int INF = 1e18; const double PI = acos(-1); using namespace std; struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } INIT; int f(int N, int a[], int b[]) { vector<int> dp(N + 1, -INF); dp[0] = 0; REP(i, N + 1) REP(j, 3) { if (i != 0) chmax(dp[i], dp[i - 1]); if (i + a[j] <= N) chmax(dp[i + a[j]], dp[i] + b[j] - a[j]); } return dp[N] + N; } signed main() { int N; cin >> N; int a[3], b[3]; REP(i, 3) cin >> a[i]; REP(i, 3) cin >> b[i]; int ret = f(N, a, b); cout << f(ret, b, a) << "\n"; return 0; }
[ "expression.operation.binary.add" ]
822,344
822,345
u812973725
cpp
p03008
#include <bits/stdc++.h> #define int long long #define endl '\n' #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define bug1(x) \ { cerr << (#x) << "=" << x << endl; } #define bug2(x, y) \ { cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << endl; } #define bug3(x, y, z) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << endl; \ } #define bug4(x, y, z, w) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << " " << (#w) << "=" << w << endl; \ } #define bug5(x, y, z, w, p) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \ << "=" << p << endl; \ } #define bug6(x, y, z, w, p, q) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \ << "=" << p << " " << (#q) << "=" << q << endl; \ } #define bugn(x, n) \ { \ cerr << (#x) << ":"; \ for (int i = 0; i < n; i++) \ cerr << x[i] << " "; \ cerr << endl; \ } #define bugnm(x, n, m) \ { \ cerr << (#x) << endl; \ for (int i = 0; i < n; i++) { \ cerr << "Row #" << i << ":"; \ for (int j = 0; j < m; j++) \ cerr << x[i][j] << " "; \ cerr << endl; \ } \ } typedef long long ll; typedef long double ld; using namespace std; #define y1 _ const int maxn = 25000001; int n, x1, y1, z1, x2, y2, z2; int dp[maxn]; int solve(int m) { int &ans = dp[m]; if (ans != -1) return ans; ans = m; if (m >= x1) { ans = max(ans, x2 + solve(m - x1)); } if (m >= y1) { ans = max(ans, y2 + solve(m - y1)); } if (m >= z2) { ans = max(ans, z2 + solve(m - z1)); } return ans; } int32_t main() { IOS cin >> n >> x1 >> y1 >> z1 >> x2 >> y2 >> z2; // A -> B memset(dp, -1, sizeof(dp)); n = solve(n); // B -> A swap(x1, x2); swap(y1, y2); swap(z1, z2); memset(dp, -1, sizeof(dp)); n = solve(n); cout << n; } /* * long long or int? * index out of bound? * Tested on own test case?corner? * Make more general solution. * Read Read Read Read .... */
#include <bits/stdc++.h> #define int long long #define endl '\n' #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define bug1(x) \ { cerr << (#x) << "=" << x << endl; } #define bug2(x, y) \ { cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << endl; } #define bug3(x, y, z) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << endl; \ } #define bug4(x, y, z, w) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << " " << (#w) << "=" << w << endl; \ } #define bug5(x, y, z, w, p) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \ << "=" << p << endl; \ } #define bug6(x, y, z, w, p, q) \ { \ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \ << (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \ << "=" << p << " " << (#q) << "=" << q << endl; \ } #define bugn(x, n) \ { \ cerr << (#x) << ":"; \ for (int i = 0; i < n; i++) \ cerr << x[i] << " "; \ cerr << endl; \ } #define bugnm(x, n, m) \ { \ cerr << (#x) << endl; \ for (int i = 0; i < n; i++) { \ cerr << "Row #" << i << ":"; \ for (int j = 0; j < m; j++) \ cerr << x[i][j] << " "; \ cerr << endl; \ } \ } typedef long long ll; typedef long double ld; using namespace std; #define y1 _ const int maxn = 25000005; int n, x1, y1, z1, x2, y2, z2; int dp[maxn]; int solve(int m) { int &ans = dp[m]; if (ans != -1) return ans; ans = m; if (m >= x1) { ans = max(ans, x2 + solve(m - x1)); } if (m >= y1) { ans = max(ans, y2 + solve(m - y1)); } if (m >= z1) { ans = max(ans, z2 + solve(m - z1)); } return ans; } int32_t main() { IOS cin >> n >> x1 >> y1 >> z1 >> x2 >> y2 >> z2; // A -> B memset(dp, -1, sizeof(dp)); n = solve(n); // B -> A swap(x1, x2); swap(y1, y2); swap(z1, z2); memset(dp, -1, sizeof(dp)); n = solve(n); cout << n; } /* * long long or int? * index out of bound? * Tested on own test case?corner? * Make more general solution. * Read Read Read Read .... */
[ "literal.number.change", "variable_declaration.value.change", "identifier.change", "control_flow.branch.if.condition.change" ]
822,350
822,351
u392058778
cpp
p03008
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ // GCC #define _GLIBCXX_DEBUG // Clang //#define _LIBCPP_DEBUG 0 #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #define f(i, n) for (int i = 0; i < (n); i++) // here!!! // define int long long !!!!! #define int long long // define int long long !!!!! #define mod (int)((1e9) + 7) // constexpr int mod = 998244353ll; #ifdef int #define inf (int)(3e18) #else #define inf (int)(5e8) #endif #define intt long long #define itn long long #define P pair<long long, long long> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define ALL(v) v.begin(), v.end() #define smallpriority_queue(x) priority_queue<x, vector<x>, greater<x>> using namespace std; // Library //モッドパウ inline int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y & 1) { res *= x; res %= m; } x = x * x % m; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { if (!x || x == 1) { return false; } for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } // saidai-kouyakusuu inline int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } inline int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x /= 2; } else { break; } } return ans; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; } template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } #define fin(i) scanf("%lld", &i) #define fout(i) printf("%lld", i) #define fendl printf("\n") int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; // cout<<kai(x, y)<<' '<<modpow(kai(y, y), mod - 2)<<endl; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } // Library-End #define vecin(v) \ for (int i = 0; i < v.size(); i++) \ scanf("%lld", &v[i]); #define vecout(v) \ { \ for (int i = 0; i < (int)v.size(); i++) \ printf("%lld ", v[i]); \ printf("\n"); \ } template <typename T> class kaageSegTree { protected: unsigned int n = 1, rank = 0; std::vector<T> node; T nodee; virtual T nodef(const T &, const T &) const = 0; public: kaageSegTree(unsigned int m, T init, T nodee) : nodee(nodee) { while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) node[i] = init; } kaageSegTree(const std::vector<T> &initvec, T nodee) : nodee(nodee) { unsigned int m = initvec.size(); while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) { if (i - n < m) node[i] = initvec[i - n]; } } virtual void update(int i, T x) { i += n; node[i] = x; while (i != 1) { i >>= 1; node[i] = nodef(node[2 * i], node[2 * i + 1]); } } virtual T query(int l, int r) { l += n; r += n; T ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } virtual T operator[](const int &x) { return node[n + x]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; class RSQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return lhs + rhs; } public: RSQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, 0) {} RSQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, 0) {} }; class RMiQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::min(lhs, rhs); } public: RMiQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, inf) {} RMiQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, inf) {} }; class RMaQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::max(lhs, rhs); } public: RMaQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, -inf) {} RMaQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, -inf) {} }; template <typename T, typename U> class IntervalSegTree : public kaageSegTree<T> { protected: using kaageSegTree<T>::n; using kaageSegTree<T>::rank; using kaageSegTree<T>::node; using kaageSegTree<T>::nodef; using kaageSegTree<T>::nodee; std::vector<U> lazy; std::vector<bool> lazyflag; std::vector<int> width; virtual void lazyf(U &, const U &) = 0; virtual void updf(T &, const U &, const unsigned int &) = 0; void eval(int k) { for (int i = rank; i > 0; i--) { int nk = k >> i; if (lazyflag[nk]) { updf(node[2 * nk], lazy[nk], width[2 * nk]); updf(node[2 * nk + 1], lazy[nk], width[2 * nk + 1]); if (lazyflag[2 * nk]) lazyf(lazy[2 * nk], lazy[nk]); else lazy[2 * nk] = lazy[nk]; if (lazyflag[2 * nk + 1]) lazyf(lazy[2 * nk + 1], lazy[nk]); else lazy[2 * nk + 1] = lazy[nk]; lazyflag[2 * nk] = lazyflag[2 * nk + 1] = true; lazyflag[nk] = false; } } } public: IntervalSegTree(unsigned int m, T init, T nodee) : kaageSegTree<T>(m, init, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } IntervalSegTree(T nodee, const std::vector<T> &initvec) : kaageSegTree<T>(initvec, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } void update(int i, U x) { i += n; eval(i); updf(node[i], x, width[i]); if (lazyflag[i]) lazyf(lazy[i], x); else { lazyflag[i] = true; lazy[i] = x; } while (i /= 2) node[i] = nodef(node[2 * i], node[2 * i + 1]); } void update(int l, int r, U x) { l += n; r += n; int nl = l, nr = r; while (!(nl & 1)) nl >>= 1; while (!(nr & 1)) nr >>= 1; nr--; eval(nl); eval(nr); while (l < r) { if (l & 1) { updf(node[l], x, width[l]); if (lazyflag[l]) lazyf(lazy[l], x); else { lazyflag[l] = true; lazy[l] = x; } l++; } if (r & 1) { r--; updf(node[r], x, width[r]); if (lazyflag[r]) lazyf(lazy[r], x); else { lazyflag[r] = true; lazy[r] = x; } } l >>= 1; r >>= 1; } while (nl >>= 1) node[nl] = nodef(node[2 * nl], node[2 * nl + 1]); while (nr >>= 1) node[nr] = nodef(node[2 * nr], node[2 * nr + 1]); } T query(int l, int r) { l += n; r += n; eval(l); eval(r - 1); int ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } T operator[](const int &x) { eval(n + x); return node[n + x]; } T queryForAll() { return node[1]; } }; class RAQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += width * b; } public: RAQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMaQ(unsigned int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = width * b; } public: RUQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMaQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; ////SegTree // template <class T> // class SegTree { // int n; // 葉の数 // vector<T> node; // データを格納するvector // T def; // 初期値かつ単位元 // function<T(T, T)> operation; // 区間クエリで使う処理 // function<T(T, T)> update; // 点更新で使う処理 // // // 区間[a,b)の総和。ノードk=[l,r)に着目している。 // T _query(int a, int b, int k, int l, int r) { // if (r <= a || b <= l) return def; // 交差しない // if (a <= l && r <= b) // return node[k]; // a,l,r,bの順で完全に含まれる // else { // T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 // T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 // return operation(c1, c2); // } // } // // public: // // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // // _update:更新関数 // SegTree(size_t _n, T _def, function<T(T, T)> _operation, // function<T(T, T)> _update) // : def(_def), operation(_operation), update(_update) { // n = 1; // while (n < _n) { // n *= 2; // } // node = vector<T>(2 * n , def); // } // // // 場所i(0-indexed)の値をxで更新 // void change(int i, T x) { // i += n - 1; // node[i] = update(node[i], x); // while (i > 0) { // i = (i - 1) / 2; // node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]); // } // } // // // [a, b)の区間クエリを実行 // T query(int a, int b) { // return _query(a, b, 0, 0, n); // } // // // 添字でアクセス // T operator[](int i) { // return node[i + n - 1]; // } //}; template <class T> class SegTree { int n; vector<T> node; T def; function<T(T, T)> operation; function<T(T, T)> update; public: SegTree(unsigned int _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } node = vector<T>(n * 2, def); } SegTree(vector<int> &initvec, function<T(T, T)> _operation, function<T(T, T)> _update) : operation(_operation), update(_update) { n = 1; while (n < initvec.size()) { n *= 2; } node = vector<T>(n * 2, def); for (int i = n; i < n + initvec.size(); i++) { node[i] = initvec[i - n]; } for (int i = n - 1; i >= 1; i--) { node[i] = operation(node[i * 2], node[i * 2 + 1]); } } void change(int i, T x) { i += n; node[i] = update(node[i], x); while (i >= 1) { i >>= 1; node[i] = operation(node[i * 2], node[i * 2 + 1]); } } T query(int l, int r) { l += n; r += n; T rx = def, lx = def; while (l < r) { if (l & 1) { lx = operation(lx, node[l]); l++; } if (r & 1) { r--; rx = operation(node[r], rx); } l >>= 1; r >>= 1; } return operation(lx, rx); } T operator[](const int &x) { return node[x - n]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } class Union_Find { vector<int> par; vector<int> rankmy; vector<int> ookisa; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); ookisa = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; ookisa[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; ookisa[y] += ookisa[x]; ookisa[x] = 0; } else { par[y] = x; ookisa[x] += ookisa[y]; ookisa[y] = 0; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } int size(int i) { i = find(i); return ookisa[i]; } bool same(int x, int y) { return find(x) == find(y); } }; class BIT { vector<int> data; int size = 0; public: BIT(int _size) { data = vector<int>(_size + 1); size = _size; } void add(int i, int x) { while (i <= size) { data[i] += x; i += i & -i; } } int sum(int i) { assert(i <= size); int s = 0; while (i > 0) { s += data[i]; i -= i & -i; } return s; } int lower_bound(int x) { if (x <= 0) { return 0; } else { int i = 0; int r = 1; while (r < size) r = r << 1; for (int len = r; len > 0; len = len >> 1) { if (i + len < size && data[i + len] < x) { x -= data[i + len]; i += len; } } return i + 1; } } }; // Union-Find-End int perm[1000005]; void init_perm() { perm[0] = 1; REP(i, 1000000) { perm[i] = perm[i - 1] * i % mod; } } int nCk(int x, int y) { return perm[x] * modpow(perm[x - y], mod - 2) % mod * modpow(perm[y], mod - 2) % mod; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } inline string stringmax(string &x, string &y) { if (x.size() > y.size()) { return x; } if (x.size() < y.size()) { return y; } rep(i, x.size()) { if (x[i] > y[i]) { return x; } if (x[i] < y[i]) { return y; } } return x; } vector<int> RollingHash(string &s, string &t) { vector<int> ans; __int128 h = 0, hamod = 0, ki = 0, kim = 0, hikaku = 0, one = 0; one = 1; ki = 1000000007ll; hamod = (one << 61) - 1; kim = 1; rep(i, t.size()) { hikaku *= ki; h *= ki; kim *= ki; hikaku += t[i]; h += s[i]; hikaku %= hamod; h %= hamod; kim %= hamod; } rep(i, (int)s.size() - (int)t.size() + 1) { if (h == hikaku) { ans.emplace_back(i); } h *= ki; h %= hamod; h += s[i + (int)t.size()]; h %= hamod; h += hamod; h -= s[i] * kim % hamod; h %= hamod; } return ans; } struct edge { int to; int length; edge(int _to, int _length) { to = _to; length = _length; } }; vector<int> djkstra(vector<vector<edge>> &road, int start) { vector<int> kyo(road.size(), inf); smallpriority_queue(P) q; q.push({0, start}); kyo[start] = 0; while (q.size()) { int x = q.top().second; itn now = q.top().first; q.pop(); if (kyo[x] < now) { continue; } for (auto &i : road[x]) { if (kyo[i.to] > now + i.length) { kyo[i.to] = now + i.length; q.push({kyo[i.to], i.to}); } } } return kyo; } #define endl "\n" // interactive の時に注意!!! #define printd cout << fixed << setprecision(10) #define eb emplace_back int n, nn, a[5], b[5], dp[5004], dp2[25000004], ans; signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n; rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i]; rep(i, 3) { if (b[i] > a[i]) { rep(j, n - a[i] + 1) { chmax(dp[j + a[i]], dp[j] + b[i] - a[i]); } } } rep(i, n + 1) { chmax(nn, dp[i] + n); } rep(i, 3) { if (a[i] > b[i]) { rep(j, nn - b[i] + 1) { chmax(dp2[j + b[i]], dp2[j] + a[i] - b[i]); } } } rep(i, n + 1) { chmax(ans, dp2[i] + nn); } cout << ans << endl; }
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ // GCC #define _GLIBCXX_DEBUG // Clang //#define _LIBCPP_DEBUG 0 #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #define f(i, n) for (int i = 0; i < (n); i++) // here!!! // define int long long !!!!! #define int long long // define int long long !!!!! #define mod (int)((1e9) + 7) // constexpr int mod = 998244353ll; #ifdef int #define inf (int)(3e18) #else #define inf (int)(5e8) #endif #define intt long long #define itn long long #define P pair<long long, long long> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define ALL(v) v.begin(), v.end() #define smallpriority_queue(x) priority_queue<x, vector<x>, greater<x>> using namespace std; // Library //モッドパウ inline int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y & 1) { res *= x; res %= m; } x = x * x % m; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { if (!x || x == 1) { return false; } for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } // saidai-kouyakusuu inline int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } inline int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x /= 2; } else { break; } } return ans; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; } template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } #define fin(i) scanf("%lld", &i) #define fout(i) printf("%lld", i) #define fendl printf("\n") int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; // cout<<kai(x, y)<<' '<<modpow(kai(y, y), mod - 2)<<endl; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } // Library-End #define vecin(v) \ for (int i = 0; i < v.size(); i++) \ scanf("%lld", &v[i]); #define vecout(v) \ { \ for (int i = 0; i < (int)v.size(); i++) \ printf("%lld ", v[i]); \ printf("\n"); \ } template <typename T> class kaageSegTree { protected: unsigned int n = 1, rank = 0; std::vector<T> node; T nodee; virtual T nodef(const T &, const T &) const = 0; public: kaageSegTree(unsigned int m, T init, T nodee) : nodee(nodee) { while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) node[i] = init; } kaageSegTree(const std::vector<T> &initvec, T nodee) : nodee(nodee) { unsigned int m = initvec.size(); while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) { if (i - n < m) node[i] = initvec[i - n]; } } virtual void update(int i, T x) { i += n; node[i] = x; while (i != 1) { i >>= 1; node[i] = nodef(node[2 * i], node[2 * i + 1]); } } virtual T query(int l, int r) { l += n; r += n; T ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } virtual T operator[](const int &x) { return node[n + x]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; class RSQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return lhs + rhs; } public: RSQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, 0) {} RSQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, 0) {} }; class RMiQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::min(lhs, rhs); } public: RMiQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, inf) {} RMiQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, inf) {} }; class RMaQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::max(lhs, rhs); } public: RMaQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, -inf) {} RMaQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, -inf) {} }; template <typename T, typename U> class IntervalSegTree : public kaageSegTree<T> { protected: using kaageSegTree<T>::n; using kaageSegTree<T>::rank; using kaageSegTree<T>::node; using kaageSegTree<T>::nodef; using kaageSegTree<T>::nodee; std::vector<U> lazy; std::vector<bool> lazyflag; std::vector<int> width; virtual void lazyf(U &, const U &) = 0; virtual void updf(T &, const U &, const unsigned int &) = 0; void eval(int k) { for (int i = rank; i > 0; i--) { int nk = k >> i; if (lazyflag[nk]) { updf(node[2 * nk], lazy[nk], width[2 * nk]); updf(node[2 * nk + 1], lazy[nk], width[2 * nk + 1]); if (lazyflag[2 * nk]) lazyf(lazy[2 * nk], lazy[nk]); else lazy[2 * nk] = lazy[nk]; if (lazyflag[2 * nk + 1]) lazyf(lazy[2 * nk + 1], lazy[nk]); else lazy[2 * nk + 1] = lazy[nk]; lazyflag[2 * nk] = lazyflag[2 * nk + 1] = true; lazyflag[nk] = false; } } } public: IntervalSegTree(unsigned int m, T init, T nodee) : kaageSegTree<T>(m, init, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } IntervalSegTree(T nodee, const std::vector<T> &initvec) : kaageSegTree<T>(initvec, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } void update(int i, U x) { i += n; eval(i); updf(node[i], x, width[i]); if (lazyflag[i]) lazyf(lazy[i], x); else { lazyflag[i] = true; lazy[i] = x; } while (i /= 2) node[i] = nodef(node[2 * i], node[2 * i + 1]); } void update(int l, int r, U x) { l += n; r += n; int nl = l, nr = r; while (!(nl & 1)) nl >>= 1; while (!(nr & 1)) nr >>= 1; nr--; eval(nl); eval(nr); while (l < r) { if (l & 1) { updf(node[l], x, width[l]); if (lazyflag[l]) lazyf(lazy[l], x); else { lazyflag[l] = true; lazy[l] = x; } l++; } if (r & 1) { r--; updf(node[r], x, width[r]); if (lazyflag[r]) lazyf(lazy[r], x); else { lazyflag[r] = true; lazy[r] = x; } } l >>= 1; r >>= 1; } while (nl >>= 1) node[nl] = nodef(node[2 * nl], node[2 * nl + 1]); while (nr >>= 1) node[nr] = nodef(node[2 * nr], node[2 * nr + 1]); } T query(int l, int r) { l += n; r += n; eval(l); eval(r - 1); int ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } T operator[](const int &x) { eval(n + x); return node[n + x]; } T queryForAll() { return node[1]; } }; class RAQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += width * b; } public: RAQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMaQ(unsigned int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = width * b; } public: RUQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMaQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; ////SegTree // template <class T> // class SegTree { // int n; // 葉の数 // vector<T> node; // データを格納するvector // T def; // 初期値かつ単位元 // function<T(T, T)> operation; // 区間クエリで使う処理 // function<T(T, T)> update; // 点更新で使う処理 // // // 区間[a,b)の総和。ノードk=[l,r)に着目している。 // T _query(int a, int b, int k, int l, int r) { // if (r <= a || b <= l) return def; // 交差しない // if (a <= l && r <= b) // return node[k]; // a,l,r,bの順で完全に含まれる // else { // T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 // T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 // return operation(c1, c2); // } // } // // public: // // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // // _update:更新関数 // SegTree(size_t _n, T _def, function<T(T, T)> _operation, // function<T(T, T)> _update) // : def(_def), operation(_operation), update(_update) { // n = 1; // while (n < _n) { // n *= 2; // } // node = vector<T>(2 * n , def); // } // // // 場所i(0-indexed)の値をxで更新 // void change(int i, T x) { // i += n - 1; // node[i] = update(node[i], x); // while (i > 0) { // i = (i - 1) / 2; // node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]); // } // } // // // [a, b)の区間クエリを実行 // T query(int a, int b) { // return _query(a, b, 0, 0, n); // } // // // 添字でアクセス // T operator[](int i) { // return node[i + n - 1]; // } //}; template <class T> class SegTree { int n; vector<T> node; T def; function<T(T, T)> operation; function<T(T, T)> update; public: SegTree(unsigned int _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } node = vector<T>(n * 2, def); } SegTree(vector<int> &initvec, function<T(T, T)> _operation, function<T(T, T)> _update) : operation(_operation), update(_update) { n = 1; while (n < initvec.size()) { n *= 2; } node = vector<T>(n * 2, def); for (int i = n; i < n + initvec.size(); i++) { node[i] = initvec[i - n]; } for (int i = n - 1; i >= 1; i--) { node[i] = operation(node[i * 2], node[i * 2 + 1]); } } void change(int i, T x) { i += n; node[i] = update(node[i], x); while (i >= 1) { i >>= 1; node[i] = operation(node[i * 2], node[i * 2 + 1]); } } T query(int l, int r) { l += n; r += n; T rx = def, lx = def; while (l < r) { if (l & 1) { lx = operation(lx, node[l]); l++; } if (r & 1) { r--; rx = operation(node[r], rx); } l >>= 1; r >>= 1; } return operation(lx, rx); } T operator[](const int &x) { return node[x - n]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } class Union_Find { vector<int> par; vector<int> rankmy; vector<int> ookisa; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); ookisa = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; ookisa[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; ookisa[y] += ookisa[x]; ookisa[x] = 0; } else { par[y] = x; ookisa[x] += ookisa[y]; ookisa[y] = 0; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } int size(int i) { i = find(i); return ookisa[i]; } bool same(int x, int y) { return find(x) == find(y); } }; class BIT { vector<int> data; int size = 0; public: BIT(int _size) { data = vector<int>(_size + 1); size = _size; } void add(int i, int x) { while (i <= size) { data[i] += x; i += i & -i; } } int sum(int i) { assert(i <= size); int s = 0; while (i > 0) { s += data[i]; i -= i & -i; } return s; } int lower_bound(int x) { if (x <= 0) { return 0; } else { int i = 0; int r = 1; while (r < size) r = r << 1; for (int len = r; len > 0; len = len >> 1) { if (i + len < size && data[i + len] < x) { x -= data[i + len]; i += len; } } return i + 1; } } }; // Union-Find-End int perm[1000005]; void init_perm() { perm[0] = 1; REP(i, 1000000) { perm[i] = perm[i - 1] * i % mod; } } int nCk(int x, int y) { return perm[x] * modpow(perm[x - y], mod - 2) % mod * modpow(perm[y], mod - 2) % mod; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } inline string stringmax(string &x, string &y) { if (x.size() > y.size()) { return x; } if (x.size() < y.size()) { return y; } rep(i, x.size()) { if (x[i] > y[i]) { return x; } if (x[i] < y[i]) { return y; } } return x; } vector<int> RollingHash(string &s, string &t) { vector<int> ans; __int128 h = 0, hamod = 0, ki = 0, kim = 0, hikaku = 0, one = 0; one = 1; ki = 1000000007ll; hamod = (one << 61) - 1; kim = 1; rep(i, t.size()) { hikaku *= ki; h *= ki; kim *= ki; hikaku += t[i]; h += s[i]; hikaku %= hamod; h %= hamod; kim %= hamod; } rep(i, (int)s.size() - (int)t.size() + 1) { if (h == hikaku) { ans.emplace_back(i); } h *= ki; h %= hamod; h += s[i + (int)t.size()]; h %= hamod; h += hamod; h -= s[i] * kim % hamod; h %= hamod; } return ans; } struct edge { int to; int length; edge(int _to, int _length) { to = _to; length = _length; } }; vector<int> djkstra(vector<vector<edge>> &road, int start) { vector<int> kyo(road.size(), inf); smallpriority_queue(P) q; q.push({0, start}); kyo[start] = 0; while (q.size()) { int x = q.top().second; itn now = q.top().first; q.pop(); if (kyo[x] < now) { continue; } for (auto &i : road[x]) { if (kyo[i.to] > now + i.length) { kyo[i.to] = now + i.length; q.push({kyo[i.to], i.to}); } } } return kyo; } #define endl "\n" // interactive の時に注意!!! #define printd cout << fixed << setprecision(10) #define eb emplace_back int n, nn, a[5], b[5], dp[5004], dp2[25000004], ans; signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n; rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i]; rep(i, 3) { if (b[i] > a[i]) { rep(j, n - a[i] + 1) { chmax(dp[j + a[i]], dp[j] + b[i] - a[i]); } } } rep(i, n + 1) { chmax(nn, dp[i] + n); } rep(i, 3) { if (a[i] > b[i]) { rep(j, nn - b[i] + 1) { chmax(dp2[j + b[i]], dp2[j] + a[i] - b[i]); } } } rep(i, nn + 1) { chmax(ans, dp2[i] + nn); } cout << ans << endl; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
822,356
822,357
u943070796
cpp
p03008
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ // GCC #define _GLIBCXX_DEBUG // Clang //#define _LIBCPP_DEBUG 0 #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #define f(i, n) for (int i = 0; i < (n); i++) // here!!! // define int long long !!!!! #define int long long // define int long long !!!!! #define mod (int)((1e9) + 7) // constexpr int mod = 998244353ll; #ifdef int #define inf (int)(3e18) #else #define inf (int)(5e8) #endif #define intt long long #define itn long long #define P pair<long long, long long> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define ALL(v) v.begin(), v.end() #define smallpriority_queue(x) priority_queue<x, vector<x>, greater<x>> using namespace std; // Library //モッドパウ inline int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y & 1) { res *= x; res %= m; } x = x * x % m; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { if (!x || x == 1) { return false; } for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } // saidai-kouyakusuu inline int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } inline int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x /= 2; } else { break; } } return ans; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; } template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } #define fin(i) scanf("%lld", &i) #define fout(i) printf("%lld", i) #define fendl printf("\n") int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; // cout<<kai(x, y)<<' '<<modpow(kai(y, y), mod - 2)<<endl; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } // Library-End #define vecin(v) \ for (int i = 0; i < v.size(); i++) \ scanf("%lld", &v[i]); #define vecout(v) \ { \ for (int i = 0; i < (int)v.size(); i++) \ printf("%lld ", v[i]); \ printf("\n"); \ } template <typename T> class kaageSegTree { protected: unsigned int n = 1, rank = 0; std::vector<T> node; T nodee; virtual T nodef(const T &, const T &) const = 0; public: kaageSegTree(unsigned int m, T init, T nodee) : nodee(nodee) { while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) node[i] = init; } kaageSegTree(const std::vector<T> &initvec, T nodee) : nodee(nodee) { unsigned int m = initvec.size(); while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) { if (i - n < m) node[i] = initvec[i - n]; } } virtual void update(int i, T x) { i += n; node[i] = x; while (i != 1) { i >>= 1; node[i] = nodef(node[2 * i], node[2 * i + 1]); } } virtual T query(int l, int r) { l += n; r += n; T ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } virtual T operator[](const int &x) { return node[n + x]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; class RSQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return lhs + rhs; } public: RSQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, 0) {} RSQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, 0) {} }; class RMiQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::min(lhs, rhs); } public: RMiQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, inf) {} RMiQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, inf) {} }; class RMaQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::max(lhs, rhs); } public: RMaQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, -inf) {} RMaQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, -inf) {} }; template <typename T, typename U> class IntervalSegTree : public kaageSegTree<T> { protected: using kaageSegTree<T>::n; using kaageSegTree<T>::rank; using kaageSegTree<T>::node; using kaageSegTree<T>::nodef; using kaageSegTree<T>::nodee; std::vector<U> lazy; std::vector<bool> lazyflag; std::vector<int> width; virtual void lazyf(U &, const U &) = 0; virtual void updf(T &, const U &, const unsigned int &) = 0; void eval(int k) { for (int i = rank; i > 0; i--) { int nk = k >> i; if (lazyflag[nk]) { updf(node[2 * nk], lazy[nk], width[2 * nk]); updf(node[2 * nk + 1], lazy[nk], width[2 * nk + 1]); if (lazyflag[2 * nk]) lazyf(lazy[2 * nk], lazy[nk]); else lazy[2 * nk] = lazy[nk]; if (lazyflag[2 * nk + 1]) lazyf(lazy[2 * nk + 1], lazy[nk]); else lazy[2 * nk + 1] = lazy[nk]; lazyflag[2 * nk] = lazyflag[2 * nk + 1] = true; lazyflag[nk] = false; } } } public: IntervalSegTree(unsigned int m, T init, T nodee) : kaageSegTree<T>(m, init, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } IntervalSegTree(T nodee, const std::vector<T> &initvec) : kaageSegTree<T>(initvec, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } void update(int i, U x) { i += n; eval(i); updf(node[i], x, width[i]); if (lazyflag[i]) lazyf(lazy[i], x); else { lazyflag[i] = true; lazy[i] = x; } while (i /= 2) node[i] = nodef(node[2 * i], node[2 * i + 1]); } void update(int l, int r, U x) { l += n; r += n; int nl = l, nr = r; while (!(nl & 1)) nl >>= 1; while (!(nr & 1)) nr >>= 1; nr--; eval(nl); eval(nr); while (l < r) { if (l & 1) { updf(node[l], x, width[l]); if (lazyflag[l]) lazyf(lazy[l], x); else { lazyflag[l] = true; lazy[l] = x; } l++; } if (r & 1) { r--; updf(node[r], x, width[r]); if (lazyflag[r]) lazyf(lazy[r], x); else { lazyflag[r] = true; lazy[r] = x; } } l >>= 1; r >>= 1; } while (nl >>= 1) node[nl] = nodef(node[2 * nl], node[2 * nl + 1]); while (nr >>= 1) node[nr] = nodef(node[2 * nr], node[2 * nr + 1]); } T query(int l, int r) { l += n; r += n; eval(l); eval(r - 1); int ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } T operator[](const int &x) { eval(n + x); return node[n + x]; } T queryForAll() { return node[1]; } }; class RAQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += width * b; } public: RAQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMaQ(unsigned int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = width * b; } public: RUQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMaQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; ////SegTree // template <class T> // class SegTree { // int n; // 葉の数 // vector<T> node; // データを格納するvector // T def; // 初期値かつ単位元 // function<T(T, T)> operation; // 区間クエリで使う処理 // function<T(T, T)> update; // 点更新で使う処理 // // // 区間[a,b)の総和。ノードk=[l,r)に着目している。 // T _query(int a, int b, int k, int l, int r) { // if (r <= a || b <= l) return def; // 交差しない // if (a <= l && r <= b) // return node[k]; // a,l,r,bの順で完全に含まれる // else { // T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 // T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 // return operation(c1, c2); // } // } // // public: // // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // // _update:更新関数 // SegTree(size_t _n, T _def, function<T(T, T)> _operation, // function<T(T, T)> _update) // : def(_def), operation(_operation), update(_update) { // n = 1; // while (n < _n) { // n *= 2; // } // node = vector<T>(2 * n , def); // } // // // 場所i(0-indexed)の値をxで更新 // void change(int i, T x) { // i += n - 1; // node[i] = update(node[i], x); // while (i > 0) { // i = (i - 1) / 2; // node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]); // } // } // // // [a, b)の区間クエリを実行 // T query(int a, int b) { // return _query(a, b, 0, 0, n); // } // // // 添字でアクセス // T operator[](int i) { // return node[i + n - 1]; // } //}; template <class T> class SegTree { int n; vector<T> node; T def; function<T(T, T)> operation; function<T(T, T)> update; public: SegTree(unsigned int _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } node = vector<T>(n * 2, def); } SegTree(vector<int> &initvec, function<T(T, T)> _operation, function<T(T, T)> _update) : operation(_operation), update(_update) { n = 1; while (n < initvec.size()) { n *= 2; } node = vector<T>(n * 2, def); for (int i = n; i < n + initvec.size(); i++) { node[i] = initvec[i - n]; } for (int i = n - 1; i >= 1; i--) { node[i] = operation(node[i * 2], node[i * 2 + 1]); } } void change(int i, T x) { i += n; node[i] = update(node[i], x); while (i >= 1) { i >>= 1; node[i] = operation(node[i * 2], node[i * 2 + 1]); } } T query(int l, int r) { l += n; r += n; T rx = def, lx = def; while (l < r) { if (l & 1) { lx = operation(lx, node[l]); l++; } if (r & 1) { r--; rx = operation(node[r], rx); } l >>= 1; r >>= 1; } return operation(lx, rx); } T operator[](const int &x) { return node[x - n]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } class Union_Find { vector<int> par; vector<int> rankmy; vector<int> ookisa; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); ookisa = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; ookisa[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; ookisa[y] += ookisa[x]; ookisa[x] = 0; } else { par[y] = x; ookisa[x] += ookisa[y]; ookisa[y] = 0; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } int size(int i) { i = find(i); return ookisa[i]; } bool same(int x, int y) { return find(x) == find(y); } }; class BIT { vector<int> data; int size = 0; public: BIT(int _size) { data = vector<int>(_size + 1); size = _size; } void add(int i, int x) { while (i <= size) { data[i] += x; i += i & -i; } } int sum(int i) { assert(i <= size); int s = 0; while (i > 0) { s += data[i]; i -= i & -i; } return s; } int lower_bound(int x) { if (x <= 0) { return 0; } else { int i = 0; int r = 1; while (r < size) r = r << 1; for (int len = r; len > 0; len = len >> 1) { if (i + len < size && data[i + len] < x) { x -= data[i + len]; i += len; } } return i + 1; } } }; // Union-Find-End int perm[1000005]; void init_perm() { perm[0] = 1; REP(i, 1000000) { perm[i] = perm[i - 1] * i % mod; } } int nCk(int x, int y) { return perm[x] * modpow(perm[x - y], mod - 2) % mod * modpow(perm[y], mod - 2) % mod; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } inline string stringmax(string &x, string &y) { if (x.size() > y.size()) { return x; } if (x.size() < y.size()) { return y; } rep(i, x.size()) { if (x[i] > y[i]) { return x; } if (x[i] < y[i]) { return y; } } return x; } vector<int> RollingHash(string &s, string &t) { vector<int> ans; __int128 h = 0, hamod = 0, ki = 0, kim = 0, hikaku = 0, one = 0; one = 1; ki = 1000000007ll; hamod = (one << 61) - 1; kim = 1; rep(i, t.size()) { hikaku *= ki; h *= ki; kim *= ki; hikaku += t[i]; h += s[i]; hikaku %= hamod; h %= hamod; kim %= hamod; } rep(i, (int)s.size() - (int)t.size() + 1) { if (h == hikaku) { ans.emplace_back(i); } h *= ki; h %= hamod; h += s[i + (int)t.size()]; h %= hamod; h += hamod; h -= s[i] * kim % hamod; h %= hamod; } return ans; } struct edge { int to; int length; edge(int _to, int _length) { to = _to; length = _length; } }; vector<int> djkstra(vector<vector<edge>> &road, int start) { vector<int> kyo(road.size(), inf); smallpriority_queue(P) q; q.push({0, start}); kyo[start] = 0; while (q.size()) { int x = q.top().second; itn now = q.top().first; q.pop(); if (kyo[x] < now) { continue; } for (auto &i : road[x]) { if (kyo[i.to] > now + i.length) { kyo[i.to] = now + i.length; q.push({kyo[i.to], i.to}); } } } return kyo; } #define endl "\n" // interactive の時に注意!!! #define printd cout << fixed << setprecision(10) #define eb emplace_back int n, nn, a[5], b[5], dp[5004], ans; signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n; rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i]; rep(i, 3) { if (b[i] > a[i]) { rep(j, n - a[i] + 1) { chmax(dp[j + a[i]], dp[j] + b[i] - a[i]); } } } rep(i, n + 1) { chmax(nn, dp[i] + n); } vector<int> dp2(nn + 1); rep(i, 3) { if (a[i] > b[i]) { rep(j, nn - b[i] + 1) { chmax(dp2[j + b[i]], dp2[j] + a[i] - b[i]); } } } rep(i, n + 1) { chmax(ans, dp2[i] + nn); } cout << ans << endl; }
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ // GCC #define _GLIBCXX_DEBUG // Clang //#define _LIBCPP_DEBUG 0 #include <bits/stdc++.h> //#pragma GCC target("avx2") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #define f(i, n) for (int i = 0; i < (n); i++) // here!!! // define int long long !!!!! #define int long long // define int long long !!!!! #define mod (int)((1e9) + 7) // constexpr int mod = 998244353ll; #ifdef int #define inf (int)(3e18) #else #define inf (int)(5e8) #endif #define intt long long #define itn long long #define P pair<long long, long long> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define ALL(v) v.begin(), v.end() #define smallpriority_queue(x) priority_queue<x, vector<x>, greater<x>> using namespace std; // Library //モッドパウ inline int modpow(int x, int y, int m = mod) { int res = 1; while (y) { if (y & 1) { res *= x; res %= m; } x = x * x % m; y /= 2; } return res; } int mypow(int x, int y) { int res = 1; while (y) { if (y % 2) { res *= x; } x = x * x; y /= 2; } return res; } // is the number (x) a prime number? bool prime(int x) { if (!x || x == 1) { return false; } for (int i = 2; i * i <= x; i++) { if (!(x % i)) { return false; } } return true; } // saidai-kouyakusuu inline int gcd(int x, int y) { if (!y) { return x; } return gcd(y, x % y); } // number of keta int keta(int x) { int ans = 0; while (x) { x /= 10; ans++; } return ans; } // sum of keta int ketasum(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } inline int lcm(int x, int y) { int ans = x / gcd(x, y) * y; return ans; } int twobeki(int x) { int ans = 0; while (1) { if (!(x & 1)) { ans++; x /= 2; } else { break; } } return ans; } template <class T, class U> inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; } template <class T, class U> inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; } void Yes() { cout << "Yes" << endl; } void No() { cout << "No" << endl; } void YES() { cout << "YES" << endl; } void NO() { cout << "NO" << endl; } #define fin(i) scanf("%lld", &i) #define fout(i) printf("%lld", i) #define fendl printf("\n") int kai(int x, int y) { int res = 1; for (int i = x - y + 1; i <= x; i++) { res *= i; res %= mod; } return res; } int comb(int x, int y) { if (y > x) return 0; // cout<<kai(x, y)<<' '<<modpow(kai(y, y), mod - 2)<<endl; return kai(x, y) * modpow(kai(y, y), mod - 2) % mod; } // Library-End #define vecin(v) \ for (int i = 0; i < v.size(); i++) \ scanf("%lld", &v[i]); #define vecout(v) \ { \ for (int i = 0; i < (int)v.size(); i++) \ printf("%lld ", v[i]); \ printf("\n"); \ } template <typename T> class kaageSegTree { protected: unsigned int n = 1, rank = 0; std::vector<T> node; T nodee; virtual T nodef(const T &, const T &) const = 0; public: kaageSegTree(unsigned int m, T init, T nodee) : nodee(nodee) { while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) node[i] = init; } kaageSegTree(const std::vector<T> &initvec, T nodee) : nodee(nodee) { unsigned int m = initvec.size(); while (n < m) { n *= 2; rank++; } node.resize(2 * n); for (unsigned int i = n; i < 2 * n; i++) { if (i - n < m) node[i] = initvec[i - n]; } } virtual void update(int i, T x) { i += n; node[i] = x; while (i != 1) { i >>= 1; node[i] = nodef(node[2 * i], node[2 * i + 1]); } } virtual T query(int l, int r) { l += n; r += n; T ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } virtual T operator[](const int &x) { return node[n + x]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; class RSQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return lhs + rhs; } public: RSQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, 0) {} RSQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, 0) {} }; class RMiQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::min(lhs, rhs); } public: RMiQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, inf) {} RMiQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, inf) {} }; class RMaQ : public kaageSegTree<int> { int nodef(const int &lhs, const int &rhs) const { return std::max(lhs, rhs); } public: RMaQ(int size, const int &def = 0) : kaageSegTree<int>(size, def, -inf) {} RMaQ(const std::vector<int> &initvec) : kaageSegTree<int>(initvec, -inf) {} }; template <typename T, typename U> class IntervalSegTree : public kaageSegTree<T> { protected: using kaageSegTree<T>::n; using kaageSegTree<T>::rank; using kaageSegTree<T>::node; using kaageSegTree<T>::nodef; using kaageSegTree<T>::nodee; std::vector<U> lazy; std::vector<bool> lazyflag; std::vector<int> width; virtual void lazyf(U &, const U &) = 0; virtual void updf(T &, const U &, const unsigned int &) = 0; void eval(int k) { for (int i = rank; i > 0; i--) { int nk = k >> i; if (lazyflag[nk]) { updf(node[2 * nk], lazy[nk], width[2 * nk]); updf(node[2 * nk + 1], lazy[nk], width[2 * nk + 1]); if (lazyflag[2 * nk]) lazyf(lazy[2 * nk], lazy[nk]); else lazy[2 * nk] = lazy[nk]; if (lazyflag[2 * nk + 1]) lazyf(lazy[2 * nk + 1], lazy[nk]); else lazy[2 * nk + 1] = lazy[nk]; lazyflag[2 * nk] = lazyflag[2 * nk + 1] = true; lazyflag[nk] = false; } } } public: IntervalSegTree(unsigned int m, T init, T nodee) : kaageSegTree<T>(m, init, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } IntervalSegTree(T nodee, const std::vector<T> &initvec) : kaageSegTree<T>(initvec, nodee) { lazy.resize(2 * n); lazyflag.resize(2 * n); width.resize(2 * n); width[1] = n; for (unsigned int i = 2; i < 2 * n; i++) { width[i] = width[i >> 1] >> 1; } } void update(int i, U x) { i += n; eval(i); updf(node[i], x, width[i]); if (lazyflag[i]) lazyf(lazy[i], x); else { lazyflag[i] = true; lazy[i] = x; } while (i /= 2) node[i] = nodef(node[2 * i], node[2 * i + 1]); } void update(int l, int r, U x) { l += n; r += n; int nl = l, nr = r; while (!(nl & 1)) nl >>= 1; while (!(nr & 1)) nr >>= 1; nr--; eval(nl); eval(nr); while (l < r) { if (l & 1) { updf(node[l], x, width[l]); if (lazyflag[l]) lazyf(lazy[l], x); else { lazyflag[l] = true; lazy[l] = x; } l++; } if (r & 1) { r--; updf(node[r], x, width[r]); if (lazyflag[r]) lazyf(lazy[r], x); else { lazyflag[r] = true; lazy[r] = x; } } l >>= 1; r >>= 1; } while (nl >>= 1) node[nl] = nodef(node[2 * nl], node[2 * nl + 1]); while (nr >>= 1) node[nr] = nodef(node[2 * nr], node[2 * nr + 1]); } T query(int l, int r) { l += n; r += n; eval(l); eval(r - 1); int ls = nodee, rs = nodee; while (l < r) { if (l & 1) { ls = nodef(ls, node[l]); l++; } if (r & 1) { r--; rs = nodef(node[r], rs); } l >>= 1; r >>= 1; } return nodef(ls, rs); } T operator[](const int &x) { eval(n + x); return node[n + x]; } T queryForAll() { return node[1]; } }; class RAQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += width * b; } public: RAQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RAQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a += b; } void updf(int &a, const int &b, const unsigned int &width) { a += b; } public: RAQRMaQ(unsigned int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RAQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRSQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return a + b; } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = width * b; } public: RUQRSQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, 0) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRSQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>((int)0, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMiQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::min(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMiQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMiQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; class RUQRMaQ : public IntervalSegTree<int, int> { int nodef(const int &a, const int &b) const { return std::max(a, b); } void lazyf(int &a, const int &b) { a = b; } void updf(int &a, const int &b, const unsigned int &width) { a = b; } public: RUQRMaQ(int size, const int &def = 0) : IntervalSegTree<int, int>(size, def, -inf) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } RUQRMaQ(const std::vector<int> &initvec) : IntervalSegTree<int, int>(-inf, initvec) { for (int i = n - 1; i > 0; i--) node[i] = nodef(node[2 * i], node[2 * i + 1]); } }; ////SegTree // template <class T> // class SegTree { // int n; // 葉の数 // vector<T> node; // データを格納するvector // T def; // 初期値かつ単位元 // function<T(T, T)> operation; // 区間クエリで使う処理 // function<T(T, T)> update; // 点更新で使う処理 // // // 区間[a,b)の総和。ノードk=[l,r)に着目している。 // T _query(int a, int b, int k, int l, int r) { // if (r <= a || b <= l) return def; // 交差しない // if (a <= l && r <= b) // return node[k]; // a,l,r,bの順で完全に含まれる // else { // T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子 // T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子 // return operation(c1, c2); // } // } // // public: // // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数, // // _update:更新関数 // SegTree(size_t _n, T _def, function<T(T, T)> _operation, // function<T(T, T)> _update) // : def(_def), operation(_operation), update(_update) { // n = 1; // while (n < _n) { // n *= 2; // } // node = vector<T>(2 * n , def); // } // // // 場所i(0-indexed)の値をxで更新 // void change(int i, T x) { // i += n - 1; // node[i] = update(node[i], x); // while (i > 0) { // i = (i - 1) / 2; // node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]); // } // } // // // [a, b)の区間クエリを実行 // T query(int a, int b) { // return _query(a, b, 0, 0, n); // } // // // 添字でアクセス // T operator[](int i) { // return node[i + n - 1]; // } //}; template <class T> class SegTree { int n; vector<T> node; T def; function<T(T, T)> operation; function<T(T, T)> update; public: SegTree(unsigned int _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } node = vector<T>(n * 2, def); } SegTree(vector<int> &initvec, function<T(T, T)> _operation, function<T(T, T)> _update) : operation(_operation), update(_update) { n = 1; while (n < initvec.size()) { n *= 2; } node = vector<T>(n * 2, def); for (int i = n; i < n + initvec.size(); i++) { node[i] = initvec[i - n]; } for (int i = n - 1; i >= 1; i--) { node[i] = operation(node[i * 2], node[i * 2 + 1]); } } void change(int i, T x) { i += n; node[i] = update(node[i], x); while (i >= 1) { i >>= 1; node[i] = operation(node[i * 2], node[i * 2 + 1]); } } T query(int l, int r) { l += n; r += n; T rx = def, lx = def; while (l < r) { if (l & 1) { lx = operation(lx, node[l]); l++; } if (r & 1) { r--; rx = operation(node[r], rx); } l >>= 1; r >>= 1; } return operation(lx, rx); } T operator[](const int &x) { return node[x - n]; } void fill(T x) { std::fill(ALL(node), x); } void print() { rep(i, n) std::cout << operator[](i) << " "; std::cout << std::endl; } }; #define R_MIN ([](long long a, long long b) { return min(a, b); }) #define R_MAX ([](long long a, long long b) { return max(a, b); }) #define R_SUM ([](long long a, long long b) { return a + b; }) #define NORMAL_UPDATE ([](long long a, long long b) { return b; }) #define ADD_UPDATE ([](long long a, long long b) { return a + b; }) #define MINUS_UPDATE ([](long long a, long long b) { return a - b; } class Union_Find { vector<int> par; vector<int> rankmy; vector<int> ookisa; public: Union_Find(int size) { par = vector<int>(size); rankmy = vector<int>(size); ookisa = vector<int>(size); for (int i = 0; i < size; i++) { par[i] = i; ookisa[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (rankmy[x] < rankmy[y]) { par[x] = y; ookisa[y] += ookisa[x]; ookisa[x] = 0; } else { par[y] = x; ookisa[x] += ookisa[y]; ookisa[y] = 0; if (rankmy[x] == rankmy[y]) { rankmy[x]++; } } } int size(int i) { i = find(i); return ookisa[i]; } bool same(int x, int y) { return find(x) == find(y); } }; class BIT { vector<int> data; int size = 0; public: BIT(int _size) { data = vector<int>(_size + 1); size = _size; } void add(int i, int x) { while (i <= size) { data[i] += x; i += i & -i; } } int sum(int i) { assert(i <= size); int s = 0; while (i > 0) { s += data[i]; i -= i & -i; } return s; } int lower_bound(int x) { if (x <= 0) { return 0; } else { int i = 0; int r = 1; while (r < size) r = r << 1; for (int len = r; len > 0; len = len >> 1) { if (i + len < size && data[i + len] < x) { x -= data[i + len]; i += len; } } return i + 1; } } }; // Union-Find-End int perm[1000005]; void init_perm() { perm[0] = 1; REP(i, 1000000) { perm[i] = perm[i - 1] * i % mod; } } int nCk(int x, int y) { return perm[x] * modpow(perm[x - y], mod - 2) % mod * modpow(perm[y], mod - 2) % mod; } double kyori(pair<int, int> f, pair<int, int> s) { double ans = 0; double t = fabs(f.first - s.first); double y = fabs(f.second - s.second); ans = sqrt(t * t + y * y); return ans; } inline string stringmax(string &x, string &y) { if (x.size() > y.size()) { return x; } if (x.size() < y.size()) { return y; } rep(i, x.size()) { if (x[i] > y[i]) { return x; } if (x[i] < y[i]) { return y; } } return x; } vector<int> RollingHash(string &s, string &t) { vector<int> ans; __int128 h = 0, hamod = 0, ki = 0, kim = 0, hikaku = 0, one = 0; one = 1; ki = 1000000007ll; hamod = (one << 61) - 1; kim = 1; rep(i, t.size()) { hikaku *= ki; h *= ki; kim *= ki; hikaku += t[i]; h += s[i]; hikaku %= hamod; h %= hamod; kim %= hamod; } rep(i, (int)s.size() - (int)t.size() + 1) { if (h == hikaku) { ans.emplace_back(i); } h *= ki; h %= hamod; h += s[i + (int)t.size()]; h %= hamod; h += hamod; h -= s[i] * kim % hamod; h %= hamod; } return ans; } struct edge { int to; int length; edge(int _to, int _length) { to = _to; length = _length; } }; vector<int> djkstra(vector<vector<edge>> &road, int start) { vector<int> kyo(road.size(), inf); smallpriority_queue(P) q; q.push({0, start}); kyo[start] = 0; while (q.size()) { int x = q.top().second; itn now = q.top().first; q.pop(); if (kyo[x] < now) { continue; } for (auto &i : road[x]) { if (kyo[i.to] > now + i.length) { kyo[i.to] = now + i.length; q.push({kyo[i.to], i.to}); } } } return kyo; } #define endl "\n" // interactive の時に注意!!! #define printd cout << fixed << setprecision(10) #define eb emplace_back int n, nn, a[5], b[5], dp[5004], ans; signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n; rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i]; rep(i, 3) { if (b[i] > a[i]) { rep(j, n - a[i] + 1) { chmax(dp[j + a[i]], dp[j] + b[i] - a[i]); } } } rep(i, n + 1) { chmax(nn, dp[i] + n); } vector<int> dp2(nn + 1); rep(i, 3) { if (a[i] > b[i]) { rep(j, nn - b[i] + 1) { chmax(dp2[j + b[i]], dp2[j] + a[i] - b[i]); } } } rep(i, nn + 1) { chmax(ans, dp2[i] + nn); } cout << ans << endl; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
822,358
822,359
u943070796
cpp
p03008
#include <bits/stdc++.h> using namespace std; #define ll long long #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, n - 1, 0) #define all(v) v.begin(), v.end() const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> G(2), S(2), B(2); rep(i, 2) cin >> G[i] >> S[i] >> B[i]; vector<int> choice[] = {G, S, B}; vector<int> dp(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][1] < choice[j][0]) continue; if (i + choice[j][0] <= N) { dp[i + choice[j][0]] = max(dp[i] + choice[j][1] - choice[j][0], dp[i + choice[j][0]]); } } } N = *max_element(all(dp)); dp = vector<int>(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][0] < choice[j][1]) continue; if (i + choice[j][0] <= N) { dp[i + choice[j][1]] = max(dp[i] + choice[j][0] - choice[j][1], dp[i + choice[j][1]]); } } } cout << *max_element(all(dp)) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, n - 1, 0) #define all(v) v.begin(), v.end() const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> G(2), S(2), B(2); rep(i, 2) cin >> G[i] >> S[i] >> B[i]; vector<int> choice[] = {G, S, B}; vector<ll> dp(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][1] < choice[j][0]) continue; if (i + choice[j][0] <= N) { dp[i + choice[j][0]] = max(dp[i] + choice[j][1] - choice[j][0], dp[i + choice[j][0]]); } } } N = *max_element(all(dp)); dp = vector<ll>(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][0] < choice[j][1]) continue; if (i + choice[j][1] <= N) { dp[i + choice[j][1]] = max(dp[i] + choice[j][0] - choice[j][1], dp[i + choice[j][1]]); } } } cout << *max_element(all(dp)) << endl; return 0; }
[ "assignment.value.change", "literal.number.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
822,369
822,368
u137747137
cpp
p03008
#include <bits/stdc++.h> using namespace std; #define ll long long #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, n - 1, 0) #define all(v) v.begin(), v.end() const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> G(2), S(2), B(2); rep(i, 2) cin >> G[i] >> S[i] >> B[i]; vector<int> choice[] = {G, S, B}; vector<int> dp(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][1] < choice[j][0]) continue; if (i + choice[j][0] <= N) { dp[i + choice[j][0]] = max(dp[i] + choice[j][1] - choice[j][0], dp[i + choice[j][0]]); } } } N = *max_element(all(dp)); dp = vector<int>(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][0] < choice[j][1]) continue; if (i + choice[j][0] <= N) { dp[i + choice[j][0]] = max(dp[i] + choice[j][0] - choice[j][1], dp[i + choice[j][0]]); } } } cout << *max_element(all(dp)) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define RREP(i, m, n) for (int i = (int)(m); i >= (int)(n); i--) #define rrep(i, n) RREP(i, n - 1, 0) #define all(v) v.begin(), v.end() const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> G(2), S(2), B(2); rep(i, 2) cin >> G[i] >> S[i] >> B[i]; vector<int> choice[] = {G, S, B}; vector<ll> dp(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][1] < choice[j][0]) continue; if (i + choice[j][0] <= N) { dp[i + choice[j][0]] = max(dp[i] + choice[j][1] - choice[j][0], dp[i + choice[j][0]]); } } } N = *max_element(all(dp)); dp = vector<ll>(N + 1, N); rep(i, N + 1) { rep(j, 3) { if (choice[j][0] < choice[j][1]) continue; if (i + choice[j][1] <= N) { dp[i + choice[j][1]] = max(dp[i] + choice[j][0] - choice[j][1], dp[i + choice[j][1]]); } } } cout << *max_element(all(dp)) << endl; return 0; }
[ "assignment.value.change", "literal.number.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "assignment.variable.change", "expression.operation.binary.change", "call.arguments.change" ]
822,370
822,368
u137747137
cpp
p03008
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define ll long long #define ull unsigned long long #define ld long double #define vl vector<long long> #define vvl vector<vector<long long>> #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--) #define pll pair<long long, long long> #define pb push_back #define mp make_pair #define mt make_tuple #define vvc vector<vector<char>> #define vc vector<char> #define vvb vector<vector<bool>> #define vb vector<bool> #define maxe(x) *max_element(all(x)) #define mine(x) *min_element(all(x)) #define Size(x) ((int)(x).size()) #define umap unordered_map const long long INF = 1LL << 60; const long double pi = 3.1415926535897932; long long MOD = 1000000007; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; 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; } // lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen // mint signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; ll ga, sa, ba, gb, sb, bb; cin >> ga >> sa >> ba >> gb >> sb >> bb; vvl dp(4, vl(N + 1, 0)); ll dong = N; rep(i, N + 1) { if (i < ga) { chmax(dp[1][i], dp[0][i]); } else { chmax(dp[1][i], dp[0][i]); chmax(dp[1][i], dp[1][i - ga] + gb - ga); } } rep(i, N + 1) { if (i < sa) { chmax(dp[2][i], dp[1][i]); } else { chmax(dp[2][i], dp[1][i]); chmax(dp[2][i], dp[2][i - sa] + sb - sa); } } rep(i, N + 1) { if (i < ba) { chmax(dp[3][i], dp[2][i]); } else { chmax(dp[3][i], dp[2][i]); chmax(dp[3][i], dp[2][i - ba] + bb - ba); } } dong += dp[3][N]; N = dong; vvl dp2(4, vl(N + 1, 0)); rep(i, N + 1) { if (i < gb) { chmax(dp2[1][i], dp2[0][i]); } else { chmax(dp2[1][i], dp2[0][i]); chmax(dp2[1][i], dp2[1][i - gb] + ga - gb); } } rep(i, N + 1) { if (i < sb) { chmax(dp2[2][i], dp2[1][i]); } else { chmax(dp2[2][i], dp2[1][i]); chmax(dp2[2][i], dp2[2][i - sb] + sa - sb); } } rep(i, N + 1) { if (i < bb) { chmax(dp2[3][i], dp2[2][i]); } else { chmax(dp2[3][i], dp2[2][i]); chmax(dp2[3][i], dp2[2][i - bb] + ba - bb); } } dong += dp2[3][N]; cout << dong << endl; }
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define ll long long #define ull unsigned long long #define ld long double #define vl vector<long long> #define vvl vector<vector<long long>> #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--) #define pll pair<long long, long long> #define pb push_back #define mp make_pair #define mt make_tuple #define vvc vector<vector<char>> #define vc vector<char> #define vvb vector<vector<bool>> #define vb vector<bool> #define maxe(x) *max_element(all(x)) #define mine(x) *min_element(all(x)) #define Size(x) ((int)(x).size()) #define umap unordered_map const long long INF = 1LL << 60; const long double pi = 3.1415926535897932; long long MOD = 1000000007; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; 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; } // lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen // mint signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; ll ga, sa, ba, gb, sb, bb; cin >> ga >> sa >> ba >> gb >> sb >> bb; vvl dp(4, vl(N + 1, 0)); ll dong = N; rep(i, N + 1) { if (i < ga) { chmax(dp[1][i], dp[0][i]); } else { chmax(dp[1][i], dp[0][i]); chmax(dp[1][i], dp[1][i - ga] + gb - ga); } } rep(i, N + 1) { if (i < sa) { chmax(dp[2][i], dp[1][i]); } else { chmax(dp[2][i], dp[1][i]); chmax(dp[2][i], dp[2][i - sa] + sb - sa); } } rep(i, N + 1) { if (i < ba) { chmax(dp[3][i], dp[2][i]); } else { chmax(dp[3][i], dp[2][i]); chmax(dp[3][i], dp[3][i - ba] + bb - ba); } } dong += dp[3][N]; N = dong; vvl dp2(4, vl(N + 1, 0)); rep(i, N + 1) { if (i < gb) { chmax(dp2[1][i], dp2[0][i]); } else { chmax(dp2[1][i], dp2[0][i]); chmax(dp2[1][i], dp2[1][i - gb] + ga - gb); } } rep(i, N + 1) { if (i < sb) { chmax(dp2[2][i], dp2[1][i]); } else { chmax(dp2[2][i], dp2[1][i]); chmax(dp2[2][i], dp2[2][i - sb] + sa - sb); } } rep(i, N + 1) { if (i < bb) { chmax(dp2[3][i], dp2[2][i]); } else { chmax(dp2[3][i], dp2[2][i]); chmax(dp2[3][i], dp2[3][i - bb] + ba - bb); } } dong += dp2[3][N]; cout << dong << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
822,375
822,376
u190580703
cpp
p03008
#include <bits/stdc++.h> using namespace std; #define mid ((s + e) / 2) #define makefast \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define comp(x) (lower_bound(vec.begin(), vec.end(), x) - vec.begin()) long long M = 1e9 + 7; //>>>>>>>>>>>>>>>>>>> #define int long long const int N = 5e3 + 7; int dp[N * N]; int s; int a[4], b[4]; int32_t main() { makefast; cin >> s; for (int i = 1; i <= 3; i++) cin >> a[i]; for (int i = 1; i <= 3; i++) cin >> b[i]; dp[0] = 0; for (int i = 1; i <= s; i++) { dp[i] = 0; for (int j = 1; j <= 3; j++) if (i >= a[j]) dp[i] = max(dp[i], dp[i - a[j]] + b[j]); } s = dp[s]; dp[0] = 0; for (int i = 1; i <= s; i++) { dp[i] = 0; for (int j = 1; j <= 3; j++) if (i >= b[j]) dp[i] = max(dp[i], dp[i - b[j]] + a[j]); } cout << dp[s]; return 0; }
#include <bits/stdc++.h> using namespace std; #define mid ((s + e) / 2) #define makefast \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define comp(x) (lower_bound(vec.begin(), vec.end(), x) - vec.begin()) long long M = 1e9 + 7; //>>>>>>>>>>>>>>>>>>> #define int long long const int N = 5e3 + 7; int dp[N * N]; int s; int a[4], b[4]; int32_t main() { makefast; cin >> s; for (int i = 1; i <= 3; i++) cin >> a[i]; for (int i = 1; i <= 3; i++) cin >> b[i]; dp[0] = 0; for (int i = 1; i <= s; i++) { dp[i] = i; for (int j = 1; j <= 3; j++) if (i >= a[j]) dp[i] = max(dp[i], dp[i - a[j]] + b[j]); } s = dp[s]; dp[0] = 0; for (int i = 1; i <= s; i++) { dp[i] = i; for (int j = 1; j <= 3; j++) if (i >= b[j]) dp[i] = max(dp[i], dp[i - b[j]] + a[j]); } cout << dp[s]; return 0; }
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
822,386
822,387
u766633720
cpp
p03008
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i, s, n) for (int i = s; i < n; i++) #define NUM 2520 #define INF (1LL << 50) #define DEBUG 1 #define mp(a, b) make_pair(a, b) #define SORT(V) sort(V.begin(), V.end()) #define PI (3.141592653589794) #define TO_STRING(VariableName) #VariableName #define LOG(x) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << endl; #define LOG2(x, y) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << TO_STRING(y) << "=" << y << endl; #define LOG3(x, y, z) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << TO_STRING(y) << "=" << y << " " \ << TO_STRING(z) << "=" << z << endl; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define MAX (5000 * 5000 + 5000) lli dp[5000 * 5000 + 5000]; vector<lli> a, b; lli func(vector<lli> &buy, vector<lli> &sell, lli m) { REP(i, 0, MAX) dp[i] = 0; REP(i, 0, 3) { REP(j, 0, m + 1) { chmax(dp[j + buy[i]], dp[j] + sell[i]); } } lli res = m; REP(i, 0, m + 1) chmax(res, dp[i]); return res; } int main() { // cout << fixed << setprecision(5); a.resize(3), b.resize(3); lli n; cin >> n; REP(i, 0, 3) cin >> a[i]; REP(j, 0, 3) cin >> b[j]; n = func(a, b, n); // LOG(n); n = func(b, a, n); cout << n << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i, s, n) for (int i = s; i < n; i++) #define NUM 2520 #define INF (1LL << 50) #define DEBUG 1 #define mp(a, b) make_pair(a, b) #define SORT(V) sort(V.begin(), V.end()) #define PI (3.141592653589794) #define TO_STRING(VariableName) #VariableName #define LOG(x) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << endl; #define LOG2(x, y) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << TO_STRING(y) << "=" << y << endl; #define LOG3(x, y, z) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << TO_STRING(y) << "=" << y << " " \ << TO_STRING(z) << "=" << z << endl; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define MAX (5000 * 5000 + 5000) lli dp[5000 * 5000 + 5000]; vector<lli> a, b; lli func(vector<lli> &buy, vector<lli> &sell, lli m) { REP(i, 0, MAX) dp[i] = 0; REP(i, 0, 3) { REP(j, 0, m + 1) { chmax(dp[j + buy[i]], dp[j] + sell[i]); } } lli res = m; REP(i, 0, m + 1) chmax(res, dp[i] + m - i); return res; } int main() { // cout << fixed << setprecision(5); a.resize(3), b.resize(3); lli n; cin >> n; REP(i, 0, 3) cin >> a[i]; REP(j, 0, 3) cin >> b[j]; n = func(a, b, n); // LOG(n); n = func(b, a, n); cout << n << endl; return 0; }
[ "expression.operation.binary.add" ]
822,392
822,393
u041513069
cpp
p03008
#include <bits/stdc++.h> using namespace std; long long Price[3][2]; vector<int> V; long long Ans; void dfs(int pos, long long Left, long long Sum) { if ((int)(V.size()) == 0) { Ans = Sum; return; } int Realpos = V[pos]; long long mx = Left / Price[Realpos][0]; if (pos == (int)(V.size()) - 1) { Ans = max(Ans, Sum + mx * (Price[Realpos][1] - Price[Realpos][0])); return; } for (int i = 0; i <= mx; i++) dfs(pos + 1, Left - i * Price[Realpos][0], Sum - i * Price[Realpos][0] + i * Price[Realpos][1]); return; } int main() { int N; cin >> N; for (int j = 0; j < 2; j++) for (int i = 0; i < 3; i++) cin >> Price[i][j]; for (int i = 0; i < 3; i++) if (Price[i][0] > Price[i][1]) V.push_back(i); dfs(0, N, N); for (int i = 0; i < 3; i++) swap(Price[i][0], Price[i][1]); V.clear(); N = Ans; for (int i = 0; i < 3; i++) if (Price[i][0] > Price[i][1]) V.push_back(i); dfs(0, N, N); cout << Ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long Price[3][2]; vector<int> V; long long Ans; void dfs(int pos, long long Left, long long Sum) { if ((int)(V.size()) == 0) { Ans = Sum; return; } int Realpos = V[pos]; long long mx = Left / Price[Realpos][0]; if (pos == (int)(V.size()) - 1) { Ans = max(Ans, Sum + mx * (Price[Realpos][1] - Price[Realpos][0])); return; } for (int i = 0; i <= mx; i++) dfs(pos + 1, Left - i * Price[Realpos][0], Sum - i * Price[Realpos][0] + i * Price[Realpos][1]); return; } int main() { long long N; cin >> N; for (int j = 0; j < 2; j++) for (int i = 0; i < 3; i++) cin >> Price[i][j]; for (int i = 0; i < 3; i++) if (Price[i][0] < Price[i][1]) V.push_back(i); dfs(0, N, N); for (int i = 0; i < 3; i++) swap(Price[i][0], Price[i][1]); V.clear(); N = Ans; for (int i = 0; i < 3; i++) if (Price[i][0] < Price[i][1]) V.push_back(i); dfs(0, N, N); cout << Ans << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,399
822,400
u538921909
cpp
p03008
#include <algorithm> #include <cstdio> using namespace std; typedef long long ll; ll dp[25000000]; int main() { ll n, g[2], s[2], b[2], ans = 0LL, a = 0LL; scanf("%lld", &n); for (int i = 0; i < 2; i++) { scanf("%lld%lld%lld", &g[i], &s[i], &b[i]); } for (int i = 0; i <= n; i++) { a = max(a, dp[i]); if (i + g[0] <= n) { dp[i + g[0]] = max(dp[i + g[0]], dp[i] + g[1] - g[0]); } if (i + s[0] <= n) { dp[i + s[0]] = max(dp[i + s[0]], dp[i] + s[1] - s[0]); } if (i + b[0] <= n) { dp[i + b[0]] = max(dp[i + b[0]], dp[i] + b[1] - b[0]); } } a = max(a, dp[n]) + n; for (int i = 0; i <= n; i++) { dp[i] = 0LL; } for (ll i = 0; i <= a; i++) { ans = max(ans, dp[i] + a); if (i + g[1] <= n) { dp[i + g[1]] = max(dp[i + g[1]], dp[i] + g[0] - g[1]); } if (i + s[1] <= n) { dp[i + s[1]] = max(dp[i + s[1]], dp[i] + s[0] - s[1]); } if (i + b[1] <= n) { dp[i + b[1]] = max(dp[i + b[1]], dp[i] + b[0] - b[1]); } } printf("%lld\n", ans); }
#include <algorithm> #include <cstdio> using namespace std; typedef long long ll; ll dp[25000000]; int main() { ll n, g[2], s[2], b[2], ans = 0LL, a = 0LL; scanf("%lld", &n); for (int i = 0; i < 2; i++) { scanf("%lld%lld%lld", &g[i], &s[i], &b[i]); } for (int i = 0; i <= n; i++) { a = max(a, dp[i]); if (i + g[0] <= n) { dp[i + g[0]] = max(dp[i + g[0]], dp[i] + g[1] - g[0]); } if (i + s[0] <= n) { dp[i + s[0]] = max(dp[i + s[0]], dp[i] + s[1] - s[0]); } if (i + b[0] <= n) { dp[i + b[0]] = max(dp[i + b[0]], dp[i] + b[1] - b[0]); } } a = max(a, dp[n]) + n; for (int i = 0; i <= n; i++) { dp[i] = 0LL; } for (ll i = 0; i <= a; i++) { ans = max(ans, dp[i] + a); if (i + g[1] <= a) { dp[i + g[1]] = max(dp[i + g[1]], dp[i] + g[0] - g[1]); } if (i + s[1] <= a) { dp[i + s[1]] = max(dp[i + s[1]], dp[i] + s[0] - s[1]); } if (i + b[1] <= a) { dp[i + b[1]] = max(dp[i + b[1]], dp[i] + b[0] - b[1]); } } printf("%lld\n", ans); }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
822,406
822,407
u855429581
cpp
p03008
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < int(n); i++) using namespace std; long long MOD = 1000000007; long long INF = 1000000000000000; // 10^15 typedef long long ll; typedef unsigned long long ull; ll powMod(ll x, ll n, ll mod) { if (n == 0) return 1; ll t = powMod(x, n / 2, mod); t = t * t % mod; if (n & 1) return t * x % mod; return t; } int main(void) { ll n, ga, gb, sa, sb, ba, bb; cin >> n; cin >> ga >> sa >> ba; cin >> gb >> sb >> bb; ll d = 0; ll p = gb - ga, q = sb - sa, r = bb - ba; ll g = ga, s = sa, b = ba; vector<ll> pq(n, 0); // gx+sy+bz<=nのもとでpx+qy+rzを最大化 for (ll i = 1; i <= n; i++) { if (i - g >= 0) pq[i] = max(0LL, pq[i - g] + p); if (i - s >= 0) pq[i] = max(pq[i], pq[i - s] + q); } for (ll z = 0; b * z <= n; z++) { d = max(d, r * z + pq[n - b * z]); } n += d; d = 0; p = ga - gb; q = sa - sb; r = ba - bb; g = gb; s = sb; b = bb; vector<ll> qp(n, 0); for (ll i = 1; i <= n; i++) { if (i - g >= 0) qp[i] = max(0LL, qp[i - g] + p); if (i - s >= 0) qp[i] = max(qp[i], qp[i - s] + q); } for (ll z = 0; b * z <= n; z++) { d = max(d, r * z + qp[n - b * z]); } cout << n + d << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < int(n); i++) using namespace std; long long MOD = 1000000007; long long INF = 1000000000000000; // 10^15 typedef long long ll; typedef unsigned long long ull; ll powMod(ll x, ll n, ll mod) { if (n == 0) return 1; ll t = powMod(x, n / 2, mod); t = t * t % mod; if (n & 1) return t * x % mod; return t; } int main(void) { ll n, ga, gb, sa, sb, ba, bb; cin >> n; cin >> ga >> sa >> ba; cin >> gb >> sb >> bb; ll d = 0; ll p = gb - ga, q = sb - sa, r = bb - ba; ll g = ga, s = sa, b = ba; vector<ll> pq(n + 2, 0); // gx+sy+bz<=nのもとでpx+qy+rzを最大化 for (ll i = 1; i <= n; i++) { if (i - g >= 0) pq[i] = max(0LL, pq[i - g] + p); if (i - s >= 0) pq[i] = max(pq[i], pq[i - s] + q); } for (ll z = 0; b * z <= n; z++) { d = max(d, r * z + pq[n - b * z]); } n += d; d = 0; p = ga - gb; q = sa - sb; r = ba - bb; g = gb; s = sb; b = bb; vector<ll> qp(n + 2, 0); for (ll i = 1; i <= n; i++) { if (i - g >= 0) qp[i] = max(0LL, qp[i - g] + p); if (i - s >= 0) qp[i] = max(qp[i], qp[i - s] + q); } for (ll z = 0; b * z <= n; z++) { d = max(d, r * z + qp[n - b * z]); } cout << n + d << endl; return 0; }
[ "assignment.change" ]
822,427
822,428
u801102476
cpp
p03008
#include <array> #include <bits/stdc++.h> using namespace std; using ULL = unsigned long long; using UL = unsigned; using LL = long long; #define rep(i, n) for (UL i = 0; i < (n); i++) struct Problem { void Solve() { ULL N; cin >> N; int A[3], B[3]; rep(i, 3) cin >> A[i]; rep(i, 3) cin >> B[i]; rep(t, 2) { vector<ULL> dp(N + 1); ULL ans = 0; rep(i, N + 1) { ULL &p = dp[i]; rep(j, 3) { if (A[j] <= i) p = max(p, dp[i - A[j]] + B[j]); } ans = max(N, dp[i] + N - i); } N = ans; rep(i, 3) swap(A[i], B[i]); } cout << N << endl; } Problem(); }; int main() { unique_ptr<Problem> p(new Problem()); p->Solve(); return 0; } Problem::Problem() { cout << fixed << setprecision(10); }
#include <array> #include <bits/stdc++.h> using namespace std; using ULL = unsigned long long; using UL = unsigned; using LL = long long; #define rep(i, n) for (UL i = 0; i < (n); i++) struct Problem { void Solve() { ULL N; cin >> N; int A[3], B[3]; rep(i, 3) cin >> A[i]; rep(i, 3) cin >> B[i]; rep(t, 2) { vector<ULL> dp(N + 1); ULL ans = 0; rep(i, N + 1) { ULL &p = dp[i]; rep(j, 3) { if (A[j] <= i) p = max(p, dp[i - A[j]] + B[j]); } ans = max(ans, dp[i] + N - i); } N = ans; rep(i, 3) swap(A[i], B[i]); } cout << N << endl; } Problem(); }; int main() { unique_ptr<Problem> p(new Problem()); p->Solve(); return 0; } Problem::Problem() { cout << fixed << setprecision(10); }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
822,429
822,430
u331948661
cpp
p03008
#include <algorithm> #include <cstdio> using namespace std; #define ll long long ll solve(ll n, ll a[], ll b[]) { ll dp[n + 1]; dp[0] = 0; for (ll i = 1; i <= n; i++) { dp[i] = 0; for (ll j = 0; j < 4; j++) { if (i - a[j] >= 0) dp[i] = max(dp[i], dp[i - a[j]] + b[j]); } } return dp[n]; } int main() { ll n, a[4], b[4]; scanf("%lld", &n); for (ll i = 0; i < 3; i++) scanf("%lld", &a[i]); for (ll i = 0; i < 3; i++) scanf("%lld", &b[i]); a[3] = 1; b[3] = 1; ll t = solve(n, a, b) + n; printf("%lld\n", solve(t, b, a) + t); }
#include <algorithm> #include <cstdio> using namespace std; #define ll long long ll solve(ll n, ll a[], ll b[]) { ll dp[n + 1]; dp[0] = 0; for (ll i = 1; i <= n; i++) { dp[i] = 0; for (ll j = 0; j < 4; j++) { if (i - a[j] >= 0) dp[i] = max(dp[i], dp[i - a[j]] + b[j]); } } return dp[n]; } int main() { ll n, a[4], b[4]; scanf("%lld", &n); for (ll i = 0; i < 3; i++) scanf("%lld", &a[i]); for (ll i = 0; i < 3; i++) scanf("%lld", &b[i]); a[3] = 1; b[3] = 1; ll t = solve(n, a, b); printf("%lld\n", solve(t, b, a)); }
[ "expression.operation.binary.remove" ]
822,433
822,434
u340969800
cpp
p03008
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> gsb_A(3), gsb_B(3); cin >> gsb_A[0] >> gsb_A[1] >> gsb_A[2]; cin >> gsb_B[0] >> gsb_B[1] >> gsb_B[2]; // A -> B // dp[n] := with n acrons, chokudai can gain dp[n] profit // dp[n] = max(dp[n], dp[n - g_A] + (g_B - g_A)); vector<long long> dp1(N + 1); vector<int> profits(3); for (int i = 0; i < 3; i++) { profits[i] = max(0, gsb_B[i] - gsb_A[i]); } for (int n = 0; n <= N; n++) { for (int i = 0; i < 3; i++) { if (n >= gsb_A[i]) { dp1[n] = max(dp1[n], dp1[n - gsb_A[i]] + profits[i]); } } } long long N2 = dp1[N] + N; for (int i = 0; i < 3; i++) { profits[i] = max(0, gsb_A[i] - gsb_B[i]); } vector<long long> dp2(N2); for (int n = 0; n <= N2; n++) { for (int i = 0; i < 3; i++) { if (n >= gsb_B[i]) { dp2[n] = max(dp2[n], dp2[n - gsb_B[i]] + profits[i]); } } } cout << dp2[N2] + N2 << endl; }
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> gsb_A(3), gsb_B(3); cin >> gsb_A[0] >> gsb_A[1] >> gsb_A[2]; cin >> gsb_B[0] >> gsb_B[1] >> gsb_B[2]; // A -> B // dp[n] := with n acrons, chokudai can gain dp[n] profit // dp[n] = max(dp[n], dp[n - g_A] + (g_B - g_A)); vector<long long> dp1(N + 1); vector<int> profits(3); for (int i = 0; i < 3; i++) { profits[i] = max(0, gsb_B[i] - gsb_A[i]); } for (int n = 0; n <= N; n++) { for (int i = 0; i < 3; i++) { if (n >= gsb_A[i]) { dp1[n] = max(dp1[n], dp1[n - gsb_A[i]] + profits[i]); } } } long long N2 = dp1[N] + N; for (int i = 0; i < 3; i++) { profits[i] = max(0, gsb_A[i] - gsb_B[i]); } vector<long long> dp2(N2 + 1); for (int n = 0; n <= N2; n++) { for (int i = 0; i < 3; i++) { if (n >= gsb_B[i]) { dp2[n] = max(dp2[n], dp2[n - gsb_B[i]] + profits[i]); } } } cout << dp2[N2] + N2 << endl; }
[ "assignment.change" ]
822,435
822,436
u425351967
cpp
p03008
#include <bits/stdc++.h> using namespace std; const int maxn = 100500; const int mod = 1e9 + 7; #define int long long signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; int gg[2], ss[2], bb[2]; cin >> n; for (int i = 0; i < 2; ++i) cin >> gg[i] >> ss[i] >> bb[i]; vector<pair<int, int>> a, b; if (gg[0] > gg[1]) a.push_back({gg[1], gg[0]}); else b.push_back({gg[0], gg[1]}); if (ss[0] > ss[1]) a.push_back({ss[1], ss[0]}); else b.push_back({ss[0], ss[1]}); if (bb[0] > bb[1]) a.push_back({bb[1], bb[0]}); else b.push_back({bb[0], bb[1]}); int ans = n; if ((int)b.size() > 0) { if ((int)b.size() == 1) ans = b[0].second * (ans / b[0].first) + ans % b[0].first; if ((int)b.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * b[0].first > ans) break; int sm = b[0].second * i; int rem = ans - i * b[0].first; sm += b[1].second * (rem / b[1].first); sm += rem % b[1].second; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)b.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[0] + j * ss[0] > ans) continue; int sm = (i * gg[1]) + (j * ss[1]); int rem = ans - i * gg[0] - j * ss[0]; sm += bb[1] * (rem / bb[0]); rem %= bb[0]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } if ((int)a.size() > 0) { if ((int)a.size() == 1) ans = a[0].second * (ans / a[0].first) + ans % a[0].first; if ((int)a.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * a[0].first > ans) break; int sm = a[0].second * i; int rem = ans - i * a[0].first; sm += a[1].second * (rem / a[1].first); sm += rem % a[1].second; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)a.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[1] + j * ss[1] > ans) continue; int sm = (i * gg[0]) + (j * ss[0]); int rem = ans - i * gg[1] - j * ss[1]; sm += bb[0] * (rem / bb[1]); rem %= bb[1]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100500; const int mod = 1e9 + 7; #define int long long signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; int gg[2], ss[2], bb[2]; cin >> n; for (int i = 0; i < 2; ++i) cin >> gg[i] >> ss[i] >> bb[i]; vector<pair<int, int>> a, b; if (gg[0] > gg[1]) a.push_back({gg[1], gg[0]}); else b.push_back({gg[0], gg[1]}); if (ss[0] > ss[1]) a.push_back({ss[1], ss[0]}); else b.push_back({ss[0], ss[1]}); if (bb[0] > bb[1]) a.push_back({bb[1], bb[0]}); else b.push_back({bb[0], bb[1]}); int ans = n; if ((int)b.size() > 0) { if ((int)b.size() == 1) ans = b[0].second * (ans / b[0].first) + ans % b[0].first; if ((int)b.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * b[0].first > ans) break; int sm = b[0].second * i; int rem = ans - i * b[0].first; sm += b[1].second * (rem / b[1].first); sm += rem % b[1].first; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)b.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[0] + j * ss[0] > ans) continue; int sm = (i * gg[1]) + (j * ss[1]); int rem = ans - i * gg[0] - j * ss[0]; sm += bb[1] * (rem / bb[0]); rem %= bb[0]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } if ((int)a.size() > 0) { if ((int)a.size() == 1) ans = a[0].second * (ans / a[0].first) + ans % a[0].first; if ((int)a.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * a[0].first > ans) break; int sm = a[0].second * i; int rem = ans - i * a[0].first; sm += a[1].second * (rem / a[1].first); sm += rem % a[1].first; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)a.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[1] + j * ss[1] > ans) continue; int sm = (i * gg[0]) + (j * ss[0]); int rem = ans - i * gg[1] - j * ss[1]; sm += bb[0] * (rem / bb[1]); rem %= bb[1]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } cout << ans << '\n'; return 0; }
[ "assignment.value.change", "expression.operation.binary.change" ]
822,447
822,448
u386842336
cpp
p03008
#include <bits/stdc++.h> using namespace std; const int maxn = 100500; const int mod = 1e9 + 7; #define int long long signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; int gg[2], ss[2], bb[2]; cin >> n; for (int i = 0; i < 2; ++i) cin >> gg[i] >> ss[i] >> bb[i]; vector<pair<int, int>> a, b; if (gg[0] > gg[1]) a.push_back({gg[1], gg[0]}); else b.push_back({gg[0], gg[1]}); if (ss[0] > ss[1]) a.push_back({ss[1], ss[0]}); else b.push_back({ss[0], ss[1]}); if (bb[0] > bb[1]) a.push_back({bb[1], bb[0]}); else b.push_back({bb[0], bb[1]}); int ans = n; if ((int)b.size() > 0) { if ((int)b.size() == 1) ans = b[0].second * (ans / b[0].first) + ans % b[0].first; if ((int)b.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * b[0].first > ans) break; int sm = b[0].second * i; int rem = ans - i * b[0].first; sm += b[1].second * (rem / b[1].second); sm += rem % b[1].second; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)b.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[0] + j * ss[0] > ans) continue; int sm = (i * gg[1]) + (j * ss[1]); int rem = ans - i * gg[0] - j * ss[0]; sm += bb[1] * (rem / bb[0]); rem %= bb[0]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } if ((int)a.size() > 0) { if ((int)a.size() == 1) ans = a[0].second * (ans / a[0].first) + ans % a[0].first; if ((int)a.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * a[0].first > ans) break; int sm = a[0].second * i; int rem = ans - i * a[0].first; sm += a[1].second * (rem / a[1].second); sm += rem % a[1].second; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)a.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[1] + j * ss[1] > ans) continue; int sm = (i * gg[0]) + (j * ss[0]); int rem = ans - i * gg[1] - j * ss[1]; sm += bb[0] * (rem / bb[1]); rem %= bb[1]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100500; const int mod = 1e9 + 7; #define int long long signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; int gg[2], ss[2], bb[2]; cin >> n; for (int i = 0; i < 2; ++i) cin >> gg[i] >> ss[i] >> bb[i]; vector<pair<int, int>> a, b; if (gg[0] > gg[1]) a.push_back({gg[1], gg[0]}); else b.push_back({gg[0], gg[1]}); if (ss[0] > ss[1]) a.push_back({ss[1], ss[0]}); else b.push_back({ss[0], ss[1]}); if (bb[0] > bb[1]) a.push_back({bb[1], bb[0]}); else b.push_back({bb[0], bb[1]}); int ans = n; if ((int)b.size() > 0) { if ((int)b.size() == 1) ans = b[0].second * (ans / b[0].first) + ans % b[0].first; if ((int)b.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * b[0].first > ans) break; int sm = b[0].second * i; int rem = ans - i * b[0].first; sm += b[1].second * (rem / b[1].first); sm += rem % b[1].first; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)b.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[0] + j * ss[0] > ans) continue; int sm = (i * gg[1]) + (j * ss[1]); int rem = ans - i * gg[0] - j * ss[0]; sm += bb[1] * (rem / bb[0]); rem %= bb[0]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } if ((int)a.size() > 0) { if ((int)a.size() == 1) ans = a[0].second * (ans / a[0].first) + ans % a[0].first; if ((int)a.size() == 2) { int bst = 0; for (int i = 0; i <= ans; ++i) { if (i * a[0].first > ans) break; int sm = a[0].second * i; int rem = ans - i * a[0].first; sm += a[1].second * (rem / a[1].first); sm += rem % a[1].first; bst = max(bst, sm); } ans = max(ans, bst); } if ((int)a.size() == 3) { int bst = 0; for (int i = 0; i <= ans; ++i) for (int j = 0; j <= ans; ++j) { if (i * gg[1] + j * ss[1] > ans) continue; int sm = (i * gg[0]) + (j * ss[0]); int rem = ans - i * gg[1] - j * ss[1]; sm += bb[0] * (rem / bb[1]); rem %= bb[1]; bst = max(bst, sm + rem); } ans = max(ans, bst); } } cout << ans << '\n'; return 0; }
[ "assignment.value.change", "expression.operation.binary.change" ]
822,449
822,448
u386842336
cpp
p03008
#include <algorithm> #include <cassert> #include <cfloat> #include <cmath> #include <cstdint> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using lint = int64_t; using uint = uint32_t; using ulint = uint64_t; template <class T> using vector2d = vector<vector<T>>; template <class T> bool UpdateMax(T &a, const T &b) { if (a < b) { a = b; return true; } else { return false; } } template <class T> bool UpdateMin(T &a, const T &b) { if (a > b) { a = b; return true; } else { return false; } } template <class T> void OutVec(const vector<T> &vec) { for (int i = 0; i < vec.size() - 1; ++i) { cout << vec[i] << " "; } cout << vec.back() << endl; } template <class T> void OutVec2d(const vector2d<T> &vec) { for (auto v : vec) { OutVec(v); } } lint solve(lint n, lint ga, lint gb, lint sa, lint sb, lint ba, lint bb) { lint tmp_max_nuts = n; for (lint gi = 0; gi <= 5000; gi++) { for (lint si = 0; si <= 5000; si++) { lint nuts = n - gi * ga - si * sa; if (nuts < 0) continue; if (ba < bb) { lint bi = nuts / ba; nuts -= bi * ba; nuts += gi * gb + si * sb + bi * bb; UpdateMax(tmp_max_nuts, nuts); } else { nuts += gi * gb + si * sb; UpdateMax(tmp_max_nuts, nuts); } } } lint result = tmp_max_nuts; for (lint gi = 0; gi <= 5000; gi++) { for (lint si = 0; si <= 5000; si++) { lint nuts = tmp_max_nuts - gi * gb - si * sb; if (nuts < 0) continue; if (ba > bb) { lint bi = nuts / bb; nuts -= bi * bb; nuts += gi * ga + si * sa + bi * ba; UpdateMax(result, nuts); } else { nuts += gi * ga + si * sa; UpdateMax(result, nuts); } } } return result; } int main() { cout << std::fixed << std::setprecision(16); cin.tie(nullptr); std::ios::sync_with_stdio(false); lint n, ga, gb, sa, sb, ba, bb; cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; lint result = n; UpdateMax(result, solve(n, ga, gb, sa, sb, ba, bb)); UpdateMax(result, solve(n, sa, sb, ba, bb, ga, gb)); UpdateMax(result, solve(n, ba, bb, ga, gb, sa, sb)); return result; return 0; }
#include <algorithm> #include <cassert> #include <cfloat> #include <cmath> #include <cstdint> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using lint = int64_t; using uint = uint32_t; using ulint = uint64_t; template <class T> using vector2d = vector<vector<T>>; template <class T> bool UpdateMax(T &a, const T &b) { if (a < b) { a = b; return true; } else { return false; } } template <class T> bool UpdateMin(T &a, const T &b) { if (a > b) { a = b; return true; } else { return false; } } template <class T> void OutVec(const vector<T> &vec) { for (int i = 0; i < vec.size() - 1; ++i) { cout << vec[i] << " "; } cout << vec.back() << endl; } template <class T> void OutVec2d(const vector2d<T> &vec) { for (auto v : vec) { OutVec(v); } } lint solve(lint n, lint ga, lint gb, lint sa, lint sb, lint ba, lint bb) { lint tmp_max_nuts = n; for (lint gi = 0; gi <= 5000; gi++) { for (lint si = 0; si <= 5000; si++) { lint nuts = n - gi * ga - si * sa; if (nuts < 0) continue; if (ba < bb) { lint bi = nuts / ba; nuts -= bi * ba; nuts += gi * gb + si * sb + bi * bb; UpdateMax(tmp_max_nuts, nuts); } else { nuts += gi * gb + si * sb; UpdateMax(tmp_max_nuts, nuts); } } } lint result = tmp_max_nuts; for (lint gi = 0; gi <= 5000; gi++) { for (lint si = 0; si <= 5000; si++) { lint nuts = tmp_max_nuts - gi * gb - si * sb; if (nuts < 0) continue; if (ba > bb) { lint bi = nuts / bb; nuts -= bi * bb; nuts += gi * ga + si * sa + bi * ba; UpdateMax(result, nuts); } else { nuts += gi * ga + si * sa; UpdateMax(result, nuts); } } } return result; } int main() { cout << std::fixed << std::setprecision(16); cin.tie(nullptr); std::ios::sync_with_stdio(false); lint n, ga, gb, sa, sb, ba, bb; cin >> n >> ga >> sa >> ba >> gb >> sb >> bb; lint result = n; UpdateMax(result, solve(n, ga, gb, sa, sb, ba, bb)); UpdateMax(result, solve(n, sa, sb, ba, bb, ga, gb)); UpdateMax(result, solve(n, ba, bb, ga, gb, sa, sb)); cout << result << endl; return 0; }
[ "io.output.change", "io.output.newline.add" ]
822,454
822,455
u844133200
cpp
p03008
#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, a[2][3], b[3]; cin >> N; rep(i, 2) rep(j, 3) cin >> a[i][j]; rep(i, 3) b[i] = a[1][i] - a[0][i]; vector<vector<ll>> dp1(4, vector<ll>(N + 1, 0)); rep(i, 3) { rep(j, N + 1) { dp1[i + 1][j] = dp1[i][j]; if (j >= a[0][i]) { ll x = dp1[i + 1][j - a[0][i]] + b[i]; if (x > dp1[i + 1][j]) dp1[i + 1][j] = x; } } } N += dp1[3][N]; vector<vector<ll>> dp2(4, vector<ll>(N + 1, 0)); rep(i, 3) { rep(j, N + 1) { dp2[i + 1][j] = dp2[i][j]; if (j >= a[1][i]) { ll x = dp2[i + 1][j - a[0][i]] - b[i]; if (x > dp2[i + 1][j]) dp2[i + 1][j] = x; } } } cout << N + dp2[3][N] << 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, a[2][3], b[3]; cin >> N; rep(i, 2) rep(j, 3) cin >> a[i][j]; rep(i, 3) b[i] = a[1][i] - a[0][i]; vector<vector<ll>> dp1(4, vector<ll>(N + 1, 0)); rep(i, 3) { rep(j, N + 1) { dp1[i + 1][j] = dp1[i][j]; if (j >= a[0][i]) { ll x = dp1[i + 1][j - a[0][i]] + b[i]; if (x > dp1[i + 1][j]) dp1[i + 1][j] = x; } } } N += dp1[3][N]; vector<vector<ll>> dp2(4, vector<ll>(N + 1, 0)); rep(i, 3) { rep(j, N + 1) { dp2[i + 1][j] = dp2[i][j]; if (j >= a[1][i]) { ll x = dp2[i + 1][j - a[1][i]] - b[i]; if (x > dp2[i + 1][j]) dp2[i + 1][j] = x; } } } cout << N + dp2[3][N] << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
822,458
822,459
u555962250
cpp
p03008
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout << fixed << setprecision(10) #define ALL(a) (a).begin(), (a).end() #define ALLR(a) (a).rbegin(), (a).rend() #define spa << " " << #define test cout << "test" << endl; #define fi first #define se second #define MP make_pair #define PB push_back #define EB emplace_back #define rep(i, n, m) for (ll i = (n); i < (ll)(m); i++) #define rrep(i, n, m) for (ll i = (m)-1; i >= (ll)(n); i--) using ll = long long; using ld = long double; const ll MOD = 1e9 + 7; // const ll MOD = 998244353; const ll INF = 1e18; using P = pair<ll, ll>; template <typename T> void chmin(T &a, T b) { if (a > b) a = b; } template <typename T> void chmax(T &a, T b) { if (a < b) a = b; } void pmod(ll &a, ll b) { a = (a + b) % MOD; } void pmod(ll &a, ll b, ll c) { a = (b + c) % MOD; } void qmod(ll &a, ll b) { a = (a * b) % MOD; } void qmod(ll &a, ll b, ll c) { a = (b * c) % MOD; } ll median(ll a, ll b, ll c) { return a + b + c - max({a, b, c}) - min({a, b, c}); } void ans1(bool x) { if (x) cout << "Yes" << endl; else cout << "No" << endl; } void ans2(bool x) { if (x) cout << "YES" << endl; else cout << "NO" << endl; } void ans3(bool x) { if (x) cout << "Yay!" << endl; else cout << ":(" << endl; } template <typename T1, typename T2> void ans(bool x, T1 y, T2 z) { if (x) cout << y << endl; else cout << z << endl; } template <typename T> void debug(vector<vector<T>> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { cout << v[i][0]; for (ll j = 1; j < w; j++) cout spa v[i][j]; cout << endl; } }; void debug(vector<string> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) cout << v[i][j]; cout << endl; } }; template <typename T> void debug(vector<T> &v, ll n) { if (n != 0) cout << v[0]; for (ll i = 1; i < n; i++) cout spa v[i]; cout << endl; }; template <typename T> vector<vector<T>> vec(ll x, ll y, T w) { vector<vector<T>> v(x, vector<T>(y, w)); return v; } ll gcd(ll x, ll y) { ll r; while (y != 0 && (r = x % y) != 0) { x = y; y = r; } return y == 0 ? x : y; } vector<ll> dx = {1, 0, -1, 0, 1, 1, -1, -1}; vector<ll> dy = {0, 1, 0, -1, 1, -1, 1, -1}; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); } ostream &operator<<(ostream &os, pair<ll, ll> &p) { return os << p.first << " " << p.second; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); ll res = 0, buf = 0; bool judge = true; ll n; cin >> n; ll a[2][3]; rep(i, 0, 2) cin >> a[i][0] >> a[i][1] >> a[i][2]; vector<ll> dp(n + 1); rep(j, 0, 3) { rep(i, 0, n + 1) if (i + a[0][j] <= n) chmax(dp[i + a[0][j]], dp[i] + a[1][j] - a[0][j]); } ll n2 = n; rep(i, 0, n2 + 1) chmax(n, dp[i] + n2); dp = vector<ll>(n + 1); rep(j, 0, 3) { rep(i, 0, n + 1) if (i + a[0][j] <= n) chmax(dp[i + a[1][j]], dp[i] + a[0][j] - a[1][j]); } n2 = n; rep(i, 0, n2 + 1) chmax(n, dp[i] + n2); cout << n << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout << fixed << setprecision(10) #define ALL(a) (a).begin(), (a).end() #define ALLR(a) (a).rbegin(), (a).rend() #define spa << " " << #define test cout << "test" << endl; #define fi first #define se second #define MP make_pair #define PB push_back #define EB emplace_back #define rep(i, n, m) for (ll i = (n); i < (ll)(m); i++) #define rrep(i, n, m) for (ll i = (m)-1; i >= (ll)(n); i--) using ll = long long; using ld = long double; const ll MOD = 1e9 + 7; // const ll MOD = 998244353; const ll INF = 1e18; using P = pair<ll, ll>; template <typename T> void chmin(T &a, T b) { if (a > b) a = b; } template <typename T> void chmax(T &a, T b) { if (a < b) a = b; } void pmod(ll &a, ll b) { a = (a + b) % MOD; } void pmod(ll &a, ll b, ll c) { a = (b + c) % MOD; } void qmod(ll &a, ll b) { a = (a * b) % MOD; } void qmod(ll &a, ll b, ll c) { a = (b * c) % MOD; } ll median(ll a, ll b, ll c) { return a + b + c - max({a, b, c}) - min({a, b, c}); } void ans1(bool x) { if (x) cout << "Yes" << endl; else cout << "No" << endl; } void ans2(bool x) { if (x) cout << "YES" << endl; else cout << "NO" << endl; } void ans3(bool x) { if (x) cout << "Yay!" << endl; else cout << ":(" << endl; } template <typename T1, typename T2> void ans(bool x, T1 y, T2 z) { if (x) cout << y << endl; else cout << z << endl; } template <typename T> void debug(vector<vector<T>> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { cout << v[i][0]; for (ll j = 1; j < w; j++) cout spa v[i][j]; cout << endl; } }; void debug(vector<string> &v, ll h, ll w) { for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) cout << v[i][j]; cout << endl; } }; template <typename T> void debug(vector<T> &v, ll n) { if (n != 0) cout << v[0]; for (ll i = 1; i < n; i++) cout spa v[i]; cout << endl; }; template <typename T> vector<vector<T>> vec(ll x, ll y, T w) { vector<vector<T>> v(x, vector<T>(y, w)); return v; } ll gcd(ll x, ll y) { ll r; while (y != 0 && (r = x % y) != 0) { x = y; y = r; } return y == 0 ? x : y; } vector<ll> dx = {1, 0, -1, 0, 1, 1, -1, -1}; vector<ll> dy = {0, 1, 0, -1, 1, -1, 1, -1}; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); } ostream &operator<<(ostream &os, pair<ll, ll> &p) { return os << p.first << " " << p.second; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); ll res = 0, buf = 0; bool judge = true; ll n; cin >> n; ll a[2][3]; rep(i, 0, 2) cin >> a[i][0] >> a[i][1] >> a[i][2]; vector<ll> dp(n + 1); rep(j, 0, 3) { rep(i, 0, n + 1) if (i + a[0][j] <= n) chmax(dp[i + a[0][j]], dp[i] + a[1][j] - a[0][j]); } ll n2 = n; rep(i, 0, n2 + 1) chmax(n, dp[i] + n2); dp = vector<ll>(n + 1); rep(j, 0, 3) { rep(i, 0, n + 1) if (i + a[1][j] <= n) chmax(dp[i + a[1][j]], dp[i] + a[0][j] - a[1][j]); } // debug(dp,n+1); n2 = n; rep(i, 0, n2 + 1) chmax(n, dp[i] + n2); cout << n << endl; return 0; }
[ "literal.number.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
822,460
822,461
u898167769
cpp
p03008
// #define DEBUGGING #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; template <typename T, typename U> using P = pair<T, U>; using ll = int64_t; using PLL = P<ll, ll>; template <typename T> const T &var_min(const T &t) { return t; } template <typename T> const T &var_max(const T &t) { return t; } template <typename T, typename... Tail> const T &var_min(const T &t, const Tail &...tail) { return min(t, var_min(tail...)); } template <typename T, typename... Tail> const T &var_max(const T &t, const Tail &...tail) { return max(t, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail &...tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail &...tail) { t = var_max(t, tail...); } template <typename T> const T &clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); } template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); } namespace init__ { struct InitIO { InitIO() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); } } init_io; } // namespace init__ #ifdef DEBUGGING #include "../debug.cpp" #else #define DEBUG(...) 0 #define DEBUG_SEPARATOR_LINE 0 #endif template <typename T> T make_v(T init) { return init; } template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { #define rec make_v(init, tail...) return V<decltype(rec)>(s, rec); #undef rec } int main() { ll N; cin >> N; V<PLL> changes(3); for (auto &ele : changes) cin >> ele.first; for (auto &ele : changes) cin >> ele.second; ll max_d = N; for (ll loops = 0; loops <= 1; loops++) { V<ll> dp(max_d + 10, 0); for (ll i = 0; i < max_d; i++) { chmax(dp[i + 1], dp[i] + 1); for (ll j = 0; j < 3; j++) { ll a, b; tie(a, b) = changes[j]; if (loops) swap(a, b); if (i + a > N) continue; chmax(dp[i + a], dp[i] + b); } } max_d = dp[max_d]; } cout << max_d << endl; return 0; }
// #define DEBUGGING #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; template <typename T, typename U> using P = pair<T, U>; using ll = int64_t; using PLL = P<ll, ll>; template <typename T> const T &var_min(const T &t) { return t; } template <typename T> const T &var_max(const T &t) { return t; } template <typename T, typename... Tail> const T &var_min(const T &t, const Tail &...tail) { return min(t, var_min(tail...)); } template <typename T, typename... Tail> const T &var_max(const T &t, const Tail &...tail) { return max(t, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail &...tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail &...tail) { t = var_max(t, tail...); } template <typename T> const T &clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); } template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); } namespace init__ { struct InitIO { InitIO() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(30); } } init_io; } // namespace init__ #ifdef DEBUGGING #include "../debug.cpp" #else #define DEBUG(...) 0 #define DEBUG_SEPARATOR_LINE 0 #endif template <typename T> T make_v(T init) { return init; } template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { #define rec make_v(init, tail...) return V<decltype(rec)>(s, rec); #undef rec } int main() { ll N; cin >> N; V<PLL> changes(3); for (auto &ele : changes) cin >> ele.first; for (auto &ele : changes) cin >> ele.second; ll max_d = N; for (ll loops = 0; loops <= 1; loops++) { V<ll> dp(max_d + 10, 0); for (ll i = 0; i < max_d; i++) { chmax(dp[i + 1], dp[i] + 1); for (ll j = 0; j < 3; j++) { ll a, b; tie(a, b) = changes[j]; if (loops) swap(a, b); if (i + a > max_d) continue; chmax(dp[i + a], dp[i] + b); } } max_d = dp[max_d]; } cout << max_d << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
822,462
822,463
u216962796
cpp
p03008
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) using ll = long long; using P = pair<ll, ll>; ll solve(vector<P> p, ll n) { ll ans = n; if (p.size() == 1) { ans = n / p[0].first * p[0].second + n % p[0].first; } else if (p.size() == 2) { for (ll i = 0; i < n; i++) { ll d = n - p[0].first * i; if (d < 0) break; ans = max(ans, p[0].second * i + d / p[1].first * p[1].second + d % p[1].first); } } else if (p.size() == 3) { for (ll i = 0; i < n; i++) { for (ll j = 0; j < n; j++) { ll d = n - p[0].first * i - p[1].first * j; if (d < 0) continue; ans = max(ans, p[0].second * i + p[1].second * j + d / p[2].first * p[2].second + d % p[2].first); } } } return ans; } int main() { ll n; cin >> n; ll a[3], b[3]; rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i]; vector<P> p, q; rep(i, 3) { if (a[i] < b[i]) p.push_back(P(a[i], b[i])); else if (b[i] < a[i]) q.push_back(P(b[i], a[i])); } n = solve(p, n); n = solve(q, n); cout << n << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) using ll = long long; using P = pair<ll, ll>; ll solve(vector<P> p, ll n) { ll ans = n; if (p.size() == 1) { ans = n / p[0].first * p[0].second + n % p[0].first; } else if (p.size() == 2) { for (ll i = 0; i <= n; i++) { ll d = n - p[0].first * i; if (d < 0) break; ans = max(ans, p[0].second * i + d / p[1].first * p[1].second + d % p[1].first); } } else if (p.size() == 3) { for (ll i = 0; i <= n; i++) { for (ll j = 0; j <= n; j++) { ll d = n - p[0].first * i - p[1].first * j; if (d < 0) continue; ans = max(ans, p[0].second * i + p[1].second * j + d / p[2].first * p[2].second + d % p[2].first); } } } return ans; } int main() { ll n; cin >> n; ll a[3], b[3]; rep(i, 3) cin >> a[i]; rep(i, 3) cin >> b[i]; vector<P> p, q; rep(i, 3) { if (a[i] < b[i]) p.push_back(P(a[i], b[i])); else if (b[i] < a[i]) q.push_back(P(b[i], a[i])); } n = solve(p, n); n = solve(q, n); cout << n << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,466
822,467
u970690920
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; cin >> i >> j >> k; cout << min(i, j) + min(j, k) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; cin >> i >> j >> k; cout << min(i, j) + min(max(i, j), k) << endl; return 0; }
[ "call.add", "call.arguments.change" ]
822,585
822,586
u319965179
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a + b + c - (max(a, b) && max(b, c)) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a + b + c - max(max(a, b), max(b, c)) << endl; }
[ "call.add", "io.output.change" ]
822,589
822,590
u751515087
cpp
p03011
#include <iostream> using namespace std; int main() { int p, q, r; cin >> p >> q >> r; cout << p + q + r - min(min(p, q), r) << endl; }
#include <iostream> using namespace std; int main() { int p, q, r; cin >> p >> q >> r; cout << p + q + r - max(max(p, q), r) << endl; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
822,591
822,592
u880449276
cpp
p03011
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int p, q, r; cin >> p >> q >> r; if (p > q && p > r) cout << q + r << endl; else if (q > p && q > r) cout << p + r << endl; else cout << p + q << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int p, q, r; cin >> p >> q >> r; if (p >= q && p >= r) cout << q + r << endl; else if (q >= p && q >= r) cout << p + r << endl; else cout << p + q << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,599
822,600
u965095643
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int m; m = max((a, b), c); cout << a + b + c - m << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int m; m = max(max(a, b), c); cout << a + b + c - m << endl; }
[ "call.add", "call.arguments.change" ]
822,614
822,615
u668010224
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int m; m = max((a, b), c); cout << a + b + c - m << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int m; m = max({a, b, c}); cout << a + b + c - m << endl; }
[ "assignment.value.change", "call.arguments.change" ]
822,614
822,616
u668010224
cpp
p03011
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) typedef long long ll; typedef pair<int, int> P; const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; int main() { int P, Q, R; cin >> P >> Q >> R; cout << min(P + Q, min(Q + R, R + Q)) << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) typedef long long ll; typedef pair<int, int> P; const int INF = 100100100; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; int main() { int P, Q, R; cin >> P >> Q >> R; cout << min(P + Q, min(Q + R, R + P)) << endl; }
[ "identifier.change", "io.output.change" ]
822,617
822,618
u893239355
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int a, p, q, r; cin >> p >> q >> r; if (p > q && p > r) { a = q + r; } if (q > p && q > r) { a = p + r; } if (r > p && r > q) { a = p + q; } cout << a; }
#include <bits/stdc++.h> using namespace std; int main() { int a, p, q, r; cin >> p >> q >> r; if (p >= q && p >= r) { a = q + r; } if (q >= p && q >= r) { a = p + r; } if (r >= p && r >= q) { a = p + q; } cout << a; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,623
822,622
u642426958
cpp
p03011
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> //sqrt pow #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cout, endl, cin #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector #define rep(i, n) for (int i = 0; i < n; i++) #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define mod 1000000007 using ll = long long; using namespace std; int main() { int p, q, r; cin >> p >> q >> r; int ans = max({p + q, q + r, r + p}); cout << ans << endl; }
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> //sqrt pow #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iostream> // cout, endl, cin #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector #define rep(i, n) for (int i = 0; i < n; i++) #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define mod 1000000007 using ll = long long; using namespace std; int main() { int p, q, r; cin >> p >> q >> r; int ans = min({p + q, q + r, r + p}); cout << ans << endl; }
[ "misc.opposites", "identifier.change", "call.function.change" ]
822,632
822,633
u396266329
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int P, Q, R; cin >> P >> Q >> R; cout << min(P, min(Q, R)); }
#include <bits/stdc++.h> using namespace std; int main() { int P, Q, R; cin >> P >> Q >> R; cout << min(P + Q, min(Q + R, R + P)); }
[ "expression.operation.binary.add" ]
822,640
822,641
u391725672
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int m = max(a, (b, c)); cout << a + b + c - m << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int d = max(a, max(b, c)); cout << a + b + c - d << endl; }
[ "variable_declaration.name.change", "identifier.change", "call.add", "call.arguments.change", "io.output.change" ]
822,661
822,662
u258387753
cpp
p03011
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) #define ll long long #define MAX 100005 #define NIL -1 int n, pos; vector<int> pre, in, post; void rec(int l, int r) { if (l >= 0) return; int root = pre[pos++]; int m = distance(in.begin(), find(in.begin(), in.end(), root)); } void solve() { pos = 0; rec(0, pre.size()); for (int i = 0; i < n; i++) { if (i) cout << " "; cout << post[i]; } cout << endl; } int main() { int ab, bc, ca; cin >> ab >> bc >> ca; int x, y, z; x = ab + bc; y = bc + ca; z = ca = ab; if (x < y && x < z) cout << x << endl; else if (y < x && y < z) cout << y << endl; else cout << z << endl; return 0; }
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) #define ll long long #define MAX 100005 #define NIL -1 int n, pos; vector<int> pre, in, post; void rec(int l, int r) { if (l >= 0) return; int root = pre[pos++]; int m = distance(in.begin(), find(in.begin(), in.end(), root)); } void solve() { pos = 0; rec(0, pre.size()); for (int i = 0; i < n; i++) { if (i) cout << " "; cout << post[i]; } cout << endl; } int main() { int ab, bc, ca; cin >> ab >> bc >> ca; int x, y, z; x = ab + bc; y = bc + ca; z = ca + ab; if (x <= y && x <= z) cout << x << endl; else if (y <= x && y <= z) cout << y << endl; else cout << z << endl; return 0; }
[ "assignment.value.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,663
822,664
u101048376
cpp
p03011
#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 p, q, r; cin >> p >> q >> r; int ans = min(r + q, min(p + q, q + r)); cout << ans << endl; return 0; }
#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 p, q, r; cin >> p >> q >> r; int ans = min(r + p, min(p + q, q + r)); cout << ans << endl; return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
822,667
822,668
u194930818
cpp
p03011
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n)) #define ALL(a) (a).begin(), (a).end() using ll = long long; int main() { int P, Q, R; cin >> P >> Q >> R; int ans = P + Q + R - min(P, min(Q, R)); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n)) #define ALL(a) (a).begin(), (a).end() using ll = long long; int main() { int P, Q, R; cin >> P >> Q >> R; int ans = P + Q + R - max(P, max(Q, R)); cout << ans << endl; }
[ "misc.opposites", "identifier.change", "call.function.change", "expression.operation.binary.change", "call.arguments.change" ]
822,693
822,694
u842897677
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int p, q, r, pq, qr, rp; cin >> p >> q >> r; pq = p + q; qr = q + r; rp = r + p; cout << min(pq, (qr, rp)) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int p, q, r, pq, qr, rp; cin >> p >> q >> r; pq = p + q; qr = q + r; rp = r + p; cout << min(pq, min(qr, rp)) << endl; }
[ "call.add", "call.arguments.change" ]
822,698
822,699
u921792500
cpp
p03011
#include <stdio.h> int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); int sum = a + b, ans = b + c, num = c + a; int temp; if (sum < ans) { temp = sum; sum = ans; ans = temp; } if (num < ans) { temp = num; num = ans; ans = num; } printf("%d", ans); return 0; }
#include <stdio.h> int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); int sum = a + b, ans = b + c, num = c + a; int temp; if (sum < ans) { temp = sum; sum = ans; ans = temp; } if (num < ans) { temp = num; num = ans; ans = temp; } printf("%d", ans); return 0; }
[ "assignment.value.change", "identifier.change" ]
822,700
822,701
u018679195
cpp
p03011
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (long long)(n); ++i) #define all(a) a.begin(), a.end() using namespace std; typedef long long ll; typedef pair<ll, ll> P; 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 ll MOD = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1); int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1}; const int MAX = 510000; int main() { cin.tie(0); ios::sync_with_stdio(false); int p, q, r; cin >> p >> q >> r; cout << min({p + q, q + p, r + p}) << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (long long)(n); ++i) #define all(a) a.begin(), a.end() using namespace std; typedef long long ll; typedef pair<ll, ll> P; 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 ll MOD = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1); int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1}; const int MAX = 510000; int main() { cin.tie(0); ios::sync_with_stdio(false); int p, q, r; cin >> p >> q >> r; cout << min({p + q, q + r, r + p}) << endl; return 0; }
[ "identifier.change", "io.output.change" ]
822,702
822,703
u371149954
cpp
p03011
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; int main() { int p, q, r; cin >> p >> q >> r; cout << min({p + r, q + r, r + p}) << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; int main() { int p, q, r; cin >> p >> q >> r; cout << min({p + q, q + r, r + p}) << endl; return 0; }
[ "identifier.change", "io.output.change" ]
822,704
822,705
u371149954
cpp
p03011
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define MOD 1000000007 // 10^9+7 #define ALL(a) (a).begin(), (a).end() using namespace std; using ll = long long; using PII = pair<int, int>; using PLL = pair<long long, long long>; const int INF = numeric_limits<int>::max(); constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } // 負の数にも対応した % 演算 long long mod(long long val, long long m) { long long res = val % m; if (res < 0) res += m; return res; } // greatest common divisor long long gcd(ll a, ll b) { if (a % b == 0) { return b; } else { return gcd(b, a % b); } } // least common multiple long long lcm(ll a, ll b) { return a / gcd(a, b) * b; } bool is_prime(ll n) { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return n != 1; } int main() { int p, q, r; cin >> p >> q >> r; cout << min(p + q, min(p + q, r + q)) << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define MOD 1000000007 // 10^9+7 #define ALL(a) (a).begin(), (a).end() using namespace std; using ll = long long; using PII = pair<int, int>; using PLL = pair<long long, long long>; const int INF = numeric_limits<int>::max(); constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } // 負の数にも対応した % 演算 long long mod(long long val, long long m) { long long res = val % m; if (res < 0) res += m; return res; } // greatest common divisor long long gcd(ll a, ll b) { if (a % b == 0) { return b; } else { return gcd(b, a % b); } } // least common multiple long long lcm(ll a, ll b) { return a / gcd(a, b) * b; } bool is_prime(ll n) { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return n != 1; } int main() { int p, q, r; cin >> p >> q >> r; cout << min(p + q, min(p + r, r + q)) << endl; return 0; }
[ "identifier.change", "io.output.change" ]
822,729
822,730
u366581326
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if (a < b) swap(a, b); if (b < c) swap(b, c); cout << a + b << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); if (b > c) swap(b, c); cout << a + b << '\n'; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,735
822,736
u600244905
cpp
p03011
#include <bits/stdc++.h> #define rep0(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i <= (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int P, Q, R; cin >> P >> Q >> R; vector<int> v(3); v[0] = P; v[1] = Q; v[2] = R; sort(v.begin(), v.begin()); cout << v[0] + v[1]; }
#include <bits/stdc++.h> #define rep0(i, n) for (int i = 0; i < (n); ++i) #define rep1(i, n) for (int i = 1; i <= (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int P, Q, R; cin >> P >> Q >> R; vector<int> v(3); v[0] = P; v[1] = Q; v[2] = R; sort(v.begin(), v.end()); cout << v[0] + v[1]; }
[ "call.function.change", "call.arguments.change" ]
822,739
822,740
u290292036
cpp
p03011
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) typedef long long int ll; typedef unsigned long long int ull; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b, c, ans; string s, t; cin >> a >> b >> c; if (a <= b && a <= c) ans = b + c; if (b <= a && b <= c) ans = a + c; if (c <= b && c <= a) ans = b + a; cout << ans; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) typedef long long int ll; typedef unsigned long long int ull; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b, c, ans; string s, t; cin >> a >> b >> c; if (a >= b && a >= c) ans = b + c; if (b >= a && b >= c) ans = a + c; if (c >= b && c >= a) ans = b + a; cout << ans; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,754
822,755
u906199847
cpp
p03011
#include <bits/stdc++.h> using namespace std; // TYPEDEF // ---------------------------------------- typedef long long ll; typedef long double ld; typedef pair<ll, ll> Pair; typedef vector<ll> vll; typedef vector<vector<ll>> Graph; typedef vector<string> vs; typedef vector<pair<ll, ll>> Pll; typedef queue<ll> qll; // REPEAT // ---------------------------------------- #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define REPA(i, a) \ for (ll i = 0; i < (ll)(a.size()); i++) \ ; #define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--) #define COUT(a) cout << (a) << endl; #define ENDL(a) cout << endl; #define COUTA(i, a) \ for (ll i = 0; i < (ll)(a.size()); i++) { \ cout << (a)[i] << " "; \ } \ cout << endl; // UTIL // ---------------------------------------- #define pb push_back #define paired make_pair #define ALL(a) (a).begin(), (a).end() #define SORT(a) sort((a).begin(), (a).end()) #define RSORT(a) sort((a).rbegin(), (a).rend()) // DEBUG // ---------------------------------------- #ifdef _DEBUG #define debug(x) cout << "[debug] " << #x << ": " << x << endl #else #define debug(x) #endif template <typename T> void debugV(const vector<T> v) { #ifdef _DEBUG rep(i, v.size()) { cout << i << ":" << v[i] << " "; } cout << endl; #else (void)v; #endif } // BIT FLAG // ---------------------------------------- const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001 const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010 const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100 const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000 const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000 const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000 const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000 const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000 const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000 const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000 const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000 const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000 // CONST // ---------------------------------------- constexpr ll INF = 0x3f3f3f3f3f3f3f3f; constexpr double PI = 3.14159265358979323846; // or M_PI constexpr int MOD = 1000000007; void Main() { ll p, q, r; cin >> p >> q >> r; COUT(min(p + q, min(q + r, q + p))); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); } /* 3 2 */
#include <bits/stdc++.h> using namespace std; // TYPEDEF // ---------------------------------------- typedef long long ll; typedef long double ld; typedef pair<ll, ll> Pair; typedef vector<ll> vll; typedef vector<vector<ll>> Graph; typedef vector<string> vs; typedef vector<pair<ll, ll>> Pll; typedef queue<ll> qll; // REPEAT // ---------------------------------------- #define REP(i, n) for (ll i = 0; i < (ll)(n); i++) #define REPD(i, n) for (ll i = n - 1; i >= 0; i--) #define REPA(i, a) \ for (ll i = 0; i < (ll)(a.size()); i++) \ ; #define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++) #define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--) #define COUT(a) cout << (a) << endl; #define ENDL(a) cout << endl; #define COUTA(i, a) \ for (ll i = 0; i < (ll)(a.size()); i++) { \ cout << (a)[i] << " "; \ } \ cout << endl; // UTIL // ---------------------------------------- #define pb push_back #define paired make_pair #define ALL(a) (a).begin(), (a).end() #define SORT(a) sort((a).begin(), (a).end()) #define RSORT(a) sort((a).rbegin(), (a).rend()) // DEBUG // ---------------------------------------- #ifdef _DEBUG #define debug(x) cout << "[debug] " << #x << ": " << x << endl #else #define debug(x) #endif template <typename T> void debugV(const vector<T> v) { #ifdef _DEBUG rep(i, v.size()) { cout << i << ":" << v[i] << " "; } cout << endl; #else (void)v; #endif } // BIT FLAG // ---------------------------------------- const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001 const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010 const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100 const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000 const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000 const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000 const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000 const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000 const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000 const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000 const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000 const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000 // CONST // ---------------------------------------- constexpr ll INF = 0x3f3f3f3f3f3f3f3f; constexpr double PI = 3.14159265358979323846; // or M_PI constexpr int MOD = 1000000007; void Main() { ll p, q, r; cin >> p >> q >> r; COUT(min(p + q, min(q + r, r + p))); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); } /* 3 2 */
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
822,756
822,757
u644224332
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; cout << min(min(A, B), C) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; cout << min(min(A + B, B + C), A + C) << endl; }
[ "expression.operation.binary.add" ]
822,758
822,759
u991713078
cpp
p03011
// BISMILLAHHIR RAHMANIR RAHIM #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define min3(a, b, c) min(a, min(b, c)) #define F first #define S second #define PB push_back #define MP make_pair #define PI 2 * acos(0.0) #define MOD 998244353 int main() { int ara[3], mn = 1e6, sum = 0; for (int i = 0; i < 3; i++) cin >> ara[i]; for (int i = 0; i < 3 - 1; i++) { for (int j = i + 1; j < 3; j++) { sum += ara[i] + ara[j]; mn = min(mn, sum); } sum = 0; } cout << mn << endl; return 0; }
// BISMILLAHHIR RAHMANIR RAHIM #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define min3(a, b, c) min(a, min(b, c)) #define F first #define S second #define PB push_back #define MP make_pair #define PI 2 * acos(0.0) #define MOD 998244353 int main() { int ara[3], mn = 1e6, sum = 0; for (int i = 0; i < 3; i++) cin >> ara[i]; for (int i = 0; i < 3 - 1; i++) { for (int j = i + 1; j < 3; j++) { sum += ara[i] + ara[j]; mn = min(mn, sum); sum = 0; } } cout << mn << endl; return 0; }
[]
822,785
822,786
u605722102
cpp
p03011
// BISMILLAHHIR RAHMANIR RAHIM #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define min3(a, b, c) min(a, min(b, c)) #define F first #define S second #define PB push_back #define MP make_pair #define PI 2 * acos(0.0) #define MOD 998244353 int main() { int ara[3], mn = 1e6, sum = 0; for (int i = 0; i < 3; i++) cin >> ara[i]; for (int i = 0; i < 3 - 1; i++) { for (int j = i + 1; j < 3; j++) { sum += ara[i] + ara[j]; mn = min(mn, sum); } } cout << mn << endl; return 0; }
// BISMILLAHHIR RAHMANIR RAHIM #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define min3(a, b, c) min(a, min(b, c)) #define F first #define S second #define PB push_back #define MP make_pair #define PI 2 * acos(0.0) #define MOD 998244353 int main() { int ara[3], mn = 1e6, sum = 0; for (int i = 0; i < 3; i++) cin >> ara[i]; for (int i = 0; i < 3 - 1; i++) { for (int j = i + 1; j < 3; j++) { sum += ara[i] + ara[j]; mn = min(mn, sum); sum = 0; } } cout << mn << endl; return 0; }
[ "assignment.add" ]
822,787
822,786
u605722102
cpp
p03011
// BISMILLAHHIR RAHMANIR RAHIM #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define min3(a, b, c) min(a, min(b, c)) #define F first #define S second #define PB push_back #define MP make_pair #define PI 2 * acos(0.0) #define MOD 998244353 int main() { int ara[3], mn = 1e6, sum = 0; for (int i = 0; i < 3; i++) cin >> ara[i]; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 3; j++) { sum += ara[i] + ara[j]; mn = min(mn, sum); } } cout << mn << endl; return 0; }
// BISMILLAHHIR RAHMANIR RAHIM #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; #define min3(a, b, c) min(a, min(b, c)) #define F first #define S second #define PB push_back #define MP make_pair #define PI 2 * acos(0.0) #define MOD 998244353 int main() { int ara[3], mn = 1e6, sum = 0; for (int i = 0; i < 3; i++) cin >> ara[i]; for (int i = 0; i < 3 - 1; i++) { for (int j = i + 1; j < 3; j++) { sum += ara[i] + ara[j]; mn = min(mn, sum); sum = 0; } } cout << mn << endl; return 0; }
[ "control_flow.loop.for.condition.change", "misc.off_by_one", "assignment.add" ]
822,788
822,786
u605722102
cpp
p03011
#include <bits/stdc++.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { int a, b, c, d; cin >> a >> b >> c; d = a + b + c; cout << max(a, max(b, c)) + (d - max(a, max(b, c)) - min(a, min(b, c))); }
#include <bits/stdc++.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { int a, b, c, d; cin >> a >> b >> c; d = a + b + c; cout << min(a, min(b, c)) + (d - max(a, max(b, c)) - min(a, min(b, c))); }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
822,791
822,792
u683078179
cpp
p03011
#include <bits/stdc++.h> using namespace std; void Main() { int p, q, r; cin >> p >> q >> r; cout << p + q + r - min({p, q, r}); } int main(void) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed << std::setprecision(10); #ifdef DEBUG_BUILD while (true) { Main(); cout << std::endl; } #endif Main(); cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void Main() { int p, q, r; cin >> p >> q >> r; cout << p + q + r - max({p, q, r}); } int main(void) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed << std::setprecision(10); #ifdef DEBUG_BUILD while (true) { Main(); cout << std::endl; } #endif Main(); cout << endl; return 0; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
822,801
822,802
u588369531
cpp
p03011
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, m; cin >> a >> b >> c; m = min({a, b, c}); cout << a + b + c - m << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, m; cin >> a >> b >> c; m = max({a, b, c}); cout << a + b + c - m << endl; }
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change" ]
822,803
822,804
u522993719
cpp
p03011
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { ll a, b, c; cin >> a >> b >> c; ll d = min(c, min(a, b)); cout << a + b + c - d; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { ll a, b, c; cin >> a >> b >> c; ll d = max(max(a, b), c); cout << a + b + c - d; return 0; }
[ "misc.opposites", "identifier.change", "call.function.change", "call.arguments.change", "call.arguments.add" ]
822,805
822,806
u548977290
cpp
p03011
#include <bits/stdc++.h> using namespace std; using lint = long long; const lint mod = 998244353; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) template <class T> inline void YES(T condition) { if (condition) cout << "YES" << endl; else cout << "NO" << endl; } template <class T> inline void Yes(T condition) { if (condition) cout << "Yes" << endl; else cout << "No" << endl; } template <class T = string, class U = char> int character_count(T text, U character) { int ans = 0; for (U i : text) { ans += (i == character); } return ans; } lint power(lint base, lint exponent, lint module) { if (exponent % 2) { return power(base, exponent - 1, module) * base % module; } else if (exponent) { lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; } else { return 1; } } struct position { int y, x; }; position mv[4] = { {0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return // sqrt((second.x - first.x) * (second.x - first.x) + (second.y - // first.y) * (second.y - first.y)); } template <class T, class U> string to_string(pair<T, U> x) { return to_string(x.first) + "," + to_string(x.second); } string to_string(string x) { return x; } template <class itr> void array_output(itr start, itr goal) { string ans; for (auto i = start; i != goal; i++) ans += to_string(*i) + " "; if (!ans.empty()) ans.pop_back(); cout << ans << endl; } template <class itr> void cins(itr first, itr last) { for (auto i = first; i != last; i++) { cin >> (*i); } } template <class T> T gcd_calc(T a, T b) { if (b) { return gcd_calc(b, a % b); } else { return a; } } template <class T> T gcd(T a, T b) { if (a < b) swap(a, b); return gcd_calc(a, b); } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } struct combination { vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1) { fact[0] = 1; for (int i = 1; i <= sz; i++) { fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for (int i = sz - 1; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const { if (q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } }; template <class itr> bool next_sequence(itr first, itr last, int max_bound) { itr now = last; while (now != first) { now--; (*now)++; if ((*now) == max_bound) { (*now) = 0; } else { return true; } } return false; } inline int at(int x, int k) { return (x >> k) & 1; } random_device rnd; string day[7] = {"Sunny", "Cloudy", "Rainy"}; int main() { int P, Q, R; cin >> P >> Q >> R; cout << P + Q + R - min({P, Q, R}) << endl; }
#include <bits/stdc++.h> using namespace std; using lint = long long; const lint mod = 998244353; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) template <class T> inline void YES(T condition) { if (condition) cout << "YES" << endl; else cout << "NO" << endl; } template <class T> inline void Yes(T condition) { if (condition) cout << "Yes" << endl; else cout << "No" << endl; } template <class T = string, class U = char> int character_count(T text, U character) { int ans = 0; for (U i : text) { ans += (i == character); } return ans; } lint power(lint base, lint exponent, lint module) { if (exponent % 2) { return power(base, exponent - 1, module) * base % module; } else if (exponent) { lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; } else { return 1; } } struct position { int y, x; }; position mv[4] = { {0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return // sqrt((second.x - first.x) * (second.x - first.x) + (second.y - // first.y) * (second.y - first.y)); } template <class T, class U> string to_string(pair<T, U> x) { return to_string(x.first) + "," + to_string(x.second); } string to_string(string x) { return x; } template <class itr> void array_output(itr start, itr goal) { string ans; for (auto i = start; i != goal; i++) ans += to_string(*i) + " "; if (!ans.empty()) ans.pop_back(); cout << ans << endl; } template <class itr> void cins(itr first, itr last) { for (auto i = first; i != last; i++) { cin >> (*i); } } template <class T> T gcd_calc(T a, T b) { if (b) { return gcd_calc(b, a % b); } else { return a; } } template <class T> T gcd(T a, T b) { if (a < b) swap(a, b); return gcd_calc(a, b); } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } struct combination { vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1) { fact[0] = 1; for (int i = 1; i <= sz; i++) { fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for (int i = sz - 1; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const { if (q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } }; template <class itr> bool next_sequence(itr first, itr last, int max_bound) { itr now = last; while (now != first) { now--; (*now)++; if ((*now) == max_bound) { (*now) = 0; } else { return true; } } return false; } inline int at(int x, int k) { return (x >> k) & 1; } random_device rnd; string day[7] = {"Sunny", "Cloudy", "Rainy"}; int main() { int P, Q, R; cin >> P >> Q >> R; cout << P + Q + R - max({P, Q, R}) << endl; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
822,807
822,808
u115888500
cpp
p03011
#include <algorithm> #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << min((a + b, b + c), a + c) << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << min(min(a + b, b + c), a + c) << endl; return 0; }
[ "call.add", "call.arguments.change" ]
822,815
822,816
u745267317
cpp
p03011
#include <iostream> using namespace std; int main(void) { int p, q, r; cin >> p >> q >> r; int ac, ab, bc; ac = p + q; ab = q + r; bc = r + p; if (ac < ab && ac < bc) { cout << ac << endl; } else if (ab < bc && ab < ac) { cout << ab << endl; } else { cout << bc << endl; } }
#include <iostream> using namespace std; int main(void) { int p, q, r; cin >> p >> q >> r; int ac, ab, bc; ac = p + q; ab = q + r; bc = r + p; if (ac <= ab && ac <= bc) { cout << ac << endl; } else if (ab <= bc && ab <= ac) { cout << ab << endl; } else { cout << bc << endl; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
822,819
822,820
u693378622
cpp
p03011
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define REP(i, n) FOR(i, 0, n) #define fi first #define se second #define pb push_back #define mp make_pair #define eb emplace_back #define bcnt __builtin_popcountll using namespace std; #ifdef LOCAL #include <prettyprint.hpp> #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__); #else #define debug(...) 83; #endif typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pin; ll INF = 1e16; int inf = 1e9; ll MOD = 1e9 + 7; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "{ "; REP(i, vec.size()) { os << vec[i] << " "; } os << "}"; return os; } void d_err() { cerr << endl; } template <typename H, typename... T> void d_err(H h, T... t) { cerr << h << " "; d_err(t...); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); int P, Q, R; cin >> P >> Q >> R; cout << max(P + Q, max(Q + R, R + P)) << endl; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define REP(i, n) FOR(i, 0, n) #define fi first #define se second #define pb push_back #define mp make_pair #define eb emplace_back #define bcnt __builtin_popcountll using namespace std; #ifdef LOCAL #include <prettyprint.hpp> #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__); #else #define debug(...) 83; #endif typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pin; ll INF = 1e16; int inf = 1e9; ll MOD = 1e9 + 7; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "{ "; REP(i, vec.size()) { os << vec[i] << " "; } os << "}"; return os; } void d_err() { cerr << endl; } template <typename H, typename... T> void d_err(H h, T... t) { cerr << h << " "; d_err(t...); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); int P, Q, R; cin >> P >> Q >> R; cout << min(P + Q, min(Q + R, R + P)) << endl; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
822,824
822,825
u089177147
cpp