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 |
|---|---|---|---|---|---|---|---|
p03162 | #include "bits/stdc++.h"
#pragma warning(disable : 4996)
using namespace std;
const int N = 1e5 + 5;
struct node {
int a, b, c;
} s[N];
long long dp[N][3];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s[i].a >> s[i].b >> s[i].c;
}
dp[0][0] = s[0].a;
dp[0][1] = s[0].b;
dp[0][2] = s[0].c;
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i][0], dp[i - 1][1] + s[i].b);
dp[i][0] = max(dp[i][0], dp[i - 1][2] + s[i].c);
dp[i][1] = max(dp[i][1], dp[i - 1][0] + s[i].a);
dp[i][1] = max(dp[i][1], dp[i - 1][2] + s[i].c);
dp[i][2] = max(dp[i][2], dp[i - 1][0] + s[i].a);
dp[i][2] = max(dp[i][2], dp[i - 1][1] + s[i].b);
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
} | #include "bits/stdc++.h"
#pragma warning(disable : 4996)
using namespace std;
const int N = 1e5 + 5;
struct node {
int a, b, c;
} s[N];
long long dp[N][3];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s[i].a >> s[i].b >> s[i].c;
}
dp[0][0] = s[0].a;
dp[0][1] = s[0].b;
dp[0][2] = s[0].c;
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i][0], dp[i - 1][1] + s[i].a);
dp[i][0] = max(dp[i][0], dp[i - 1][2] + s[i].a);
dp[i][1] = max(dp[i][1], dp[i - 1][0] + s[i].b);
dp[i][1] = max(dp[i][1], dp[i - 1][2] + s[i].b);
dp[i][2] = max(dp[i][2], dp[i - 1][0] + s[i].c);
dp[i][2] = max(dp[i][2], dp[i - 1][1] + s[i].c);
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
} | [
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,089 | 964,090 | u873935558 | cpp |
p03162 | // C - Vacation
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll n;
// vector<ll> dp(3, vector<ll>(1000005, -1));
ll dp[3][1000005];
ll cost(vector<vector<ll>> &matrix, ll selected, ll day) {
if (dp[day][selected] != -1)
return dp[day][selected];
if (day == matrix.size())
return matrix[day][selected];
dp[day][selected] =
max(cost(matrix, (selected + 1) % 3, day + 1) + matrix[day][selected],
cost(matrix, (selected + 2) % 3, day + 1) + matrix[day][selected]);
return dp[day][selected];
}
int main() {
cin >> n;
vector<vector<ll>> matrix(n, vector<ll>(3, -1));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> matrix[i][j];
}
}
cout << max(max(cost(matrix, 0, 0), cost(matrix, 1, 0)), cost(matrix, 2, 0));
} | // C - Vacation
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll n;
// vector<ll> dp(3, vector<ll>(1000005, -1));
ll dp[1000005][3];
ll cost(vector<vector<ll>> &matrix, ll selected, ll day) {
if (dp[day][selected] != -1)
return dp[day][selected];
if (day == matrix.size())
return matrix[day][selected];
dp[day][selected] =
max(cost(matrix, (selected + 1) % 3, day + 1) + matrix[day][selected],
cost(matrix, (selected + 2) % 3, day + 1) + matrix[day][selected]);
return dp[day][selected];
}
int main() {
cin >> n;
vector<vector<ll>> matrix(n, vector<ll>(3, -1));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> matrix[i][j];
}
}
cout << max(max(cost(matrix, 0, 0), cost(matrix, 1, 0)), cost(matrix, 2, 0));
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 964,105 | 964,106 | u339512054 | cpp |
p03162 | // C - Vacation
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll n;
// vector<ll> dp(3, vector<ll>(1000005, -1));
ll dp[3][1000005];
ll cost(vector<vector<ll>> &matrix, ll selected, ll day) {
if (dp[day][selected] != -1)
return dp[day][selected];
if (day == matrix.size())
return matrix[day][selected];
dp[day][selected] =
max(cost(matrix, (selected + 1) % 3, day + 1) + matrix[day][selected],
cost(matrix, (selected + 2) % 3, day + 1) + matrix[day][selected]);
return dp[day][selected];
}
int main() {
cin >> n;
vector<vector<ll>> matrix(n, vector<ll>(3, -1));
for (int i = 0; i < 3; i++) {
for (int j = 0; j < n; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> matrix[i][j];
}
}
cout << max(max(cost(matrix, 0, 0), cost(matrix, 1, 0)), cost(matrix, 2, 0));
} | // C - Vacation
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll n;
// vector<ll> dp(3, vector<ll>(1000005, -1));
ll dp[1000005][3];
ll cost(vector<vector<ll>> &matrix, ll selected, ll day) {
if (dp[day][selected] != -1)
return dp[day][selected];
if (day == matrix.size())
return matrix[day][selected];
dp[day][selected] =
max(cost(matrix, (selected + 1) % 3, day + 1) + matrix[day][selected],
cost(matrix, (selected + 2) % 3, day + 1) + matrix[day][selected]);
return dp[day][selected];
}
int main() {
cin >> n;
vector<vector<ll>> matrix(n, vector<ll>(3, -1));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
dp[i][j] = -1;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> matrix[i][j];
}
}
cout << max(max(cost(matrix, 0, 0), cost(matrix, 1, 0)), cost(matrix, 2, 0));
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"identifier.replace.add",
"literal.replace.remove",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"identifier.replace.remove",
"literal.replace.add"
] | 964,107 | 964,106 | u339512054 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define ub upper_bound // first element > val(itr)
#define lb lower_bound // first element >= val(itr)
#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(), (x).end()
const ll MOD = 1e9 + 7;
const int inf = 1e9 + 9;
const long long INF = 1e18 + 3;
// to debug
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl
template <typename T> T gcd(T a, T b) {
if (b > a)
return gcd(b, a);
return b == 0 ? a : gcd(b, a % b);
}
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T fast_power(T x, T y, ll m = MOD) {
T ans = 1;
while (y > 0) {
if (y & 1LL)
ans = (ans * x) % m;
y >>= 1LL;
x = (x * x) % m;
}
return ans % m;
}
inline ll mod(ll x, ll n) {
if (x < n)
return x;
if (x >= n)
return x - n;
}
string IntToString(ll a) {
ostringstream temp;
temp << a;
return temp.str();
}
ll findMMI_fermat(ll n, ll M) {
ll ans = fast_power(n, M - 2, M);
return ans;
} // i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a, ll b, ll M) { return (mod(a, M) + mod(b, M)) % M; }
ll sub(ll a, ll b, ll M) { return (mod(a, M) + M - mod(b, M)) % M; }
ll mult(ll a, ll b, ll M) { return (mod(a, M) * mod(b, M)) % M; }
bool isprime(ll a) {
if (a == 2) {
return 1;
}
if (!(a & 1)) {
return 0;
}
for (ll i = 3; i * i <= a; i += 2) {
if (a % i == 0) {
return 0;
}
}
return 1;
}
/* -------------------------------Main Code------------------------------- */
int main() {
FAST;
int n;
cin >> n;
vector<int> dp(3);
for (int i = 0; i < n; i++) {
vector<int> new_dp(3, 0);
vector<int> arr(3);
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
new_dp[i] = max(new_dp[i], dp[i] + arr[j]);
}
}
}
dp = new_dp;
}
cout << max(dp[0], max(dp[1], dp[2]));
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define ub upper_bound // first element > val(itr)
#define lb lower_bound // first element >= val(itr)
#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(), (x).end()
const ll MOD = 1e9 + 7;
const int inf = 1e9 + 9;
const long long INF = 1e18 + 3;
// to debug
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl
template <typename T> T gcd(T a, T b) {
if (b > a)
return gcd(b, a);
return b == 0 ? a : gcd(b, a % b);
}
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T fast_power(T x, T y, ll m = MOD) {
T ans = 1;
while (y > 0) {
if (y & 1LL)
ans = (ans * x) % m;
y >>= 1LL;
x = (x * x) % m;
}
return ans % m;
}
inline ll mod(ll x, ll n) {
if (x < n)
return x;
if (x >= n)
return x - n;
}
string IntToString(ll a) {
ostringstream temp;
temp << a;
return temp.str();
}
ll findMMI_fermat(ll n, ll M) {
ll ans = fast_power(n, M - 2, M);
return ans;
} // i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a, ll b, ll M) { return (mod(a, M) + mod(b, M)) % M; }
ll sub(ll a, ll b, ll M) { return (mod(a, M) + M - mod(b, M)) % M; }
ll mult(ll a, ll b, ll M) { return (mod(a, M) * mod(b, M)) % M; }
bool isprime(ll a) {
if (a == 2) {
return 1;
}
if (!(a & 1)) {
return 0;
}
for (ll i = 3; i * i <= a; i += 2) {
if (a % i == 0) {
return 0;
}
}
return 1;
}
/* -------------------------------Main Code------------------------------- */
int main() {
FAST;
int n;
cin >> n;
vector<int> dp(3);
for (int i = 0; i < n; i++) {
vector<int> new_dp(3, 0);
vector<int> arr(3);
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
new_dp[j] = max(new_dp[j], dp[i] + arr[j]);
}
}
}
dp = new_dp;
}
cout << max(dp[0], max(dp[1], dp[2]));
return 0;
}
| [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change",
"assignment.value.change",
"call.arguments.change"
] | 964,108 | 964,109 | u227976892 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const int M = 3;
ll dp[N][M];
int a[N], b[N], c[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
for (int i = 1; i < n; i++) {
dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][2]);
}
ll res = max(dp[n - 1][0], dp[n - 1][1]);
cout << max(res, dp[n - 1][2]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const int M = 3;
ll dp[N][M];
int a[N], b[N], c[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
for (int i = 1; i < n; i++) {
dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
}
ll res = max(dp[n - 1][0], dp[n - 1][1]);
cout << max(res, dp[n - 1][2]);
return 0;
}
| [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,110 | 964,111 | u767097637 | cpp |
p03162 | #include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;
int n = 0;
struct Dia {
int a = 0;
int b = 0;
int c = 0;
};
Dia a[100002];
int pd[100002][4];
long long int func(int dia, int anterior) {
if (pd[dia][anterior] != -1)
return pd[dia][anterior];
if (dia == n)
return 0;
else if (anterior == 1)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3));
else if (anterior == 2)
return pd[dia][anterior] =
max(a[dia].a + func(dia + 1, 1), a[dia].c + func(dia + 1, 3));
else if (anterior == 3)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].a + func(dia + 1, 1));
else
return pd[dia][anterior] = max(
a[dia].a + func(dia + 1, 1),
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3)));
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d %d %d", &a[i].a, &a[i].b, &a[i].c);
for (int j = 0; j < 3; ++j)
pd[i][j] = -1;
}
long long int resp = func(0, 0);
printf("%lld", resp);
return 0;
} | #include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;
int n = 0;
struct Dia {
int a = 0;
int b = 0;
int c = 0;
};
Dia a[100002];
int pd[100002][4];
long long int func(int dia, int anterior) {
if (pd[dia][anterior] != -1)
return pd[dia][anterior];
if (dia == n)
return 0;
else if (anterior == 1)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3));
else if (anterior == 2)
return pd[dia][anterior] =
max(a[dia].a + func(dia + 1, 1), a[dia].c + func(dia + 1, 3));
else if (anterior == 3)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].a + func(dia + 1, 1));
else
return pd[dia][anterior] = max(
a[dia].a + func(dia + 1, 1),
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3)));
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d %d %d", &a[i].a, &a[i].b, &a[i].c);
for (int j = 0; j < 4; ++j)
pd[i][j] = -1;
}
long long int resp = func(0, 0);
printf("%lld", resp);
return 0;
} | [
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 964,112 | 964,113 | u216881850 | cpp |
p03162 | #include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;
int n = 0;
struct Dia {
int a = 0;
int b = 0;
int c = 0;
};
Dia a[100002];
int pd[100002][3];
long long int func(int dia, int anterior) {
if (pd[dia][anterior] != -1)
return pd[dia][anterior];
if (dia == n)
return 0;
else if (anterior == 1)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3));
else if (anterior == 2)
return pd[dia][anterior] =
max(a[dia].a + func(dia + 1, 1), a[dia].c + func(dia + 1, 3));
else if (anterior == 3)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].a + func(dia + 1, 1));
else
return pd[dia][anterior] = max(
a[dia].a + func(dia + 1, 1),
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3)));
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d %d %d", &a[i].a, &a[i].b, &a[i].c);
for (int j = 0; j < 3; ++j)
pd[i][j] = -1;
}
long long int resp = func(0, 0);
printf("%lld", resp);
return 0;
} | #include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;
int n = 0;
struct Dia {
int a = 0;
int b = 0;
int c = 0;
};
Dia a[100002];
int pd[100002][4];
long long int func(int dia, int anterior) {
if (pd[dia][anterior] != -1)
return pd[dia][anterior];
if (dia == n)
return 0;
else if (anterior == 1)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3));
else if (anterior == 2)
return pd[dia][anterior] =
max(a[dia].a + func(dia + 1, 1), a[dia].c + func(dia + 1, 3));
else if (anterior == 3)
return pd[dia][anterior] =
max(a[dia].b + func(dia + 1, 2), a[dia].a + func(dia + 1, 1));
else
return pd[dia][anterior] = max(
a[dia].a + func(dia + 1, 1),
max(a[dia].b + func(dia + 1, 2), a[dia].c + func(dia + 1, 3)));
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d %d %d", &a[i].a, &a[i].b, &a[i].c);
for (int j = 0; j < 4; ++j)
pd[i][j] = -1;
}
long long int resp = func(0, 0);
printf("%lld", resp);
return 0;
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 964,114 | 964,113 | u216881850 | cpp |
p03162 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long INF = (1 << 30);
int main() {
int n;
cin >> n;
int a[100000][3];
rep(i, n) {
rep(j, 3) { cin >> a[i][j]; }
}
long long dp[100100][3] = {}; //幸福度を0で初期化
rep(i, 3) { dp[0][i] = a[0][i]; }
rep(i, n) {
rep(j, 3) {
rep(k, 3) {
if (j == k)
continue;
dp[i + 1][j] = max(dp[i][k] + a[i + 1][j], dp[i + 1][j]);
}
}
}
long long ans = 0;
rep(i, n) { ans = max(ans, dp[n - 1][i]); }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long INF = (1 << 30);
int main() {
int n;
cin >> n;
int a[100000][3];
rep(i, n) {
rep(j, 3) { cin >> a[i][j]; }
}
long long dp[100100][3] = {}; //幸福度を0で初期化
rep(i, 3) { dp[0][i] = a[0][i]; }
rep(i, n) {
rep(j, 3) {
rep(k, 3) {
if (j == k)
continue;
dp[i + 1][j] = max(dp[i][k] + a[i + 1][j], dp[i + 1][j]);
}
}
}
long long ans = 0;
rep(i, 3) { ans = max(ans, dp[n - 1][i]); }
cout << ans << endl;
return 0;
} | [] | 964,117 | 964,118 | u621582427 | cpp |
p03162 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long INF = (1 << 30);
int main() {
int n;
cin >> n;
int a[10000][3];
rep(i, n) {
rep(j, 3) { cin >> a[i][j]; }
}
long long dp[100100][3] = {}; //幸福度を0で初期化
rep(i, 3) { dp[0][i] = a[0][i]; }
rep(i, n) {
rep(j, 3) {
rep(k, 3) {
if (j == k)
continue;
dp[i + 1][j] = max(dp[i][k] + a[i + 1][j], dp[i + 1][j]);
}
}
}
long long ans = 0;
rep(i, n) { ans = max(ans, dp[n - 1][i]); }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long INF = (1 << 30);
int main() {
int n;
cin >> n;
int a[100000][3];
rep(i, n) {
rep(j, 3) { cin >> a[i][j]; }
}
long long dp[100100][3] = {}; //幸福度を0で初期化
rep(i, 3) { dp[0][i] = a[0][i]; }
rep(i, n) {
rep(j, 3) {
rep(k, 3) {
if (j == k)
continue;
dp[i + 1][j] = max(dp[i][k] + a[i + 1][j], dp[i + 1][j]);
}
}
}
long long ans = 0;
rep(i, 3) { ans = max(ans, dp[n - 1][i]); }
cout << ans << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 964,119 | 964,118 | u621582427 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int result[110000][3], A[110000], B[110000], C[110000];
for (int i = 0; i < 3; i++)
result[0][i] = 0;
A[0] = B[0] = C[0] = 0;
for (int i = 1; i <= n; i++)
cin >> A[i] >> B[i] >> C[i];
int s = 0, b = 1, h = 2;
for (int i = 1; i <= n; i++) {
result[i][s] = A[s] + max(result[i - 1][b], result[i - 1][h]);
result[i][b] = A[b] + max(result[i - 1][s], result[i - 1][h]);
result[i][h] = A[h] + max(result[i - 1][s], result[i - 1][b]);
}
cout << max(max(result[n][s], result[n][b]), result[n][h]);
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int result[110000][3], A[110000], B[110000], C[110000];
for (int i = 0; i < 3; i++)
result[0][i] = 0;
A[0] = B[0] = C[0] = 0;
for (int i = 1; i <= n; i++)
cin >> A[i] >> B[i] >> C[i];
int s = 0, b = 1, h = 2;
for (int i = 1; i <= n; i++) {
result[i][s] = A[i] + max(result[i - 1][b], result[i - 1][h]);
result[i][b] = B[i] + max(result[i - 1][s], result[i - 1][h]);
result[i][h] = C[i] + max(result[i - 1][s], result[i - 1][b]);
}
cout << max(max(result[n][s], result[n][b]), result[n][h]);
} | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 964,129 | 964,130 | u498651680 | cpp |
p03162 | #include <iostream>
using namespace std;
const int MAXN = 1e5 + 1;
int dp[MAXN][3];
int a[MAXN];
int b[MAXN];
int c[MAXN];
int n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
for (int j = 1; j < n; j++) {
dp[j][0] = a[j] + max(dp[j - 1][1], dp[j - 1][2]);
dp[j][1] = b[j] + max(dp[j - 1][0], dp[j - 1][2]);
dp[j][2] = c[j] + max(dp[j - 1][1], dp[j - 1][0]);
}
cout << max(max(dp[n - 1][0], dp[n - 1][2]), dp[n - 1][2]);
return 0;
}
| #include <iostream>
using namespace std;
const int MAXN = 1e5 + 1;
int dp[MAXN][3];
int a[MAXN];
int b[MAXN];
int c[MAXN];
int n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
for (int j = 1; j < n; j++) {
dp[j][0] = a[j] + max(dp[j - 1][1], dp[j - 1][2]);
dp[j][1] = b[j] + max(dp[j - 1][0], dp[j - 1][2]);
dp[j][2] = c[j] + max(dp[j - 1][1], dp[j - 1][0]);
}
cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
return 0;
}
| [
"literal.number.change",
"variable_access.subscript.index.change",
"io.output.change"
] | 964,131 | 964,132 | u247141523 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define fast_IO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define PI 3.14159265358979323
typedef long long ll;
const int INF = 1e9 + 5;
ll MOD(ll ans, ll m) { return (ans % m + m) % m; }
int main() {
fast_IO;
int n;
cin >> n;
vector<int> ans(3);
for (int i = 0; i < n; i++) {
vector<int> dp(3, 0);
vector<int> c(3);
for (int i = 0; i < 3; i++) {
cin >> c[i];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
dp[j] = max(dp[j], dp[i] + c[j]);
}
}
}
ans = dp;
}
cout << max({ans[0], ans[1], ans[2]}) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define fast_IO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define PI 3.14159265358979323
typedef long long ll;
const int INF = 1e9 + 5;
ll MOD(ll ans, ll m) { return (ans % m + m) % m; }
int main() {
fast_IO;
int n;
cin >> n;
vector<int> ans(3);
for (int i = 0; i < n; i++) {
vector<int> dp(3, 0);
vector<int> c(3);
for (int i = 0; i < 3; i++) {
cin >> c[i];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
dp[j] = max(dp[j], ans[i] + c[j]);
}
}
}
ans = dp;
}
cout << max({ans[0], ans[1], ans[2]}) << endl;
}
| [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,133 | 964,134 | u260130097 | cpp |
p03162 | #include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
const int IMAX = pow(2.0, 31.0) - 1;
#define max(a, b) a > b ? a : b
#define min(a, b) a < b ? a : b
void strInit(char str[]); // str[]を0で初期化
void extIntStr(char str[],
int data[]); // str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[], int len); // data[]を昇順ソート
void decsort(int data[], int len); // data[]を降順ソート
void printIntArray(int data[], int len); // data[]をprint
int *inputArray(
int n); //文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int *cpyArray(int data[], int len); //配列(int)を複製した配列のポインタをreturn
// don't forget free(data);
int main() {
int n;
cin >> n;
int(*data)[3] = (int(*)[3])malloc(100010 * 3 * sizeof(int));
for (int i = 0; i < n; i++) {
cin >> data[i][0] >> data[i][1] >> data[i][2];
}
int(*dp)[3] = (int(*)[3])malloc(100010 * 3 * sizeof(int));
for (int i = 0; i < 100010; i++) {
for (int j = 0; j < 3; j++) {
dp[i][j] = 0;
}
}
for (int i = 0; i < 100010; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k)
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + data[i][k]);
}
}
}
int ans = 0;
for (int i = 0; i < 3; i++) {
if (dp[n][i] > ans)
ans = dp[n][i];
}
printf("%d", ans);
free(data);
free(dp);
return 0;
}
// temp##############################################
void strInit(char str[]) {
int len = strlen(str);
for (int i = 0; i < len; i++) {
str[i] = 0;
}
}
void extIntStr(char str[], int data[]) {
int length = strlen(str);
str[length - 1] = ' ';
char buff[12];
int j, index;
index = j = 0;
for (int i = 0; i < length; i++) {
if (str[i] != ' ') {
buff[j++] = str[i];
} else {
data[index++] = atoi(buff);
strInit(buff);
j = 0;
}
}
}
void incsort(int data[], int len) {
for (int i = 0; i < len - 1; i++) {
for (int j = i + 1; j < len; j++) {
if (data[i] > data[j]) {
int tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
}
}
}
void decsort(int data[], int len) {
for (int i = 0; i < len - 1; i++) {
for (int j = i + 1; j < len; j++) {
if (data[i] < data[j]) {
int tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
}
}
}
void printIntArray(int data[], int len) {
for (int i = 0; i < len; i++) {
printf("%d\n", data[i]);
}
}
int *inputArray(int n) {
int *data;
data = (int *)malloc(sizeof(int) * n);
char *get;
get = (char *)malloc(sizeof(char) * 11 * n + 1);
fgets(get, 11 * n + 1, stdin);
extIntStr(get, data);
free(get);
return data;
}
int *cpyArray(int data[], int len) {
int *cp;
cp = (int *)malloc(sizeof(int) * len);
for (int i = 0; i < len; i++) {
cp[i] = data[i];
}
return cp;
}
// temp##############################################
| #include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
const int IMAX = pow(2.0, 31.0) - 1;
#define max(a, b) a > b ? a : b
#define min(a, b) a < b ? a : b
void strInit(char str[]); // str[]を0で初期化
void extIntStr(char str[],
int data[]); // str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[], int len); // data[]を昇順ソート
void decsort(int data[], int len); // data[]を降順ソート
void printIntArray(int data[], int len); // data[]をprint
int *inputArray(
int n); //文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int *cpyArray(int data[], int len); //配列(int)を複製した配列のポインタをreturn
// don't forget free(data);
int main() {
int n;
cin >> n;
int(*data)[3] = (int(*)[3])malloc(100010 * 3 * sizeof(int));
for (int i = 0; i < n; i++) {
cin >> data[i][0] >> data[i][1] >> data[i][2];
}
int(*dp)[3] = (int(*)[3])malloc(100010 * 3 * sizeof(int));
for (int i = 0; i < 100010; i++) {
for (int j = 0; j < 3; j++) {
dp[i][j] = 0;
}
}
for (int i = 0; i < 100010; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k)
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + data[i][k]);
}
}
}
int ans = 0;
for (int i = 0; i < 3; i++) {
if (dp[n][i] > ans)
ans = dp[n][i];
}
printf("%d", ans);
free(data);
free(dp);
return 0;
}
// temp##############################################
void strInit(char str[]) {
int len = strlen(str);
for (int i = 0; i < len; i++) {
str[i] = 0;
}
}
void extIntStr(char str[], int data[]) {
int length = strlen(str);
str[length - 1] = ' ';
char buff[12];
int j, index;
index = j = 0;
for (int i = 0; i < length; i++) {
if (str[i] != ' ') {
buff[j++] = str[i];
} else {
data[index++] = atoi(buff);
strInit(buff);
j = 0;
}
}
}
void incsort(int data[], int len) {
for (int i = 0; i < len - 1; i++) {
for (int j = i + 1; j < len; j++) {
if (data[i] > data[j]) {
int tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
}
}
}
void decsort(int data[], int len) {
for (int i = 0; i < len - 1; i++) {
for (int j = i + 1; j < len; j++) {
if (data[i] < data[j]) {
int tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
}
}
}
void printIntArray(int data[], int len) {
for (int i = 0; i < len; i++) {
printf("%d\n", data[i]);
}
}
int *inputArray(int n) {
int *data;
data = (int *)malloc(sizeof(int) * n);
char *get;
get = (char *)malloc(sizeof(char) * 11 * n + 1);
fgets(get, 11 * n + 1, stdin);
extIntStr(get, data);
free(get);
return data;
}
int *cpyArray(int data[], int len) {
int *cp;
cp = (int *)malloc(sizeof(int) * len);
for (int i = 0; i < len; i++) {
cp[i] = data[i];
}
return cp;
}
// temp##############################################
| [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change",
"assignment.value.change",
"call.arguments.change"
] | 964,151 | 964,152 | u493708099 | cpp |
p03162 | #include <iostream>
#include <vector>
//#include <boost/multi_array.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
template <class T> inline bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const long long INF = 1LL << 60;
const int SIZE = 100010;
ll dp[SIZE][3];
ll h[SIZE][3];
int main() {
int n;
cin >> n;
rep(i, n) {
rep(j, 3) { cin >> h[i][j]; }
}
rep(i, n) {
rep(j, 3) {
rep(k, 3) {
if (j != k) {
chmax(dp[i + 1][k], dp[i][j] + h[i][k]);
}
}
}
}
ll res = 0;
rep(j, 3) { chmax(res, dp[n - 1][j]); }
cout << res << endl;
return 0;
} | #include <iostream>
#include <vector>
//#include <boost/multi_array.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
template <class T> inline bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const long long INF = 1LL << 60;
const int SIZE = 100010;
ll dp[SIZE][3];
ll h[SIZE][3];
int main() {
int n;
cin >> n;
rep(i, n) {
rep(j, 3) { cin >> h[i][j]; }
}
rep(i, n) {
rep(j, 3) {
rep(k, 3) {
if (j != k) {
chmax(dp[i + 1][k], dp[i][j] + h[i][k]);
}
}
}
}
ll res = 0;
rep(j, 3) { chmax(res, dp[n][j]); }
cout << res << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 964,155 | 964,156 | u544563563 | cpp |
p03162 | #include "bits/stdc++.h"
using namespace std;
const int inf = 10e9 + 5;
int main() {
int n;
cin >> n;
vector<int> dp(3);
for (int days = 0; days < n; ++days) {
vector<int> cost(3);
for (int i = 0; i < 3; i++) {
cin >> cost[i];
}
vector<int> newDp(3, inf);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
newDp[j] = min(newDp[j], dp[i] + cost[j]);
}
}
}
dp = newDp;
}
cout << min({dp[0], dp[1], dp[2]}) << endl;
} | #include "bits/stdc++.h"
using namespace std;
const int inf = 10e9 + 5;
int main() {
int n;
cin >> n;
vector<int> dp(3);
for (int days = 0; days < n; ++days) {
vector<int> cost(3);
for (int i = 0; i < 3; i++) {
cin >> cost[i];
}
vector<int> newDp(3, 0);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
newDp[j] = max(newDp[j], dp[i] + cost[j]);
}
}
}
dp = newDp;
}
cout << max({dp[0], dp[1], dp[2]}) << endl;
} | [
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change",
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change",
"io.output.change"
] | 964,165 | 964,166 | u021688125 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int b[N];
int c[N];
long long dp[N][3];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
dp[0][0] = a[1];
dp[0][1] = b[1];
dp[0][2] = c[1];
for (int i = 1; i < n; i++) {
dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
}
cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int b[N];
int c[N];
long long dp[N][3];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
for (int i = 1; i < n; i++) {
dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
}
cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << '\n';
return 0;
} | [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 964,171 | 964,172 | u559671281 | cpp |
p03162 | #include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
const int Nmax = 1e5 + 5;
int N, S, Max, p;
int a[Nmax][3], dp[Nmax][3];
int main() {
scanf("%d", &N);
for (int i = 1; i <= N; ++i) {
scanf("%d%d%d", a[i][0], a[i][1], a[i][2]);
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k)
if (j != k)
dp[i][j] = max(dp[i - 1][k], dp[i][j]);
dp[i][j] += a[i][j];
}
}
printf("%d", max({dp[N][0], dp[N][1], dp[N][2]}));
/// cout << dp[N][0] << " " << dp[N][1] << " " << dp[N][2];
return 0;
}
| #include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
const int Nmax = 1e5 + 5;
int N, S, Max, p;
int a[Nmax][3], dp[Nmax][3];
int main() {
scanf("%d", &N);
for (int i = 1; i <= N; ++i) {
scanf("%d%d%d", &a[i][0], &a[i][1], &a[i][2]);
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k)
if (j != k)
dp[i][j] = max(dp[i - 1][k], dp[i][j]);
dp[i][j] += a[i][j];
}
}
printf("%d", max({dp[N][0], dp[N][1], dp[N][2]}));
/// cout << dp[N][0] << " " << dp[N][1] << " " << dp[N][2];
return 0;
}
| [
"expression.operation.unary.reference.add"
] | 964,192 | 964,193 | u361594188 | cpp |
p03162 | // motatoes cp snippet
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define forr(a, b, v) for (int v = a; v <= b; v++)
#define ford(a, b, v) for (int v = a; v >= b; v--)
// https://www.topcoder.com/community/competitive-programming/tutorials/power-up-c-with-the-standard-template-library-part-1/#map
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef pair<int, int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A> string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
// get default value from map type
template <class K, class V> V get(map<K, V> m, K k, V def) {
if (m.find(k) != m.end()) {
return m[k];
} else {
return def;
}
}
// <geometry>
const double PI = acos(-1.0);
double toDegreeFromMinutes(double minutes) { return (minutes / 60); }
double toRadians(double degree) { return (degree * PI / 180.0); }
double toDegree(double radian) {
if (radian < 0)
radian += 2 * PI;
return (radian * 180 / PI);
}
double fixAngle(double A) { return A > 1 ? 1 : (A < -1 ? -1 : A); }
// sin(A)/a = sin(B)/b = sin(C)/c
double getSide_a_bAB(double b, double A, double B) {
return (sin(A) * b) / sin(B);
}
double getAngle_A_abB(double a, double b, double B) {
return asin(fixAngle((a * sin(B)) / b));
}
// a^2 = b^2 + c^2 - 2*b*c*cos(A)
double getAngle_A_abc(double a, double b, double c) {
return acos(fixAngle((b * b * c * c - a * a) / (2 * b * c)));
}
// </geometry>
#define INF 1e9 + 5
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int REW[n][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> REW[i][j];
}
}
vector<vector<ll>> dp(n + 5, vector<ll>(3, 0));
dp[1][0] = REW[0][0];
dp[1][1] = REW[0][1];
dp[1][2] = REW[0][2];
for (int i = 2; i <= n; i++) {
dp[i][0] = REW[i - 2][0] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = REW[i - 2][1] + max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = REW[i - 2][2] + max(dp[i - 1][0], dp[i - 1][1]);
}
ll mx;
cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
return 0;
}
| // motatoes cp snippet
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define forr(a, b, v) for (int v = a; v <= b; v++)
#define ford(a, b, v) for (int v = a; v >= b; v--)
// https://www.topcoder.com/community/competitive-programming/tutorials/power-up-c-with-the-standard-template-library-part-1/#map
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef pair<int, int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A> string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
// get default value from map type
template <class K, class V> V get(map<K, V> m, K k, V def) {
if (m.find(k) != m.end()) {
return m[k];
} else {
return def;
}
}
// <geometry>
const double PI = acos(-1.0);
double toDegreeFromMinutes(double minutes) { return (minutes / 60); }
double toRadians(double degree) { return (degree * PI / 180.0); }
double toDegree(double radian) {
if (radian < 0)
radian += 2 * PI;
return (radian * 180 / PI);
}
double fixAngle(double A) { return A > 1 ? 1 : (A < -1 ? -1 : A); }
// sin(A)/a = sin(B)/b = sin(C)/c
double getSide_a_bAB(double b, double A, double B) {
return (sin(A) * b) / sin(B);
}
double getAngle_A_abB(double a, double b, double B) {
return asin(fixAngle((a * sin(B)) / b));
}
// a^2 = b^2 + c^2 - 2*b*c*cos(A)
double getAngle_A_abc(double a, double b, double c) {
return acos(fixAngle((b * b * c * c - a * a) / (2 * b * c)));
}
// </geometry>
#define INF 1e9 + 5
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int REW[n][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> REW[i][j];
}
}
vector<vector<ll>> dp(n + 5, vector<ll>(3, 0));
dp[1][0] = REW[0][0];
dp[1][1] = REW[0][1];
dp[1][2] = REW[0][2];
for (int i = 2; i <= n; i++) {
dp[i][0] = REW[i - 1][0] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = REW[i - 1][1] + max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = REW[i - 1][2] + max(dp[i - 1][0], dp[i - 1][1]);
}
ll mx;
cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
return 0;
}
| [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 964,197 | 964,198 | u798678713 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
long long N, cost[100001][3], DP[100001][3];
int main() {
cin >> N;
for (int i = 1; i <= N; i++) {
for (int j = 0; j < 3; j++) {
cin >> cost[i][j];
}
}
DP[0][0] = 0;
DP[0][1] = 0;
DP[0][2] = 0;
cost[0][0] = 0;
cost[0][1] = 0;
cost[0][2] = 0;
for (int k = 1; k <= N + 1; k++) {
for (int j = 0; j < 3; j++) {
DP[k][j] = 0;
if (j == 0) {
DP[k][j] = max(DP[k - 1][1], DP[k - 1][2]) + cost[k][j];
} else if (j == 1) {
DP[k][j] = max(DP[k - 1][0], DP[k - 1][2]) + cost[k][j];
} else {
DP[k][j] = max(DP[k - 1][1], DP[k - 1][1]) + cost[k][j];
}
}
}
long long res = 0;
for (int i = 0; i < 3; i++) {
res = max(res, DP[N + 1][i]);
}
cout << res << endl;
} | #include <bits/stdc++.h>
using namespace std;
long long N, cost[100001][3], DP[100001][3];
int main() {
cin >> N;
for (int i = 1; i <= N; i++) {
for (int j = 0; j < 3; j++) {
cin >> cost[i][j];
}
}
DP[0][0] = 0;
DP[0][1] = 0;
DP[0][2] = 0;
cost[0][0] = 0;
cost[0][1] = 0;
cost[0][2] = 0;
for (int k = 1; k <= N; k++) {
for (int j = 0; j < 3; j++) {
DP[k][j] = 0;
if (j == 0) {
DP[k][j] = max(DP[k - 1][1], DP[k - 1][2]) + cost[k][j];
} else if (j == 1) {
DP[k][j] = max(DP[k - 1][0], DP[k - 1][2]) + cost[k][j];
} else {
DP[k][j] = max(DP[k - 1][1], DP[k - 1][0]) + cost[k][j];
}
}
}
long long res = 0;
for (int i = 0; i < 3; i++) {
res = max(res, DP[N][i]);
}
cout << res << endl;
} | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,202 | 964,200 | u312604259 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
void chmin(auto &a, auto b) {
if (b < a)
a = b;
}
void chmax(auto &a, auto b) {
if (a < b)
a = b;
}
int main() {
int n;
cin >> n;
vvi v(n, vi(3));
rep(i, n) {
rep(j, 3) { cin >> v[i][j]; }
}
vector<vector<ll>> dp(n, vector<ll>(3));
dp[0][0] = v[0][0];
dp[0][1] = v[0][1];
dp[0][2] = v[0][2];
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1] + v[i][1], dp[i - 1][2] + v[i][2]);
dp[i][1] = max(dp[i - 1][0] + v[i][0], dp[i - 1][2] + v[i][2]);
dp[i][2] = max(dp[i - 1][1] + v[i][1], dp[i - 1][0] + v[i][0]);
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
void chmin(auto &a, auto b) {
if (b < a)
a = b;
}
void chmax(auto &a, auto b) {
if (a < b)
a = b;
}
int main() {
int n;
cin >> n;
vvi v(n, vi(3));
rep(i, n) {
rep(j, 3) { cin >> v[i][j]; }
}
vector<vector<ll>> dp(n, vector<ll>(3));
dp[0][0] = v[0][0];
dp[0][1] = v[0][1];
dp[0][2] = v[0][2];
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1] + v[i][0], dp[i - 1][2] + v[i][0]);
dp[i][1] = max(dp[i - 1][0] + v[i][1], dp[i - 1][2] + v[i][1]);
dp[i][2] = max(dp[i - 1][1] + v[i][2], dp[i - 1][0] + v[i][2]);
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}
| [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,203 | 964,204 | u422633119 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define int long long int
const int INF = 1e9 + 5;
#undef int
int main() {
int n, k;
scanf("%d", &n);
vector<int> dp(3, 0);
vector<int> arr(3, 0);
dp[0] = 0;
for (int i = 0; i < n; i++) {
vector<int> new_dp(3, 0);
for (int j = 0; j < 3; j++)
scanf("%d", &arr[j]);
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k) {
new_dp[j] = max(new_dp[j], dp[i] + arr[j]);
}
}
}
dp = new_dp;
}
printf("%d", max(max(dp[0], dp[1]), dp[2]));
} | #include <bits/stdc++.h>
using namespace std;
#define int long long int
const int INF = 1e9 + 5;
#undef int
int main() {
int n, k;
scanf("%d", &n);
vector<int> dp(3, 0);
vector<int> arr(3, 0);
dp[0] = 0;
for (int i = 0; i < n; i++) {
vector<int> new_dp(3, 0);
for (int j = 0; j < 3; j++)
scanf("%d", &arr[j]);
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k) {
new_dp[j] = max(new_dp[j], dp[k] + arr[j]);
}
}
}
dp = new_dp;
}
printf("%d", max(max(dp[0], dp[1]), dp[2]));
} | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,205 | 964,206 | u720279479 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << " = " << x << endl;
#define ll long long
#define A 0
#define B 1
#define C 2
#define INF 0x3f3f3f3f
int n;
vector<int> height;
vector<vector<int>> dp;
vector<vector<int>> vis;
vector<vector<int>> matriz;
int solve(int i, int anterior) {
if (vis[i][anterior])
return vis[i][anterior];
if (i == n - 1) {
dp[i][anterior] = 0;
if (anterior != A)
dp[i][anterior] = max(dp[i][anterior], matriz[i][A]);
if (anterior != B)
dp[i][anterior] = max(dp[i][anterior], matriz[i][B]);
if (anterior != C)
dp[i][anterior] = max(dp[i][anterior], matriz[i][C]);
return dp[i][anterior];
}
vis[i][anterior] = 1;
dp[i][anterior] = 0;
if (anterior != A)
dp[i][anterior] = max(dp[i][anterior], solve(i + 1, A) + matriz[i][A]);
if (anterior != B)
dp[i][anterior] = max(dp[i][anterior], solve(i + 1, B) + matriz[i][B]);
if (anterior != C)
dp[i][anterior] = max(dp[i][anterior], solve(i + 1, C) + matriz[i][C]);
return dp[i][anterior];
}
int main() {
scanf("%d", &n);
dp = vector<vector<int>>(n, vector<int>(3));
vis = vector<vector<int>>(n, vector<int>(3));
matriz = vector<vector<int>>(n, vector<int>(3));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
int aux;
scanf("%d", &aux);
matriz[i][j] = aux;
}
}
int maxi = solve(0, A);
maxi = max(maxi, solve(0, B));
maxi = max(maxi, solve(0, C));
printf("%d", maxi);
}
| #include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << " = " << x << endl;
#define ll long long
#define A 0
#define B 1
#define C 2
#define INF 0x3f3f3f3f
int n;
vector<int> height;
vector<vector<int>> dp;
vector<vector<int>> vis;
vector<vector<int>> matriz;
int solve(int i, int anterior) {
if (vis[i][anterior])
return dp[i][anterior];
if (i == n - 1) {
dp[i][anterior] = 0;
if (anterior != A)
dp[i][anterior] = max(dp[i][anterior], matriz[i][A]);
if (anterior != B)
dp[i][anterior] = max(dp[i][anterior], matriz[i][B]);
if (anterior != C)
dp[i][anterior] = max(dp[i][anterior], matriz[i][C]);
return dp[i][anterior];
}
vis[i][anterior] = 1;
dp[i][anterior] = 0;
if (anterior != A)
dp[i][anterior] = max(dp[i][anterior], solve(i + 1, A) + matriz[i][A]);
if (anterior != B)
dp[i][anterior] = max(dp[i][anterior], solve(i + 1, B) + matriz[i][B]);
if (anterior != C)
dp[i][anterior] = max(dp[i][anterior], solve(i + 1, C) + matriz[i][C]);
return dp[i][anterior];
}
int main() {
scanf("%d", &n);
dp = vector<vector<int>>(n, vector<int>(3));
vis = vector<vector<int>>(n, vector<int>(3));
matriz = vector<vector<int>>(n, vector<int>(3));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
int aux;
scanf("%d", &aux);
matriz[i][j] = aux;
}
}
int maxi = solve(0, A);
maxi = max(maxi, solve(0, B));
maxi = max(maxi, solve(0, C));
printf("%d", maxi);
}
| [
"identifier.change",
"function.return_value.change"
] | 964,207 | 964,208 | u565819128 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using llu = unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
#define mms(x, y) memset(x, y, sizeof(x))
#define pqm priority_queue<ll, vector<ll>, greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main() {
fast;
ll t, n, m, i, j, k;
cin >> n >> k;
ll a[n], b[n], c[n];
for (i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
ll dp[n][3];
mms(dp, 0);
i = 0;
dp[0][0] = a[i];
dp[0][1] = b[i];
dp[0][2] = c[i];
for (i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using llu = unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
#define mms(x, y) memset(x, y, sizeof(x))
#define pqm priority_queue<ll, vector<ll>, greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main() {
fast;
ll t, n, m, i, j, k;
cin >> n;
ll a[n], b[n], c[n];
for (i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
ll dp[n][3];
mms(dp, 0);
i = 0;
dp[0][0] = a[i];
dp[0][1] = b[i];
dp[0][2] = c[i];
for (i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}
| [
"expression.operation.binary.remove"
] | 964,209 | 964,210 | u168298651 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int N;
long long a[100010][3];
// DPテーブル
long long dp[100010][3];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 3; j++)
cin >> a[i][j];
}
for (int i = 1; i < N; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long ans = 0;
for (int j = 0; j < 3; ++j)
chmax(ans, dp[N][j]);
printf("%lld", ans);
}
| #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int N;
long long a[100010][3];
// DPテーブル
long long dp[100010][3];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 3; j++)
cin >> a[i][j];
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long ans = 0;
for (int j = 0; j < 3; ++j)
chmax(ans, dp[N][j]);
printf("%lld", ans);
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 964,211 | 964,212 | u553129408 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int N;
long long a[100010][3];
// DPテーブル
long long dp[100010][3];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 3; j++)
cin >> a[i][j];
}
for (int i = 1; i < N; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; j < 3; ++k) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long ans = 0;
for (int j = 0; j < 3; ++j)
chmax(ans, dp[N][j]);
printf("%lld", ans);
}
| #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int N;
long long a[100010][3];
// DPテーブル
long long dp[100010][3];
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 3; j++)
cin >> a[i][j];
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long ans = 0;
for (int j = 0; j < 3; ++j)
chmax(ans, dp[N][j]);
printf("%lld", ans);
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,213 | 964,212 | u553129408 | cpp |
p03162 | #include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
long long a[1000000][3];
long long dp[1000000][3];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long res = 0;
for (int j = 0; j < 3; ++j)
chmax(res, dp[n][j]);
cout << res << endl;
}
| #include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
long long a[1000000][3];
long long dp[1000000][3];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long res = 0;
for (int j = 0; j < 3; ++j)
chmax(res, dp[n][j]);
cout << res << endl;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,214 | 964,215 | u147556624 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define inf 1e17
#define si 400005
#define For(i, a, b) for (i = a; i < b; i++)
#define piv pair<int, vector<int>>
ll powmod(ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1)
ans = (ans % M * a % M) % M;
a = (a % M * a % M) % M;
b = b >> 1;
}
return ans;
}
int main() {
boost int n, i, vac[100000][3], dp[100000][3];
cin >> n;
For(i, 0, n) cin >> vac[i][0] >> vac[i][1] >> vac[i][2];
dp[0][0] = vac[0][0];
dp[0][1] = vac[0][1];
dp[0][2] = vac[0][2];
for (i = 1; i < n; i++) {
dp[i][0] = vac[i][0] + min(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = vac[i][1] + min(dp[i - 1][2], dp[i - 1][0]);
dp[i][2] = vac[i][2] + min(dp[i - 1][1], dp[i - 1][0]);
}
cout << min(dp[n - 1][0], min(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define inf 1e17
#define si 400005
#define For(i, a, b) for (i = a; i < b; i++)
#define piv pair<int, vector<int>>
ll powmod(ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1)
ans = (ans % M * a % M) % M;
a = (a % M * a % M) % M;
b = b >> 1;
}
return ans;
}
int main() {
boost int n, i, vac[100000][3], dp[100000][3];
cin >> n;
For(i, 0, n) cin >> vac[i][0] >> vac[i][1] >> vac[i][2];
dp[0][0] = vac[0][0];
dp[0][1] = vac[0][1];
dp[0][2] = vac[0][2];
for (i = 1; i < n; i++) {
dp[i][0] = vac[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = vac[i][1] + max(dp[i - 1][2], dp[i - 1][0]);
dp[i][2] = vac[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change",
"expression.operation.binary.change",
"io.output.change"
] | 964,218 | 964,219 | u860215190 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))
#define INF 2e9
#define INF_LL 1LL << 60
#define ll long long
#define MOD 1e9 + 7
#define print2D(h, w, arr) \
REP(i, h) { \
REP(j, w) cout << arr[i][j] << " "; \
cout << endl; \
}
#define print_line(vec, n) \
{ \
for (int i = 0; i < (n - 1); i++) \
cout << (vec)[i] << " "; \
cout << (vec)[(n)-1] << endl; \
}
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
cout << first << " ";
print(rest...);
}
struct PreMain {
PreMain() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} premain;
/* dp[i][j]: i日目に行動jをしたときの幸福度の最大値 */
int dp[100001][3];
int main() {
int n;
cin >> n;
vector<int> a(n), b(n), c(n);
REP(i, n) cin >> a[i] >> b[i] >> c[i];
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
REPN(i, 1, n) {
dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
}
int ans = max(dp[n - 1][0], dp[n - 1][0]);
ans = max(ans, dp[n - 1][2]);
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))
#define INF 2e9
#define INF_LL 1LL << 60
#define ll long long
#define MOD 1e9 + 7
#define print2D(h, w, arr) \
REP(i, h) { \
REP(j, w) cout << arr[i][j] << " "; \
cout << endl; \
}
#define print_line(vec, n) \
{ \
for (int i = 0; i < (n - 1); i++) \
cout << (vec)[i] << " "; \
cout << (vec)[(n)-1] << endl; \
}
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
cout << first << " ";
print(rest...);
}
struct PreMain {
PreMain() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} premain;
/* dp[i][j]: i日目に行動jをしたときの幸福度の最大値 */
int dp[100001][3];
int main() {
int n;
cin >> n;
vector<int> a(n), b(n), c(n);
REP(i, n) cin >> a[i] >> b[i] >> c[i];
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
REPN(i, 1, n) {
dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
}
int ans = max(dp[n - 1][0], dp[n - 1][1]);
ans = max(ans, dp[n - 1][2]);
cout << ans << endl;
return 0;
} | [
"literal.number.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 964,222 | 964,223 | u127768253 | cpp |
p03162 | #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REPr(i, n) for (int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for (int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for (int i = (n); i >= (m); --i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n", "debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
int main() {
ll ans = 0;
int N;
cin >> N;
ll a[N + 1];
ll b[N + 1];
ll c[N + 1];
rep(i, N) { cin >> a[i] >> b[i] >> c[i]; }
ll A[N + 1]; // i日目にaを選んだ時の幸福度の和
ll B[N + 1];
ll C[N + 1];
rep(i, N) {
if (i == 0) {
A[0] = a[0];
B[0] = b[0];
C[0] = c[0];
continue;
}
A[i] = max(B[i - 1], C[i - 1]) + a[i];
B[i] = max(B[i - 1], A[i - 1]) + b[i];
C[i] = max(A[i - 1], B[i - 1]) + c[i];
}
ans = max(A[N - 1], max(B[N - 1], C[N - 1]));
cout << ans << endl;
} | #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REPr(i, n) for (int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for (int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for (int i = (n); i >= (m); --i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n", "debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
int main() {
ll ans = 0;
int N;
cin >> N;
ll a[N + 1];
ll b[N + 1];
ll c[N + 1];
rep(i, N) { cin >> a[i] >> b[i] >> c[i]; }
ll A[N + 1]; // i日目にaを選んだ時の幸福度の和
ll B[N + 1];
ll C[N + 1];
rep(i, N) {
if (i == 0) {
A[0] = a[0];
B[0] = b[0];
C[0] = c[0];
continue;
}
A[i] = max(B[i - 1], C[i - 1]) + a[i];
B[i] = max(A[i - 1], C[i - 1]) + b[i];
C[i] = max(A[i - 1], B[i - 1]) + c[i];
}
ans = max(A[N - 1], max(B[N - 1], C[N - 1]));
cout << ans << endl;
} | [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,242 | 964,243 | u532894762 | cpp |
p03162 | #include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ifstream f("test.in");
ofstream g("test.out");
ll n, a[100005], b[100005], c[100005], dp[100005][5];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i] >> c[i];
dp[1][1] = a[1];
dp[1][2] = b[1];
dp[1][3] = c[1];
for (int i = 2; i <= n; i++) {
dp[i][1] = max(dp[i - 1][2] + a[i], dp[i - 1][3] + a[i]);
dp[i][2] = max(dp[i - 1][1] + b[i], dp[i - 1][3] + b[i]);
dp[i][3] = max(dp[i - 1][2] + c[i], dp[i - 1][2] + c[i]);
}
cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ifstream f("test.in");
ofstream g("test.out");
ll n, a[100005], b[100005], c[100005], dp[100005][5];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i] >> c[i];
dp[1][1] = a[1];
dp[1][2] = b[1];
dp[1][3] = c[1];
for (int i = 2; i <= n; i++) {
dp[i][1] = max(dp[i - 1][2] + a[i], dp[i - 1][3] + a[i]);
dp[i][2] = max(dp[i - 1][1] + b[i], dp[i - 1][3] + b[i]);
dp[i][3] = max(dp[i - 1][1] + c[i], dp[i - 1][2] + c[i]);
}
cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
return 0;
}
| [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,244 | 964,245 | u842916328 | cpp |
p03162 | #include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ifstream f("test.in");
ofstream g("test.out");
ll n, a[100005], b[100005], c[100005], dp[100005][5];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i] >> c[i];
dp[1][1] = a[1];
dp[1][2] = b[1];
dp[1][3] = c[1];
for (int i = 2; i <= n; i++) {
dp[i][1] = max(dp[i - 1][2] + a[i], dp[i - 1][3] + a[i]);
dp[i][2] = max(dp[i - 1][1] + b[i], dp[i - 1][3] + b[i]);
dp[i][1] = max(dp[i - 1][2] + c[i], dp[i - 1][2] + c[i]);
}
cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
ifstream f("test.in");
ofstream g("test.out");
ll n, a[100005], b[100005], c[100005], dp[100005][5];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i] >> c[i];
dp[1][1] = a[1];
dp[1][2] = b[1];
dp[1][3] = c[1];
for (int i = 2; i <= n; i++) {
dp[i][1] = max(dp[i - 1][2] + a[i], dp[i - 1][3] + a[i]);
dp[i][2] = max(dp[i - 1][1] + b[i], dp[i - 1][3] + b[i]);
dp[i][3] = max(dp[i - 1][1] + c[i], dp[i - 1][2] + c[i]);
}
cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
return 0;
}
| [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,246 | 964,245 | u842916328 | cpp |
p03162 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int n, a[101010][3], dp[101010][3];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k) {
continue;
}
dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][k]);
}
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int n, a[101010][3], dp[101010][3];
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k) {
continue;
}
dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
}
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
} | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,253 | 964,254 | u386107860 | cpp |
p03162 | #include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
int N;
ll dp[100001][3]; // dp[i][j] := i日目(1-idx)に行動jをした時の幸福度
// 今回は1-idxで実装してることに注意!
// j == 0なら行動A、j == 1なら行動B、j == 2なら行動C
ll A[100001], B[100001],
C[100001]; //三つの行動の日にちごとに得られる幸福度 今回は1-xで実装してることに注意!
ll memo(int a, int act) {
if (dp[a][act] != -1)
return dp[a][act];
if (a == 1) {
if (act == 0)
return dp[a][act] = A[1];
if (act == 1)
return dp[a][act] = B[1];
if (act == 2)
return dp[a][act] = C[1];
} else {
ll best = 0;
for (int i = 0; i < 3; i++) {
if (i != act) {
best = memo(a - 1, i);
}
}
if (act == 0)
return dp[a][act] = best + A[a];
if (act == 1)
return dp[a][act] = best + B[a];
if (act == 2)
return dp[a][act] = best + C[a];
}
}
int main() {
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> A[i] >> B[i] >> C[i];
}
for (int i = 0; i <= N; i++) {
for (int j = 0; j < 3; j++)
dp[i][j] = -1;
}
memo(N, 0), memo(N, 1), memo(N, 2);
//最終日の最大は、行動A~Cのうちのいずれかなので、その最大をとる
ll ans = 0;
for (int i = 0; i < 3; i++)
ans = max(ans, dp[N][i]);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
int N;
ll dp[100001][3];
// dp[i][j] := i日目(1-idx)に行動jをした時の幸福度
// 今回は1-idxで実装してることに注意! j == 0なら行動A、j == 1なら行動B、j ==
// 2なら行動C
ll A[100001], B[100001],
C[100001]; //三つの行動の日にちごとに得られる幸福度 今回は1-xで実装してることに注意!
ll memo(int a, int act) {
if (dp[a][act] != -1)
return dp[a][act];
if (a == 1) {
if (act == 0)
return dp[a][act] = A[1];
if (act == 1)
return dp[a][act] = B[1];
if (act == 2)
return dp[a][act] = C[1];
} else {
ll best = 0;
for (int i = 0; i < 3; i++) {
if (i != act) {
best = max(best, memo(a - 1, i));
}
}
if (act == 0)
return dp[a][act] = best + A[a];
if (act == 1)
return dp[a][act] = best + B[a];
if (act == 2)
return dp[a][act] = best + C[a];
}
}
int main() {
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> A[i] >> B[i] >> C[i];
}
for (int i = 0; i <= N; i++) {
for (int j = 0; j < 3; j++)
dp[i][j] = -1;
}
memo(N, 0), memo(N, 1), memo(N, 2);
//最終日の最大は、行動A~Cのうちのいずれかなので、その最大をとる
ll ans = 0;
for (int i = 0; i < 3; i++)
ans = max(ans, dp[N][i]);
cout << ans << endl;
return 0;
} | [
"call.add",
"call.arguments.change"
] | 964,263 | 964,264 | u107077805 | cpp |
p03162 | #include <algorithm>
#include <array>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9 + 7;
int n, k;
vector<array<int, 3>> happy;
int dp[100000][4];
int dfs(int now, int before) {
if (now == n)
return 0;
if (~dp[now][before])
return dp[now][before];
int res = 0;
for (int i = 0; i < 3; i++) {
if (before == i)
continue;
res = max(res, happy[now][i] + dfs(now + 1, i));
}
return dp[now][before] = res;
}
int main() {
cin >> n >> k;
happy.resize(n);
memset(dp, -1, sizeof dp);
for (auto &&i : happy) {
for (auto &&j : i) {
cin >> j;
}
}
cout << dfs(0, 3) << "\n";
} | #include <algorithm>
#include <array>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9 + 7;
int n;
vector<array<int, 3>> happy;
int dp[100000][4];
int dfs(int now, int before) {
if (now == n)
return 0;
if (~dp[now][before])
return dp[now][before];
int res = 0;
for (int i = 0; i < 3; i++) {
if (before == i)
continue;
res = max(res, happy[now][i] + dfs(now + 1, i));
}
return dp[now][before] = res;
}
int main() {
cin >> n;
happy.resize(n);
memset(dp, -1, sizeof dp);
for (auto &&i : happy) {
for (auto &&j : i) {
cin >> j;
}
}
cout << dfs(0, 3) << "\n";
}
| [
"variable_declaration.remove",
"expression.operation.binary.remove"
] | 964,265 | 964,266 | u752074356 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
int n;
cin >> n;
int a[n + 1], b[n + 1], c[n + 1];
for (int i = 1; i < n + 1; i++)
cin >> a[i] >> b[i] >> c[i];
int dp[n + 1][3];
for (int i = 0; i <= n; i++) {
dp[i][0] = 0;
dp[i][1] = 0;
dp[i][2] = 0;
}
for (int i = 1; i <= n; i++) {
dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
dp[i][2] = max(dp[i - 1][1] + c[i], dp[i - 1][1] + c[i]);
}
cout << max({dp[n][0], dp[n][1], dp[n][2]});
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
int n;
cin >> n;
int a[n + 1], b[n + 1], c[n + 1];
for (int i = 1; i < n + 1; i++)
cin >> a[i] >> b[i] >> c[i];
int dp[n + 1][3];
for (int i = 0; i <= n; i++) {
dp[i][0] = 0;
dp[i][1] = 0;
dp[i][2] = 0;
}
for (int i = 1; i <= n; i++) {
dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
}
cout << max({dp[n][0], dp[n][1], dp[n][2]});
return 0;
} | [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,271 | 964,272 | u672771778 | cpp |
p03162 | #include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int a[n][3];
for (int i = 0; i < n; i++)
cin >> a[i][0] >> a[i][1] >> a[i][2];
long long dp[n][3];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]);
dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1]);
dp[i][2] = max(dp[i - 1][1] + a[i][2], dp[i - 1][1] + a[i][2]);
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}
| #include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
int a[n][3];
for (int i = 0; i < n; i++)
cin >> a[i][0] >> a[i][1] >> a[i][2];
long long dp[n][3];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]);
dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1]);
dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2]);
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}
| [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,273 | 964,274 | u427681070 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD = 1e9 + 7;
#ifndef HOME
#define cerr \
if (0) \
cerr
#endif
const int MaxN = 1e5 + 5;
int dp[MaxN][3];
int a[MaxN][3];
int n;
int solve(int i, int type) {
if (i == n) {
return 0;
}
int &ans = dp[i][type];
if (ans != -1) {
return ans;
}
int res = 0;
if (i == 0) {
res = max(res, a[i][0] + solve(i + 1, 1));
res = max(res, a[i][0] + solve(i + 1, 2));
res = max(res, a[i][1] + solve(i + 1, 2));
res = max(res, a[i][1] + solve(i + 1, 0));
res = max(res, a[i][2] + solve(i + 1, 1));
res = max(res, a[i][2] + solve(i + 1, 0));
} else {
for (int j = 0; j < n; j++) {
if (type != j) {
res = max(res, a[i][type] + solve(i + 1, j));
}
}
}
return ans = res;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
memset(dp, -1, sizeof(dp));
cout << solve(0, 0);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD = 1e9 + 7;
#ifndef HOME
#define cerr \
if (0) \
cerr
#endif
const int MaxN = 1e5 + 5;
int dp[MaxN][3];
int a[MaxN][3];
int n;
int solve(int i, int type) {
if (i == n) {
return 0;
}
int &ans = dp[i][type];
if (ans != -1) {
return ans;
}
int res = 0;
if (i == 0) {
res = max(res, a[i][0] + solve(i + 1, 1));
res = max(res, a[i][0] + solve(i + 1, 2));
res = max(res, a[i][1] + solve(i + 1, 2));
res = max(res, a[i][1] + solve(i + 1, 0));
res = max(res, a[i][2] + solve(i + 1, 1));
res = max(res, a[i][2] + solve(i + 1, 0));
} else {
for (int j = 0; j < 3; j++) {
if (type != j) {
res = max(res, a[i][type] + solve(i + 1, j));
}
}
}
return ans = res;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
memset(dp, -1, sizeof(dp));
cout << solve(0, 0);
return 0;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.branch.if.condition.change"
] | 964,275 | 964,276 | u124992729 | cpp |
p03162 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// DP テーブル
long long dpa[100010];
long long dpb[100010];
long long dpc[100010];
int main() {
// DP テーブル全体を初期化
for (int i = 0; i < 100010; ++i) {
dpa[i] = 0;
dpb[i] = 0;
dpc[i] = 0;
}
int N;
cin >> N;
vector<int> a(N);
vector<int> b(N);
vector<int> c(N);
for (int i = 0; i < N; ++i) {
cin >> a[i] >> b[i] >> c[i];
}
dpa[0] = a[0];
dpb[0] = b[0];
dpc[0] = c[0];
for (int i = 1; i < N; ++i) {
dpa[i] = a[i] + max(dpb[i - 1], dpc[i - 1]);
dpb[i] = b[i] + max(dpc[i - 1], dpa[i - 1]);
dpc[i] = c[i] + max(dpa[i - 1], dpb[i - 1]);
}
cout << max(dpa[N - 1], max(dpc[N - 1], dpc[N - 1])) << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// DP テーブル
long long dpa[100010];
long long dpb[100010];
long long dpc[100010];
int main() {
// DP テーブル全体を初期化
for (int i = 0; i < 100010; ++i) {
dpa[i] = 0;
dpb[i] = 0;
dpc[i] = 0;
}
int N;
cin >> N;
vector<int> a(N);
vector<int> b(N);
vector<int> c(N);
for (int i = 0; i < N; ++i) {
cin >> a[i] >> b[i] >> c[i];
}
dpa[0] = a[0];
dpb[0] = b[0];
dpc[0] = c[0];
for (int i = 1; i < N; ++i) {
dpa[i] = a[i] + max(dpb[i - 1], dpc[i - 1]);
dpb[i] = b[i] + max(dpc[i - 1], dpa[i - 1]);
dpc[i] = c[i] + max(dpa[i - 1], dpb[i - 1]);
}
cout << max(dpa[N - 1], max(dpb[N - 1], dpc[N - 1])) << endl;
return 0;
}
| [
"identifier.change",
"io.output.change"
] | 964,277 | 964,278 | u774160580 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define forn1(i, n) for (int i = 1; i <= n; i++)
#define loop(i, sta, end, inc) for (int i = sta; i <= end; i += inc)
#define itr(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(a, b, c) assert(b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii pair<long long int, long long int>
#define vi vector<long long int>
#define vii vector<pair<long long int, long long int>>
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr << #x << " =" << x << " ";
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
#define LINT_MAX 9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0
template <typename T, typename U> inline void amin(T &x, U y) {
if (y < x)
x = y;
}
template <typename T, typename U> inline void amax(T &x, U y) {
if (x < y)
x = y;
}
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
if (DEBUG == 0)
return;
cerr << *it << " = " << a << " ";
err(++it, args...);
}
ll A[100000][3];
ll dp[100000][3];
int main() {
// freopen("test.txt", "r", stdin);
int n;
cin >> n;
forn(i, n) cin >> A[i][0] >> A[i][1] >> A[i][2];
dp[0][0] = A[0][0];
dp[0][1] = A[0][1];
dp[0][1] = A[0][2];
forn1(i, n - 1) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define forn1(i, n) for (int i = 1; i <= n; i++)
#define loop(i, sta, end, inc) for (int i = sta; i <= end; i += inc)
#define itr(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(a, b, c) assert(b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii pair<long long int, long long int>
#define vi vector<long long int>
#define vii vector<pair<long long int, long long int>>
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr << #x << " =" << x << " ";
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
#define LINT_MAX 9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0
template <typename T, typename U> inline void amin(T &x, U y) {
if (y < x)
x = y;
}
template <typename T, typename U> inline void amax(T &x, U y) {
if (x < y)
x = y;
}
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
if (DEBUG == 0)
return;
cerr << *it << " = " << a << " ";
err(++it, args...);
}
int A[100000][3];
int dp[100000][3];
int main() {
// freopen("test.txt", "r", stdin);
int n;
cin >> n;
forn(i, n) cin >> A[i][0] >> A[i][1] >> A[i][2];
dp[0][0] = A[0][0];
dp[0][1] = A[0][1];
dp[0][2] = A[0][2];
forn1(i, n - 1) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| [
"variable_declaration.type.change",
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 964,279 | 964,280 | u858856811 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define forn1(i, n) for (int i = 1; i <= n; i++)
#define loop(i, sta, end, inc) for (int i = sta; i <= end; i += inc)
#define itr(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(a, b, c) assert(b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii pair<long long int, long long int>
#define vi vector<long long int>
#define vii vector<pair<long long int, long long int>>
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr << #x << " =" << x << " ";
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
#define LINT_MAX 9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0
template <typename T, typename U> inline void amin(T &x, U y) {
if (y < x)
x = y;
}
template <typename T, typename U> inline void amax(T &x, U y) {
if (x < y)
x = y;
}
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
if (DEBUG == 0)
return;
cerr << *it << " = " << a << " ";
err(++it, args...);
}
int A[100000][3];
int dp[100000][3];
int main() {
// freopen("test.txt", "r", stdin);
int n;
cin >> n;
forn(i, n) cin >> A[i][0] >> A[i][1] >> A[i][2];
dp[0][0] = A[0][0];
dp[0][1] = A[0][1];
dp[0][1] = A[0][2];
forn1(i, n - 1) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define forn1(i, n) for (int i = 1; i <= n; i++)
#define loop(i, sta, end, inc) for (int i = sta; i <= end; i += inc)
#define itr(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(a, b, c) assert(b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii pair<long long int, long long int>
#define vi vector<long long int>
#define vii vector<pair<long long int, long long int>>
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr << #x << " =" << x << " ";
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
#define LINT_MAX 9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0
template <typename T, typename U> inline void amin(T &x, U y) {
if (y < x)
x = y;
}
template <typename T, typename U> inline void amax(T &x, U y) {
if (x < y)
x = y;
}
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
if (DEBUG == 0)
return;
cerr << *it << " = " << a << " ";
err(++it, args...);
}
int A[100000][3];
int dp[100000][3];
int main() {
// freopen("test.txt", "r", stdin);
int n;
cin >> n;
forn(i, n) cin >> A[i][0] >> A[i][1] >> A[i][2];
dp[0][0] = A[0][0];
dp[0][1] = A[0][1];
dp[0][2] = A[0][2];
forn1(i, n - 1) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 964,281 | 964,280 | u858856811 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
typedef std::vector<int> vi;
int main() {
int n;
scanf("%d", &n);
vi ans(3, 0);
for (int day = 0; day < n; day++) {
vi c(3);
for (int i = 0; i < n; i++) {
scanf("%d", &c[i]);
}
vi dp(3, 0);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
dp[j] = max(dp[j], dp[i] + c[j]);
}
}
}
ans = dp;
}
cout << max({ans[0], ans[1], ans[2]});
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef std::vector<int> vi;
int main() {
int n;
scanf("%d", &n);
vi ans(3);
for (int day = 0; day < n; day++) {
vi c(3);
for (int i = 0; i < 3; i++) {
scanf("%d", &c[i]);
}
vi dp(3, 0);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
dp[j] = max(dp[j], ans[i] + c[j]);
}
}
}
ans = dp;
}
cout << max({ans[0], ans[1], ans[2]});
return 0;
} | [
"call.arguments.change",
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"assignment.value.change",
"identifier.change"
] | 964,300 | 964,301 | u864207035 | cpp |
p03162 | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
long long a[100100][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
long long dp[100100][3] = {0};
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long res = 0;
for (int i = 0; i < n; i++)
res = max(res, dp[n][i]);
cout << res << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
long long a[100100][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
long long dp[100100][3] = {0};
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long res = 0;
for (int i = 0; i < 3; i++)
res = max(res, dp[n][i]);
cout << res << endl;
return 0;
} | [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,309 | 964,310 | u513736711 | cpp |
p03162 | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[100100][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
long long dp[100100][3] = {0};
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long res = 0;
for (int i = 0; i < n; i++)
res = max(res, dp[n][i]);
cout << res << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
long long a[100100][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
long long dp[100100][3] = {0};
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
long long res = 0;
for (int i = 0; i < 3; i++)
res = max(res, dp[n][i]);
cout << res << endl;
return 0;
} | [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,311 | 964,310 | u513736711 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9 + 5;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif*/
int n;
cin >> n;
vector<int> dp(3, 0);
for (int day = 0; day < n; day++) {
vector<int> new_dp(3, 0);
vector<int> c(3);
for (int i = 0; i < 3; i++)
cin >> c[i];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j)
dp[j] = max(dp[j], dp[i] + c[j]);
}
}
dp = new_dp;
}
cout << max(dp[0], max(dp[1], dp[2]));
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9 + 5;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif*/
int n;
cin >> n;
vector<int> dp(3, 0);
for (int day = 0; day < n; day++) {
vector<int> new_dp(3, 0);
vector<int> c(3);
for (int i = 0; i < 3; i++)
cin >> c[i];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j)
new_dp[j] = max(new_dp[j], dp[i] + c[j]);
}
}
dp = new_dp;
}
cout << max(dp[0], max(dp[1], dp[2]));
} | [
"assignment.variable.change",
"identifier.change",
"assignment.value.change",
"call.arguments.change"
] | 964,314 | 964,315 | u319343724 | cpp |
p03162 | /*
* Created by Dipta Das on 27-06-2019
* Title:
* Problem Link:
* Editorial:
* Source Code:
* Comments:
*/
#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<vector<int>> ar(n, vector<int>(3));
for (auto &i : ar)
for (auto &j : i)
cin >> j;
vector<vector<ll>> dp(n, vector<ll>(3, 0));
for (int i = 0; i < 3; ++i)
dp[0][i] = ar[0][i];
// 1 -> 2, 3
// 2 -> 3%3 = 0, 4%3 = 1
for (int i = 1; i < n; ++i) {
/* dp[i][0] = ar[i][0] + max (dp[i-1][1], dp[i-1][2]); */
/* dp[i][1] = ar[i][1] + max (dp[i-1][2], dp[i-1][0]); */
/* dp[i][2] = ar[i][2] + max (dp[i-1][1], dp[i-1][0]); */
for (int j = 0; j < 3; ++j) {
dp[i][j] =
ar[i - 1][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| /*
* Created by Dipta Das on 27-06-2019
* Title:
* Problem Link:
* Editorial:
* Source Code:
* Comments:
*/
#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<vector<int>> ar(n, vector<int>(3));
for (auto &i : ar)
for (auto &j : i)
cin >> j;
vector<vector<ll>> dp(n, vector<ll>(3, 0));
for (int i = 0; i < 3; ++i)
dp[0][i] = ar[0][i];
// 1 -> 2, 3
// 2 -> 3%3 = 0, 4%3 = 1
for (int i = 1; i < n; ++i) {
/* dp[i][0] = ar[i][0] + max (dp[i-1][1], dp[i-1][2]); */
/* dp[i][1] = ar[i][1] + max (dp[i-1][2], dp[i-1][0]); */
/* dp[i][2] = ar[i][2] + max (dp[i-1][1], dp[i-1][0]); */
for (int j = 0; j < 3; ++j) {
dp[i][j] = ar[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 964,335 | 964,336 | u567992495 | cpp |
p03162 | #include <iostream>
using namespace std;
int ans[100000][3];
int main() {
int n;
cin >> n;
int arr[n][3];
for (int i = 0; i < n; ++i) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
ans[0][0] = arr[0][0];
ans[0][1] = ans[0][1];
ans[0][2] = ans[0][2];
for (int i = 1; i < n; i++) {
if (ans[i - 1][1] > ans[i - 1][2])
ans[i][0] = ans[i - 1][1] + arr[i][0];
else
ans[i][0] = ans[i - 1][2] + arr[i][0];
if (ans[i - 1][0] > ans[i - 1][2])
ans[i][1] = ans[i - 1][0] + arr[i][1];
else
ans[i][1] = ans[i - 1][2] + arr[i][1];
if (ans[i - 1][0] > ans[i - 1][1])
ans[i][2] = ans[i - 1][0] + arr[i][2];
else
ans[i][2] = ans[i - 1][1] + arr[i][2];
}
int max = 0;
for (int i = 0; i < 3; i++) {
if (ans[n - 1][i] > max)
max = ans[n - 1][i];
}
cout << max << endl;
} | #include <iostream>
using namespace std;
int ans[100000][3];
int main() {
int n;
cin >> n;
int arr[n][3];
for (int i = 0; i < n; ++i) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
ans[0][0] = arr[0][0];
ans[0][1] = arr[0][1];
ans[0][2] = arr[0][2];
for (int i = 1; i < n; i++) {
if (ans[i - 1][1] > ans[i - 1][2])
ans[i][0] = ans[i - 1][1] + arr[i][0];
else
ans[i][0] = ans[i - 1][2] + arr[i][0];
if (ans[i - 1][0] > ans[i - 1][2])
ans[i][1] = ans[i - 1][0] + arr[i][1];
else
ans[i][1] = ans[i - 1][2] + arr[i][1];
if (ans[i - 1][0] > ans[i - 1][1])
ans[i][2] = ans[i - 1][0] + arr[i][2];
else
ans[i][2] = ans[i - 1][1] + arr[i][2];
// cout<<arr[i][0]<<endl<<arr[i][1]<<endl<<arr[i][2]<<endl;
}
int max = 0;
for (int i = 0; i < 3; i++) {
if (ans[n - 1][i] > max)
max = ans[n - 1][i];
}
cout << max << endl;
} | [
"assignment.value.change",
"identifier.change"
] | 964,339 | 964,340 | u855642922 | cpp |
p03162 | #include <iostream>
/* run this program using the console pauser or add your own getch,
* system("pause") or input loop */
using namespace std;
int main() {
int i, j, n;
cin >> n;
int dp[n][3], a[n][3];
for (i = 0; i < n; i++) {
for (j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + a[i][2];
}
cout << max(max(dp[n - 1][1], dp[n - 1][2]), dp[n - 1][3]);
}
| #include <iostream>
/* run this program using the console pauser or add your own getch,
* system("pause") or input loop */
using namespace std;
int main() {
int i, j, n;
cin >> n;
int dp[n][3], a[n][3];
for (i = 0; i < n; i++) {
for (j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + a[i][2];
}
cout << max((max(dp[n - 1][0], dp[n - 1][1])), dp[n - 1][2]);
}
| [
"call.arguments.change",
"call.arguments.add"
] | 964,341 | 964,342 | u700270455 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int N = 100007;
const int INF = 1000000007;
int a[N], b[N], c[N], dp[N][3];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i] >> b[i] >> c[i];
for (int i = 1; i <= n; ++i) {
dp[i][0] = max(dp[i][0], max(dp[i - 1][1], dp[i - 1][2]) + a[i]);
dp[i][1] = max(dp[i][0], max(dp[i - 1][2], dp[i - 1][0]) + b[i]);
dp[i][2] = max(dp[i][0], max(dp[i - 1][0], dp[i - 1][1]) + c[i]);
}
cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int N = 100007;
const int INF = 1000000007;
int a[N], b[N], c[N], dp[N][3];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i] >> b[i] >> c[i];
for (int i = 1; i <= n; ++i) {
dp[i][0] = max(dp[i][0], max(dp[i - 1][1], dp[i - 1][2]) + a[i]);
dp[i][1] = max(dp[i][1], max(dp[i - 1][2], dp[i - 1][0]) + b[i]);
dp[i][2] = max(dp[i][2], max(dp[i - 1][0], dp[i - 1][1]) + c[i]);
}
cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";
return 0;
}
| [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 964,347 | 964,348 | u411195488 | cpp |
p03162 | /*..................................
manojeet24
....................................*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i, a, b) for (int i = a; i < b; i++)
#define flr(i, a, b) for (int i = a; i > b; i--)
#define INF INT_MAX
ll dp[100005][3], h[100005][3], k;
int n;
ll solve(int i, int e) {
if (dp[i][e] != 0)
return dp[i][e];
if (i == n - 1) {
return dp[n - 1][e];
}
fl(j, 0, 3) {
if (j != e)
dp[i][e] = max(solve(i + 1, j) + h[i][e], dp[i][e]);
}
return dp[n][e];
}
int main() {
cin >> n;
fl(i, 0, n) { fl(j, 0, 3) cin >> h[i][j]; }
fl(i, 0, n) { fl(j, 0, 3) dp[i][j] = 0; }
dp[n - 1][0] = h[n - 1][0];
dp[n - 1][1] = h[n - 1][1];
dp[n - 1][2] = h[n - 1][2];
solve(0, 0);
solve(0, 1);
solve(0, 2);
cout << *max_element(dp[0], dp[0] + 3);
}
| /*..................................
manojeet24
....................................*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i, a, b) for (int i = a; i < b; i++)
#define flr(i, a, b) for (int i = a; i > b; i--)
#define INF INT_MAX
ll dp[100005][3], h[100005][3], k;
int n;
ll solve(int i, int e) {
if (dp[i][e] != 0)
return dp[i][e];
if (i == n - 1) {
return dp[n - 1][e];
}
fl(j, 0, 3) {
if (j != e)
dp[i][e] = max(solve(i + 1, j) + h[i][e], dp[i][e]);
}
return dp[i][e];
}
int main() {
cin >> n;
fl(i, 0, n) { fl(j, 0, 3) cin >> h[i][j]; }
fl(i, 0, n) { fl(j, 0, 3) dp[i][j] = 0; }
dp[n - 1][0] = h[n - 1][0];
dp[n - 1][1] = h[n - 1][1];
dp[n - 1][2] = h[n - 1][2];
solve(0, 0);
solve(0, 1);
solve(0, 2);
cout << *max_element(dp[0], dp[0] + 3);
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"function.return_value.change"
] | 964,349 | 964,350 | u973352787 | cpp |
p03162 | /*..................................
manojeet24
....................................*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i, a, b) for (int i = a; i < b; i++)
#define flr(i, a, b) for (int i = a; i > b; i--)
#define INF INT_MAX
int dp[100005][3], h[100005][3], k;
int n;
int solve(int i, int e) {
if (dp[i][e] != 0)
return dp[i][e];
if (i == n - 1) {
return dp[n - 1][e];
}
fl(j, 0, 3) {
if (j != e)
dp[i][e] = max(solve(i + 1, j) + h[i][e], dp[i][e]);
}
return dp[n][e];
}
int main() {
cin >> n;
fl(i, 0, n) { fl(j, 0, 3) cin >> h[i][j]; }
fl(i, 0, n) { fl(j, 0, 3) dp[i][j] = 0; }
dp[n - 1][0] = h[n - 1][0];
dp[n - 1][1] = h[n - 1][1];
dp[n - 1][2] = h[n - 1][2];
solve(0, 0);
solve(0, 1);
solve(0, 2);
cout << *max_element(dp[0], dp[0] + 3);
}
| /*..................................
manojeet24
....................................*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i, a, b) for (int i = a; i < b; i++)
#define flr(i, a, b) for (int i = a; i > b; i--)
#define INF INT_MAX
ll dp[100005][3], h[100005][3], k;
int n;
ll solve(int i, int e) {
if (dp[i][e] != 0)
return dp[i][e];
if (i == n - 1) {
return dp[n - 1][e];
}
fl(j, 0, 3) {
if (j != e)
dp[i][e] = max(solve(i + 1, j) + h[i][e], dp[i][e]);
}
return dp[i][e];
}
int main() {
cin >> n;
fl(i, 0, n) { fl(j, 0, 3) cin >> h[i][j]; }
fl(i, 0, n) { fl(j, 0, 3) dp[i][j] = 0; }
dp[n - 1][0] = h[n - 1][0];
dp[n - 1][1] = h[n - 1][1];
dp[n - 1][2] = h[n - 1][2];
solve(0, 0);
solve(0, 1);
solve(0, 2);
cout << *max_element(dp[0], dp[0] + 3);
}
| [
"variable_declaration.type.change",
"identifier.change",
"variable_access.subscript.index.change",
"function.return_value.change"
] | 964,351 | 964,350 | u973352787 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ll n, i, j;
ll a[n][3];
for (i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
for (i = 1; i < n; i++) {
a[i][0] += max(a[i - 1][1], a[i - 1][2]);
a[i][1] += max(a[i - 1][0], a[i - 1][2]);
a[i][2] += max(a[i - 1][0], a[i - 1][1]);
}
cout << max(max(a[n - 1][0], a[n - 1][1]), a[n - 1][2]) << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ll n, i, j;
cin >> n;
ll a[n][3];
for (i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
for (i = 1; i < n; i++) {
a[i][0] += max(a[i - 1][1], a[i - 1][2]);
a[i][1] += max(a[i - 1][0], a[i - 1][2]);
a[i][2] += max(a[i - 1][0], a[i - 1][1]);
}
cout << max(max(a[n - 1][0], a[n - 1][1]), a[n - 1][2]) << endl;
} | [] | 964,352 | 964,353 | u231613785 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
llong dp[100001][3];
int main(int argc, char *argv[]) {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<llong> A(n), B(n), C(n);
rep(i, n) cin >> A[i] >> B[i] >> C[i];
dp[0][0] = A[0];
dp[0][1] = B[0];
dp[0][2] = C[0];
for (int i = 1; i < n; ++i) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
}
cout << max({dp[n - 1][0], dp[n - 1][2], dp[n - 1][2]}) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
llong dp[100001][3];
int main(int argc, char *argv[]) {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<llong> A(n), B(n), C(n);
rep(i, n) cin >> A[i] >> B[i] >> C[i];
dp[0][0] = A[0]; // dp[i][j] i日目にjを選択した場合の幸福度の最大値
dp[0][1] = B[0];
dp[0][2] = C[0];
for (int i = 1; i < n; ++i) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
}
cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
return 0;
} | [
"literal.number.change",
"variable_access.subscript.index.change",
"io.output.change"
] | 964,356 | 964,357 | u943004959 | cpp |
p03162 | //
// main.cpp
// C - Vacation
//
// Created by Hashizo on 2019/06/12.
//
#include <algorithm>
#include <iostream>
#include <regex>
#include <string>
#include <vector>
using namespace std;
#undef INT_MAX
#undef INT_MIN
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX - 1)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)
int main(int argc, const char *argv[]) {
int n;
cin >> n;
int activity[4][3];
int dp[4 + 1][3];
REP(i, n) {
REP(j, 3) { cin >> activity[i][j]; }
}
REP(j, 3) { dp[0][j] = 0; }
REP(i, n) {
dp[i + 1][0] = activity[i][0] + max(dp[i][1], dp[i][2]);
dp[i + 1][1] = activity[i][1] + max(dp[i][0], dp[i][2]);
dp[i + 1][2] = activity[i][2] + max(dp[i][0], dp[i][1]);
// dp[i+1][0] = dp[i][0] + max(activity[i][1], activity[i][2]);
// dp[i+1][1] = dp[i][1] + max(activity[i][0], activity[i][2]);
// dp[i+1][2] = dp[i][2] + max(activity[i][0], activity[i][1]);
}
int res = 0;
REP(j, 3) { res = max(dp[n][j], res); }
cout << res << endl;
return 0;
}
| //
// main.cpp
// C - Vacation
//
// Created by Hashizo on 2019/06/12.
//
#include <algorithm>
#include <iostream>
#include <regex>
#include <string>
#include <vector>
using namespace std;
#undef INT_MAX
#undef INT_MIN
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX - 1)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)
int main(int argc, const char *argv[]) {
int n;
cin >> n;
int activity[n][3];
int dp[n + 1][3];
REP(i, n) {
REP(j, 3) { cin >> activity[i][j]; }
}
REP(j, 3) { dp[0][j] = 0; }
REP(i, n) {
dp[i + 1][0] = activity[i][0] + max(dp[i][1], dp[i][2]);
dp[i + 1][1] = activity[i][1] + max(dp[i][0], dp[i][2]);
dp[i + 1][2] = activity[i][2] + max(dp[i][0], dp[i][1]);
// dp[i+1][0] = dp[i][0] + max(activity[i][1], activity[i][2]);
// dp[i+1][1] = dp[i][1] + max(activity[i][0], activity[i][2]);
// dp[i+1][2] = dp[i][2] + max(activity[i][0], activity[i][1]);
}
int res = 0;
REP(j, 3) { res = max(dp[n][j], res); }
cout << res << endl;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"variable_declaration.array_dimensions.change",
"expression.operation.binary.change"
] | 964,369 | 964,370 | u156723325 | cpp |
p03162 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(x) cout << #x << " " << x << "\n"
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll N = 1e5 + 3;
ll n, k, a[N][4], res[N][4];
ll _max(ll x, ll y, ll z) { return max(max(x, y), z); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (ll i = 1; i <= n; ++i) {
for (ll j = 1; j <= 3; ++j)
cin >> a[i][j];
}
for (ll i = 1; i <= n; ++i) {
for (ll j = 1; j <= n; ++j) {
for (ll k = 1; k <= 3; ++k) {
if (k == j)
continue;
res[i][j] = max(res[i][j], res[i - 1][k] + a[i][j]);
}
}
}
cout << _max(res[n][1], res[n][2], res[n][3]);
return 0;
}
| #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(x) cout << #x << " " << x << "\n"
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll N = 1e5 + 3;
ll n, k, a[N][4], res[N][4];
ll _max(ll x, ll y, ll z) { return max(max(x, y), z); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (ll i = 1; i <= n; ++i) {
for (ll j = 1; j <= 3; ++j)
cin >> a[i][j];
}
for (ll i = 1; i <= n; ++i) {
for (ll j = 1; j <= 3; ++j) {
for (ll k = 1; k <= 3; ++k) {
if (k == j)
continue;
res[i][j] = max(res[i][j], res[i - 1][k] + a[i][j]);
}
}
}
cout << _max(res[n][1], res[n][2], res[n][3]);
return 0;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,371 | 964,372 | u381052328 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<array<int, 3>> dp(n);
vector<array<int, 3>> happy(n);
for (auto idx(0); idx < n; ++idx) {
cin >> happy[idx][0] >> happy[idx][1] >> happy[idx][2];
}
dp[0][0] = happy[0][0];
dp[0][3] = happy[0][1];
dp[0][2] = happy[0][2];
for (auto idx(1); idx < n; ++idx) {
dp[idx][0] = max(dp[idx - 1][1], dp[idx - 1][2]) + happy[idx][0];
dp[idx][1] = max(dp[idx - 1][0], dp[idx - 1][2]) + happy[idx][1];
dp[idx][2] = max(dp[idx - 1][0], dp[idx - 1][1]) + happy[idx][2];
}
cout << max(max(dp.back()[0], dp.back()[1]), dp.back()[2]) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<array<int, 3>> dp(n);
vector<array<int, 3>> happy(n);
for (auto idx(0); idx < n; ++idx) {
cin >> happy[idx][0] >> happy[idx][1] >> happy[idx][2];
}
dp[0][0] = happy[0][0];
dp[0][1] = happy[0][1];
dp[0][2] = happy[0][2];
for (auto idx(1); idx < n; ++idx) {
dp[idx][0] = max(dp[idx - 1][1], dp[idx - 1][2]) + happy[idx][0];
dp[idx][1] = max(dp[idx - 1][0], dp[idx - 1][2]) + happy[idx][1];
dp[idx][2] = max(dp[idx - 1][0], dp[idx - 1][1]) + happy[idx][2];
}
cout << max(max(dp.back()[0], dp.back()[1]), dp.back()[2]) << endl;
return 0;
} | [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 964,373 | 964,374 | u268434654 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
int main() {
long int n, i, j;
cin >> n;
long int a[n][3];
for (i = 0; i < n; i++) {
for (j = 0; j < 3; j++)
cin >> a[i][j];
}
long int dp[n][3];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (i = 0; i < n; i++) {
for (j = 0; j < 3; j++) {
if (j == 0)
dp[i][j] = a[i][j] + max(dp[i - 1][1], dp[i - 1][2]);
if (j == 1)
dp[i][j] = a[i][j] + max(dp[i - 1][0], dp[i - 1][2]);
if (j == 2)
dp[i][j] = a[i][j] + max(dp[i - 1][0], dp[i - 1][1]);
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long int n, i, j;
cin >> n;
long int a[n][3];
for (i = 0; i < n; i++) {
for (j = 0; j < 3; j++)
cin >> a[i][j];
}
long int dp[n][3];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (i = 1; i < n; i++) {
for (j = 0; j < 3; j++) {
if (j == 0)
dp[i][j] = a[i][j] + max(dp[i - 1][1], dp[i - 1][2]);
if (j == 1)
dp[i][j] = a[i][j] + max(dp[i - 1][0], dp[i - 1][2]);
if (j == 2)
dp[i][j] = a[i][j] + max(dp[i - 1][0], dp[i - 1][1]);
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
} | [
"literal.number.change",
"assignment.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 964,377 | 964,378 | u415896336 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
ll n;
cin >> n;
ll a[n + 1], b[n + 1], c[n + 1];
ll dp[n + 1][3];
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
dp[1][0] = a[1];
dp[1][1] = b[1];
dp[1][2] = c[1];
for (int i = 2; i <= n; i++) {
dp[i][0] = a[i] + min(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = b[i] + min(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = c[i] + min(dp[i - 1][0], dp[i - 1][1]);
}
cout << min(dp[n][2], min(dp[n][0], dp[n][1])) << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
ll n;
cin >> n;
ll a[n + 1], b[n + 1], c[n + 1];
ll dp[n + 1][3];
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
dp[1][0] = a[1];
dp[1][1] = b[1];
dp[1][2] = c[1];
for (int i = 2; i <= n; i++) {
dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
}
cout << max(dp[n][2], max(dp[n][0], dp[n][1])) << endl;
} | [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change",
"expression.operation.binary.change",
"io.output.change"
] | 964,379 | 964,380 | u742642200 | cpp |
p03162 | #include <bits/stdc++.h>
#define endl "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;
int n, arr[100001][3];
ll dp[100001][3];
int main() {
IOS
// bfreopen("balalance.in", "r", stdin);
cin >>
n;
for (int i = 1; i <= n; ++i) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
for (int i = 1; i <= n; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j != k) {
dp[i][k] = max(dp[i][k], arr[i][k] + dp[i][j]);
}
}
}
}
cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
return 0;
}
| #include <bits/stdc++.h>
#define endl "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;
int n, arr[100001][3];
ll dp[100001][3];
int main() {
IOS
// bfreopen("balalance.in", "r", stdin);
cin >>
n;
for (int i = 1; i <= n; ++i) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
for (int i = 1; i <= n; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j != k) {
dp[i][k] = max(dp[i][k], arr[i][k] + dp[i - 1][j]);
}
}
}
}
cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
return 0;
}
| [
"assignment.change"
] | 964,381 | 964,382 | u398135166 | cpp |
p03162 | #include <bits/stdc++.h>
#define endl "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;
int n, arr[100001][3], dp[100001][3];
int main() {
IOS
// bfreopen("balalance.in", "r", stdin);
cin >>
n;
for (int i = 1; i <= n; ++i) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
for (int i = 1; i <= n; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j != k) {
dp[i][k] = max(dp[i][k], arr[i][k] + dp[i][j]);
}
}
}
}
cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
return 0;
}
| #include <bits/stdc++.h>
#define endl "\n"
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;
int n, arr[100001][3];
ll dp[100001][3];
int main() {
IOS
// bfreopen("balalance.in", "r", stdin);
cin >>
n;
for (int i = 1; i <= n; ++i) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
for (int i = 1; i <= n; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j != k) {
dp[i][k] = max(dp[i][k], arr[i][k] + dp[i - 1][j]);
}
}
}
}
cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
return 0;
}
| [
"assignment.change"
] | 964,383 | 964,382 | u398135166 | cpp |
p03162 | #include <bits/stdc++.h>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int, int> fd[] = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1),
make_pair(0, -1)};
signed main() {
int n;
cin >> n;
int dp[110000][3];
int a[110000], b[110000], c[110000];
rep(i, n) cin >> a[i] >> b[i] >> c[i];
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
rep(i, n - 1) {
dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i];
dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
} | #include <bits/stdc++.h>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int, int> fd[] = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1),
make_pair(0, -1)};
signed main() {
int n;
cin >> n;
int dp[110000][3];
int a[110000], b[110000], c[110000];
rep(i, n) cin >> a[i] >> b[i] >> c[i];
dp[0][0] = a[0];
dp[0][1] = b[0];
dp[0][2] = c[0];
rep(i, n - 1) {
dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1];
dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i + 1];
dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i + 1];
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
} | [
"assignment.change"
] | 964,400 | 964,401 | u317754719 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define faster ios::sync_with_stdio(false)
#define ll long long int
#define sz 200005
#define mp(x, y) make_pair(x, y)
#define pii pair<long long int, long long int>
#define tor ::iterator
#define letsgo \
long long int i, j, k, q = 0, t, tmp, n, flg = 0, cntr = 0, maxxer = 0
#define fi first
#define se second
#define be begin()
#define en end()
#define mod 1000000007
#define debug(x) cout << " " << x << endl
bool comparator(pair<ll, ll> p1, pair<ll, ll> p2) {
if (p1.fi < p2.fi)
return true;
else if (p1.fi == p2.fi) {
return p1.se > p2.se;
} else
return false;
}
ll dp[100005][3];
int val[100005][3];
int main() {
faster;
letsgo;
cin >> n;
vector<ll> v;
for (i = 0; i < n; i++) {
cin >> val[i][0] >> val[i][1] >> val[i][2];
}
dp[0][0] = val[0][0];
dp[1][0] = val[0][1];
dp[2][0] = val[0][2];
for (i = 1; i < n; i++) {
for (j = 0; j < 3; j++) {
dp[i][(j) % 3] =
max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + val[i][(j) % 3];
}
}
for (i = 0; i < 3; i++) {
maxxer = max(maxxer, dp[n - 1][i]);
}
cout << maxxer;
} | #include <bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define faster ios::sync_with_stdio(false)
#define ll long long int
#define sz 200005
#define mp(x, y) make_pair(x, y)
#define pii pair<long long int, long long int>
#define tor ::iterator
#define letsgo \
long long int i, j, k, q = 0, t, tmp, n, flg = 0, cntr = 0, maxxer = 0
#define fi first
#define se second
#define be begin()
#define en end()
#define mod 1000000007
#define debug(x) cout << " " << x << endl
bool comparator(pair<ll, ll> p1, pair<ll, ll> p2) {
if (p1.fi < p2.fi)
return true;
else if (p1.fi == p2.fi) {
return p1.se > p2.se;
} else
return false;
}
ll dp[100005][3];
int val[100005][3];
int main() {
faster;
letsgo;
cin >> n;
vector<ll> v;
for (i = 0; i < n; i++) {
cin >> val[i][0] >> val[i][1] >> val[i][2];
}
dp[0][0] = val[0][0];
dp[0][1] = val[0][1];
dp[0][2] = val[0][2];
for (i = 1; i < n; i++) {
for (j = 0; j < 3; j++) {
dp[i][(j) % 3] =
max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + val[i][(j) % 3];
}
}
// for(i=1;i<n;i++){
// for(j=0;j<3;j++){
// cout<<dp[i][j]<<" ";
// }
// cout<<endl;
// }
for (i = 0; i < 3; i++) {
maxxer = max(maxxer, dp[n - 1][i]);
}
cout << maxxer;
} | [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 964,409 | 964,410 | u116062521 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n), b(n), c(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
vector<vector<int>> dp(n, vector<int>(3));
dp[n - 1][0] = a[n - 1];
dp[n - 1][1] = b[n - 1];
dp[n - 1][2] = c[n - 1];
for (int i = n - 2; i >= 0; i--) {
dp[i][0] = max(dp[i + 1][1] + a[i], dp[i + 1][2] + a[i]);
dp[i][1] = max(dp[i + 1][0] + b[i], dp[i + 1][2] + b[i]);
dp[i][1] = max(dp[i + 1][0] + c[i], dp[i + 1][1] + c[i]);
}
cout << max({dp[0][0], dp[0][1], dp[0][2]}) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(n), b(n), c(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
vector<vector<int>> dp(n, vector<int>(3));
dp[n - 1][0] = a[n - 1];
dp[n - 1][1] = b[n - 1];
dp[n - 1][2] = c[n - 1];
for (int i = n - 2; i >= 0; i--) {
dp[i][0] = max(dp[i + 1][1] + a[i], dp[i + 1][2] + a[i]);
dp[i][1] = max(dp[i + 1][0] + b[i], dp[i + 1][2] + b[i]);
dp[i][2] = max(dp[i + 1][0] + c[i], dp[i + 1][1] + c[i]);
}
cout << max({dp[0][0], dp[0][1], dp[0][2]}) << endl;
return 0;
} | [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 964,422 | 964,423 | u355724718 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int n, h[4][maxn], dp[maxn][4];
int solve(int x, int last) {
if (dp[x][last] == -1)
return dp[x][last];
if (x == n + 1)
return 0;
for (int i = 1; i <= 3; i++) {
if (i != last) {
dp[x][last] = max(dp[x][last], h[i][x] + solve(x + 1, i));
}
}
return dp[x][last];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> h[1][i] >> h[2][i] >> h[3][i];
memset(dp, -1, sizeof dp);
cout << solve(1, 0) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int n, h[4][maxn], dp[maxn][4];
int solve(int x, int last) {
if (dp[x][last] != -1)
return dp[x][last];
if (x == n + 1)
return 0;
for (int i = 1; i <= 3; i++) {
if (i != last) {
dp[x][last] = max(dp[x][last], h[i][x] + solve(x + 1, i));
}
}
return dp[x][last];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> h[1][i] >> h[2][i] >> h[3][i];
memset(dp, -1, sizeof dp);
cout << solve(1, 0) << endl;
}
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 964,440 | 964,441 | u427216196 | cpp |
p03162 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
vector<int> c(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
vector<vector<int>> answer(3, vector<int>(n, 0));
answer[0][0] = a[0];
answer[2][0] = b[0];
answer[2][0] = c[0];
for (int i = 1; i < n; i++) {
answer[0][i] = a[i] + max(answer[1][i - 1], answer[2][i - 1]);
answer[1][i] = b[i] + max(answer[0][i - 1], answer[2][i - 1]);
answer[2][i] = c[i] + max(answer[1][i - 1], answer[0][i - 1]);
}
cout << max(answer[0][n - 1], max(answer[1][n - 1], answer[2][n - 1]));
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
vector<int> c(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i] >> c[i];
}
vector<vector<int>> answer(3, vector<int>(n, 0));
answer[0][0] = a[0];
answer[1][0] = b[0];
answer[2][0] = c[0];
for (int i = 1; i < n; i++) {
answer[0][i] = a[i] + max(answer[1][i - 1], answer[2][i - 1]);
answer[1][i] = b[i] + max(answer[0][i - 1], answer[2][i - 1]);
answer[2][i] = c[i] + max(answer[1][i - 1], answer[0][i - 1]);
}
cout << max(answer[0][n - 1], max(answer[1][n - 1], answer[2][n - 1]));
return 0;
}
| [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change"
] | 964,451 | 964,452 | u667099228 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
long long mem[100005][3];
int arr[100005][3];
int n;
long long go(int x, int y) {
if (x >= n)
return 0;
if (mem[x][y] != -1)
return mem[x][y];
for (int i = 0; i < 3; i++) {
if (i == y && i != 0)
continue;
mem[x][y] = max(mem[x][y], go(x + 1, i) + arr[x][i]);
}
return mem[x][y];
}
int main() {
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
cin >> arr[i][j];
memset(mem, -1, sizeof mem);
cout << go(0, 0) << endl;
} | #include <bits/stdc++.h>
using namespace std;
long long mem[100005][3];
int arr[100005][3];
int n;
long long go(int x, int y) {
if (x >= n)
return 0;
if (mem[x][y] != -1)
return mem[x][y];
for (int i = 0; i < 3; i++) {
if (i == y && x != 0)
continue;
mem[x][y] = max(mem[x][y], go(x + 1, i) + arr[x][i]);
}
return mem[x][y];
}
int main() {
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
cin >> arr[i][j];
memset(mem, -1, sizeof mem);
cout << go(0, 0) << endl;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 964,453 | 964,454 | u360904601 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int max_n = 1e5 + 20;
int n, k;
int a[max_n], b[max_n], c[max_n], DP[3][max_n];
int main() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
DP[0][0] = a[0];
DP[0][1] = b[0];
DP[0][2] = c[0];
for (int i = 1; i < n; i++) {
DP[i][0] = max(DP[i - 1][1], DP[i - 1][2]) + a[i];
DP[i][1] = max(DP[i - 1][0], DP[i - 1][2]) + b[i];
DP[i][2] = max(DP[i - 1][1], DP[i - 1][0]) + c[i];
}
cout << max(max(DP[n - 1][0], DP[n - 1][1]), DP[n - 1][2]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int max_n = 1e5 + 20;
int n, k;
int a[max_n], b[max_n], c[max_n], DP[max_n][3];
int main() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
DP[0][0] = a[0];
DP[0][1] = b[0];
DP[0][2] = c[0];
for (int i = 1; i < n; i++) {
DP[i][0] = max(DP[i - 1][1], DP[i - 1][2]) + a[i];
DP[i][1] = max(DP[i - 1][0], DP[i - 1][2]) + b[i];
DP[i][2] = max(DP[i - 1][1], DP[i - 1][0]) + c[i];
}
cout << max(max(DP[n - 1][0], DP[n - 1][1]), DP[n - 1][2]);
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"variable_declaration.array_dimensions.change",
"identifier.replace.remove",
"literal.replace.add"
] | 964,457 | 964,458 | u986144116 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
int n, dp[300005][5], arr[300005][5];
int main() {
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
scanf("%d", arr[i][j]);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k) {
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + arr[i][k]);
}
}
}
}
int res = max(dp[n][0], dp[n][1]);
res = max(res, dp[n][2]);
printf("%d\n", res);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int n, dp[300005][5], arr[300005][5];
int main() {
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
scanf("%d", &arr[i][j]);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k) {
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + arr[i][k]);
}
}
}
}
int res = max(dp[n][0], dp[n][1]);
res = max(res, dp[n][2]);
printf("%d\n", res);
return 0;
} | [
"expression.operation.unary.reference.add"
] | 964,463 | 964,464 | u078937298 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define MAXN 100100
int n, a[MAXN][3], dp[MAXN][3], k;
int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 3; ++j) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (i == 0) {
dp[i][j] = a[i][j];
} else {
dp[i][j] =
max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + a[i][j];
}
}
}
cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define MAXN 100100
int n, a[MAXN][3], dp[MAXN][3], k;
int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 3; ++j) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 3; ++j) {
if (i == 0) {
dp[i][j] = a[i][j];
} else {
dp[i][j] =
max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + a[i][j];
}
}
}
cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
return 0;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,471 | 964,472 | u463720901 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll dx[4] = {-1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
const ll MAX = 3e5 + 10;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(), v.end()
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n, m, x, k, Q, ans;
string s;
ll dp[MAX][3];
ll a[MAX][3];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("test.in","r",stdin);
cin >> n;
for (int i = 0; i < n; ++i)
for (int j = 0; j < 3; ++j)
cin >> a[i][j];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; ++i)
for (int j = 0; j < 3; ++j)
for (int k = 0; k < 3; ++k)
if (j != k)
dp[i][j] = max(dp[i][j], a[i][j] + dp[i - 1][k]);
cout << max({dp[n - 1][0], dp[n - 1][2], dp[n - 1][3]}) << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll dx[4] = {-1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
const ll MAX = 3e5 + 10;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(), v.end()
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n, m, x, k, Q, ans;
string s;
ll dp[MAX][3];
ll a[MAX][3];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("test.in","r",stdin);
cin >> n;
for (int i = 0; i < n; ++i)
for (int j = 0; j < 3; ++j)
cin >> a[i][j];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; ++i)
for (int j = 0; j < 3; ++j)
for (int k = 0; k < 3; ++k)
if (j != k)
dp[i][j] = max(dp[i][j], a[i][j] + dp[i - 1][k]);
cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << '\n';
return 0;
}
| [
"literal.number.change",
"variable_access.subscript.index.change",
"io.output.change"
] | 964,475 | 964,476 | u386842336 | cpp |
p03162 | #include <iostream>
#define NMAX 100001
using namespace std;
int DP[NMAX][4], initial[NMAX][4], n, p;
void read() {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= 2; j++) {
cin >> initial[i][j];
}
}
}
void solve() {
for (int i = 0; i <= 2; i++)
DP[1][i] = initial[1][i];
for (int i = 1; i <= n - 1; i++) {
for (int j = 0; j <= 2; j++) {
DP[i + 1][(j + 1) % 3] =
max(DP[i][j] + initial[i + 1][(j + 1) % 3], DP[i + 1][(j + 1) % 3]);
DP[i + 1][(j + 3) % 3] =
max(DP[i][j] + initial[i + 1][(j + 2) % 3], DP[i + 1][(j + 2) % 3]);
}
}
int maxx = 0;
for (int i = 0; i <= 2; i++) {
if (maxx < DP[n][i])
maxx = DP[n][i];
}
cout << maxx;
}
int main() {
read();
solve();
return 0;
} | #include <iostream>
#define NMAX 100001
using namespace std;
int DP[NMAX][4], initial[NMAX][4], n, p;
void read() {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= 2; j++) {
cin >> initial[i][j];
}
}
}
void solve() {
for (int i = 0; i <= 2; i++)
DP[1][i] = initial[1][i];
for (int i = 1; i <= n - 1; i++) {
for (int j = 0; j <= 2; j++) {
DP[i + 1][(j + 1) % 3] =
max(DP[i][j] + initial[i + 1][(j + 1) % 3], DP[i + 1][(j + 1) % 3]);
DP[i + 1][(j + 2) % 3] =
max(DP[i][j] + initial[i + 1][(j + 2) % 3], DP[i + 1][(j + 2) % 3]);
// DP[i+1][(j+3) % 3] = max(DP[i][j] + initial[i+1][(j+3)%3],
// DP[i+1][(j+3)%3]);
}
}
int maxx = 0;
for (int i = 0; i <= 2; i++) {
if (maxx < DP[n][i])
maxx = DP[n][i];
}
cout << maxx;
}
int main() {
read();
solve();
return 0;
} | [
"literal.number.change",
"assignment.variable.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 964,488 | 964,489 | u389532053 | cpp |
p03162 | #include <iostream>
#define NMAX 100001
using namespace std;
int DP[NMAX][4], initial[NMAX][4], n, p;
void read() {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= 2; j++) {
cin >> initial[i][j];
}
}
}
void solve() {
for (int i = 1; i <= 3; i++)
DP[1][i] = initial[1][i];
for (int i = 1; i <= n - 1; i++) {
for (int j = 0; j <= 2; j++) {
DP[i + 1][(j + 1) % 3] =
max(DP[i][j] + initial[i + 1][(j + 1) % 3], DP[i + 1][(j + 1) % 3]);
DP[i + 1][(j + 2) % 3] =
max(DP[i][j] + initial[i + 1][(j + 2) % 3], DP[i + 1][(j + 2) % 3]);
}
}
int maxx = 0;
for (int i = 0; i <= 2; i++) {
if (maxx < DP[n][i])
maxx = DP[n][i];
}
cout << maxx;
}
int main() {
read();
solve();
return 0;
} | #include <iostream>
#define NMAX 100001
using namespace std;
int DP[NMAX][4], initial[NMAX][4], n, p;
void read() {
cin >> n;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= 2; j++) {
cin >> initial[i][j];
}
}
}
void solve() {
for (int i = 0; i <= 2; i++)
DP[1][i] = initial[1][i];
for (int i = 1; i <= n - 1; i++) {
for (int j = 0; j <= 2; j++) {
DP[i + 1][(j + 1) % 3] =
max(DP[i][j] + initial[i + 1][(j + 1) % 3], DP[i + 1][(j + 1) % 3]);
DP[i + 1][(j + 2) % 3] =
max(DP[i][j] + initial[i + 1][(j + 2) % 3], DP[i + 1][(j + 2) % 3]);
// DP[i+1][(j+3) % 3] = max(DP[i][j] + initial[i+1][(j+3)%3],
// DP[i+1][(j+3)%3]);
}
}
int maxx = 0;
for (int i = 0; i <= 2; i++) {
if (maxx < DP[n][i])
maxx = DP[n][i];
}
cout << maxx;
}
int main() {
read();
solve();
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,490 | 964,489 | u389532053 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<vector<int>> abc(n, vector<int>(3));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> abc[i][j];
vector<vector<int>> dp(n + 1, vector<int>(3, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i][j]);
}
}
}
cout << *max_element(dp[n].begin(), dp[n].end()) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<vector<int>> abc(n, vector<int>(3));
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
cin >> abc[i][j];
vector<vector<int>> dp(n + 1, vector<int>(3, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j == k)
continue;
dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[i][j]);
}
}
}
cout << *max_element(dp[n].begin(), dp[n].end()) << endl;
return 0;
} | [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,493 | 964,494 | u283229916 | cpp |
p03162 | #include <bits/stdc++.h>
#define int long long
#define N 100011
using namespace std;
const int INF = -(int)1e17;
int n, arr[N][3], opt[N][3];
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int res = INF;
if (i == 0)
res = arr[i][j];
else {
if (j == 0)
res = max(opt[i - 1][1], opt[i - 1][2]);
else if (j == 1)
res = max(opt[i - 1][0], opt[i - 1][2]);
else
res = max(opt[i - 1][0], opt[i - 1][1]);
res += arr[i][j];
}
opt[i][j] = res;
}
}
int ans = INF;
for (int i = 0; i < 3; i++)
ans = max(ans, opt[n - 1][i]);
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define int long long
#define N 100011
using namespace std;
const int INF = -(int)1e17;
int n, arr[N][3], opt[N][3];
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
int res = INF;
if (i == 0)
res = arr[i][j];
else {
if (j == 0)
res = max(opt[i - 1][1], opt[i - 1][2]);
else if (j == 1)
res = max(opt[i - 1][0], opt[i - 1][2]);
else
res = max(opt[i - 1][0], opt[i - 1][1]);
res += arr[i][j];
}
opt[i][j] = res;
}
}
int ans = INF;
for (int i = 0; i < 3; i++)
ans = max(ans, opt[n - 1][i]);
cout << ans << endl;
return 0;
}
| [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,497 | 964,498 | u800680442 | cpp |
p03162 | #include <algorithm>
#include <cassert>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359
int N;
int a[100000], b[100000], c[100000];
LL dp[100000][3][3];
LL solve(int now, int yesterdayActivity, int days) {
if (days >= 3)
return -MAX;
if (now == N)
return 0;
if (dp[now][yesterdayActivity][days] != -1)
return dp[now][yesterdayActivity][days];
int dayA = 1;
int dayB = 1;
int dayC = 1;
switch (yesterdayActivity) {
case 0:
dayA = days + 1;
break;
case 1:
dayB = days + 1;
break;
case 2:
dayC = days + 1;
break;
}
return dp[now][yesterdayActivity][days] =
max(a[now] + solve(now + 1, 0, dayA),
max(b[now] + solve(now + 1, 1, dayB),
c[now] + solve(now + 1, 2, dayC)));
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a[i] >> b[i] >> c[i];
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
dp[i][j][k] = -1;
}
}
}
cout << solve(0, 0, 0) << endl;
return 0;
} | #include <algorithm>
#include <cassert>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359
int N;
int a[100000], b[100000], c[100000];
LL dp[100000][3][3];
LL solve(int now, int yesterdayActivity, int days) {
if (days >= 2)
return -MAX;
if (now == N)
return 0;
if (dp[now][yesterdayActivity][days] != -1)
return dp[now][yesterdayActivity][days];
int dayA = 1;
int dayB = 1;
int dayC = 1;
switch (yesterdayActivity) {
case 0:
dayA = days + 1;
break;
case 1:
dayB = days + 1;
break;
case 2:
dayC = days + 1;
break;
}
return dp[now][yesterdayActivity][days] =
max(a[now] + solve(now + 1, 0, dayA),
max(b[now] + solve(now + 1, 1, dayB),
c[now] + solve(now + 1, 2, dayC)));
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a[i] >> b[i] >> c[i];
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
dp[i][j][k] = -1;
}
}
}
cout << solve(0, 0, 0) << endl;
return 0;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change"
] | 964,499 | 964,500 | u422592877 | cpp |
p03162 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.sync_with_stdio(false);
cin.tie();
vector<int> prev(3, 0);
vector<int> cur(3);
int N;
cin >> N;
cin >> cur[0] >> cur[1] >> cur[2];
for (int i = 1; i < N; ++i) {
std::swap(prev, cur);
for (int i = 0; i < 3; ++i) {
cin >> cur[i];
cur[i] += max(prev[(i + 1) ^ 3], prev[(i + 2) ^ 3]);
}
}
int ans = max(max(cur[0], cur[1]), cur[2]);
cout << ans;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.sync_with_stdio(false);
cin.tie();
vector<int> prev(3, 0);
vector<int> cur(3);
int N;
cin >> N;
cin >> cur[0] >> cur[1] >> cur[2];
for (int i = 1; i < N; ++i) {
std::swap(prev, cur);
for (int i = 0; i < 3; ++i) {
cin >> cur[i];
cur[i] += max(prev[(i + 1) % 3], prev[(i + 2) % 3]);
}
}
int ans = max(max(cur[0], cur[1]), cur[2]);
cout << ans;
return 0;
}
| [
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,501 | 964,502 | u046277696 | cpp |
p03162 | // *
// *
// * Created By :hozaifa wahid
// * "mai maut ko takia aur kafan ko chadar banakar sota hu"
// *------------------------------------
// * OS : Ubuntu 16.04
// * Language : CPP14
// * Editor : Sublime Text 3
// * C++ compiler : g++
// *
// *
// https://www.geeksforgeeks.org/find-the-point-where-maximum-intervals-overlap/
#include <bits/stdc++.h>
#define pb push_back
//#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d", &x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for (int i = 0; i < n; i++)
#define repc(i, n) for (int i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
ll MOD = 1000000007;
vector<ll> v[100055];
void sieve() {
for (int n = 1; n <= 100055; n++) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
// If divisors are equal, print only one
if (n / i == i)
v[n].push_back(i);
else // Otherwise print both
{
v[n].push_back(i);
v[n].push_back(n / i);
}
}
}
}
}
ll pw(ll a, ll b) {
if (b == 0)
return 1;
ll x = pw(a, b / 2);
x = (x * x) % MOD;
if (b % 2)
x = (x * a) % MOD;
return x;
}
ll n, s;
ll a[100005][3];
int ok = 0;
// ll res=0;
ll dp[100005];
ll mpi[3][100005];
ll go(ll i, ll prev) {
if (i == n - 1) {
// s=0;
return a[i][prev];
}
if (mpi[i][prev])
return mpi[i][prev];
else if (prev == 0) {
s = a[i][prev] + (max(go(i + 1, 2), go(i + 1, 1)));
mpi[i][prev] = s;
} else if (prev == 1) {
s = a[i][prev] + (max(go(i + 1, 2), go(i + 1, 0)));
mpi[i][prev] = s;
} else if (prev == 2) {
s = a[i][prev] + (max(go(i + 1, 0), go(i + 1, 1)));
mpi[i][prev] = s;
}
return s;
}
void solve() {
ll t;
t = 1;
while (t--) {
// ll n;
cin >> n;
// ll a[n];
FOR(i, 0, n)
FOR(j, 0, 3)
cin >> a[i][j], mpi[i][j] = 0;
ll res = max(go(0, 0), max(go(0, 1), go(0, 2)));
cout << res;
}
}
int main() {
std::ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int start = clock();
#ifdef ONLINE_JUDGE
#else
// freopen("input.in" , "r" , stdin);
// freopen("output.txt", "w", stdout);
#endif
solve();
int stop = clock();
#ifdef ONLINE_JUDGE
#else
// cout << setprecision(6) << fixed << (stop - start) * 1000.00 /
// double(CLOCKS_PER_SEC)<< endl;
#endif
}
| // *
// *
// * Created By :hozaifa wahid
// * "mai maut ko takia aur kafan ko chadar banakar sota hu"
// *------------------------------------
// * OS : Ubuntu 16.04
// * Language : CPP14
// * Editor : Sublime Text 3
// * C++ compiler : g++
// *
// *
// https://www.geeksforgeeks.org/find-the-point-where-maximum-intervals-overlap/
#include <bits/stdc++.h>
#define pb push_back
//#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d", &x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for (int i = 0; i < n; i++)
#define repc(i, n) for (int i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
ll MOD = 1000000007;
vector<ll> v[100055];
void sieve() {
for (int n = 1; n <= 100055; n++) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
// If divisors are equal, print only one
if (n / i == i)
v[n].push_back(i);
else // Otherwise print both
{
v[n].push_back(i);
v[n].push_back(n / i);
}
}
}
}
}
ll pw(ll a, ll b) {
if (b == 0)
return 1;
ll x = pw(a, b / 2);
x = (x * x) % MOD;
if (b % 2)
x = (x * a) % MOD;
return x;
}
ll n, s;
ll a[100005][3];
int ok = 0;
// ll res=0;
ll dp[100005];
ll mpi[100005][3];
ll go(ll i, ll prev) {
if (i == n - 1) {
// s=0;
return a[i][prev];
}
if (mpi[i][prev])
return mpi[i][prev];
else if (prev == 0) {
s = a[i][prev] + (max(go(i + 1, 2), go(i + 1, 1)));
mpi[i][prev] = s;
} else if (prev == 1) {
s = a[i][prev] + (max(go(i + 1, 2), go(i + 1, 0)));
mpi[i][prev] = s;
} else if (prev == 2) {
s = a[i][prev] + (max(go(i + 1, 0), go(i + 1, 1)));
mpi[i][prev] = s;
}
return s;
}
void solve() {
ll t;
t = 1;
while (t--) {
// ll n;
cin >> n;
// ll a[n];
FOR(i, 0, n)
FOR(j, 0, 3)
cin >> a[i][j], mpi[i][j] = 0;
ll res = max(go(0, 0), max(go(0, 1), go(0, 2)));
cout << res;
}
}
int main() {
std::ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int start = clock();
#ifdef ONLINE_JUDGE
#else
// freopen("input.in" , "r" , stdin);
// freopen("output.txt", "w", stdout);
#endif
solve();
int stop = clock();
#ifdef ONLINE_JUDGE
#else
// cout << setprecision(6) << fixed << (stop - start) * 1000.00 /
// double(CLOCKS_PER_SEC)<< endl;
#endif
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 964,503 | 964,504 | u872703130 | cpp |
p03162 | #include <algorithm>
#include <cstdio>
using namespace std;
int n, m, i, j, k, a, b, c, dp[500000][3], cc[500000][3];
int main() {
scanf("%d", &n, &k);
for (int i = 1; i <= n; i++)
for (int j = 0; j < 3; j++)
scanf("%d", &cc[i][j]);
// for (int i=2;i<=n;i++) for (int j=0;j<3;j++) dp[i][j]=9999999999;
for (int i = 1; i < n; i++) {
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
if (k != j)
dp[i][j] = max(dp[i][j], dp[i - 1][k] + cc[i][j]);
}
printf("%d\n", max(dp[n][2], max(dp[n][0], dp[n][1])));
return 0;
} | #include <algorithm>
#include <cstdio>
using namespace std;
int n, m, i, j, k, a, b, c, dp[500000][3], cc[500000][3];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++)
for (int j = 0; j < 3; j++)
scanf("%d", &cc[i][j]);
// for (int i=2;i<=n;i++) for (int j=0;j<3;j++) dp[i][j]=9999999999;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
if (k != j)
dp[i][j] = max(dp[i][j], dp[i - 1][k] + cc[i][j]);
}
printf("%d\n", max(dp[n][2], max(dp[n][0], dp[n][1])));
return 0;
} | [
"call.arguments.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 964,509 | 964,510 | u704549083 | cpp |
p03162 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<vector<int>> abc(N, vector<int>(3));
int a, b, c;
for (auto &i : abc)
cin >> i[0] >> i[1] >> i[2];
a = abc[0][0];
b = abc[0][1];
b = abc[0][2];
for (int i = 1; i < N; i++) {
int x = max(b, c) + abc[i][0];
int y = max(a, c) + abc[i][1];
int z = max(a, b) + abc[i][2];
a = x;
b = y;
c = z;
}
cout << max(a, max(b, c)) << '\n';
}
| #include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<vector<int>> abc(N, vector<int>(3));
int a, b, c;
for (auto &i : abc)
cin >> i[0] >> i[1] >> i[2];
a = abc[0][0];
b = abc[0][1];
c = abc[0][2];
for (int i = 1; i < N; i++) {
int x = max(b, c) + abc[i][0];
int y = max(a, c) + abc[i][1];
int z = max(a, b) + abc[i][2];
a = x;
b = y;
c = z;
}
cout << max(a, max(b, c)) << '\n';
}
| [
"assignment.variable.change",
"identifier.change"
] | 964,517 | 964,518 | u042026294 | cpp |
p03162 | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i, n) for (int i = 0; i < n; i++)
#define eREP(i, n) for (int i = 0; i <= n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define eFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define SORT(c) sort((c).begin(), (c).end())
#define rSORT(c) sort((c).rbegin(), (c).rend())
#define LB(x, a) lower_bound((x).begin(), (x).end(), (a))
#define UB(x, a) upper_bound((x).begin(), (x).end(), (a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
// vector<vector<int> > dp;
// vector<vector<vector<int> > > vvvi;
// dp=vector<vector<int> >(N, vector<int>(M,0));
// vector<pair<int,int> > v;
// v.push_back(make_pair(x,y));
// do {
// print(v);
// } while (std::next_permutation(v.begin(), v.end()));
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
VI dpa(N);
VI dpb(N);
VI dpc(N);
REP(i, N) {
int a, b, c;
cin >> a >> b >> c;
if (i == 0) {
dpa[i] = a;
dpb[i] = b;
dpc[i] = c;
} else {
dpa[i] = max(a + dpc[i - 1], b + dpb[i - 1]);
dpb[i] = max(b + dpc[i - 1], b + dpa[i - 1]);
dpc[i] = max(c + dpa[i - 1], c + dpb[i - 1]);
}
}
cout << max(dpa[N - 1], max(dpb[N - 1], dpc[N - 1])) << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i, n) for (int i = 0; i < n; i++)
#define eREP(i, n) for (int i = 0; i <= n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define eFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define SORT(c) sort((c).begin(), (c).end())
#define rSORT(c) sort((c).rbegin(), (c).rend())
#define LB(x, a) lower_bound((x).begin(), (x).end(), (a))
#define UB(x, a) upper_bound((x).begin(), (x).end(), (a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
// vector<vector<int> > dp;
// vector<vector<vector<int> > > vvvi;
// dp=vector<vector<int> >(N, vector<int>(M,0));
// vector<pair<int,int> > v;
// v.push_back(make_pair(x,y));
// do {
// print(v);
// } while (std::next_permutation(v.begin(), v.end()));
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
VI dpa(N);
VI dpb(N);
VI dpc(N);
REP(i, N) {
int a, b, c;
cin >> a >> b >> c;
if (i == 0) {
dpa[i] = a;
dpb[i] = b;
dpc[i] = c;
} else {
dpa[i] = max(a + dpc[i - 1], a + dpb[i - 1]);
dpb[i] = max(b + dpc[i - 1], b + dpa[i - 1]);
dpc[i] = max(c + dpa[i - 1], c + dpb[i - 1]);
}
}
cout << max(dpa[N - 1], max(dpb[N - 1], dpc[N - 1])) << endl;
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,519 | 964,520 | u266643907 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int maxi = 1e5 + 10;
int M[maxi][3];
long long dp[maxi][4];
long long f(int n, int hacer) {
if (n < 0)
return 0;
if (dp[n][hacer] != -1)
return dp[n][hacer];
long long ans = 0;
for (int i = 0; i < 3; i++) {
if (i == hacer)
continue;
ans = max(ans, M[n][hacer] + f(n - 1, i));
}
return dp[ans][hacer] = ans;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
cin >> M[i][j];
memset(dp, -1, sizeof(dp));
long long ans = -1;
for (int i = 0; i < 3; i++)
ans = max(ans, f(n - 1, i));
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int maxi = 1e5 + 10;
int M[maxi][3];
long long dp[maxi][4];
long long f(int n, int hacer) {
if (n < 0)
return 0;
if (dp[n][hacer] != -1)
return dp[n][hacer];
long long ans = 0;
for (int i = 0; i < 3; i++) {
if (i == hacer)
continue;
ans = max(ans, M[n][hacer] + f(n - 1, i));
}
return dp[n][hacer] = ans;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < 3; j++)
cin >> M[i][j];
memset(dp, -1, sizeof(dp));
long long ans = 0;
for (int i = 0; i < 3; i++)
ans = max(ans, f(n - 1, i));
cout << ans;
return 0;
} | [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change",
"function.return_value.change",
"literal.number.change",
"variable_declaration.value.change"
] | 964,533 | 964,534 | u380410396 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<vector<int>> vec(n, vector<int>(3));
vector<vector<int>> dp(n, vector<int>(3, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> vec[i][j];
}
}
dp[0][0] = vec[0][0];
dp[0][1] = vec[0][1];
dp[0][2] = vec[0][2];
for (int i = 1; i < n; i++) {
for (int j = 0; i < 3; j++) {
for (int k = 0; k < 3; k++) {
if (k == j)
continue;
dp[i][j] = max(dp[i][j], dp[i - 1][k] + vec[i][j]);
}
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<vector<int>> vec(n, vector<int>(3));
vector<vector<int>> dp(n, vector<int>(3, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> vec[i][j];
}
}
dp[0][0] = vec[0][0];
dp[0][1] = vec[0][1];
dp[0][2] = vec[0][2];
for (int i = 1; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (k == j)
continue;
dp[i][j] = max(dp[i][j], dp[i - 1][k] + vec[i][j]);
}
}
}
cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,535 | 964,536 | u823444917 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for (i = j; i < k; i++)
#define sep(i, j, k) for (i = j; i > k; i--)
const int N = 2e5 + 5, inf = 1e9 + 7;
int n, k, i, j;
int A[N][3];
int dp[N][3];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int i, j, a, b, ans = 0;
cin >> n;
rep(i, 1, n + 1) for (int j : {0, 1, 2}) cin >> A[i][j];
rep(i, 1, n + 2) for (int j : {0, 1, 2}) for (int k : {0, 1, 2}) if (j != k)
dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i][k]);
cout << min(dp[n + 1][0], dp[n + 1][1]);
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for (i = j; i < k; i++)
#define sep(i, j, k) for (i = j; i > k; i--)
const int N = 2e5 + 5, inf = 1e9 + 7;
int n, k, i, j;
int A[N][3];
int dp[N][3];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int i, j, a, b, ans = 0;
cin >> n;
rep(i, 1, n + 1) for (int j : {0, 1, 2}) cin >> A[i][j];
rep(i, 1, n + 2) for (int j : {0, 1, 2}) for (int k : {0, 1, 2}) if (j != k)
dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i][k]);
cout << max(dp[n + 1][0], dp[n + 1][1]);
} | [
"misc.opposites",
"identifier.change",
"call.function.change",
"io.output.change"
] | 964,537 | 964,538 | u761472821 | cpp |
p03162 | //============================================================================
// Name : c
// Date : Tue Feb 19 22:22:47 CST 2019
// Author : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) \
{ \
cout << x[a]; \
if (a < n - 1) \
cout << " "; \
}
#define pvi(x, v) \
if (v) \
pvar(x); \
fora(a, x) cout << a << " "; \
cout << "\n"
#define par(x, s, n, v) \
if (v) \
pvar(x); \
fori(y, s, n) prt(x, y, n) cout << "\n"
#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
void amax(int &a, int b) { a = max(a, b); }
void solve() {
int n, k;
cin >> n >> k;
vi dp(3, 0);
fori(day, 0, n) {
vi new_dp(3, 0), aa(3);
fori(i, 0, 3) { cin >> aa[i]; }
fori(i, 0, 3) fori(j, 0, 3) {
if (i != j) {
new_dp[j] = max(new_dp[j], dp[i] + aa[j]);
}
}
trace(dp, new_dp);
dp = new_dp;
}
output(max(max(dp[0], dp[1]), dp[2]));
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
| //============================================================================
// Name : c
// Date : Tue Feb 19 22:22:47 CST 2019
// Author : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) \
{ \
cout << x[a]; \
if (a < n - 1) \
cout << " "; \
}
#define pvi(x, v) \
if (v) \
pvar(x); \
fora(a, x) cout << a << " "; \
cout << "\n"
#define par(x, s, n, v) \
if (v) \
pvar(x); \
fori(y, s, n) prt(x, y, n) cout << "\n"
#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
void amax(int &a, int b) { a = max(a, b); }
void solve() {
int n;
cin >> n;
vi dp(3, 0);
fori(day, 0, n) {
vi new_dp(3, 0), aa(3);
fori(i, 0, 3) { cin >> aa[i]; }
fori(i, 0, 3) fori(j, 0, 3) {
if (i != j) {
new_dp[j] = max(new_dp[j], dp[i] + aa[j]);
}
}
trace(dp, new_dp);
dp = new_dp;
}
output(max(max(dp[0], dp[1]), dp[2]));
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
| [
"variable_declaration.remove",
"expression.operation.binary.remove"
] | 964,541 | 964,542 | u161007542 | cpp |
p03162 | /*
Author : Pranav_Raut.
*/
#include <bits/stdc++.h>
using namespace std;
#define input(arr, n) \
for (ll i = 0; i < n; i++) { \
cin >> arr[i]; \
}
typedef long long int ll;
ll MOD = 1000000007;
ll MAXN = 100005;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t = 1;
while (t--) {
/* JUST CODE TILL YOU CRACK IT !!! */
ll n;
cin >> n;
ll a[n], b[n], c[n];
for (ll i = 0; i < n; ++i) {
cin >> a[i] >> b[i] >> c[i];
}
for (ll i = n - 2; i >= 0; --i) {
a[i] += min(b[i + 1], c[i + 1]);
b[i] += min(a[i + 1], c[i + 1]);
c[i] += min(b[i + 1], a[i + 1]);
}
cout << min(a[0], min(b[0], c[0])) << endl;
}
return 0;
}
| /*
Author : Pranav_Raut.
*/
#include <bits/stdc++.h>
using namespace std;
#define input(arr, n) \
for (ll i = 0; i < n; i++) { \
cin >> arr[i]; \
}
typedef long long int ll;
ll MOD = 1000000007;
ll MAXN = 100005;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t = 1;
while (t--) {
/* JUST CODE TILL YOU CRACK IT !!! */
ll n;
cin >> n;
ll a[n], b[n], c[n];
for (ll i = 0; i < n; ++i) {
cin >> a[i] >> b[i] >> c[i];
}
for (ll i = n - 2; i >= 0; --i) {
a[i] += max(b[i + 1], c[i + 1]);
b[i] += max(a[i + 1], c[i + 1]);
c[i] += max(b[i + 1], a[i + 1]);
}
cout << max(a[0], max(b[0], c[0])) << endl;
}
return 0;
}
| [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change",
"io.output.change"
] | 964,543 | 964,544 | u743925717 | cpp |
p03162 | #include <bits/stdc++.h>
#pragma GCC_compile("Ofast")
using namespace std;
int N, MAX;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
vector<vector<int>> a(N);
for (int i = 0; i < N; i++) {
a[i] = vector<int>(3);
for (int &x : a[i])
cin >> x;
}
// dp[i] - the total cost such that we did activity i on the last day.
int dp[N][3];
for (int i = 0; i < N; i++) {
dp[i][0] = dp[i][1] = dp[i][2] = -1;
}
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < N; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k) {
dp[i][j] = max(dp[i][j], dp[i - 1][j] + a[i][k]);
}
}
}
}
cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]});
/*
for(auto x:a){
for(auto val:x){
cout<<val<<" ";
}
}
*/
return 0;
}
| #include <bits/stdc++.h>
#pragma GCC_compile("Ofast")
using namespace std;
int N, MAX;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
vector<vector<int>> a(N);
for (int i = 0; i < N; i++) {
a[i] = vector<int>(3);
for (int &x : a[i])
cin >> x;
}
// dp[i] - the total cost such that we did activity i on the last day.
int dp[N][3];
for (int i = 0; i < N; i++) {
dp[i][0] = dp[i][1] = dp[i][2] = -1;
}
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < N; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k) {
dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
}
}
}
}
cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]});
/*
for(auto x:a){
for(auto val:x){
cout<<val<<" ";
}
}
*/
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,545 | 964,546 | u368952837 | cpp |
p03162 | //----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------
#include <bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
const LL MOD = (1e9) + 7;
const LD EPS = 0.0000001;
const int N = 100000 + 50;
LL A[N], B[N], C[N];
int n;
LL cache[N][4];
LL solve(int idx, int last) {
if (idx == n + 1)
return 0;
LL &ans = cache[idx][last];
if (ans != -1) {
return ans;
}
if (last == 1) {
ans = min(solve(idx + 1, 2) + B[idx], solve(idx + 1, 3) + C[idx]);
} else if (last == 2) {
ans = min(solve(idx + 1, 1) + A[idx], solve(idx + 1, 3) + C[idx]);
} else {
ans = min(solve(idx + 1, 1) + A[idx], solve(idx + 1, 2) + B[idx]);
}
return ans;
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(cache, -1, sizeof(cache));
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> A[i] >> B[i] >> C[i];
}
LL ans = min(solve(2, 1) + A[1], solve(2, 2) + B[1]);
ans = min(ans, solve(2, 3) + C[1]);
cout << ans << endl;
return 0;
} | //----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------
#include <bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
const LL MOD = (1e9) + 7;
const LD EPS = 0.0000001;
const int N = 100000 + 50;
LL A[N], B[N], C[N];
int n;
LL cache[N][4];
LL solve(int idx, int last) {
if (idx == n + 1)
return 0;
LL &ans = cache[idx][last];
if (ans != -1) {
return ans;
}
if (last == 1) {
ans = max(solve(idx + 1, 2) + B[idx], solve(idx + 1, 3) + C[idx]);
} else if (last == 2) {
ans = max(solve(idx + 1, 1) + A[idx], solve(idx + 1, 3) + C[idx]);
} else {
ans = max(solve(idx + 1, 1) + A[idx], solve(idx + 1, 2) + B[idx]);
}
return ans;
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(cache, -1, sizeof(cache));
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> A[i] >> B[i] >> C[i];
}
LL ans = max(solve(2, 1) + A[1], solve(2, 2) + B[1]);
ans = max(ans, solve(2, 3) + C[1]);
cout << ans << endl;
return 0;
} | [
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change"
] | 964,547 | 964,548 | u109311178 | cpp |
p03162 | //----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------
#include <bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
const LL MOD = (1e9) + 7;
const LD EPS = 0.0000001;
const int N = 100000 + 50;
int A[N], B[N], C[N];
int n;
LL cache[N][4];
LL solve(int idx, int last) {
if (idx == n + 1)
return 0;
LL &ans = cache[idx][last];
if (ans != -1) {
return ans;
}
if (last == 1) {
ans = min(solve(idx + 1, 2) + B[idx], solve(idx + 1, 3) + C[idx]);
} else if (last == 2) {
ans = min(solve(idx + 1, 1) + A[idx], solve(idx + 1, 3) + C[idx]);
} else {
ans = min(solve(idx + 1, 1) + A[idx], solve(idx + 1, 2) + B[idx]);
}
return ans;
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(cache, -1, sizeof(cache));
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> A[i] >> B[i] >> C[i];
}
LL ans = min(solve(2, 1) + A[1], solve(2, 2) + B[1]);
ans = min(ans, solve(2, 3) + C[1]);
cout << ans << endl;
return 0;
} | //----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------
#include <bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
const LL MOD = (1e9) + 7;
const LD EPS = 0.0000001;
const int N = 100000 + 50;
LL A[N], B[N], C[N];
int n;
LL cache[N][4];
LL solve(int idx, int last) {
if (idx == n + 1)
return 0;
LL &ans = cache[idx][last];
if (ans != -1) {
return ans;
}
if (last == 1) {
ans = max(solve(idx + 1, 2) + B[idx], solve(idx + 1, 3) + C[idx]);
} else if (last == 2) {
ans = max(solve(idx + 1, 1) + A[idx], solve(idx + 1, 3) + C[idx]);
} else {
ans = max(solve(idx + 1, 1) + A[idx], solve(idx + 1, 2) + B[idx]);
}
return ans;
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(cache, -1, sizeof(cache));
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> A[i] >> B[i] >> C[i];
}
LL ans = max(solve(2, 1) + A[1], solve(2, 2) + B[1]);
ans = max(ans, solve(2, 3) + C[1]);
cout << ans << endl;
return 0;
} | [
"variable_declaration.type.change",
"misc.opposites",
"assignment.value.change",
"identifier.change",
"call.function.change"
] | 964,549 | 964,548 | u109311178 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int ans = 0;
void up(int &x, int y) {
if (x < y) {
x = y;
if (ans < y)
ans = y;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/// freopen("input.txt", "r", stdin);
int n;
cin >> n;
vector<vector<int>> a(n, vector<int>(3));
for (auto &v : a)
for (int &x : v)
cin >> x;
vector<vector<int>> dp(n, vector<int>(3));
for (int i = 0; i < 3; ++i)
dp[0][i] = a[0][i];
for (int i = 1; i < n; ++i)
for (int prev = 0; prev < 3; ++prev)
for (int cur = 0; cur < 3; ++cur)
if (prev != cur)
up(dp[i][cur], a[i][cur] + dp[i - 1][prev]);
cout << ans << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int ans = 0;
void up(int &x, int y) {
if (x < y) {
x = y;
if (ans < y)
ans = y;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/// freopen("input.txt", "r", stdin);
int n;
cin >> n;
vector<vector<int>> a(n, vector<int>(3));
for (auto &v : a)
for (int &x : v)
cin >> x;
vector<vector<int>> dp(n, vector<int>(3));
for (int i = 0; i < 3; ++i)
up(dp[0][i], a[0][i]);
for (int i = 1; i < n; ++i)
for (int prev = 0; prev < 3; ++prev)
for (int cur = 0; cur < 3; ++cur)
if (prev != cur)
up(dp[i][cur], a[i][cur] + dp[i - 1][prev]);
cout << ans << '\n';
return 0;
}
| [
"call.add",
"call.arguments.change"
] | 964,550 | 964,551 | u784576081 | cpp |
p03162 | #include <stdio.h>
#include <vector>
using namespace std;
const int C = 150001;
int n, k, a, b, c, dp[2][C];
int abs(int a) { return (a > 0) ? (a) : (-a); }
int main() {
int j;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d %d %d", &a, &b, &c);
dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a;
dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b;
dp[2][i] = max(dp[1][i - 1], dp[0][i - 1]) + c;
}
printf("%d\n", max(dp[2][n], max(dp[1][n], dp[0][n])));
return 0;
} | #include <stdio.h>
#include <vector>
using namespace std;
const int C = 150001;
int n, k, a, b, c, dp[3][C];
int abs(int a) { return (a > 0) ? (a) : (-a); }
int main() {
int j;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d %d %d", &a, &b, &c);
dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a;
dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b;
dp[2][i] = max(dp[1][i - 1], dp[0][i - 1]) + c;
}
printf("%d\n", max(dp[2][n], max(dp[1][n], dp[0][n])));
return 0;
} | [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 964,560 | 964,561 | u679729810 | cpp |
p03162 | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <ccomplex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define reft0(i, j) setfill('0') << setw(i) << j
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;
}
int main() {
ll N;
vector<ll> a;
vector<ll> b;
vector<ll> c;
cin >> N;
rep(i, 0, N) {
ll tempA, tempB, tempC;
cin >> tempA >> tempB >> tempC;
a.push_back(tempA);
b.push_back(tempB);
c.push_back(tempC);
}
ll ansA[100003];
ll ansB[100003];
ll ansC[100003];
rep(i, 0, 100010) {
ansA[i] = 0;
ansB[i] = 0;
ansC[i] = 0;
}
ansA[0] = a[0];
ansB[0] = b[0];
ansC[0] = c[0];
rep(idx, 1, N) {
chMax(ansA[idx], max(ansB[idx - 1], ansC[idx - 1]) + a[idx]);
chMax(ansB[idx], max(ansA[idx - 1], ansC[idx - 1]) + b[idx]);
chMax(ansC[idx], max(ansA[idx - 1], ansB[idx - 1]) + c[idx]);
}
cout << max(ansA[N - 1], max(ansB[N - 1], ansC[N - 1])) << endl;
return 0;
}
| #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <ccomplex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define reft0(i, j) setfill('0') << setw(i) << j
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;
}
int main() {
ll N;
vector<ll> a;
vector<ll> b;
vector<ll> c;
cin >> N;
rep(i, 0, N) {
ll tempA, tempB, tempC;
cin >> tempA >> tempB >> tempC;
a.push_back(tempA);
b.push_back(tempB);
c.push_back(tempC);
}
ll ansA[100003];
ll ansB[100003];
ll ansC[100003];
rep(i, 0, 100003) {
ansA[i] = 0;
ansB[i] = 0;
ansC[i] = 0;
}
ansA[0] = a[0];
ansB[0] = b[0];
ansC[0] = c[0];
rep(idx, 1, N) {
chMax(ansA[idx], max(ansB[idx - 1], ansC[idx - 1]) + a[idx]);
chMax(ansB[idx], max(ansA[idx - 1], ansC[idx - 1]) + b[idx]);
chMax(ansC[idx], max(ansA[idx - 1], ansB[idx - 1]) + c[idx]);
}
cout << max(ansA[N - 1], max(ansB[N - 1], ansC[N - 1])) << endl;
return 0;
}
| [
"literal.number.change",
"call.arguments.change"
] | 964,566 | 964,567 | u935056190 | cpp |
p03162 | #include <bits/stdc++.h>
#define F first
#define S second
#define endl "\n"
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define re0(i, a) for (int i = 0; i < (a); i++)
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 7 + 1e9;
const int inf = 1e9;
const int N = 1e5 + 5;
int a[N], b[N], c[N], n;
int dp[N][6];
int f(int i, int pre) {
if (i >= n)
return 0;
int &ret = dp[i][pre];
if (ret != -1)
return ret;
if (pre != 1)
ret = max(ret, a[i] + f(i + 1, 1));
if (pre != 2)
ret = max(ret, b[i] + f(i + 1, 2));
if (pre != 3)
ret = max(ret, c[i] + f(i + 1, 3));
return ret;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
#endif // ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
re0(i, n) cin >> a[i] >> b[i] >> c[i];
memset(dp, -1, sizeof dp);
cout << f(0, 0);
}
| #include <bits/stdc++.h>
#define F first
#define S second
#define endl "\n"
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define re0(i, a) for (int i = 0; i < (a); i++)
using namespace std;
typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 7 + 1e9;
const int inf = 1e9;
const int N = 1e5 + 5;
int a[N], b[N], c[N], n;
int dp[N][4];
int f(int i, int pre) {
if (i >= n)
return 0;
int &ret = dp[i][pre];
if (ret != -1)
return ret;
if (pre != 1)
ret = max(ret, a[i] + f(i + 1, 1));
if (pre != 2)
ret = max(ret, b[i] + f(i + 1, 2));
if (pre != 3)
ret = max(ret, c[i] + f(i + 1, 3));
return ret;
}
int main() {
#ifdef LOCAL
freopen("input.in", "r", stdin);
#endif // ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
re0(i, n) cin >> a[i] >> b[i] >> c[i];
memset(dp, -1, sizeof dp);
cout << f(0, 0);
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 964,568 | 964,569 | u465705011 | cpp |
p03162 | #include <bits/stdc++.h>
#define ll long long
#define OO 2e18
#define oo 1e9
#define yalla ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define FILES \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define sz 100005
#define re return
#define mod 1000000007
#define pi acos(-1)
using namespace std;
int n, ans[sz][3], a[sz], b[sz], c[sz];
int main() {
yalla;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
ans[0][0] = a[0], ans[0][1] = a[1], ans[0][2] = a[2];
///
for (int i = 1; i < n; i++) {
ans[i][0] = max(ans[i - 1][1], ans[i - 1][2]) + a[i];
ans[i][1] = max(ans[i - 1][0], ans[i - 1][2]) + b[i];
ans[i][2] = max(ans[i - 1][0], ans[i - 1][1]) + c[i];
}
cout << max(ans[n - 1][0], max(ans[n - 1][1], ans[n - 1][2])) << endl;
re 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define OO 2e18
#define oo 1e9
#define yalla ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define FILES \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define sz 100005
#define re return
#define mod 1000000007
#define pi acos(-1)
using namespace std;
int n, ans[sz][3], a[sz], b[sz], c[sz];
int main() {
yalla;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i] >> c[i];
ans[0][0] = a[0], ans[0][1] = b[0], ans[0][2] = c[0];
///
for (int i = 1; i < n; i++) {
ans[i][0] = max(ans[i - 1][1], ans[i - 1][2]) + a[i];
ans[i][1] = max(ans[i - 1][0], ans[i - 1][2]) + b[i];
ans[i][2] = max(ans[i - 1][0], ans[i - 1][1]) + c[i];
}
cout << max(ans[n - 1][0], max(ans[n - 1][1], ans[n - 1][2])) << endl;
re 0;
}
| [
"assignment.value.change",
"identifier.change",
"literal.number.change",
"variable_access.subscript.index.change"
] | 964,580 | 964,581 | u412213585 | cpp |
p03162 | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define FORR(i, j, k) for (int i = j; i >= k; i--)
#define ll long long
// Make sure no overflow problems
//#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define VAR(i, n) __typeof(n) i = (n)
#define FOREACH(i, c) for (VAR(i, (c).begin()); i != (c).end(); i++)
#define FORDEACH(i, c) for (VAR(i, (c).rbegin()), i != (c).rend(); i++)
#define REP(i, n) FOR(i, 0, n)
#define ld long double
const int INF = 1e9 + 7;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
using namespace std;
int main(void) {
int N;
cin >> N;
vector<int> activities(3);
vector<int> dp(3, 0);
for (int day = 0; day < N; day++) {
vector<int> new_dp(3, 0);
for (int i = 0; i < 3; i++) {
cin >> activities[i];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
new_dp[j] = max(new_dp[j], new_dp[i] + activities[j]);
}
}
}
dp = new_dp;
}
cout << max({dp[0], dp[1], dp[2]}) << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(i, j, k) for (int i = j; i < k; i++)
#define FORR(i, j, k) for (int i = j; i >= k; i--)
#define ll long long
// Make sure no overflow problems
//#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define VAR(i, n) __typeof(n) i = (n)
#define FOREACH(i, c) for (VAR(i, (c).begin()); i != (c).end(); i++)
#define FORDEACH(i, c) for (VAR(i, (c).rbegin()), i != (c).rend(); i++)
#define REP(i, n) FOR(i, 0, n)
#define ld long double
const int INF = 1e9 + 7;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;
using namespace std;
int main(void) {
int N;
cin >> N;
vector<int> activities(3);
vector<int> dp(3, 0);
for (int day = 0; day < N; day++) {
vector<int> new_dp(3, 0);
for (int i = 0; i < 3; i++) {
cin >> activities[i];
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
new_dp[j] = max(new_dp[j], dp[i] + activities[j]);
}
}
}
dp = new_dp;
}
cout << max({dp[0], dp[1], dp[2]}) << endl;
return 0;
} | [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 964,582 | 964,583 | u767717086 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
#define ll long long
const ll inf = 1e18;
int main() {
int n;
scanf("%d", &n);
vector<ll> c(3, 0);
vector<ll> dp(3, 0);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 3; ++j)
cin >> c[j];
vector<ll> ndp(3, 0);
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j != k) {
ndp[j] = max(ndp[j], dp[j] + c[k]);
}
}
}
dp = ndp;
}
ll ans = 0;
for (int i = 0; i < 3; ++i)
ans = max(ans, dp[i]);
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
#define ll long long
const ll inf = 1e18;
int main() {
int n;
scanf("%d", &n);
vector<ll> c(3, 0);
vector<ll> dp(3, 0);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 3; ++j)
cin >> c[j];
vector<ll> ndp(3, 0);
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 3; ++k) {
if (j != k) {
ndp[k] = max(ndp[k], dp[j] + c[k]);
}
}
}
dp = ndp;
}
ll ans = 0;
for (int i = 0; i < 3; ++i)
ans = max(ans, dp[i]);
cout << ans << endl;
return 0;
} | [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change",
"assignment.value.change",
"call.arguments.change"
] | 964,608 | 964,609 | u763404917 | cpp |
p03162 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector<T>>
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define rep(i, n) REP(i, 0, n) // 0, 1, ..., n-1
#define REP(i, x, n) for (int i = x; i < n; i++) // x, x + 1, ..., n-1
#define invrep(i, n) for (int i = (n)-1; i >= 0; i--) // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--) // n-1, n-2, ..., x
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define COUT(x) cout << (x) << endl
#define VECCIN(x) \
for (auto &youso_ : (x)) \
cin >> youso_
#define VECCOUT(x) \
for (auto &youso_ : (x)) \
cout << youso_ << " "; \
cout << endl
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
ll dp[100010][3];
ll a[100010][3];
int main() {
int N;
cin >> N;
rep(i, N) rep(j, 3) cin >> dp[i][j];
rep(i, N) {
rep(j, 3) {
rep(k, 3) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
ll res = 0;
rep(j, 3) chmax(res, dp[N][j]);
COUT(res);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector<T>>
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define rep(i, n) REP(i, 0, n) // 0, 1, ..., n-1
#define REP(i, x, n) for (int i = x; i < n; i++) // x, x + 1, ..., n-1
#define invrep(i, n) for (int i = (n)-1; i >= 0; i--) // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--) // n-1, n-2, ..., x
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define COUT(x) cout << (x) << endl
#define VECCIN(x) \
for (auto &youso_ : (x)) \
cin >> youso_
#define VECCOUT(x) \
for (auto &youso_ : (x)) \
cout << youso_ << " "; \
cout << endl
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
ll dp[100010][3];
ll a[100010][3];
int main() {
int N;
cin >> N;
rep(i, N) rep(j, 3) cin >> a[i][j];
rep(i, N) {
rep(j, 3) {
rep(k, 3) {
if (j == k)
continue;
chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
}
}
}
ll res = 0;
rep(j, 3) chmax(res, dp[N][j]);
COUT(res);
} | [
"identifier.change",
"expression.operation.binary.change"
] | 964,624 | 964,625 | u038027079 | cpp |
p03162 | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int n;
cin >> n;
int a[n][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
int dp[n][3];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; i++) {
for (int j = 0; j < 3; j++) {
dp[i][j] = 0;
}
}
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][0]) + a[i][2];
}
int ans = max(dp[n - 1][0], dp[n - 1][1]);
cout << max(ans, dp[n - 1][1]) << '\n';
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int n;
cin >> n;
int a[n][3];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
int dp[n][3];
dp[0][0] = a[0][0];
dp[0][1] = a[0][1];
dp[0][2] = a[0][2];
for (int i = 1; i < n; i++) {
for (int j = 0; j < 3; j++) {
dp[i][j] = 0;
}
}
for (int i = 1; i < n; i++) {
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + a[i][2];
}
int ans = max(dp[n - 1][0], dp[n - 1][1]);
cout << max(ans, dp[n - 1][2]) << '\n';
} | [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 964,630 | 964,631 | u430781070 | cpp |
p03162 | // Problem link - https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define INF 0x3f3f3f3f
#define mod 1000000007
int main() {
fast;
ll n;
cin >> n;
ll arr[n][3];
for (ll i = 0; i < 3; i++)
for (ll j = 0; j < 3; j++)
cin >> arr[i][j];
ll dp[n][3];
for (ll j = 0; j < 3; j++)
dp[n - 1][j] = arr[n - 1][j];
for (ll i = n - 2; i >= 0; i--) {
dp[i][0] = arr[i][0] + max(dp[i + 1][1], dp[i + 1][2]);
dp[i][1] = arr[i][1] + max(dp[i + 1][0], dp[i + 1][2]);
dp[i][2] = arr[i][2] + max(dp[i + 1][0], dp[i + 1][1]);
}
cout << max({dp[0][0], dp[0][1], dp[0][2]});
return 0;
} | // Problem link - https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define INF 0x3f3f3f3f
#define mod 1000000007
int main() {
fast;
ll n;
cin >> n;
ll arr[n][3];
for (ll i = 0; i < n; i++)
for (ll j = 0; j < 3; j++)
cin >> arr[i][j];
ll dp[n][3];
for (ll j = 0; j < 3; j++)
dp[n - 1][j] = arr[n - 1][j];
for (ll i = n - 2; i >= 0; i--) {
dp[i][0] = arr[i][0] + max(dp[i + 1][1], dp[i + 1][2]);
dp[i][1] = arr[i][1] + max(dp[i + 1][0], dp[i + 1][2]);
dp[i][2] = arr[i][2] + max(dp[i + 1][0], dp[i + 1][1]);
}
cout << max({dp[0][0], dp[0][1], dp[0][2]});
return 0;
} | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 964,632 | 964,633 | u266433281 | cpp |
p03162 | #include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll INF = -1;
int solve(void);
int main(void) {
while (solve()) {
}
return 0;
}
int solve(void) {
ll N;
cin >> N;
const int K = 3;
vector<vector<ll>> act(K, vector<ll>(N, 0));
for (int i = 0; i < N; i++)
for (int j = 0; j < K; j++)
cin >> act[j][i];
// dp[i][j] := 最後にiの行動をしたときの j 日目の幸福度の総和の最大値
vector<vector<ll>> dp(K, vector<ll>(N, INF));
for (int i = 0; i < N; i++) {
for (int j = 0; j < K; j++) {
for (int k = 0; k < K; k++) {
if (j != k) {
continue;
}
const ll prev = (i > 0) ? dp[j][i - 1] : 0;
const ll delta = act[k][i];
dp[k][i] =
(dp[k][i] == INF) ? prev + delta : max(dp[k][i], prev + delta);
}
}
}
ll ans = dp[0][N - 1];
for (int i = 0; i < K; i++)
if (dp[i][N - 1] != INF)
ans = max(dp[i][N - 1], ans);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll INF = -1;
int solve(void);
int main(void) {
while (solve()) {
}
return 0;
}
int solve(void) {
ll N;
cin >> N;
const int K = 3;
vector<vector<ll>> act(K, vector<ll>(N, 0));
for (int i = 0; i < N; i++)
for (int j = 0; j < K; j++)
cin >> act[j][i];
// dp[i][j] := 最後にiの行動をしたときの j 日目の幸福度の総和の最大値
vector<vector<ll>> dp(K, vector<ll>(N, INF));
for (int i = 0; i < N; i++) {
for (int j = 0; j < K; j++) {
for (int k = 0; k < K; k++) {
if (j == k) {
continue;
}
const ll prev = (i > 0) ? dp[j][i - 1] : 0;
const ll delta = act[k][i];
dp[k][i] =
(dp[k][i] == INF) ? prev + delta : max(dp[k][i], prev + delta);
}
}
}
ll ans = dp[0][N - 1];
for (int i = 0; i < K; i++)
if (dp[i][N - 1] != INF)
ans = max(dp[i][N - 1], ans);
cout << ans << endl;
return 0;
} | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 964,638 | 964,639 | u462237086 | cpp |
p03162 | #include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll INF = -1;
int solve(void);
int main(void) {
while (solve()) {
}
return 0;
}
int solve(void) {
ll N;
cin >> N;
const int K = 3;
vector<vector<ll>> act(K, vector<ll>(N, 0));
for (int i = 0; i < N; i++)
for (int j = 0; j < K; j++)
cin >> act[j][i];
// dp[i][j] := 最後にiの行動をしたときの j 日目の幸福度の総和の最大値
vector<vector<ll>> dp(K, vector<ll>(N, INF));
for (int i = 0; i < N; i++) {
for (int j = 0; j < K; j++) {
for (int k = 0; k < K; k++) {
if (i > 0 && j != k) {
continue;
}
const ll prev = (i > 0) ? dp[j][i - 1] : 0;
const ll delta = act[k][i];
dp[k][i] =
(dp[k][i] == INF) ? prev + delta : max(dp[k][i], prev + delta);
}
}
}
ll ans = dp[0][N - 1];
for (int i = 0; i < K; i++)
if (dp[i][N - 1] != INF)
ans = max(dp[i][N - 1], ans);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll INF = -1;
int solve(void);
int main(void) {
while (solve()) {
}
return 0;
}
int solve(void) {
ll N;
cin >> N;
const int K = 3;
vector<vector<ll>> act(K, vector<ll>(N, 0));
for (int i = 0; i < N; i++)
for (int j = 0; j < K; j++)
cin >> act[j][i];
// dp[i][j] := 最後にiの行動をしたときの j 日目の幸福度の総和の最大値
vector<vector<ll>> dp(K, vector<ll>(N, INF));
for (int i = 0; i < N; i++) {
for (int j = 0; j < K; j++) {
for (int k = 0; k < K; k++) {
if (j == k) {
continue;
}
const ll prev = (i > 0) ? dp[j][i - 1] : 0;
const ll delta = act[k][i];
dp[k][i] =
(dp[k][i] == INF) ? prev + delta : max(dp[k][i], prev + delta);
}
}
}
ll ans = dp[0][N - 1];
for (int i = 0; i < K; i++)
if (dp[i][N - 1] != INF)
ans = max(dp[i][N - 1], ans);
cout << ans << endl;
return 0;
} | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 964,640 | 964,639 | u462237086 | cpp |
p03162 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int dp[100001][3] = {0};
int h[100001][3];
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> h[i][j];
}
}
for (int i = 1; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k)
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + h[i][k]);
}
}
}
int v = 0;
for (int i = 0; i < 3; i++)
v = max(v, dp[n][i]);
cout << v << endl;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int dp[100001][3] = {0};
int h[100001][3];
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> h[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
if (j != k) {
dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + h[i][k]);
// printf("dp[%d][%d]=%d\n",i+1,k,dp[i+1][k]);
}
}
}
}
int v = 0;
for (int i = 0; i < 3; i++)
v = max(v, dp[n][i]);
cout << v << endl;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 964,641 | 964,642 | u192541825 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.