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 |
|---|---|---|---|---|---|---|---|
p03131 | #include <cstring>
#include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
if (a >= b || k - a + 1 <= 0)
cout << k + 1;
else {
k = k - a + 1;
if (k == 1)
cout << a + 1;
else if (k % 2 != 0)
cout << (k / 2) * b - (k / 2 - 1) * a + 1;
else
cout << (k / 2) * b - (k / 2 - 1) * a;
}
return 0;
}
| #include <cstring>
#include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
if (a + 1 >= b || k - a + 1 <= 0)
cout << k + 1;
else {
k = k - a + 1;
if (k == 1)
cout << a + 1;
else if (k % 2 != 0)
cout << (k / 2) * b - (k / 2 - 1) * a + 1;
else
cout << (k / 2) * b - (k / 2 - 1) * a;
}
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 933,520 | 933,521 | u387480576 | cpp |
p03131 | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int k, a, b;
cin >> k >> a >> b;
if (a >= b || k - a + 1 <= 0)
cout << k + 1;
else {
k = k - a + 1;
if (k == 1)
cout << a + 1;
else if (k % 2 != 0)
cout << (k / 2) * b - (k / 2 - 1) * a + 1;
else
cout << (k / 2) * b - (k / 2 - 1) * a;
}
return 0;
}
| #include <cstring>
#include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
if (a + 1 >= b || k - a + 1 <= 0)
cout << k + 1;
else {
k = k - a + 1;
if (k == 1)
cout << a + 1;
else if (k % 2 != 0)
cout << (k / 2) * b - (k / 2 - 1) * a + 1;
else
cout << (k / 2) * b - (k / 2 - 1) * a;
}
return 0;
}
| [
"variable_declaration.type.primitive.change",
"variable_declaration.type.widen.change",
"control_flow.branch.if.condition.change"
] | 933,522 | 933,521 | u387480576 | cpp |
p03131 | #include <iostream>
using namespace std;
int main() {
int no_of_operations, A, B;
cin >> no_of_operations >> A >> B;
long long max_biscuits = 0;
if (B <= A + 2) {
max_biscuits = no_of_operations + 1;
} else if (B > A) {
if (no_of_operations <= A) {
max_biscuits = no_of_operations + 1;
} else {
max_biscuits = B;
no_of_operations -= (A + 1);
int no_of_cycles = no_of_operations / 2;
long long gain = 0;
max_biscuits += no_of_cycles * gain;
no_of_operations %= 2;
while (no_of_operations > 0) {
max_biscuits++;
no_of_operations--;
}
}
}
cout << max_biscuits;
return 0;
}
| #include <iostream>
using namespace std;
int main() {
int no_of_operations, A, B;
cin >> no_of_operations >> A >> B;
long long max_biscuits = 0;
if (B <= A + 2) {
max_biscuits = no_of_operations + 1;
} else if (B > A) {
if (no_of_operations <= A) {
max_biscuits = no_of_operations + 1;
} else {
max_biscuits = B;
no_of_operations -= (A + 1);
int no_of_cycles = no_of_operations / 2;
long long gain = B - A;
max_biscuits += no_of_cycles * gain;
no_of_operations %= 2;
while (no_of_operations > 0) {
max_biscuits++;
no_of_operations--;
}
}
}
cout << max_biscuits;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove"
] | 933,523 | 933,524 | u927253988 | cpp |
p03131 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
typedef unsigned long long ll;
int main() {
ll k, a, b;
std::cin >> k >> a >> b;
b -= a;
ll ans = 1;
if (b <= 2)
std::cout << k + 1 << '\n';
else {
ll tmp = std::min(k, a - 1);
ans += tmp;
k -= tmp;
if (k % 2)
ans++, k--;
ans += k / 2 * (b);
std::cout << ans << '\n';
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
int main() {
ll k, a, b;
std::cin >> k >> a >> b;
b -= a;
ll ans = 1;
if (b <= 2)
std::cout << k + 1 << '\n';
else {
ll tmp = std::min(k, a - 1);
ans += tmp;
k -= tmp;
if (k % 2)
ans++, k--;
ans += k / 2 * (b);
std::cout << ans << '\n';
}
return 0;
} | [
"variable_declaration.type.narrow.change"
] | 933,546 | 933,547 | u176331779 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> p;
int main() {
ll k, a, b;
cin >> k >> a >> b;
ll res = 1;
ll num = 0;
num = a - 1;
ll nokori = k - num;
if (nokori < 2 || b < a * 2) {
cout << k + 1 << endl;
return 0;
}
res = a;
res += (b - a) * (nokori / 2);
if (nokori % 2 == 1) {
res++;
}
cout << res << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> p;
int main() {
ll k, a, b;
cin >> k >> a >> b;
ll res = 1;
ll num = 0;
num = a - 1;
ll nokori = k - num;
if (nokori < 2 || b - a <= 2) {
cout << k + 1 << endl;
return 0;
}
res = a;
res += (b - a) * (nokori / 2);
if (nokori % 2 == 1) {
res++;
}
cout << res << endl;
}
| [
"control_flow.branch.if.condition.change"
] | 933,561 | 933,562 | u916743460 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> p;
int main() {
ll k, a, b;
cin >> k >> a >> b;
ll res = 1;
ll num = 0;
num = a - 1;
ll nokori = k - num;
if (nokori < 2 || b <= a * 2) {
cout << k + 1 << endl;
return 0;
}
res = a;
res += (b - a) * (nokori / 2);
if (nokori % 2 == 1) {
res++;
}
cout << res << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> p;
int main() {
ll k, a, b;
cin >> k >> a >> b;
ll res = 1;
ll num = 0;
num = a - 1;
ll nokori = k - num;
if (nokori < 2 || b - a <= 2) {
cout << k + 1 << endl;
return 0;
}
res = a;
res += (b - a) * (nokori / 2);
if (nokori % 2 == 1) {
res++;
}
cout << res << endl;
}
| [
"control_flow.branch.if.condition.change"
] | 933,563 | 933,562 | u916743460 | cpp |
p03131 | #include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef unsigned long long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ul K, A, B;
cin >> K >> A >> B;
if (B - A <= 2) {
cout << K + 1 << endl;
return 0;
}
if (K < A + 1) {
cout << K + 1 << endl;
return 0;
}
if ((K - A + 1) % 2 == 0) {
cout << ((K - A + 1) / 2 * (B - A)) + A << endl;
} else {
cout << int((K - A + 1) / 2) * (B - A) + 1 + A << endl;
}
return 0;
} | #include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef unsigned long long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (B - A <= 2) {
cout << K + 1 << endl;
return 0;
}
if (K < A + 1) {
cout << K + 1 << endl;
return 0;
}
if ((K - A + 1) % 2 == 0) {
cout << ((K - A + 1) / 2 * (B - A)) + A << endl;
} else {
cout << (K - A) / 2 * (B - A) + 1 + A << endl;
}
return 0;
} | [
"variable_declaration.type.change",
"call.remove",
"expression.operation.binary.remove",
"call.arguments.change"
] | 933,564 | 933,565 | u276479653 | cpp |
p03131 | #include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
if ((b - a <= 2) || (k <= a)) {
cout << k + 1 << endl;
return 0;
} else {
if (a == 1) {
cout << ((k - a + 1) / 2) * (b - a) + a + (k % 2) << endl;
return 0;
} else {
cout << ((k - a + 1) / 2) * (b - a) + a + ((k - 1) % 2) << endl;
return 0;
}
}
} | #include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
if ((b - a <= 2) || (k <= a)) {
cout << k + 1 << endl;
return 0;
} else {
if (a == 1) {
cout << ((k - a + 1) / 2) * (b - a) + a + (k % 2) << endl;
return 0;
} else {
cout << ((k - a + 1) / 2) * (b - a) + a + ((k - a - 1) % 2) << endl;
return 0;
}
}
} | [
"expression.operation.binary.add"
] | 933,566 | 933,567 | u841641310 | cpp |
p03131 | #include <iostream>
using namespace std;
int main() {
unsigned long long k, a, b;
cin >> k >> a >> b;
if ((b - a <= 2) || (k <= a)) {
cout << k + 1 << endl;
return 0;
} else {
if (a == 1) {
cout << ((k - a + 1) / 2) * (b - a) + a + (k % 2) << endl;
return 0;
} else {
cout << ((k - a + 1) / 2) * (b - a) + a + ((k - 1) % 2) << endl;
return 0;
}
}
} | #include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
if ((b - a <= 2) || (k <= a)) {
cout << k + 1 << endl;
return 0;
} else {
if (a == 1) {
cout << ((k - a + 1) / 2) * (b - a) + a + (k % 2) << endl;
return 0;
} else {
cout << ((k - a + 1) / 2) * (b - a) + a + ((k - a - 1) % 2) << endl;
return 0;
}
}
} | [
"variable_declaration.type.narrow.change"
] | 933,568 | 933,567 | u841641310 | cpp |
p03131 | #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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A > B) {
cout << K + 1LL << endl;
return 0;
}
if (K - A - 1LL <= 0LL) {
cout << K + 1LL << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << 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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A + 2LL >= B) {
cout << K + 1LL << endl;
return 0;
}
if (K - A - 1LL < 0LL) {
cout << K + 1LL << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change",
"expression.operator.compare.change"
] | 933,573 | 933,571 | u435321965 | cpp |
p03131 | #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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A > B) {
cout << K + 1LL << endl;
return 0;
}
if (K - A - 1LL < 0LL) {
cout << K + 1LL << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << 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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A + 2LL >= B) {
cout << K + 1LL << endl;
return 0;
}
if (K - A - 1LL < 0LL) {
cout << K + 1LL << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 933,574 | 933,571 | u435321965 | cpp |
p03131 | #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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A > B) {
cout << K + 1LL << endl;
return 0;
}
if (K - A - 1LL < 0) {
cout << K + 1LL << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << 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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A + 2LL >= B) {
cout << K + 1LL << endl;
return 0;
}
if (K - A - 1LL < 0LL) {
cout << K + 1LL << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 933,575 | 933,571 | u435321965 | cpp |
p03131 | #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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A >= B) {
cout << K + 1 << endl;
return 0;
}
if (K - A - 1LL < 0) {
cout << K + 1 << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << 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;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define foreach(c, itr) \
for (__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (A + 2LL >= B) {
cout << K + 1LL << endl;
return 0;
}
if (K - A - 1LL < 0LL) {
cout << K + 1LL << endl;
return 0;
}
ll q = (K - A - 1LL) / 2LL, r = (K - A - 1LL) % 2LL;
cout << B + q * (B - A) + r << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change",
"literal.number.type.widen.change"
] | 933,576 | 933,571 | u435321965 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n = 0, a = 0, b = 0;
cin >> n >> a >> b;
long long int dif = b - a;
long long int res = 0;
if (dif <= 1)
cout << (n + 1) << endl;
else {
// cout << "in" << endl;
long long int m = n;
res = 0;
n = n - (a);
// cout << "dif -> "<< dif << ", n - >" << n << endl;
if (n % 2 == 0)
res++;
n /= 2;
res += n * b + ((n - 1) * a);
res = max(m + 1, res);
cout << res << endl;
}
// cout << 58507834935779158 - 48518828981938099 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n = 0, a = 0, b = 0;
cin >> n >> a >> b;
long long int dif = b - a;
long long int res = 0;
if (dif <= 1)
cout << (n + 1) << endl;
else {
// cout << "in" << endl;
long long int m = n;
res = 0;
n = n - (a);
// cout << "dif -> "<< dif << ", n - >" << n;
if (n % 2 == 0)
res++;
else
n++;
n /= 2;
res += n * b - ((n - 1) * a);
// cout << ", nn -> " << n << ", res -> "<< res << endl;
res = max(m + 1, res);
cout << res << endl;
}
// cout << 58507834935779158 - 48518828981938099 << endl;
return 0;
}
// 314159265
// 35897932
// 384626433 | [
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add",
"expression.unary.arithmetic.add",
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 933,577 | 933,578 | u031482407 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
long long K, A, B;
long long biscuit = 1; //,yen = 0;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> K >> A >> B;
if (A + 2 < B) {
if (K >= A + 1) {
K -= A + 1;
biscuit += B - 1;
}
while (K >= 2) {
K -= 2;
biscuit += B - A;
}
}
cout << biscuit + K << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
long long K, A, B;
long long biscuit = 1; //,yen = 0;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> K >> A >> B;
if (A + 2 < B) {
if (K >= A + 1) {
K -= A + 1;
biscuit += B - 1;
while (K >= 2) {
K -= 2;
biscuit += B - A;
}
}
}
cout << biscuit + K << endl;
}
| [] | 933,585 | 933,586 | u325820449 | cpp |
p03131 | #include <iostream>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define int long long
using namespace std;
signed main() {
int k, a, b;
int sum = 1;
cin >> k >> a >> b;
if (k < a) {
sum += k;
k = 0;
} else {
sum += (a - 1);
k -= (a - 1);
}
while (k > 0) {
if (b > a && k > 1 && (b - a) > k / 2) {
sum += k / 2 * (b - a);
k %= 2;
} else {
sum += k;
k = 0;
}
}
cout << sum << endl;
return 0;
} | #include <iostream>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define int long long
using namespace std;
signed main() {
int k, a, b;
int sum = 1;
cin >> k >> a >> b;
if (k < a) {
sum += k;
k = 0;
} else {
sum += (a - 1);
k -= (a - 1);
}
while (k > 0) {
if (b > a && k > 1 && (b - a) > 2) {
sum += k / 2 * (b - a);
k %= 2;
} else {
sum += k;
k = 0;
}
}
cout << sum << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 933,587 | 933,588 | u021140967 | cpp |
p03131 | #include <iostream>
using namespace std;
int main(void) {
long long K, A, B;
int check = 1;
long long count = 0;
long long pre_K;
cin >> K >> A >> B;
pre_K = K;
int i;
if (K == 1 || K <= A - 1) {
cout << K + 1 << endl;
} else if (A >= B - 1) {
cout << K + 1 << endl;
} else {
while (K > 1) {
if (check == 1 && A != 1 && K > A) {
K = K - A + 1;
check = 0;
pre_K = A;
}
if (check == 1) {
pre_K = A;
check = 0;
}
if (pre_K >= A) {
pre_K = pre_K - A + B;
K = K - 2;
// count ++;
// pre_K = pre_K -2;
}
}
cout << K + pre_K << endl;
}
return 0;
}
| #include <iostream>
using namespace std;
int main(void) {
long long K, A, B;
int check = 1;
long long count = 0;
long long pre_K;
cin >> K >> A >> B;
pre_K = K;
int i;
if (K == 1 || K <= A) {
cout << K + 1 << endl;
} else if (A >= B - 1) {
cout << K + 1 << endl;
} else {
while (K > 1) {
if (check == 1 && A != 1) {
K = K - A + 1;
check = 0;
pre_K = A;
}
if (check == 1) {
pre_K = A;
check = 0;
}
if (pre_K >= A) {
pre_K = pre_K - A + B;
K = K - 2;
// count ++;
// pre_K = pre_K -2;
}
}
cout << K + pre_K << endl;
}
return 0;
} | [
"expression.operation.binary.remove"
] | 933,604 | 933,605 | u586244382 | cpp |
p03131 | #include <iostream>
using namespace std;
int main(void) {
long long K, A, B;
int check = 1;
long long count = 0;
long long pre_K;
cin >> K >> A >> B;
pre_K = K;
int i;
if (K == 1) {
cout << K + 1 << endl;
} else if (A >= B - 1) {
cout << K + 1 << endl;
} else {
while (K > 1) {
if (check == 1 && A != 1) {
K = K - A + 1;
check = 0;
pre_K = A;
}
if (check == 1) {
pre_K = A;
check = 0;
}
if (pre_K >= A) {
pre_K = pre_K - A + B;
K = K - 2;
// count ++;
// pre_K = pre_K -2;
}
}
cout << K + pre_K << endl;
}
return 0;
}
| #include <iostream>
using namespace std;
int main(void) {
long long K, A, B;
int check = 1;
long long count = 0;
long long pre_K;
cin >> K >> A >> B;
pre_K = K;
int i;
if (K == 1 || K <= A) {
cout << K + 1 << endl;
} else if (A >= B - 1) {
cout << K + 1 << endl;
} else {
while (K > 1) {
if (check == 1 && A != 1) {
K = K - A + 1;
check = 0;
pre_K = A;
}
if (check == 1) {
pre_K = A;
check = 0;
}
if (pre_K >= A) {
pre_K = pre_K - A + B;
K = K - 2;
// count ++;
// pre_K = pre_K -2;
}
}
cout << K + pre_K << endl;
}
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 933,606 | 933,605 | u586244382 | cpp |
p03131 | #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)
int main(int argc, char **argv) {
std::cin.tie(0);
std::ios_base::sync_with_stdio(0);
std::cout << std::fixed << std::setprecision(6);
std::cerr << std::fixed << std::setprecision(6);
long long K, A, B;
std::cin >> K >> A >> B;
if (A + 1 >= B) {
std::cout << K + 1 << std::endl;
} else if (K < A) {
std::cout << K + 1 << std::endl;
} else {
int c = K - (A + 1), q = c / 2, r = c % 2;
std::cout << B + q * (B - A) + r << std::endl;
}
return 0;
}
| #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)
int main(int argc, char **argv) {
std::cin.tie(0);
std::ios_base::sync_with_stdio(0);
std::cout << std::fixed << std::setprecision(6);
std::cerr << std::fixed << std::setprecision(6);
long long K, A, B;
std::cin >> K >> A >> B;
if (A + 1 >= B) {
std::cout << K + 1 << std::endl;
} else if (K <= A) {
std::cout << K + 1 << std::endl;
} else {
int c = K - (A + 1), q = c / 2, r = c % 2;
std::cout << B + q * (B - A) + r << std::endl;
}
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 933,617 | 933,618 | u629650917 | cpp |
p03131 | #include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
long long it;
long long res;
if (b <= (a + 2))
res = 1 + k;
else {
it = (k - a - 1) / 2;
res = 1 + k + it * (b - a - 2);
}
cout << res << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main() {
long long k, a, b;
cin >> k >> a >> b;
long long it;
long long res;
if (b <= (a + 2))
res = 1 + k;
else {
it = (k - a + 1) / 2;
res = 1 + k + it * (b - a - 2);
}
cout << res << endl;
return 0;
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 933,639 | 933,640 | u462329577 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
namespace io {
const int L = (1 << 20) + 1;
char buf[L], *S, *T, c;
char getchar() {
if (__builtin_expect(S == T, 0)) {
T = (S = buf) + fread(buf, 1, L, stdin);
return (S == T ? EOF : *S++);
}
return *S++;
}
int inp() {
int x = 0, f = 1;
char ch;
for (ch = getchar(); !isdigit(ch); ch = getchar())
if (ch == '-')
f = -1;
for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
;
return x * f;
}
unsigned inpu() {
unsigned x = 0;
char ch;
for (ch = getchar(); !isdigit(ch); ch = getchar())
;
for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
;
return x;
}
ll inp_ll() {
ll x = 0;
int f = 1;
char ch;
for (ch = getchar(); !isdigit(ch); ch = getchar())
if (ch == '-')
f = -1;
for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
;
return x * f;
}
char B[25], *outs = B + 20, *outr = B + 20;
template <class T> inline void print(register T a, register char x = 0) {
if (x)
*--outs = x, x = 0;
if (!a)
*--outs = '0';
else
while (a)
*--outs = (a % 10) + 48, a /= 10;
if (x)
*--outs = x;
fwrite(outs, outr - outs, 1, stdout);
outs = outr;
}
}; // namespace io
using io ::inp;
using io ::inp_ll;
using io ::inpu;
using io ::print;
const int maxN = 1e5;
struct node {
ll cnt, mon;
} F[maxN];
int a[maxN];
int main() {
int K = inp();
ll A = inp_ll();
ll B = inp_ll();
ll ans = 0;
if (B - A <= 2 && K <= A) {
ans = 1 + K;
cout << ans << endl;
return 0;
} else {
ans = A + (K - A + 1) / 2 * (B - A) + (K - A + 1) % 2;
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
namespace io {
const int L = (1 << 20) + 1;
char buf[L], *S, *T, c;
char getchar() {
if (__builtin_expect(S == T, 0)) {
T = (S = buf) + fread(buf, 1, L, stdin);
return (S == T ? EOF : *S++);
}
return *S++;
}
int inp() {
int x = 0, f = 1;
char ch;
for (ch = getchar(); !isdigit(ch); ch = getchar())
if (ch == '-')
f = -1;
for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
;
return x * f;
}
unsigned inpu() {
unsigned x = 0;
char ch;
for (ch = getchar(); !isdigit(ch); ch = getchar())
;
for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
;
return x;
}
ll inp_ll() {
ll x = 0;
int f = 1;
char ch;
for (ch = getchar(); !isdigit(ch); ch = getchar())
if (ch == '-')
f = -1;
for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
;
return x * f;
}
char B[25], *outs = B + 20, *outr = B + 20;
template <class T> inline void print(register T a, register char x = 0) {
if (x)
*--outs = x, x = 0;
if (!a)
*--outs = '0';
else
while (a)
*--outs = (a % 10) + 48, a /= 10;
if (x)
*--outs = x;
fwrite(outs, outr - outs, 1, stdout);
outs = outr;
}
}; // namespace io
using io ::inp;
using io ::inp_ll;
using io ::inpu;
using io ::print;
const int maxN = 1e5;
struct node {
ll cnt, mon;
} F[maxN];
int a[maxN];
int main() {
int K = inp();
ll A = inp_ll();
ll B = inp_ll();
ll ans = 0;
if (B - A <= 2 || K <= A) {
ans = 1 + K;
cout << ans << endl;
return 0;
} else {
ans = A + (K - A + 1) / 2 * (B - A) + (K - A + 1) % 2;
cout << ans << endl;
}
return 0;
} | [
"misc.opposites",
"control_flow.branch.if.condition.change"
] | 933,647 | 933,648 | u807919574 | cpp |
p03131 | #include <iostream>
using namespace std;
int main() {
long long int K, A, B;
cin >> K >> A >> B;
long long int max = 0;
max = K + 1;
int mh = 0;
mh = max;
int ct = 1;
if (B - A > 2) {
if ((K + 1 - A) % 2 == 0) {
max = A + (B - A) * (K + 1 - A) / 2;
} else {
max = A + (B - A) * (K + 1 - A) / 2 + 1;
}
}
/*
while(1){
mh=mh-2*ct;
if(mh<0){
break;
}
mh=mh+(B-A)*ct;
if(mh>max){
max=mh;
}else{
break;
}
mh=K+1;
ct++;
}
*/
cout << max << endl;
} | #include <iostream>
using namespace std;
int main() {
long long int K, A, B;
cin >> K >> A >> B;
long long int max = 0;
max = K + 1;
int mh = 0;
mh = max;
int ct = 1;
if (B - A > 2) {
if ((K + 1 - A) % 2 == 0) {
max = A + (B - A) * ((K + 1 - A) / 2);
} else {
max = A + (B - A) * ((K + 1 - A) / 2) + 1;
}
}
/*
while(1){
mh=mh-2*ct;
if(mh<0){
break;
}
mh=mh+(B-A)*ct;
if(mh>max){
max=mh;
}else{
break;
}
mh=K+1;
ct++;
}
*/
cout << max << endl;
} | [] | 933,655 | 933,656 | u724063025 | cpp |
p03131 | #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (B - A == 1) {
cout << K + 1 << endl;
return 0;
}
ll temp1 = 0, temp2 = 0, ans = 0, diff = 0;
ans = B;
diff = B - A;
temp1 = K - (A + 1);
temp2 = temp1 / 2;
if (temp1 % 2 == 0) {
ans += diff * temp2;
} else {
temp2 = (temp1 - 1) / 2;
ans += diff * temp2;
ans++;
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll K, A, B;
cin >> K >> A >> B;
if (B - A <= 1) {
cout << K + 1 << endl;
return 0;
}
ll temp1 = 0, temp2 = 0, ans = 0, diff = 0;
ans = B;
diff = B - A;
temp1 = K - (A + 1);
temp2 = temp1 / 2;
if (temp1 % 2 == 0) {
ans += diff * temp2;
} else {
temp2 = (temp1 - 1) / 2;
ans += diff * temp2;
ans++;
}
cout << ans << endl;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 933,661 | 933,662 | u199371251 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll k, m, ans, a, b;
ll t[1 << 17], d[1 << 17];
vector<ll> u, v;
int main() {
cin >> k >> a >> b;
ans = 1;
if (a + 1 >= b || a > k - 1) {
cout << k + 1 << endl;
return 0;
} else {
ans = a;
k -= a - 3;
ans = b;
ans += (b - a) * (k / 2) + k % 2;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll k, m, ans, a, b;
ll t[1 << 17], d[1 << 17];
vector<ll> u, v;
int main() {
cin >> k >> a >> b;
ans = 1;
if (a + 1 >= b || a > k - 1) {
cout << k + 1 << endl;
return 0;
} else {
ans = a;
k -= a + 1;
ans = b;
ans += (b - a) * (k / 2) + k % 2;
}
cout << ans << endl;
}
| [] | 933,663 | 933,664 | u394482932 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9 + 7;
// Int MOD = 998244353;
int main() {
ios::sync_with_stdio(false);
Int k, a, b;
cin >> k >> a >> b;
if (a + 2 >= b) {
dump(k + 1);
return 0;
}
if (k <= a + 1) {
dump(k);
return 0;
}
Int res = b;
k -= (a - 1) + 2;
res += (k / 2) * (b - a);
if (k % 2 == 1)
res++;
dump(res);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9 + 7;
// Int MOD = 998244353;
int main() {
ios::sync_with_stdio(false);
Int k, a, b;
cin >> k >> a >> b;
if (a + 2 >= b) {
dump(k + 1);
return 0;
}
if (k < a + 1) {
dump(k + 1);
return 0;
}
Int res = b;
k -= (a - 1) + 2;
res += (k / 2) * (b - a);
if (k % 2 == 1)
res++;
dump(res);
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 933,667 | 933,666 | u572665222 | cpp |
p03131 | #include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9 + 7;
// Int MOD = 998244353;
int main() {
ios::sync_with_stdio(false);
Int k, a, b;
cin >> k >> a >> b;
if (a + 1 >= b) {
dump(k + 1);
return 0;
}
if (k <= a + 1) {
dump(k);
return 0;
}
Int res = b;
k -= (a - 1) + 2;
res += (k / 2) * (b - a);
if (k % 2 == 1)
res++;
dump(res);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9 + 7;
// Int MOD = 998244353;
int main() {
ios::sync_with_stdio(false);
Int k, a, b;
cin >> k >> a >> b;
if (a + 2 >= b) {
dump(k + 1);
return 0;
}
if (k < a + 1) {
dump(k + 1);
return 0;
}
Int res = b;
k -= (a - 1) + 2;
res += (k / 2) * (b - a);
if (k % 2 == 1)
res++;
dump(res);
return 0;
} | [
"literal.number.change",
"control_flow.branch.if.condition.change",
"expression.operator.compare.change"
] | 933,668 | 933,666 | u572665222 | cpp |
p03131 | #include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long K, A, B;
cin >> K >> A >> B;
long long ans = 0;
if (B - A > 2 && K >= 2) {
K = K - (A + 1);
long long a_num = K / 2;
long long k_num = K % 2;
ans = a_num * (B - A) + B;
ans += k_num;
} else {
ans = K + 1;
}
cout << ans;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long K, A, B;
cin >> K >> A >> B;
long long ans = 0;
if (K > A && B - A > 2 && K >= 2) {
K = K - (A + 1);
long long a_num = K / 2;
long long k_num = K % 2;
ans = a_num * (B - A) + B;
ans += k_num;
} else {
ans = K + 1;
}
cout << ans;
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 933,688 | 933,689 | u758765597 | cpp |
p03131 | #include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long K, A, B;
cin >> K >> A >> B;
long long ans = 0;
if (B - A > 2 && K > 2) {
K = K - (A + 1);
long long a_num = K / 2;
long long k_num = K % 2;
ans = a_num * (B - A) + B;
ans += k_num;
} else {
ans = K + 1;
}
cout << ans;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long K, A, B;
cin >> K >> A >> B;
long long ans = 0;
if (K > A && B - A > 2 && K >= 2) {
K = K - (A + 1);
long long a_num = K / 2;
long long k_num = K % 2;
ans = a_num * (B - A) + B;
ans += k_num;
} else {
ans = K + 1;
}
cout << ans;
return 0;
} | [
"control_flow.branch.if.condition.change",
"expression.operator.compare.change"
] | 933,690 | 933,689 | u758765597 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int, int, int> tpl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define EXIST(m, v) (m).find((v)) != (m).end()
#define LB(a, x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a, x) upper_bound((a).begin(), (a).end(), x) - (a).begin()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define RREP(i, n) RFOR(i, n, 0)
#define en "\n"
constexpr double EPS = 1e-9;
constexpr double PI = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL << 60;
constexpr long long MOD = 1000000007; // 998244353;
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
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;
}
void Main() {
int L;
cin >> L;
VL A(L);
REP(i, L) cin >> A[i];
ll dp[L + 1][5];
REP(i, L + 1) REP(j, 5) dp[i][j] = LINF;
REP(i, 5) dp[0][i] = 0;
REP(i, L) REP(j, 5) {
if (j == 0 || j == 4)
chmin(dp[i + 1][j], dp[i][j] + A[i]);
else if (j == 2)
chmin(dp[i + 1][j], dp[i][j] + (A[i] % 2 != 1));
else if (j < 4) {
if (A[i] > 0)
chmin(dp[i + 1][j], dp[i][j] + (A[i] % 2 != 0));
else
chmin(dp[i + 1][j], dp[i][j] + 2);
}
if (j < 4)
chmin(dp[i + 1][j + 1], dp[i + 1][j]);
}
ll ans = dp[L][4];
cout << ans << en;
return;
}
int main(void) {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cout << fixed << setprecision(15);
int t = 1;
cin >> t;
REP(_, t) Main();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int, int, int> tpl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define EXIST(m, v) (m).find((v)) != (m).end()
#define LB(a, x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a, x) upper_bound((a).begin(), (a).end(), x) - (a).begin()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define RREP(i, n) RFOR(i, n, 0)
#define en "\n"
constexpr double EPS = 1e-9;
constexpr double PI = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL << 60;
constexpr long long MOD = 1000000007; // 998244353;
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
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;
}
void Main() {
int L;
cin >> L;
VL A(L);
REP(i, L) cin >> A[i];
ll dp[L + 1][5];
REP(i, L + 1) REP(j, 5) dp[i][j] = LINF;
REP(i, 5) dp[0][i] = 0;
REP(i, L) REP(j, 5) {
if (j == 0 || j == 4)
chmin(dp[i + 1][j], dp[i][j] + A[i]);
else if (j == 2)
chmin(dp[i + 1][j], dp[i][j] + (A[i] % 2 != 1));
else if (j < 4) {
if (A[i] > 0)
chmin(dp[i + 1][j], dp[i][j] + (A[i] % 2 != 0));
else
chmin(dp[i + 1][j], dp[i][j] + 2);
}
if (j < 4)
chmin(dp[i + 1][j + 1], dp[i + 1][j]);
}
ll ans = dp[L][4];
cout << ans << en;
return;
}
int main(void) {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cout << fixed << setprecision(15);
int t = 1; // cin>>t;
REP(_, t) Main();
return 0;
} | [] | 933,695 | 933,696 | u934272719 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL << 61;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = jou(N, P / 2);
return t * t % mod;
}
return (N * jou(N, P - 1)) % mod;
} // jou(n,mod-2)で逆元
// intの最大値2147483647 ≒ 2×10^9
// long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32; で小文字に
// cout << fixed << setprecision (20); 小数点以下20桁まで
//実行時間制約2秒では2×10^8回くらいまで計算できる
int main() {
ll n;
cin >> n;
vector<ll> p(n);
rep(i, n) { cin >> p[i]; }
vector<vector<ll>> ans(n + 10, vector<ll>(5, INF));
rep(i, 5) { ans[0][i] = 0; }
rep(i, n) {
chmin(ans[i + 1][0], ans[i][0] + p[i]);
if (p[i] == 0)
chmin(ans[i + 1][1], min(ans[i][0], ans[i][1]) + 2);
else
chmin(ans[i + 1][1], min(ans[i][0], ans[i][1]) + p[i] % 2);
chmin(ans[i + 1][2],
min({ans[i][0], ans[i][1], ans[i][2]}) + (p[i] + 1) % 2);
if (p[i] == 0)
chmin(ans[i + 1][3],
min({ans[i][0], ans[i][1], ans[i][2], ans[i][3]}) + 2);
chmin(ans[i + 1][3],
min({ans[i][0], ans[i][1], ans[i][2], ans[i][3]}) + p[i] % 2);
chmin(ans[i + 1][4],
min({ans[i][0], ans[i][1], ans[i][2], ans[i][3], ans[i][4]}) + p[i]);
}
ll an = INF;
rep(i, 5) { chmin(an, ans[n][i]); }
cout << an << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repo(i, n) for (int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL << 61;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P) {
if (P == 0)
return 1;
if (P % 2 == 0) {
ll t = jou(N, P / 2);
return t * t % mod;
}
return (N * jou(N, P - 1)) % mod;
} // jou(n,mod-2)で逆元
// intの最大値2147483647 ≒ 2×10^9
// long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32; で小文字に
// cout << fixed << setprecision (20); 小数点以下20桁まで
//実行時間制約2秒では2×10^8回くらいまで計算できる
int main() {
ll n;
cin >> n;
vector<ll> p(n);
rep(i, n) { cin >> p[i]; }
vector<vector<ll>> ans(n + 10, vector<ll>(5, INF));
rep(i, 5) { ans[0][i] = 0; }
rep(i, n) {
chmin(ans[i + 1][0], ans[i][0] + p[i]);
if (p[i] == 0)
chmin(ans[i + 1][1], min(ans[i][0], ans[i][1]) + 2);
else
chmin(ans[i + 1][1], min(ans[i][0], ans[i][1]) + p[i] % 2);
chmin(ans[i + 1][2],
min({ans[i][0], ans[i][1], ans[i][2]}) + (p[i] + 1) % 2);
if (p[i] == 0)
chmin(ans[i + 1][3],
min({ans[i][0], ans[i][1], ans[i][2], ans[i][3]}) + 2);
else
chmin(ans[i + 1][3],
min({ans[i][0], ans[i][1], ans[i][2], ans[i][3]}) + p[i] % 2);
chmin(ans[i + 1][4],
min({ans[i][0], ans[i][1], ans[i][2], ans[i][3], ans[i][4]}) + p[i]);
}
ll an = INF;
rep(i, 5) { chmin(an, ans[n][i]); }
cout << an << endl;
} | [
"control_flow.branch.else_if.replace.remove",
"control_flow.branch.if.replace.add"
] | 933,697 | 933,698 | u604329931 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
const ll INF = 1e18;
const int N = 2e5 + 5;
ll dp[N][5], a[N];
int n;
ll solve() {
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 5; j++) {
dp[i][j] = INF;
}
}
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 5; j++) {
if (j + 1 < 5) {
dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
}
ll w = a[i];
if (j == 1 || j == 3) {
w = a[i] - 2;
if (w > 0)
w &= 1;
else
w = -w;
} else if (j == 2) {
w = a[i] - 1;
if (w > 0)
w &= 1;
else
w = -w;
}
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w);
}
}
ll ans = INF;
for (int i = 0; i < 4; i++)
ans = min(ans, dp[n][i]);
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll ans = solve();
cout << ans << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
const ll INF = 1e18;
const int N = 2e5 + 5;
ll dp[N][5], a[N];
int n;
ll solve() {
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 5; j++) {
dp[i][j] = INF;
}
}
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 5; j++) {
if (j + 1 < 5) {
dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
}
ll w = a[i];
if (j == 1 || j == 3) {
w = a[i] - 2;
if (w > 0)
w &= 1;
else
w = -w;
} else if (j == 2) {
w = a[i] - 1;
if (w > 0)
w &= 1;
else
w = -w;
}
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + w);
}
}
ll ans = INF;
for (int i = 0; i < 5; i++)
ans = min(ans, dp[n][i]);
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll ans = solve();
cout << ans << "\n";
return 0;
} | [
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 933,701 | 933,702 | u399309850 | cpp |
p03132 | #include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
ll A[200010], dp[200010][5] = {};
int main(void) {
int L;
cin >> L;
for (int i = 0; i < L; ++i)
cin >> A[i];
for (int i = 0; i < L; ++i) {
ll mn = 1e18;
for (int j = 0; j < 5; ++j) {
mn = min(mn, dp[i][j]);
if (j == 0 || j == 4)
dp[i + 1][j] = mn + A[i];
else if (j == 2)
dp[i + 1][j] = mn + (1 - A[i] % 2);
else if (A[j] > 0)
dp[i + 1][j] = mn + A[i] % 2;
else
dp[i + 1][j] = mn + 2;
}
}
ll ans = 1e18;
for (int i = 0; i < 5; ++i)
ans = min(ans, dp[L][i]);
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
typedef long long ll;
using namespace std;
ll A[200010], dp[200010][5] = {};
int main(void) {
int L;
cin >> L;
for (int i = 0; i < L; ++i)
cin >> A[i];
for (int i = 0; i < L; ++i) {
ll mn = 1e18;
for (int j = 0; j < 5; ++j) {
mn = min(mn, dp[i][j]);
if (j == 0 || j == 4)
dp[i + 1][j] = mn + A[i];
else if (j == 2)
dp[i + 1][j] = mn + (1 - A[i] % 2);
else if (A[i] > 0)
dp[i + 1][j] = mn + A[i] % 2;
else
dp[i + 1][j] = mn + 2;
}
}
ll ans = 1e18;
for (int i = 0; i < 5; ++i)
ans = min(ans, dp[L][i]);
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 933,709 | 933,710 | u297367372 | cpp |
p03132 | #ifndef DEBUG
#define NDEBUG
#endif
#include <cassert>
#include <iostream>
#include <iterator>
#include <limits>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
using namespace std;
// template {{{
// misc {{{
using Z = long long;
[[maybe_unused]] constexpr Z INF = numeric_limits<Z>::max() / 3;
// }}}
// debug {{{
template <class T>
using enable_if_sequence_t = enable_if_t<
is_same<typename iterator_traits<typename remove_cv_t<
remove_reference_t<T>>::iterator>::iterator_category,
random_access_iterator_tag>{}>;
#ifdef NDEBUG
#define dump(x)
#define debug if (0)
template <class T> inline T &&ix(T &&value) { return value; }
template <class T, class Index, class... Indices,
class = enable_if_sequence_t<T>>
inline auto &&ix(T &&container, Index index, Indices... indices) {
return ix(container[index], indices...);
}
#else
#define dump(x) \
do { \
cerr << "\e[33m[dump: " << __LINE__ << "] " << (#x) << " = " << x \
<< "\e[0m" << endl; \
} while (0);
#define debug
template <class T>
inline auto &&ix_impl([[maybe_unused]] int line,
[[maybe_unused]] const char *code, T &&value) {
return value;
}
template <class T, class Index, class... Indices,
class = enable_if_sequence_t<T>>
inline auto &&ix_impl(int line, const char *code, T &&container, Index index,
Indices... indices) {
if (index < 0) {
cerr << "\e[31mix: negative index at line " << line << ", ix(" << code
<< ")\e[0m" << endl;
exit(1);
}
int size = container.size();
if (index >= size) {
cerr << "\e[31mix: index out of range at line " << line << ", ix(" << code
<< ")\n"
<< "index = " << index << " whereas size = " << size << "\e[0m"
<< endl;
exit(1);
}
return ix_impl(line, code, container[index], indices...);
}
#define ix(...) ix_impl(__LINE__, #__VA_ARGS__, __VA_ARGS__)
#endif
// }}}
// IO {{{
template <class T> false_type is_container_impl(...);
template <class T, class = typename T::iterator> true_type is_container_impl(T);
template <class T>
struct is_container : decltype(is_container_impl<T>(declval<T>())) {};
template <> struct is_container<string> : std::false_type {};
template <class Container, class = enable_if_t<is_container<Container>{}>>
istream &operator>>(istream &is, Container &cont) {
for (auto &v : cont)
is >> v;
return is;
}
template <class Container, class = enable_if_t<is_container<Container>{}>>
ostream &operator<<(ostream &os, Container const &cont) {
bool first = true;
constexpr char sep =
is_container<typename Container::value_type>{} ? '\n' : ' ';
for (auto const &v : cont) {
if (!first) {
os << sep;
}
first = false;
os << v;
}
return os;
}
template <class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) {
os << '(' << p.first << ", " << p.second << ')';
return os;
}
// }}}
// }}}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
Z L;
cin >> L;
vector<Z> as(L);
cin >> as;
vector<vector<Z>> dp(L + 1, vector<Z>(5, INF));
ix(dp, 0).assign(5, 0);
for (auto i = 0; i < L; i++) {
Z zero_cost = ix(as, i) == 0 ? 1 : 0;
ix(dp, i + 1, 0) = min(ix(dp, i + 1, 0), ix(dp, i, 0) + ix(as, i));
ix(dp, i + 1, 1) =
min(ix(dp, i + 1, 1), ix(dp, i, 1) + ix(as, i) % 2 + zero_cost * 2);
ix(dp, i + 1, 2) =
min(ix(dp, i + 1, 2), ix(dp, i, 2) + 1 - ix(as, i) % 2 + zero_cost);
ix(dp, i + 1, 3) =
min(ix(dp, i + 1, 3), ix(dp, i, 3) + ix(as, i) % 2 + zero_cost * 2);
ix(dp, i + 1, 4) = min(ix(dp, i + 1, 4), ix(dp, i, 4) + ix(as, i));
for (auto j = 0; j < 4; j++)
ix(dp, i + 1, j + 1) = min(ix(dp, i + 1, j + 1), ix(dp, i + 1, j));
}
dump(dp);
cout << ix(dp, L, 4) << endl;
}
| #ifndef DEBUG
#define NDEBUG
#endif
#include <cassert>
#include <iostream>
#include <iterator>
#include <limits>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
using namespace std;
// template {{{
// misc {{{
using Z = long long;
[[maybe_unused]] constexpr Z INF = numeric_limits<Z>::max() / 3;
// }}}
// debug {{{
template <class T>
using enable_if_sequence_t = enable_if_t<
is_same<typename iterator_traits<typename remove_cv_t<
remove_reference_t<T>>::iterator>::iterator_category,
random_access_iterator_tag>{}>;
#ifdef NDEBUG
#define dump(x)
#define debug if (0)
template <class T> inline T &&ix(T &&value) { return value; }
template <class T, class Index, class... Indices,
class = enable_if_sequence_t<T>>
inline auto &&ix(T &&container, Index index, Indices... indices) {
return ix(container[index], indices...);
}
#else
#define dump(x) \
do { \
cerr << "\e[33m[dump: " << __LINE__ << "] " << (#x) << " = " << x \
<< "\e[0m" << endl; \
} while (0);
#define debug
template <class T>
inline auto &&ix_impl([[maybe_unused]] int line,
[[maybe_unused]] const char *code, T &&value) {
return value;
}
template <class T, class Index, class... Indices,
class = enable_if_sequence_t<T>>
inline auto &&ix_impl(int line, const char *code, T &&container, Index index,
Indices... indices) {
if (index < 0) {
cerr << "\e[31mix: negative index at line " << line << ", ix(" << code
<< ")\e[0m" << endl;
exit(1);
}
int size = container.size();
if (index >= size) {
cerr << "\e[31mix: index out of range at line " << line << ", ix(" << code
<< ")\n"
<< "index = " << index << " whereas size = " << size << "\e[0m"
<< endl;
exit(1);
}
return ix_impl(line, code, container[index], indices...);
}
#define ix(...) ix_impl(__LINE__, #__VA_ARGS__, __VA_ARGS__)
#endif
// }}}
// IO {{{
template <class T> false_type is_container_impl(...);
template <class T, class = typename T::iterator> true_type is_container_impl(T);
template <class T>
struct is_container : decltype(is_container_impl<T>(declval<T>())) {};
template <> struct is_container<string> : std::false_type {};
template <class Container, class = enable_if_t<is_container<Container>{}>>
istream &operator>>(istream &is, Container &cont) {
for (auto &v : cont)
is >> v;
return is;
}
template <class Container, class = enable_if_t<is_container<Container>{}>>
ostream &operator<<(ostream &os, Container const &cont) {
bool first = true;
constexpr char sep =
is_container<typename Container::value_type>{} ? '\n' : ' ';
for (auto const &v : cont) {
if (!first) {
os << sep;
}
first = false;
os << v;
}
return os;
}
template <class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) {
os << '(' << p.first << ", " << p.second << ')';
return os;
}
// }}}
// }}}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
Z L;
cin >> L;
vector<Z> as(L);
cin >> as;
vector<vector<Z>> dp(L + 1, vector<Z>(5, INF));
ix(dp, 0).assign(5, 0);
for (auto i = 0; i < L; i++) {
Z zero_cost = ix(as, i) == 0 ? 1 : 0;
ix(dp, i + 1, 0) = min(ix(dp, i + 1, 0), ix(dp, i, 0) + ix(as, i));
ix(dp, i + 1, 1) =
min(ix(dp, i + 1, 1), ix(dp, i, 1) + ix(as, i) % 2 + zero_cost * 2);
ix(dp, i + 1, 2) = min(ix(dp, i + 1, 2), ix(dp, i, 2) + 1 - ix(as, i) % 2);
ix(dp, i + 1, 3) =
min(ix(dp, i + 1, 3), ix(dp, i, 3) + ix(as, i) % 2 + zero_cost * 2);
ix(dp, i + 1, 4) = min(ix(dp, i + 1, 4), ix(dp, i, 4) + ix(as, i));
for (auto j = 0; j < 4; j++)
ix(dp, i + 1, j + 1) = min(ix(dp, i + 1, j + 1), ix(dp, i + 1, j));
}
dump(dp);
cout << ix(dp, L, 4) << endl;
}
| [
"expression.operation.binary.remove"
] | 933,718 | 933,719 | u390181802 | cpp |
p03132 | /* be name khoda */
#define stream_enable
#define long_enable
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif
typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;
const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) \
cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) \
cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' \
<< (z) << endl
#define debug4(x, y, z, t) \
cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' \
<< (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) \
cout << #x << " -> " \
<< "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) \
cout << #x << " -> "; \
fori(i1_da, n) { cout << (x)[i1_da] << ' '; } \
cout << endl
#define debugap(x, n) \
cout << #x << " ->\n"; \
fori(i1_dap, n) { \
cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; \
} \
cout << endl
#define debugaa(x, n, m) \
cout << #x << " ->\n"; \
fori(i1_daa, n) { \
fori(i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } \
cout << '\n'; \
} \
cout << endl
#define debugav(x, n) \
cout << #x << " ->\n"; \
fori(i1_dav, n) { \
fori(i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } \
cout << '\n'; \
} \
cout << endl
#define debugia(x, n) \
cout << #x << " ->\n"; \
fori(i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } \
cout << endl
#define forifrom(i, s, n) for (ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for (ll i = (n)-1; i >= (e); --i)
#define fori(i, n) forifrom(i, 0, n)
#define forir(i, n) forirto(i, n, 0)
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))
#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD
stringstream sss;
// -----------------------------------------------------------------------
const ll maxn = 200010;
ll n;
ll ar[maxn];
ll v1[maxn], v2[maxn];
ll dp[maxn][5];
void MAIN() {
cin >> n;
fori(i, n) cin >> ar[i];
ll sm = 0;
fori(i, n) {
v1[i] = ar[i] == 0 ? -2 : ar[i] - ar[i] % 2;
v2[i] = ar[i] - 1 + ar[i] % 2;
sm += ar[i];
}
fori(i, n + 1) {
dp[i + 1][1] = max(dp[i][0], dp[i][1]) + v1[i];
dp[i + 1][2] = max(max(dp[i][2], dp[i][0]), dp[i][1]) + v2[i];
dp[i + 1][3] = max(dp[i][3], dp[i][2]) + v1[i];
dp[i + 1][4] =
max(max(max(max(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]), dp[i][4]);
}
cout << sm - dp[n + 1][4] << '\n';
}
// -----------------------------------------------------------------------
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(10);
sss << R"(
12
10 0 1 1 1 1 1 1 1 1 0 10
)";
MAIN();
return 0;
}
| /* be name khoda */
// #define stream_enable
#define long_enable
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif
typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;
const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) \
cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) \
cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' \
<< (z) << endl
#define debug4(x, y, z, t) \
cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' \
<< (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) \
cout << #x << " -> " \
<< "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) \
cout << #x << " -> "; \
fori(i1_da, n) { cout << (x)[i1_da] << ' '; } \
cout << endl
#define debugap(x, n) \
cout << #x << " ->\n"; \
fori(i1_dap, n) { \
cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; \
} \
cout << endl
#define debugaa(x, n, m) \
cout << #x << " ->\n"; \
fori(i1_daa, n) { \
fori(i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } \
cout << '\n'; \
} \
cout << endl
#define debugav(x, n) \
cout << #x << " ->\n"; \
fori(i1_dav, n) { \
fori(i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } \
cout << '\n'; \
} \
cout << endl
#define debugia(x, n) \
cout << #x << " ->\n"; \
fori(i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } \
cout << endl
#define forifrom(i, s, n) for (ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for (ll i = (n)-1; i >= (e); --i)
#define fori(i, n) forifrom(i, 0, n)
#define forir(i, n) forirto(i, n, 0)
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))
#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD
stringstream sss;
// -----------------------------------------------------------------------
const ll maxn = 200010;
ll n;
ll ar[maxn];
ll v1[maxn], v2[maxn];
ll dp[maxn][5];
void MAIN() {
cin >> n;
fori(i, n) cin >> ar[i];
ll sm = 0;
fori(i, n) {
v1[i] = ar[i] == 0 ? -2 : ar[i] - ar[i] % 2;
v2[i] = ar[i] - 1 + ar[i] % 2;
sm += ar[i];
}
fori(i, n + 1) {
dp[i + 1][1] = max(dp[i][0], dp[i][1]) + v1[i];
dp[i + 1][2] = max(max(dp[i][2], dp[i][0]), dp[i][1]) + v2[i];
dp[i + 1][3] = max(dp[i][3], dp[i][2]) + v1[i];
dp[i + 1][4] =
max(max(max(max(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]), dp[i][4]);
}
cout << sm - dp[n + 1][4] << '\n';
}
// -----------------------------------------------------------------------
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(10);
sss << R"(
12
10 0 1 1 1 1 1 1 1 1 0 10
)";
MAIN();
return 0;
}
| [] | 933,720 | 933,721 | u780597450 | cpp |
p03132 | #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 l;
cin >> l;
int dp[200001][5];
rep(i, 5) dp[0][i] = 0;
repd(i, 1, l + 1) {
int a;
cin >> a;
dp[i][0] = dp[i - 1][0] + a;
dp[i][1] = min(dp[i - 1][1] + (a == 0 ? 2 : a % 2), dp[i][0]);
dp[i][2] = min(dp[i - 1][2] + ((a + 1) % 2), dp[i][1]);
dp[i][3] = min(dp[i - 1][3] + (a == 0 ? 2 : a % 2), dp[i][2]);
dp[i][4] = min(dp[i - 1][4] + a, dp[i][3]);
}
cout << dp[l][4] << 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() {
ll l;
cin >> l;
ll dp[200001][5];
rep(i, 5) dp[0][i] = 0;
repd(i, 1, l + 1) {
ll a;
cin >> a;
dp[i][0] = dp[i - 1][0] + a;
dp[i][1] = min(dp[i - 1][1] + (a == 0 ? 2 : a % 2), dp[i][0]);
dp[i][2] = min(dp[i - 1][2] + ((a + 1) % 2), dp[i][1]);
dp[i][3] = min(dp[i - 1][3] + (a == 0 ? 2 : a % 2), dp[i][2]);
dp[i][4] = min(dp[i - 1][4] + a, dp[i][3]);
}
cout << dp[l][4] << endl;
}
| [
"variable_declaration.type.change"
] | 933,728 | 933,729 | u317754719 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x + modulo)) % modulo)
#define Inf 1000000000000000
int main() {
int N;
cin >> N;
vector<vector<long long>> dp(N + 1, vector<long long>(5, Inf));
for (int i = 0; i <= N; i++) {
long long A;
if (i != 0)
cin >> A;
for (int j = 0; j < 5; j++) {
if (i == 0) {
dp[i][j] = 0;
} else {
long long cost = 0;
if (j == 0 || j == 4)
cost = A;
if (j == 1 || j == 3) {
if (A % 2 == 1)
cost = 1;
if (A == 0)
cost = 1;
}
if (j == 2) {
if (A % 2 == 0)
cost = 1;
}
for (int k = 0; k <= j; k++) {
dp[i][j] = min(dp[i][j], dp[i - 1][k] + cost);
}
}
}
}
long long ans = Inf;
/*
fr(int i=0;i<=N;i++){
for(int j=0;j<5;j++){
cout<<dp[i][j]<<',';
}
cout<<endl;
}*/
for (int i = 0; i < 5; i++) {
ans = min(ans, dp[N][i]);
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x + modulo)) % modulo)
#define Inf 1000000000000000
int main() {
int N;
cin >> N;
vector<vector<long long>> dp(N + 1, vector<long long>(5, Inf));
for (int i = 0; i <= N; i++) {
long long A;
if (i != 0)
cin >> A;
for (int j = 0; j < 5; j++) {
if (i == 0) {
dp[i][j] = 0;
} else {
long long cost = 0;
if (j == 0 || j == 4)
cost = A;
if (j == 1 || j == 3) {
if (A % 2 == 1)
cost = 1;
if (A == 0)
cost = 2;
}
if (j == 2) {
if (A % 2 == 0)
cost = 1;
}
for (int k = 0; k <= j; k++) {
dp[i][j] = min(dp[i][j], dp[i - 1][k] + cost);
}
}
}
}
long long ans = Inf;
/*
for(int i=0;i<=N;i++){
for(int j=0;j<5;j++){
cout<<dp[i][j]<<',';
}
cout<<endl;
}*/
for (int i = 0; i < 5; i++) {
ans = min(ans, dp[N][i]);
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"assignment.value.change"
] | 933,734 | 933,735 | u118797367 | cpp |
p03132 | #include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <string.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
int L;
ll A[200000];
ll dp[200001][5];
int main() {
cin >> L;
rep(i, L) cin >> A[i];
vector<vector<ll>> dp(L + 1, vector<ll>(5, linf));
dp[0][0] = 0;
rep(i, L) {
ll m = dp[i][0];
dp[i + 1][0] = dp[i][0] + A[i];
m = min(m, dp[i][1]);
if (A[i] == 0)
dp[i + 1][1] = m + 2;
else if (A[i] % 2)
dp[i + 1][1] = m + 1;
else
dp[i + 1][1] = m;
m = min(m, dp[i][2]);
dp[i + 1][2] = m + (A[i] % 2 == 0);
m = min(m, dp[i][3]);
if (A[i] == 0)
dp[i + 1][3] = m + 2;
else if (A[i] % 2)
dp[i + 1][3] = m + 1;
else
dp[i + 1][3] = m;
m = min(m, dp[i][3]);
dp[i + 1][4] = m + A[i];
}
ll ans = linf;
rep(i, 5) ans = min(ans, dp[L][i]);
cout << ans << endl;
} | #include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <string.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
int L;
ll A[200000];
ll dp[200001][5];
int main() {
cin >> L;
rep(i, L) cin >> A[i];
vector<vector<ll>> dp(L + 1, vector<ll>(5, linf));
dp[0][0] = 0;
rep(i, L) {
ll m = dp[i][0];
dp[i + 1][0] = dp[i][0] + A[i];
m = min(m, dp[i][1]);
if (A[i] == 0)
dp[i + 1][1] = m + 2;
else if (A[i] % 2)
dp[i + 1][1] = m + 1;
else
dp[i + 1][1] = m;
m = min(m, dp[i][2]);
dp[i + 1][2] = m + (A[i] % 2 == 0);
m = min(m, dp[i][3]);
if (A[i] == 0)
dp[i + 1][3] = m + 2;
else if (A[i] % 2)
dp[i + 1][3] = m + 1;
else
dp[i + 1][3] = m;
m = min(m, dp[i][4]);
dp[i + 1][4] = m + A[i];
}
ll ans = linf;
rep(i, 5) ans = min(ans, dp[L][i]);
cout << ans << endl;
} | [
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 933,740 | 933,741 | u450494974 | cpp |
p03132 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int l;
cin >> l;
long dp[l + 1][5];
fill(dp[0], dp[l + 1], 0);
for (int i = 0; i < l; i++) {
long a;
cin >> a;
long best = 1e18;
for (int j = 0; j < 5; j++) {
dp[i + 1][j] = min(best, dp[i][j]);
if (j == 0 || j == 4)
dp[i + 1][j] += a;
else if (j == 2)
dp[i + 1][j] += (a + 1) % 2;
else
dp[i + 1][j] += a % 2 + (a == 0 ? 2 : 0);
}
}
cout << min({dp[l][0], dp[l][1], dp[l][2], dp[l][3], dp[l][4]}) << '\n';
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int l;
cin >> l;
long dp[l + 1][5];
fill(dp[0], dp[l + 1], 0);
for (int i = 0; i < l; i++) {
long a;
cin >> a;
long best = 1e18;
for (int j = 0; j < 5; j++) {
dp[i + 1][j] = best = min(best, dp[i][j]);
if (j == 0 || j == 4)
dp[i + 1][j] += a;
else if (j == 2)
dp[i + 1][j] += (a + 1) % 2;
else
dp[i + 1][j] += a % 2 + (a == 0 ? 2 : 0);
}
}
cout << min({dp[l][0], dp[l][1], dp[l][2], dp[l][3], dp[l][4]}) << '\n';
return 0;
} | [
"assignment.change"
] | 933,744 | 933,745 | u956758464 | cpp |
p03132 | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int l;
cin >> l;
long dp[l + 1][5];
fill(dp[0], dp[l + 1], 0);
for (int i = 0; i < l; i++) {
long a;
cin >> a;
long best = 1000000000000000;
for (int j = 0; j < 5; j++) {
dp[i + 1][j] = min(best, dp[i][j]);
if (j == 0 || j == 4)
dp[i + 1][j] += a;
else if (j == 2)
dp[i + 1][j] += (a + 1) % 2;
else
dp[i + 1][j] += a % 2 + (a == 0 ? 2 : 0);
}
}
cout << min({dp[l][0], dp[l][1], dp[l][2], dp[l][3], dp[l][4]}) << '\n';
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int l;
cin >> l;
long dp[l + 1][5];
fill(dp[0], dp[l + 1], 0);
for (int i = 0; i < l; i++) {
long a;
cin >> a;
long best = 1e18;
for (int j = 0; j < 5; j++) {
dp[i + 1][j] = best = min(best, dp[i][j]);
if (j == 0 || j == 4)
dp[i + 1][j] += a;
else if (j == 2)
dp[i + 1][j] += (a + 1) % 2;
else
dp[i + 1][j] += a % 2 + (a == 0 ? 2 : 0);
}
}
cout << min({dp[l][0], dp[l][1], dp[l][2], dp[l][3], dp[l][4]}) << '\n';
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"assignment.change"
] | 933,746 | 933,745 | u956758464 | cpp |
p03132 | #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int l;
cin >> l;
vector<int> a(l);
rep(i, l) cin >> a[i];
vector<int> b(l);
b[0] = a[0];
Rep(i, 1, l) b[i] = b[i - 1] + a[i];
vector<int> c(l);
c[l - 1] = a[l - 1];
repr(i, l - 2) c[i] = c[i + 1] + a[i];
vector<int> x1(l + 1), x2(l + 1);
x1[l] = 0;
x2[0] = 0;
vector<int> y1(l + 1), y2(l + 1);
y1[l] = 0;
y2[0] = 0;
Rep(i, 1, l + 1) {
if (a[i - 1] % 2 == 1) {
x2[i] = min(x2[i - 1], y2[i - 1]);
y2[i] = y2[i - 1] + 1;
} else if (a[i - 1] == 0) {
x2[i] = min(x2[i - 1], y2[i - 1]) + 1;
y2[i] = y2[i - 1] + 2;
} else {
x2[i] = min(y2[i - 1], x2[i - 1] + 1);
y2[i] = y2[i - 1];
}
x2[i] = min(x2[i], b[i - 1]);
y2[i] = min(y2[i], b[i - 1]);
}
repr(i, l - 1) {
if (a[i] % 2 == 1) {
x1[i] = min(x1[i + 1], y2[i + 1]);
y1[i] = y1[i + 1] + 1;
} else if (a[i] == 0) {
x1[i] = min(x1[i + 1], y1[i + 1]) + 1;
y1[i] = y1[i + 1] + 2;
} else {
x1[i] = min(y1[i + 1], x1[i + 1] + 1);
y1[i] = y1[i + 1];
}
x1[i] = min(x1[i], c[i]);
y1[i] = min(y1[i], c[i]);
}
int ans = INF;
rep(i, l + 1) {
ans = min(min(ans, y1[i] + y2[i]), min(x1[i] + y2[i], x2[i] + y1[i]));
// cout << x1[i] << " " << y2[i] << " : " << x2[i] << " " << y1[i] << endl;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int l;
cin >> l;
vector<int> a(l);
rep(i, l) cin >> a[i];
vector<int> b(l);
b[0] = a[0];
Rep(i, 1, l) b[i] = b[i - 1] + a[i];
vector<int> c(l);
c[l - 1] = a[l - 1];
repr(i, l - 2) c[i] = c[i + 1] + a[i];
vector<int> x1(l + 1), x2(l + 1);
x1[l] = 0;
x2[0] = 0;
vector<int> y1(l + 1), y2(l + 1);
y1[l] = 0;
y2[0] = 0;
Rep(i, 1, l + 1) {
if (a[i - 1] % 2 == 1) {
x2[i] = min(x2[i - 1], y2[i - 1]);
y2[i] = y2[i - 1] + 1;
} else if (a[i - 1] == 0) {
x2[i] = min(x2[i - 1], y2[i - 1]) + 1;
y2[i] = y2[i - 1] + 2;
} else {
x2[i] = min(y2[i - 1], x2[i - 1] + 1);
y2[i] = y2[i - 1];
}
x2[i] = min(x2[i], b[i - 1]);
y2[i] = min(y2[i], b[i - 1]);
}
repr(i, l - 1) {
if (a[i] % 2 == 1) {
x1[i] = min(x1[i + 1], y1[i + 1]);
y1[i] = y1[i + 1] + 1;
} else if (a[i] == 0) {
x1[i] = min(x1[i + 1], y1[i + 1]) + 1;
y1[i] = y1[i + 1] + 2;
} else {
x1[i] = min(y1[i + 1], x1[i + 1] + 1);
y1[i] = y1[i + 1];
}
x1[i] = min(x1[i], c[i]);
y1[i] = min(y1[i], c[i]);
}
int ans = INF;
rep(i, l + 1) {
ans = min(min(ans, y1[i] + y2[i]), min(x1[i] + y2[i], x2[i] + y1[i]));
// cout << x1[i] << " " << y2[i] << " : " << x2[i] << " " << y1[i] << endl;
}
cout << ans << endl;
} | [
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 933,747 | 933,748 | u869282786 | cpp |
p03132 | #include <algorithm>
#include <climits>
#include <cstdio>
#include <cstring>
using namespace std;
const int SIZEN = 200010;
typedef long long LL;
LL a[SIZEN] = {0};
LL L1[SIZEN] = {0};
LL L2[SIZEN] = {0};
LL R1[SIZEN] = {0};
LL R2[SIZEN] = {0};
LL sum[SIZEN];
int main() {
int N;
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%lld", &a[i]);
sum[i] = a[i] + sum[i - 1];
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
a[i] == 0;
else if (a[i] % 2 == 0)
a[i] = 2;
else
a[i] = 1;
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
L1[i] = min(L1[i - 1] + 2, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
else if (a[i] == 1)
L1[i] = min(L1[i - 1] + 1, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1], sum[i]));
else
L1[i] = min(L1[i - 1], sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
}
for (int i = N - 1; i >= 0; i--) {
if (a[i] == 0)
R1[i] = min(R1[i + 1] + 2, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
else if (a[i] == 1)
R1[i] = min(R1[i + 1] + 1, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1], sum[N] - sum[i]));
else
R1[i] = min(R1[i + 1], sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
}
LL ans = LLONG_MAX;
for (int i = 0; i <= N; i++) {
ans = min(ans, min(L1[i] + R2[i], L2[i] + R1[i]));
}
printf("%lld\n", ans);
return 0;
} | #include <algorithm>
#include <climits>
#include <cstdio>
#include <cstring>
using namespace std;
const int SIZEN = 200010;
typedef long long LL;
LL a[SIZEN] = {0};
LL L1[SIZEN] = {0};
LL L2[SIZEN] = {0};
LL R1[SIZEN] = {0};
LL R2[SIZEN] = {0};
LL sum[SIZEN];
int main() {
int N;
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%lld", &a[i]);
sum[i] = a[i] + sum[i - 1];
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
a[i] == 0;
else if (a[i] % 2 == 0)
a[i] = 2;
else
a[i] = 1;
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
L1[i] = min(L1[i - 1] + 2, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
else if (a[i] == 1)
L1[i] = min(L1[i - 1] + 1, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1], sum[i]));
else
L1[i] = min(L1[i - 1], sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
}
for (int i = N - 1; i >= 0; i--) {
if (a[i + 1] == 0)
R1[i] = min(R1[i + 1] + 2, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
else if (a[i + 1] == 1)
R1[i] = min(R1[i + 1] + 1, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1], sum[N] - sum[i]));
else
R1[i] = min(R1[i + 1], sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
}
LL ans = LLONG_MAX;
for (int i = 0; i <= N; i++) {
ans = min(ans, min(L1[i] + R2[i], L2[i] + R1[i]));
}
printf("%lld\n", ans);
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 933,749 | 933,750 | u140172805 | cpp |
p03132 | #include <algorithm>
#include <climits>
#include <cstdio>
#include <cstring>
using namespace std;
const int SIZEN = 200010;
typedef long long LL;
LL a[SIZEN] = {0};
LL L1[SIZEN] = {0};
LL L2[SIZEN] = {0};
LL R1[SIZEN] = {0};
LL R2[SIZEN] = {0};
LL sum[SIZEN];
int main() {
int N;
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%lld", &a[i]);
sum[i] = a[i] + sum[i - 1];
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
a[i] == 0;
else if (a[i] % 2 == 0)
a[i] = 2;
else
a[i] = 1;
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
L1[i] = min(L1[i - 1] + 2, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
else if (a[i] == 1)
L1[i] = min(L1[i - 1] + 1, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1], sum[i]));
else
L1[i] = min(L1[i - 1], sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
}
for (int i = N - 1; i >= 0; i--) {
if (a[i] == 0)
R1[i] = min(R1[i + 1] + 2, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
else if (a[i] == 1)
R1[i] = min(R1[i + 1] + 1, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1], sum[N] - sum[i]));
else
R1[i] = min(R1[i + 1], sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
}
LL ans = LLONG_MAX;
for (int i = 1; i <= N; i++) {
ans = min(ans, min(L1[i] + R2[i], L2[i] + R1[i]));
}
printf("%lld\n", ans);
return 0;
} | #include <algorithm>
#include <climits>
#include <cstdio>
#include <cstring>
using namespace std;
const int SIZEN = 200010;
typedef long long LL;
LL a[SIZEN] = {0};
LL L1[SIZEN] = {0};
LL L2[SIZEN] = {0};
LL R1[SIZEN] = {0};
LL R2[SIZEN] = {0};
LL sum[SIZEN];
int main() {
int N;
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%lld", &a[i]);
sum[i] = a[i] + sum[i - 1];
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
a[i] == 0;
else if (a[i] % 2 == 0)
a[i] = 2;
else
a[i] = 1;
}
for (int i = 1; i <= N; i++) {
if (a[i] == 0)
L1[i] = min(L1[i - 1] + 2, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
else if (a[i] == 1)
L1[i] = min(L1[i - 1] + 1, sum[i]),
L2[i] = min(L1[i], min(L2[i - 1], sum[i]));
else
L1[i] = min(L1[i - 1], sum[i]),
L2[i] = min(L1[i], min(L2[i - 1] + 1, sum[i]));
}
for (int i = N - 1; i >= 0; i--) {
if (a[i + 1] == 0)
R1[i] = min(R1[i + 1] + 2, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
else if (a[i + 1] == 1)
R1[i] = min(R1[i + 1] + 1, sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1], sum[N] - sum[i]));
else
R1[i] = min(R1[i + 1], sum[N] - sum[i]),
R2[i] = min(R1[i], min(R2[i + 1] + 1, sum[N] - sum[i]));
}
LL ans = LLONG_MAX;
for (int i = 0; i <= N; i++) {
ans = min(ans, min(L1[i] + R2[i], L2[i] + R1[i]));
}
printf("%lld\n", ans);
return 0;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one",
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 933,751 | 933,750 | u140172805 | cpp |
p03132 | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 998244353;
pint dx[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
vector<ll> A;
ll L;
ll dpl[2 * 100005][2], dpr[2 * 100005][2], sum[2 * 100005];
int main() {
cin >> L;
A.resize(L);
rep(i, L) {
cin >> A[i];
if (i == 0) {
sum[i] = A[i];
} else
sum[i] = sum[i - 1] + A[i];
}
if (A[0] != 0) {
dpl[0][0] = A[0] % 2;
dpl[0][1] = 1 - A[0] % 2;
} else {
dpl[0][0] = 0;
dpl[0][1] = 1;
}
for (int i = 1; i < L; i++) {
if (A[i] != 0 || A[L - i] != 0) {
dpl[i][0] = dpl[i - 1][0] + A[i] % 2;
dpl[i][1] =
min(dpl[i - 1][0] + (1 - A[i] % 2), dpl[i - 1][1] + (1 - A[i] % 2));
dpr[L - i - 1][0] = dpr[L - i][0] + (A[L - i] % 2);
dpr[L - i - 1][1] = min(dpr[L - i][0] + (1 - A[L - i] % 2),
dpr[L - i][1] + (1 - A[L - i] % 2));
}
if (A[i] == 0) {
dpl[i][0] = min(sum[i], 2 + dpl[i - 1][0]);
dpl[i][1] = min(1 + dpl[i - 1][0], 1 + dpl[i - 1][1]);
}
if (A[L - i] == 0) {
dpr[L - i - 1][0] = min(sum[L - 1] - sum[L - i - 1], 2 + dpl[L - i][0]);
dpr[L - i - 1][1] = min(1 + dpr[L - i][0], dpr[L - i][1] + 1);
}
}
ll ans = inf;
rep(i, L) {
ans = min(ans, min(dpl[i][0] + dpr[i][0], dpl[i][0] + dpr[i][1]));
ans = min(ans, dpr[i][0] + dpl[i][1]);
}
cout << ans << endl;
return 0;
} |
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 998244353;
pint dx[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
vector<ll> A;
ll L;
ll dpl[2 * 100005][2], dpr[2 * 100005][2], sum[2 * 100005];
int main() {
cin >> L;
A.resize(L);
rep(i, L) {
cin >> A[i];
if (i == 0) {
sum[i] = A[i];
} else
sum[i] = sum[i - 1] + A[i];
}
if (A[0] != 0) {
dpl[0][0] = A[0] % 2;
dpl[0][1] = 1 - A[0] % 2;
} else {
dpl[0][0] = 0;
dpl[0][1] = 1;
}
for (int i = 1; i < L; i++) {
if (A[i] != 0 || A[L - i] != 0) {
dpl[i][0] = dpl[i - 1][0] + A[i] % 2;
dpl[i][1] =
min(dpl[i - 1][0] + (1 - A[i] % 2), dpl[i - 1][1] + (1 - A[i] % 2));
dpr[L - i - 1][0] = dpr[L - i][0] + (A[L - i] % 2);
dpr[L - i - 1][1] = min(dpr[L - i][0] + (1 - A[L - i] % 2),
dpr[L - i][1] + (1 - A[L - i] % 2));
}
if (A[i] == 0) {
dpl[i][0] = min(sum[i], 2 + dpl[i - 1][0]);
dpl[i][1] = min(1 + dpl[i - 1][0], 1 + dpl[i - 1][1]);
}
if (A[L - i] == 0) {
dpr[L - i - 1][0] = min(sum[L - 1] - sum[L - i - 1], 2 + dpr[L - i][0]);
dpr[L - i - 1][1] = min(1 + dpr[L - i][0], dpr[L - i][1] + 1);
}
}
ll ans = inf;
rep(i, L) {
ans = min(ans, min(dpl[i][0] + dpr[i][0], dpl[i][0] + dpr[i][1]));
ans = min(ans, dpr[i][0] + dpl[i][1]);
}
cout << ans << endl;
return 0;
} | [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 933,754 | 933,755 | u305138467 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
const ll INF = 8e18 + 7;
// lower -even-> start -odd-> end -even-> upper
int n;
ll a[N], sum[N];
int sumOfEven[N], sumOfOdd[N];
ll minCarry[4];
ll f[N][4];
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
sumOfEven[i] = sumOfEven[i - 1] + (a[i] % 2 == 0);
sumOfOdd[i] = sumOfOdd[i - 1] + (a[i] % 2 != 0 || a[i] == 0);
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 4; j++) {
f[i][j] = INF;
}
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 4; j++) {
if (j == 0) {
f[i][j] = sum[i] - sum[0];
minCarry[j] = min(minCarry[j], f[i][j] - sumOfOdd[i]);
} else if (j == 1 || j == 3) {
f[i][j] = sumOfOdd[i] + minCarry[j - 1];
minCarry[j] = min(minCarry[j], f[i][j] - sumOfEven[i]);
} else {
f[i][j] = sumOfEven[i] + minCarry[j - 1];
minCarry[j] = min(minCarry[j], f[i][j] - sumOfOdd[i]);
}
}
}
ll res = INF;
for (int i = 1; i <= n; i++) {
// printf("%lld %lld %lld %lld\n", f[i][0], f[i][1], f[i][2], f[i][3]);
res = min(res, f[i][3] + sum[n] - sum[i]);
}
cout << res << endl;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
const ll INF = 8e18 + 7;
// lower -even-> start -odd-> end -even-> upper
int n;
ll a[N], sum[N];
int sumOfEven[N], sumOfOdd[N];
ll minCarry[4];
ll f[N][4];
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
sumOfEven[i] = sumOfEven[i - 1] + (a[i] % 2 == 0);
sumOfOdd[i] = sumOfOdd[i - 1] + (a[i] % 2 != 0) + 2 * (a[i] == 0);
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 4; j++) {
f[i][j] = INF;
}
}
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 4; j++) {
if (j == 0) {
f[i][j] = sum[i] - sum[0];
minCarry[j] = min(minCarry[j], f[i][j] - sumOfOdd[i]);
} else if (j == 1 || j == 3) {
f[i][j] = sumOfOdd[i] + minCarry[j - 1];
minCarry[j] = min(minCarry[j], f[i][j] - sumOfEven[i]);
} else {
f[i][j] = sumOfEven[i] + minCarry[j - 1];
minCarry[j] = min(minCarry[j], f[i][j] - sumOfOdd[i]);
}
}
}
ll res = INF;
for (int i = 1; i <= n; i++) {
// printf("%lld %lld %lld %lld\n", f[i][0], f[i][1], f[i][2], f[i][3]);
res = min(res, f[i][3] + sum[n] - sum[i]);
}
cout << res << endl;
} | [
"assignment.value.change",
"expression.operation.binary.change",
"assignment.change"
] | 933,761 | 933,762 | u353573192 | cpp |
p03132 | #include <bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
using namespace std;
#define int long long
vector<int> calc1(int L, vector<int> &A) {
vector<int> dp(L + 1);
int sum = 0;
for (int i = 1; i <= L; ++i) {
sum += A[i];
if (A[i] == 0) {
dp[i] = min(sum, dp[i - 1] + 2);
} else if (A[i] % 2 == 0) {
dp[i] = min(sum, dp[i - 1]);
} else {
dp[i] = min(sum, dp[i - 1] + 1);
}
}
return dp;
}
vector<int> calc2(int L, vector<int> &A, vector<int> &B) {
vector<int> dp(L + 1);
for (int i = 1; i <= L + 1; ++i) {
int c;
if (A[i] % 2 == 0) {
c = 1;
} else {
c = 0;
}
dp[i] = min(B[i], dp[i - 1] + c);
}
return dp;
}
signed main() {
int L;
cin >> L;
vector<int> A(L + 2);
for (int i = 1; i <= L; ++i) {
cin >> A[i];
}
vector<int> dp1 = calc1(L, A);
vector<int> dp2 = calc2(L, A, dp1);
reverse(ALL(A));
vector<int> rdp1 = calc1(L, A);
vector<int> rdp2 = calc2(L, A, rdp1);
reverse(ALL(rdp1));
reverse(ALL(rdp2));
int res = (int)(1e17);
/*
for(int i = 0; i <= L; ++i) {
cout << dp1[i] << "," << dp2[i] << "," << rdp1[i] << "," << rdp2[i] <<
endl;
}
*/
for (int i = 1; i <= L; ++i) {
res = min(res, dp1[i] + rdp2[i]);
res = min(res, rdp1[i] + dp2[i]);
}
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
using namespace std;
#define int long long
vector<int> calc1(int L, vector<int> &A) {
vector<int> dp(L + 1);
int sum = 0;
for (int i = 1; i <= L; ++i) {
sum += A[i];
if (A[i] == 0) {
dp[i] = min(sum, dp[i - 1] + 2);
} else if (A[i] % 2 == 0) {
dp[i] = min(sum, dp[i - 1]);
} else {
dp[i] = min(sum, dp[i - 1] + 1);
}
}
return dp;
}
vector<int> calc2(int L, vector<int> &A, vector<int> &B) {
vector<int> dp(L + 1);
for (int i = 1; i <= L; ++i) {
int c;
if (A[i] % 2 == 0) {
c = 1;
} else {
c = 0;
}
dp[i] = min(B[i], dp[i - 1] + c);
}
return dp;
}
signed main() {
int L;
cin >> L;
vector<int> A(L + 2);
for (int i = 1; i <= L; ++i) {
cin >> A[i];
}
vector<int> dp1 = calc1(L, A);
vector<int> dp2 = calc2(L, A, dp1);
reverse(ALL(A));
vector<int> rdp1 = calc1(L, A);
vector<int> rdp2 = calc2(L, A, rdp1);
reverse(ALL(rdp1));
reverse(ALL(rdp2));
int res = (int)(1e17);
/*
for(int i = 0; i <= L; ++i) {
cout << dp1[i] << "," << dp2[i] << "," << rdp1[i] << "," << rdp2[i] <<
endl;
}
*/
for (int i = 1; i <= L; ++i) {
res = min(res, dp1[i] + rdp2[i]);
res = min(res, rdp1[i] + dp2[i]);
}
cout << res << endl;
return 0;
}
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 933,763 | 933,764 | u183530284 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double, double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (ll i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i, j) FOR(i, 1, j + 1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(), _a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) \
do { \
fprintf(stderr, "%s - %d (%s) = ", __PRETTY_FUNCTION__, __LINE__, \
#__VA_ARGS__); \
_do(__VA_ARGS__); \
} while (0)
template <typename T> void _do(T &&_x) { cerr << _x << endl; }
template <typename T, typename... S> void _do(T &&_x, S &&..._t) {
cerr << _x << " ,";
_do(_t...);
}
template <typename _a, typename _b>
ostream &operator<<(ostream &_s, const pair<_a, _b> &_p) {
return _s << "(" << _p.X << "," << _p.Y << ")";
}
template <typename It> ostream &_OUTC(ostream &_s, It _ita, It _itb) {
_s << "{";
for (It _it = _ita; _it != _itb; _it++) {
_s << (_it == _ita ? "" : ",") << *_it;
}
_s << "}";
return _s;
}
template <typename _a> ostream &operator<<(ostream &_s, vector<_a> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _a> ostream &operator<<(ostream &_s, set<_a> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _a> ostream &operator<<(ostream &_s, deque<_a> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _a, typename _b>
ostream &operator<<(ostream &_s, map<_a, _b> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _t> void pary(_t _a, _t _b) {
_OUTC(cerr, _a, _b);
cerr << endl;
}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#endif
const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 4e5 + 8;
ll n, a[MAXN], dp[MAXN][7];
inline bool poe(ll val) {
if (val == 0) {
return 2;
} else {
return val & 1;
}
}
ll mn(vector<ll> idx, ll i) {
ll ret = INF;
for (auto x : idx) {
ret = min(ret, dp[i][x]);
}
return ret;
}
/********** Good Luck :) **********/
int main() {
IOS();
cin >> n;
REP(i, n) { cin >> a[i]; }
dp[0][0] = 1 - (a[0] & 1);
dp[0][1] = poe(a[0]);
dp[0][2] = poe(a[0]);
dp[0][3] = a[0];
dp[0][4] = a[0];
REP1(i, n - 1) {
dp[i][0] = mn({0, 1, 3}, i - 1) + 1 - (a[i] & 1);
dp[i][1] = mn({1, 3}, i - 1) + poe(a[i]);
dp[i][2] = mn({0, 1, 2, 3}, i - 1) + poe(a[i]);
dp[i][3] = dp[i - 1][3] + a[i];
dp[i][4] = mn({0, 1, 2, 3, 4}, i - 1) + a[i];
}
ll ans = INF;
REP(i, 5) { ans = min(ans, dp[n - 1][i]); }
REP(i, n) { pary(dp[i], dp[i] + 5); }
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double, double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (ll i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i, j) FOR(i, 1, j + 1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(), _a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) \
do { \
fprintf(stderr, "%s - %d (%s) = ", __PRETTY_FUNCTION__, __LINE__, \
#__VA_ARGS__); \
_do(__VA_ARGS__); \
} while (0)
template <typename T> void _do(T &&_x) { cerr << _x << endl; }
template <typename T, typename... S> void _do(T &&_x, S &&..._t) {
cerr << _x << " ,";
_do(_t...);
}
template <typename _a, typename _b>
ostream &operator<<(ostream &_s, const pair<_a, _b> &_p) {
return _s << "(" << _p.X << "," << _p.Y << ")";
}
template <typename It> ostream &_OUTC(ostream &_s, It _ita, It _itb) {
_s << "{";
for (It _it = _ita; _it != _itb; _it++) {
_s << (_it == _ita ? "" : ",") << *_it;
}
_s << "}";
return _s;
}
template <typename _a> ostream &operator<<(ostream &_s, vector<_a> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _a> ostream &operator<<(ostream &_s, set<_a> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _a> ostream &operator<<(ostream &_s, deque<_a> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _a, typename _b>
ostream &operator<<(ostream &_s, map<_a, _b> &_c) {
return _OUTC(_s, ALL(_c));
}
template <typename _t> void pary(_t _a, _t _b) {
_OUTC(cerr, _a, _b);
cerr << endl;
}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#endif
const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 4e5 + 8;
ll n, a[MAXN], dp[MAXN][7];
inline ll poe(ll val) {
if (val == 0) {
return 2;
} else {
return val & 1;
}
}
ll mn(vector<ll> idx, ll i) {
ll ret = INF;
for (auto x : idx) {
ret = min(ret, dp[i][x]);
}
return ret;
}
/********** Good Luck :) **********/
int main() {
IOS();
cin >> n;
REP(i, n) { cin >> a[i]; }
dp[0][0] = 1 - (a[0] & 1);
dp[0][1] = poe(a[0]);
dp[0][2] = poe(a[0]);
dp[0][3] = a[0];
dp[0][4] = a[0];
REP1(i, n - 1) {
dp[i][0] = mn({0, 1, 3}, i - 1) + 1 - (a[i] & 1);
dp[i][1] = mn({1, 3}, i - 1) + poe(a[i]);
dp[i][2] = mn({0, 1, 2, 3}, i - 1) + poe(a[i]);
dp[i][3] = dp[i - 1][3] + a[i];
dp[i][4] = mn({0, 1, 2, 3, 4}, i - 1) + a[i];
}
ll ans = INF;
REP(i, 5) { ans = min(ans, dp[n - 1][i]); }
REP(i, n) { pary(dp[i], dp[i] + 5); }
cout << ans << endl;
return 0;
}
| [] | 933,767 | 933,768 | u825429292 | cpp |
p03132 | #include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#define MAX_L (200000L)
#define INF (1000000000000000000L)
using namespace std;
long accl_as[MAX_L + 2], accr_as[MAX_L + 2];
long accl_nes[MAX_L + 2];
long dp1s[MAX_L + 1], dp2s[MAX_L + 1];
long dp2ds[MAX_L + 1];
long minr_dp2ds[MAX_L + 1];
int main(int argc, char *argv[]) {
// read inputs
long L, as[MAX_L + 2] = {};
scanf("%ld", &L);
for (long i = 1; i <= L; i++) {
scanf("%ld", &as[i]);
}
// calculate accumulated sums
accl_as[0] = 0;
for (long i = 1; i <= L; i++) {
accl_as[i] = accl_as[i - 1] + as[i];
// printf("i = %ld, accl_as[i] = %ld\n", i, accl_as[i]);
}
accr_as[L + 1] = 0;
for (long i = L; i > 0; i--) {
accr_as[i] = accr_as[i + 1] + as[i];
// printf("i = %ld, accr_as[i] = %ld\n", i, accr_as[i]);
}
// calculate accumulated number of even elements in as
accl_nes[0] = 0;
for (long i = 1; i <= L; i++) {
accl_nes[i] = accl_nes[i - 1] + 1 - as[i] % 2;
// printf("i = %ld, accl_nes[i] = %ld\n", i, accl_nes[i]);
}
// calculate dp
dp1s[0] = 0;
for (long i = 1; i <= L; i++) {
const long a = as[i];
dp1s[i] = accl_as[i] - accl_as[0];
if (a == 0) {
dp1s[i] = min(dp1s[i], dp1s[i - 1] + 2);
} else {
dp1s[i] = min(dp1s[i], dp1s[i - 1] + a % 2);
}
// printf("i = %ld, dp1s[i] = %ld\n", i, dp1s[i]);
}
dp2s[L] = 0;
for (long i = L - 1; i >= 0; i--) {
const long a = as[i + 1];
dp2s[i] = accr_as[i + 1] - accr_as[L + 1];
if (a == 0) {
dp2s[i] = min(dp2s[i], dp2s[i + 1] + 2);
} else {
dp2s[i] = min(dp2s[i], dp2s[i + 1] + a % 2);
}
// printf("i = %ld, dp2s[i] = %ld\n", i, dp2s[i]);
}
// modify dp2s
for (long i = 0; i <= L; i++) {
dp2ds[i] = dp2s[i] - (accl_nes[L] - accl_nes[i]);
}
// calculate minimum of dp2ds
minr_dp2ds[L] = dp2ds[L];
for (long i = L - 1; i >= 0; i--) {
minr_dp2ds[i] = min(dp2ds[i], minr_dp2ds[i + 1]);
}
// solve
long ans = INF;
for (long i = 0; i <= L; i++) {
long ans_i = dp1s[i] + accl_nes[L] - accl_nes[i];
ans_i += minr_dp2ds[i + 1]; // TODO : check
ans = min(ans, ans_i);
}
printf("%ld\n", ans);
return 0;
}
| #include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#define MAX_L (200000L)
#define INF (1000000000000000000L)
using namespace std;
long accl_as[MAX_L + 2], accr_as[MAX_L + 2];
long accl_nes[MAX_L + 2];
long dp1s[MAX_L + 1], dp2s[MAX_L + 1];
long dp2ds[MAX_L + 1];
long minr_dp2ds[MAX_L + 1];
int main(int argc, char *argv[]) {
// read inputs
long L, as[MAX_L + 2] = {};
scanf("%ld", &L);
for (long i = 1; i <= L; i++) {
scanf("%ld", &as[i]);
}
// calculate accumulated sums
accl_as[0] = 0;
for (long i = 1; i <= L; i++) {
accl_as[i] = accl_as[i - 1] + as[i];
// printf("i = %ld, accl_as[i] = %ld\n", i, accl_as[i]);
}
accr_as[L + 1] = 0;
for (long i = L; i > 0; i--) {
accr_as[i] = accr_as[i + 1] + as[i];
// printf("i = %ld, accr_as[i] = %ld\n", i, accr_as[i]);
}
// calculate accumulated number of even elements in as
accl_nes[0] = 0;
for (long i = 1; i <= L; i++) {
accl_nes[i] = accl_nes[i - 1] + 1 - as[i] % 2;
// printf("i = %ld, accl_nes[i] = %ld\n", i, accl_nes[i]);
}
// calculate dp
dp1s[0] = 0;
for (long i = 1; i <= L; i++) {
const long a = as[i];
dp1s[i] = accl_as[i] - accl_as[0];
if (a == 0) {
dp1s[i] = min(dp1s[i], dp1s[i - 1] + 2);
} else {
dp1s[i] = min(dp1s[i], dp1s[i - 1] + a % 2);
}
// printf("i = %ld, dp1s[i] = %ld\n", i, dp1s[i]);
}
dp2s[L] = 0;
for (long i = L - 1; i >= 0; i--) {
const long a = as[i + 1];
dp2s[i] = accr_as[i + 1] - accr_as[L + 1];
if (a == 0) {
dp2s[i] = min(dp2s[i], dp2s[i + 1] + 2);
} else {
dp2s[i] = min(dp2s[i], dp2s[i + 1] + a % 2);
}
// printf("i = %ld, dp2s[i] = %ld\n", i, dp2s[i]);
}
// modify dp2s
for (long i = 0; i <= L; i++) {
dp2ds[i] = dp2s[i] - (accl_nes[L] - accl_nes[i]);
}
// calculate minimum of dp2ds
minr_dp2ds[L] = dp2ds[L];
for (long i = L - 1; i >= 0; i--) {
minr_dp2ds[i] = min(dp2ds[i], minr_dp2ds[i + 1]);
}
// solve
long ans = INF;
for (long i = 0; i <= L; i++) {
long ans_i = dp1s[i] + accl_nes[L] - accl_nes[i];
ans_i += minr_dp2ds[i]; // TODO : check
ans = min(ans, ans_i);
}
printf("%ld\n", ans);
return 0;
}
| [
"expression.operation.binary.remove"
] | 933,769 | 933,770 | u359413838 | cpp |
p03132 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
#define MAXN 200000
#define LL long long
#define DB double
#define FR first
#define SE second
int a[MAXN + 5];
LL ans;
LL L1[MAXN], L2[MAXN + 5], R1[MAXN + 5], R2[MAXN + 5];
LL lsum[MAXN + 5], rsum[MAXN + 5];
int n;
int get_num(LL p) {
if (p == 0)
return 0;
if (p % 2 == 1)
return 1;
return 2;
}
int main() {
ans = 1000000000;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%lld", &a[i]);
for (int i = 1; i <= n; i++)
lsum[i] = lsum[i - 1] + a[i];
for (int i = n - 1; i >= 0; i--)
rsum[i] = rsum[i + 1] + a[i + 1];
for (int i = 1; i <= n; i++)
a[i] = get_num(a[i]);
for (int i = 1; i <= n; i++) {
if (a[i] == 0)
L1[i] = min(L1[i - 1] + 2, lsum[i]);
else if (a[i] == 1)
L1[i] = min(L1[i - 1] + 1, lsum[i]);
else
L1[i] = min(L1[i - 1], lsum[i]);
if (a[i] == 0)
L2[i] = min(L1[i], min(L2[i - 1] + 1, lsum[i]));
else if (a[i] == 1)
L2[i] = min(L1[i], min(L2[i - 1], lsum[i]));
else
L2[i] = min(L1[i], min(L2[i - 1] + 2, lsum[i]));
}
for (int i = n - 1; i >= 0; i--) {
if (a[i + 1] == 0)
R1[i] = min(R1[i + 1] + 2, rsum[i]);
else if (a[i + 1] == 1)
R1[i] = min(R1[i + 1] + 1, rsum[i]);
else
R1[i] = min(R1[i + 1], rsum[i]);
if (a[i + 1] == 0)
R2[i] = min(R1[i], min(R2[i + 1] + 1, rsum[i]));
else if (a[i + 1] == 1)
R2[i] = min(R1[i], min(R2[i + 1], rsum[i]));
else
R2[i] = min(R1[i], min(R2[i + 1] + 2, rsum[i]));
}
for (int i = 0; i <= n; i++) {
// printf("%d %lld %lld\n",i,L1[i]+R2[i],L2[i]+R1[i]);
ans = min(ans, min(L1[i] + R2[i], L2[i] + R1[i]));
}
printf("%lld\n", ans);
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
#define MAXN 200000
#define LL long long
#define DB double
#define FR first
#define SE second
int a[MAXN + 5];
LL ans;
LL L1[MAXN], L2[MAXN + 5], R1[MAXN + 5], R2[MAXN + 5];
LL lsum[MAXN + 5], rsum[MAXN + 5];
int n;
int get_num(int p) {
if (p == 0)
return 0;
if (p % 2 == 1)
return 1;
return 2;
}
int main() {
ans = 1000000000;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (int i = 1; i <= n; i++)
lsum[i] = lsum[i - 1] + a[i];
for (int i = n - 1; i >= 0; i--)
rsum[i] = rsum[i + 1] + a[i + 1];
for (int i = 1; i <= n; i++)
a[i] = get_num(a[i]);
for (int i = 1; i <= n; i++) {
if (a[i] == 0)
L1[i] = min(L1[i - 1] + 2, lsum[i]);
else if (a[i] == 1)
L1[i] = min(L1[i - 1] + 1, lsum[i]);
else
L1[i] = min(L1[i - 1], lsum[i]);
if (a[i] == 0)
L2[i] = min(L1[i], min(L2[i - 1] + 1, lsum[i]));
else if (a[i] == 1)
L2[i] = min(L1[i], min(L2[i - 1], lsum[i]));
else
L2[i] = min(L1[i], min(L2[i - 1] + 1, lsum[i]));
}
for (int i = n - 1; i >= 0; i--) {
if (a[i + 1] == 0)
R1[i] = min(R1[i + 1] + 2, rsum[i]);
else if (a[i + 1] == 1)
R1[i] = min(R1[i + 1] + 1, rsum[i]);
else
R1[i] = min(R1[i + 1], rsum[i]);
if (a[i + 1] == 0)
R2[i] = min(R1[i], min(R2[i + 1] + 1, rsum[i]));
else if (a[i + 1] == 1)
R2[i] = min(R1[i], min(R2[i + 1], rsum[i]));
else
R2[i] = min(R1[i], min(R2[i + 1] + 1, rsum[i]));
}
for (int i = 0; i <= n; i++) {
// printf("%d %lld %lld\n",i,L1[i]+R2[i],L2[i]+R1[i]);
ans = min(ans, min(L1[i] + R2[i], L2[i] + R1[i]));
}
printf("%lld\n", ans);
} | [
"literal.string.change",
"call.arguments.change",
"literal.number.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 933,781 | 933,782 | u294179241 | cpp |
p03132 | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <float.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
long long gcd(long long a, long long b) {
if (a < b)
gcd(b, a);
long long r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
long long modinv(long long a, long long mod) {
long long b = mod, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= mod;
if (u < 0)
u += mod;
return u;
}
namespace NTT {
const int MOD = 998244353; // to be set appropriately
const long long PR = 3; // to be set appropriately
void trans(vector<long long> &v, bool inv = false) {
int n = (int)v.size();
for (int i = 0, j = 1; j < n - 1; j++) {
for (int k = n >> 1; k > (i ^= k); k >>= 1)
;
if (i > j)
swap(v[i], v[j]);
}
for (int t = 2; t <= n; t <<= 1) {
long long bw = modpow(PR, (MOD - 1) / t, MOD);
if (inv)
bw = modinv(bw, MOD);
for (int i = 0; i < n; i += t) {
long long w = 1;
for (int j = 0; j < t / 2; ++j) {
int j1 = i + j, j2 = i + j + t / 2;
long long c1 = v[j1], c2 = v[j2] * w % MOD;
v[j1] = c1 + c2;
v[j2] = c1 - c2 + MOD;
while (v[j1] >= MOD)
v[j1] -= MOD;
while (v[j2] >= MOD)
v[j2] -= MOD;
w = w * bw % MOD;
}
}
}
if (inv) {
long long inv_n = modinv(n, MOD);
for (int i = 0; i < n; ++i)
v[i] = v[i] * inv_n % MOD;
}
}
// C is A*B
vector<long long> mult(vector<long long> A, vector<long long> B) {
int size_a = 1;
while (size_a < A.size())
size_a <<= 1;
int size_b = 1;
while (size_b < B.size())
size_b <<= 1;
int size_fft = max(size_a, size_b) << 1;
vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
for (int i = 0; i < A.size(); ++i)
cA[i] = A[i];
for (int i = 0; i < B.size(); ++i)
cB[i] = B[i];
trans(cA);
trans(cB);
for (int i = 0; i < size_fft; ++i)
cC[i] = cA[i] * cB[i] % MOD;
trans(cC, true);
vector<long long> res((int)A.size() + (int)B.size() - 1);
for (int i = 0; i < res.size(); ++i)
res[i] = cC[i];
return res;
}
}; // namespace NTT
typedef pair<int, int> p;
typedef pair<int, p> pai;
const int maxn = 1 << 24;
int n2;
long long dat[2 * maxn - 1];
void init(int n_) {
n2 = 1;
while (n2 < n_)
n2 *= 2;
for (int i = 0; i < 2 * n2 - 1; i++) {
dat[i] = LLONG_MIN / 2;
}
}
void update(long long k, long long a) {
k += n2 - 1;
dat[k] = a;
while (k > 0) {
k = (k - 1) / 2;
dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
long long query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return LLONG_MIN / 2;
if (a <= l && r <= b)
return dat[k];
else {
long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return max(vl, vr);
}
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int l;
long long a[200005];
cin >> l;
long long ans = 0;
for (int i = 1; i <= l; i++) {
cin >> a[i];
ans += a[i];
}
long long ruiseki[200005];
ruiseki[0] = 0;
long long ruiseki2[200005];
ruiseki2[l + 1] = 0;
for (int i = 1; i <= l; i++) {
ruiseki[i] = ruiseki[i - 1] + (a[i] - ((a[i] + 1) % 2));
}
for (int i = l; i >= 1; i--) {
long long tmp = (a[i] == 0) ? -2 : a[i] - (a[i] % 2);
ruiseki2[i] = max((long long)0, ruiseki2[i + 1] + tmp);
}
init(l + 1);
for (int i = 0; i <= l; i++) {
update(i, ruiseki[i] + ruiseki2[i + 1]);
}
long long tmp = max((long long)0, query(0, l + 1, 0, 0, n2));
long long now = 0;
for (int i = 1; i < l; i++) {
long long dew = query(i + 1, l + 1, 0, 0, n2);
tmp = max(tmp, now + query(i, l + 1, 0, 0, n2) - ruiseki[i]);
long long ha = (a[i + 1] == 0) ? -2 : a[i + 1] - (a[i + 1] % 2);
now = max((long long)0, ha + now);
}
cout << ans - tmp;
}
| #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <float.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
long long gcd(long long a, long long b) {
if (a < b)
gcd(b, a);
long long r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
long long modinv(long long a, long long mod) {
long long b = mod, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= mod;
if (u < 0)
u += mod;
return u;
}
namespace NTT {
const int MOD = 998244353; // to be set appropriately
const long long PR = 3; // to be set appropriately
void trans(vector<long long> &v, bool inv = false) {
int n = (int)v.size();
for (int i = 0, j = 1; j < n - 1; j++) {
for (int k = n >> 1; k > (i ^= k); k >>= 1)
;
if (i > j)
swap(v[i], v[j]);
}
for (int t = 2; t <= n; t <<= 1) {
long long bw = modpow(PR, (MOD - 1) / t, MOD);
if (inv)
bw = modinv(bw, MOD);
for (int i = 0; i < n; i += t) {
long long w = 1;
for (int j = 0; j < t / 2; ++j) {
int j1 = i + j, j2 = i + j + t / 2;
long long c1 = v[j1], c2 = v[j2] * w % MOD;
v[j1] = c1 + c2;
v[j2] = c1 - c2 + MOD;
while (v[j1] >= MOD)
v[j1] -= MOD;
while (v[j2] >= MOD)
v[j2] -= MOD;
w = w * bw % MOD;
}
}
}
if (inv) {
long long inv_n = modinv(n, MOD);
for (int i = 0; i < n; ++i)
v[i] = v[i] * inv_n % MOD;
}
}
// C is A*B
vector<long long> mult(vector<long long> A, vector<long long> B) {
int size_a = 1;
while (size_a < A.size())
size_a <<= 1;
int size_b = 1;
while (size_b < B.size())
size_b <<= 1;
int size_fft = max(size_a, size_b) << 1;
vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
for (int i = 0; i < A.size(); ++i)
cA[i] = A[i];
for (int i = 0; i < B.size(); ++i)
cB[i] = B[i];
trans(cA);
trans(cB);
for (int i = 0; i < size_fft; ++i)
cC[i] = cA[i] * cB[i] % MOD;
trans(cC, true);
vector<long long> res((int)A.size() + (int)B.size() - 1);
for (int i = 0; i < res.size(); ++i)
res[i] = cC[i];
return res;
}
}; // namespace NTT
typedef pair<int, int> p;
typedef pair<int, p> pai;
const int maxn = 1 << 24;
int n2;
long long dat[2 * maxn - 1];
void init(int n_) {
n2 = 1;
while (n2 < n_)
n2 *= 2;
for (int i = 0; i < 2 * n2 - 1; i++) {
dat[i] = LLONG_MIN / 2;
}
}
void update(long long k, long long a) {
k += n2 - 1;
dat[k] = a;
while (k > 0) {
k = (k - 1) / 2;
dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
long long query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return LLONG_MIN / 2;
if (a <= l && r <= b)
return dat[k];
else {
long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return max(vl, vr);
}
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int l;
long long a[200005];
cin >> l;
long long ans = 0;
for (int i = 1; i <= l; i++) {
cin >> a[i];
ans += a[i];
}
long long ruiseki[200005];
ruiseki[0] = 0;
long long ruiseki2[200005];
ruiseki2[l + 1] = 0;
for (int i = 1; i <= l; i++) {
ruiseki[i] = ruiseki[i - 1] + (a[i] - ((a[i] + 1) % 2));
}
for (int i = l; i >= 1; i--) {
long long tmp = (a[i] == 0) ? -2 : a[i] - (a[i] % 2);
ruiseki2[i] = max((long long)0, ruiseki2[i + 1] + tmp);
}
init(l + 1);
for (int i = 0; i <= l; i++) {
update(i, ruiseki[i] + ruiseki2[i + 1]);
}
long long tmp = max((long long)0, query(0, l + 1, 0, 0, n2));
long long now = 0;
for (int i = 0; i < l; i++) {
long long dew = query(i + 1, l + 1, 0, 0, n2);
tmp = max(tmp, now + query(i, l + 1, 0, 0, n2) - ruiseki[i]);
long long ha = (a[i + 1] == 0) ? -2 : a[i + 1] - (a[i + 1] % 2);
now = max((long long)0, ha + now);
}
cout << ans - tmp;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 933,783 | 933,784 | u313288017 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
long long a[300001];
long long f[300001][5];
int main() {
int l;
scanf("%d", &l);
int i;
long long tot = 0;
for (i = 1; i <= l; i++) {
scanf("%lld", &a[i]);
tot += a[i];
}
int j;
for (i = 1; i <= l; i++) {
if (a[i] != 0) {
long long tmp = f[i - 1][0];
f[i][0] = tmp + a[i];
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + (1ll - a[i] % 2ll);
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp + a[i];
} else {
long long tmp = f[i - 1][0];
f[i][0] = tmp;
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + 1ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + 2ll;
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + 1ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp;
}
}
/* for(i=1;i<=l;i++)
{
for(int j=0;j<=4;j++)
printf("%lld ",f[i][j]);
printf("\n");
}*/
long long ans = f[l][0];
ans = min(ans, f[l][1]);
ans = min(ans, f[l][2]);
ans = min(ans, f[l][3]);
ans = min(ans, f[l][4]);
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long long a[300001];
long long f[300001][5];
int main() {
int l;
scanf("%d", &l);
int i;
long long tot = 0;
for (i = 1; i <= l; i++) {
scanf("%lld", &a[i]);
tot += a[i];
}
int j;
for (i = 1; i <= l; i++) {
if (a[i] != 0) {
long long tmp = f[i - 1][0];
f[i][0] = tmp + a[i];
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + (1ll - a[i] % 2ll);
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp + a[i];
} else {
long long tmp = f[i - 1][0];
f[i][0] = tmp;
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + 2ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + 1ll;
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + 2ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp;
}
}
/* for(i=1;i<=l;i++)
{
for(int j=0;j<=4;j++)
printf("%lld ",f[i][j]);
printf("\n");
}*/
long long ans = f[l][0];
ans = min(ans, f[l][1]);
ans = min(ans, f[l][2]);
ans = min(ans, f[l][3]);
ans = min(ans, f[l][4]);
printf("%lld\n", ans);
return 0;
} | [
"literal.number.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 933,792 | 933,793 | u137690186 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
long long a[300001];
long long f[300001][5];
int main() {
int l;
scanf("%d", &l);
int i;
long long tot = 0;
for (i = 1; i <= l; i++) {
scanf("%lld", &a[i]);
tot += a[i];
}
for (i = 1; i <= l; i++) {
if (a[i] != 0) {
long long tmp = f[i - 1][0];
f[i][0] = tmp + a[i];
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + (1ll - a[i] % 2ll);
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp + a[i];
} else {
long long tmp = f[i - 1][0];
f[i][0] = tmp;
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + 1ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + 1ll;
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + 1ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp;
}
}
/* for(i=1;i<=l;i++)
{
for(int j=0;j<=4;j++)
printf("%lld ",f[i][j]);
printf("\n");
}*/
long long ans = f[l][0];
ans = min(ans, f[l][1]);
ans = min(ans, f[l][2]);
ans = min(ans, f[l][3]);
ans = min(ans, f[l][4]);
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long long a[300001];
long long f[300001][5];
int main() {
int l;
scanf("%d", &l);
int i;
long long tot = 0;
for (i = 1; i <= l; i++) {
scanf("%lld", &a[i]);
tot += a[i];
}
int j;
for (i = 1; i <= l; i++) {
if (a[i] != 0) {
long long tmp = f[i - 1][0];
f[i][0] = tmp + a[i];
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + (1ll - a[i] % 2ll);
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + a[i] % 2ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp + a[i];
} else {
long long tmp = f[i - 1][0];
f[i][0] = tmp;
tmp = min(tmp, f[i - 1][1]);
f[i][1] = tmp + 2ll;
tmp = min(tmp, f[i - 1][2]);
f[i][2] = tmp + 1ll;
tmp = min(tmp, f[i - 1][3]);
f[i][3] = tmp + 2ll;
tmp = min(tmp, f[i - 1][4]);
f[i][4] = tmp;
}
}
/* for(i=1;i<=l;i++)
{
for(int j=0;j<=4;j++)
printf("%lld ",f[i][j]);
printf("\n");
}*/
long long ans = f[l][0];
ans = min(ans, f[l][1]);
ans = min(ans, f[l][2]);
ans = min(ans, f[l][3]);
ans = min(ans, f[l][4]);
printf("%lld\n", ans);
return 0;
} | [
"variable_declaration.add",
"literal.number.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 933,794 | 933,793 | u137690186 | cpp |
p03132 | #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll) INF *INF
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vp;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int dp[200005][5];
signed main(void) {
int n;
cin >> n;
vi a(n);
rep(i, n) cin >> a[i];
rep(i, 200005) rep(j, 5) dp[i][j] = LINF;
dp[0][0] = 0;
rep(i, n) rep(j, 5) if (dp[i][j] < LINF) {
// cout << i << " " << j << " " << dp[i][j] << endl;
if (j <= 0)
dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + a[i]);
if (j <= 1)
dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + a[i] % 2 + (a[i] == 0));
if (j <= 2)
dp[i + 1][2] = min(dp[i + 1][2], dp[i][j] + (a[i] % 2 == 0));
if (j <= 3)
dp[i + 1][3] = min(dp[i + 1][3], dp[i][j] + a[i] % 2 + (a[i] == 0));
if (j <= 4)
dp[i + 1][4] = min(dp[i + 1][4], dp[i][j] + a[i]);
dp[i][j] = LINF;
}
int ans = LINF;
rep(i, 5) ans = min(ans, dp[n][i]);
cout << ans << endl;
}
| #include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll) INF *INF
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vp;
int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int dp[200005][5];
signed main(void) {
int n;
cin >> n;
vi a(n);
rep(i, n) cin >> a[i];
rep(i, 200005) rep(j, 5) dp[i][j] = LINF;
dp[0][0] = 0;
rep(i, n) rep(j, 5) if (dp[i][j] < LINF) {
// cout << i << " " << j << " " << dp[i][j] << endl;
if (j <= 0)
dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + a[i]);
if (j <= 1)
dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + a[i] % 2 + 2 * (a[i] == 0));
if (j <= 2)
dp[i + 1][2] = min(dp[i + 1][2], dp[i][j] + (a[i] % 2 == 0));
if (j <= 3)
dp[i + 1][3] = min(dp[i + 1][3], dp[i][j] + a[i] % 2 + 2 * (a[i] == 0));
if (j <= 4)
dp[i + 1][4] = min(dp[i + 1][4], dp[i][j] + a[i]);
dp[i][j] = LINF;
}
int ans = LINF;
rep(i, 5) ans = min(ans, dp[n][i]);
cout << ans << endl;
}
| [
"assignment.change"
] | 933,795 | 933,796 | u471289663 | cpp |
p03132 |
#include <bits/stdc++.h>
#define MAX_N 200005
#define MAX_M 100005
#define pb push_back
#define mp make_pair
#define all(V) (V).begin(), (V).end()
#define reset(V) \
(V).clear(); \
(V).resize(0);
#define sq(x) ((x) * (x))
#define abs(x) ((x) > 0 ? (x) : (-(x)))
#define fi first
#define se second
#define LL_inf (1LL << 60)
#define full_inf 0x7fffffff
#define half_inf 0x3fffffff
#define inf 0x3fffffff
#define MOD 1000000007LL
#define cpx_mod(x) (((LD)(((LL)x.real()) % MOD)), ((LD)(((LL)x.imag()) % MOD)))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pil;
typedef pair<LL, string> pls;
typedef complex<LD> Complex;
typedef long double LD;
LL n, ans;
LL t[MAX_N][3], V[MAX_N];
void solve() {
LL i, x;
for (i = 1; i <= n; i++) {
t[i][0] =
max({0LL, t[i - 1][0], t[i - 1][1]}) + (V[i] % 2 ? V[i] : V[i] - 1);
if (V[i] == 0)
x = -2;
else if (V[i] == 1)
x = 0;
else
x = V[i] / 2 * 2;
t[i][1] = max(0LL, t[i - 1][1]) + x;
t[i][2] = max({0LL, t[i - 1][0], t[i - 1][1], t[i - 1][2]}) + x;
ans = max({ans, t[i][0], t[i][1], t[i - 1][2]});
}
}
int main() {
LL i;
scanf("%lld", &n);
for (i = 1; i <= n; i++)
scanf("%lld", &V[i]);
solve();
for (i = 1; i <= n / 2; i++)
swap(V[i], V[n - i + 1]);
for (i = 1; i <= n; i++)
t[i][0] = t[i][1] = t[i][2] = 0;
solve();
ans = -ans;
for (i = 1; i <= n; i++)
ans += V[i];
printf("%lld\n", ans);
return 0;
} |
#include <bits/stdc++.h>
#define MAX_N 200005
#define MAX_M 100005
#define pb push_back
#define mp make_pair
#define all(V) (V).begin(), (V).end()
#define reset(V) \
(V).clear(); \
(V).resize(0);
#define sq(x) ((x) * (x))
#define abs(x) ((x) > 0 ? (x) : (-(x)))
#define fi first
#define se second
#define LL_inf (1LL << 60)
#define full_inf 0x7fffffff
#define half_inf 0x3fffffff
#define inf 0x3fffffff
#define MOD 1000000007LL
#define cpx_mod(x) (((LD)(((LL)x.real()) % MOD)), ((LD)(((LL)x.imag()) % MOD)))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pil;
typedef pair<LL, string> pls;
typedef complex<LD> Complex;
typedef long double LD;
LL n, ans;
LL t[MAX_N][3], V[MAX_N];
void solve() {
LL i, x;
for (i = 1; i <= n; i++) {
t[i][0] =
max({0LL, t[i - 1][0], t[i - 1][1]}) + (V[i] % 2 ? V[i] : V[i] - 1);
if (V[i] == 0)
x = -2;
else if (V[i] == 1)
x = 0;
else
x = V[i] / 2 * 2;
t[i][1] = max(0LL, t[i - 1][1]) + x;
t[i][2] = max({0LL, t[i - 1][0], t[i - 1][1], t[i - 1][2]}) + x;
ans = max({ans, t[i][0], t[i][1], t[i][2]});
}
}
int main() {
LL i;
scanf("%lld", &n);
for (i = 1; i <= n; i++)
scanf("%lld", &V[i]);
solve();
for (i = 1; i <= n / 2; i++)
swap(V[i], V[n - i + 1]);
for (i = 1; i <= n; i++)
t[i][0] = t[i][1] = t[i][2] = 0;
solve();
ans = -ans;
for (i = 1; i <= n; i++)
ans += V[i];
printf("%lld\n", ans);
return 0;
} | [
"expression.operation.binary.remove"
] | 933,799 | 933,800 | u410228537 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using tpl = tuple<int, int, int>;
typedef pair<int, int> pii;
void fastStream() {
cin.tie(0);
std::ios_base::sync_with_stdio(0);
}
ll L;
ll A[200010];
ll dp[200010][5];
ll rec(int pos, int stat) {
if (dp[pos][stat] >= 0)
return dp[pos][stat];
ll res = 1LL << 60;
if (pos == L) {
return 0;
} else if (stat == 0 || stat == 4) {
if (stat == 0)
res = min(res, rec(pos, stat + 1));
res = min(res, rec(pos + 1, stat) + A[pos]);
} else if (stat == 1 || stat == 3) {
res = min(res, rec(pos, stat + 1));
ll cost = 0;
if (A[pos] == 0)
cost++;
else if (A[pos] % 2 == 1)
cost++;
res = min(res, rec(pos + 1, stat) + cost);
} else if (stat == 2) {
res = min(res, rec(pos, stat + 1));
ll cost = 0;
if (A[pos] % 2 == 0)
cost++;
res = min(res, rec(pos + 1, stat) + cost);
}
return dp[pos][stat] = res;
}
int main() {
cin >> L;
for (int i = 0; i < L; i++)
cin >> A[i];
memset(dp, -1, sizeof(dp));
cout << rec(0, 0) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using tpl = tuple<int, int, int>;
typedef pair<int, int> pii;
void fastStream() {
cin.tie(0);
std::ios_base::sync_with_stdio(0);
}
ll L;
ll A[200010];
ll dp[200010][5];
ll rec(int pos, int stat) {
if (dp[pos][stat] >= 0)
return dp[pos][stat];
ll res = 1LL << 60;
if (pos == L) {
return 0;
} else if (stat == 0 || stat == 4) {
if (stat == 0)
res = min(res, rec(pos, stat + 1));
res = min(res, rec(pos + 1, stat) + A[pos]);
} else if (stat == 1 || stat == 3) {
res = min(res, rec(pos, stat + 1));
ll cost = 0;
if (A[pos] == 0)
cost += 2;
else if (A[pos] % 2 == 1)
cost++;
res = min(res, rec(pos + 1, stat) + cost);
} else if (stat == 2) {
res = min(res, rec(pos, stat + 1));
ll cost = 0;
if (A[pos] % 2 == 0)
cost++;
res = min(res, rec(pos + 1, stat) + cost);
}
return dp[pos][stat] = res;
}
int main() {
cin >> L;
for (int i = 0; i < L; i++)
cin >> A[i];
memset(dp, -1, sizeof(dp));
cout << rec(0, 0) << endl;
return 0;
}
| [] | 933,801 | 933,802 | u489053642 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cerr << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cerr << " " << v[i]; \
cerr << endl
#define DEBUG_MAT(v) \
cerr << #v << endl; \
for (int i = 0; i < v.size(); i++) { \
for (int j = 0; j < v[i].size(); j++) { \
cout << v[i][j] << " "; \
} \
cout << endl; \
}
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
#define X first
#define Y second
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(), c.end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
#define fio() \
cin.tie(0); \
ios::sync_with_stdio(false);
//#define mp make_pair
int main() {
int l;
cin >> l;
vl a(l);
rep(i, l) { cin >> a[i]; }
ll ans = INF;
rep(aaa, 2) {
vll dp(l + 1, vl(4, INF));
dp[0][1] = 0;
dp[0][0] = 0;
dp[0][2] = 0;
dp[0][3] = 0;
ll era = 0;
rep(i, l) {
era += a[i];
dp[i + 1][0] = era;
dp[i + 1][1] = era;
dp[i + 1][2] = min(dp[i][2] + a[i], era);
dp[i + 1][3] = era;
rep(j, 4) {
if (j == 0) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][2], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 2);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][0], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 1);
} else {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][3], dp[i][0]);
}
} else if (j == 1) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][1] + 1);
chmin(dp[i + 1][1], dp[i][1] + 2);
chmin(dp[i + 1][2], dp[i][1]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][1], dp[i][1] + 1);
chmin(dp[i + 1][0], dp[i][1]);
} else {
chmin(dp[i + 1][1], dp[i][1]);
chmin(dp[i + 1][0], dp[i][1] + 1);
}
} else if (j == 3) {
if (a[i] == 0) {
chmin(dp[i + 1][3], dp[i][3] + 2);
chmin(dp[i + 1][2], dp[i][3]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][3], dp[i][3] + 1);
} else {
chmin(dp[i + 1][3], dp[i][3]);
}
}
}
}
rep(i, 3) { chmin(ans, dp[l][i]); }
reverse(all(a));
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cerr << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cerr << " " << v[i]; \
cerr << endl
#define DEBUG_MAT(v) \
cerr << #v << endl; \
for (int i = 0; i < v.size(); i++) { \
for (int j = 0; j < v[i].size(); j++) { \
cout << v[i][j] << " "; \
} \
cout << endl; \
}
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
#define X first
#define Y second
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(), c.end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
#define fio() \
cin.tie(0); \
ios::sync_with_stdio(false);
//#define mp make_pair
int main() {
int l;
cin >> l;
vl a(l);
rep(i, l) { cin >> a[i]; }
ll ans = INF;
rep(aaa, 2) {
vll dp(l + 1, vl(4, INF));
dp[0][1] = 0;
dp[0][0] = 0;
dp[0][2] = 0;
dp[0][3] = 0;
ll era = 0;
rep(i, l) {
era += a[i];
dp[i + 1][0] = era;
dp[i + 1][1] = era;
dp[i + 1][2] = min(dp[i][2] + a[i], era);
dp[i + 1][3] = era;
rep(j, 4) {
if (j == 0) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][2], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 2);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][0], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 1);
} else {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][3], dp[i][0]);
}
} else if (j == 1) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][1] + 1);
chmin(dp[i + 1][1], dp[i][1] + 2);
chmin(dp[i + 1][2], dp[i][1]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][1], dp[i][1] + 1);
chmin(dp[i + 1][0], dp[i][1]);
} else {
chmin(dp[i + 1][1], dp[i][1]);
chmin(dp[i + 1][0], dp[i][1] + 1);
}
} else if (j == 3) {
if (a[i] == 0) {
chmin(dp[i + 1][3], dp[i][3] + 2);
chmin(dp[i + 1][2], dp[i][3]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][3], dp[i][3] + 1);
} else {
chmin(dp[i + 1][3], dp[i][3]);
}
}
}
}
rep(i, 4) { chmin(ans, dp[l][i]); }
reverse(all(a));
}
cout << ans << endl;
}
| [
"literal.number.change",
"call.arguments.change"
] | 933,805 | 933,806 | u579152247 | cpp |
p03132 | #include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cerr << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cerr << " " << v[i]; \
cerr << endl
#define DEBUG_MAT(v) \
cerr << #v << endl; \
for (int i = 0; i < v.size(); i++) { \
for (int j = 0; j < v[i].size(); j++) { \
cout << v[i][j] << " "; \
} \
cout << endl; \
}
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
#define X first
#define Y second
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(), c.end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
#define fio() \
cin.tie(0); \
ios::sync_with_stdio(false);
//#define mp make_pair
int main() {
int l;
cin >> l;
vl a(l);
rep(i, l) { cin >> a[i]; }
ll ans = INF;
rep(aaa, 2) {
vll dp(l + 1, vl(4, INF));
dp[0][1] = 0;
dp[0][0] = 0;
dp[0][2] = 0;
dp[0][3] = 0;
ll era = 0;
rep(i, l) {
era += a[i];
dp[i + 1][0] = era;
dp[i + 1][1] = era;
dp[i + 1][2] = min(dp[i][2] + a[i], era);
dp[i + 1][3] = era;
rep(j, 4) {
if (j == 0) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][2], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 2);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][0], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 1);
} else {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][3], dp[i][0]);
}
} else if (j == 1) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][1] + 1);
chmin(dp[i + 1][1], dp[i][1] + 2);
chmin(dp[i + 1][2], dp[i][1]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][1], dp[i][1] + 1);
chmin(dp[i + 1][0], dp[i][1]);
} else {
chmin(dp[i + 1][1], dp[i][1]);
chmin(dp[i + 1][0], dp[i][0] + 1);
}
} else if (j == 3) {
if (a[i] == 0) {
chmin(dp[i + 1][3], dp[i][3] + 2);
chmin(dp[i + 1][2], dp[i][3]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][3], dp[i][3] + 1);
} else {
chmin(dp[i + 1][3], dp[i][3]);
}
}
}
}
rep(i, 3) { chmin(ans, dp[l][i]); }
reverse(all(a));
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cerr << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cerr << " " << v[i]; \
cerr << endl
#define DEBUG_MAT(v) \
cerr << #v << endl; \
for (int i = 0; i < v.size(); i++) { \
for (int j = 0; j < v[i].size(); j++) { \
cout << v[i][j] << " "; \
} \
cout << endl; \
}
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T> ostream &operator<<(ostream &os, pair<S, T> p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
#define X first
#define Y second
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(), c.end()
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
#define fio() \
cin.tie(0); \
ios::sync_with_stdio(false);
//#define mp make_pair
int main() {
int l;
cin >> l;
vl a(l);
rep(i, l) { cin >> a[i]; }
ll ans = INF;
rep(aaa, 2) {
vll dp(l + 1, vl(4, INF));
dp[0][1] = 0;
dp[0][0] = 0;
dp[0][2] = 0;
dp[0][3] = 0;
ll era = 0;
rep(i, l) {
era += a[i];
dp[i + 1][0] = era;
dp[i + 1][1] = era;
dp[i + 1][2] = min(dp[i][2] + a[i], era);
dp[i + 1][3] = era;
rep(j, 4) {
if (j == 0) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][2], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 2);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][0], dp[i][0]);
chmin(dp[i + 1][3], dp[i][0] + 1);
} else {
chmin(dp[i + 1][0], dp[i][0] + 1);
chmin(dp[i + 1][3], dp[i][0]);
}
} else if (j == 1) {
if (a[i] == 0) {
chmin(dp[i + 1][0], dp[i][1] + 1);
chmin(dp[i + 1][1], dp[i][1] + 2);
chmin(dp[i + 1][2], dp[i][1]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][1], dp[i][1] + 1);
chmin(dp[i + 1][0], dp[i][1]);
} else {
chmin(dp[i + 1][1], dp[i][1]);
chmin(dp[i + 1][0], dp[i][1] + 1);
}
} else if (j == 3) {
if (a[i] == 0) {
chmin(dp[i + 1][3], dp[i][3] + 2);
chmin(dp[i + 1][2], dp[i][3]);
} else if (a[i] % 2 == 1) {
chmin(dp[i + 1][3], dp[i][3] + 1);
} else {
chmin(dp[i + 1][3], dp[i][3]);
}
}
}
}
rep(i, 4) { chmin(ans, dp[l][i]); }
reverse(all(a));
}
cout << ans << endl;
}
| [
"literal.number.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 933,807 | 933,806 | u579152247 | cpp |
p03132 | #define DEB
#include <bits/stdc++.h>
#define REP(i, m) for (int i = 0; i < (m); ++i)
#define REPN(i, m, in) for (int i = (in); i < (m); ++i)
#define ALL(t) (t).begin(), (t).end()
#define CLR(a) memset((a), 0, sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
using namespace std;
#ifdef DEB
#define dump(x) cerr << #x << " = " << (x) << endl
#define prl cerr << "called:" << __LINE__ << endl
#define dumpR(x) cerr << "\x1b[31m" << #x << " = " << (x) << "\x1b[39m" << endl
#define dumpY(x) cerr << "\x1b[33m" << #x << " = " << (x) << "\x1b[39m" << endl
#define dumpG(x) cerr << "\x1b[32m" << #x << " = " << (x) << "\x1b[39m" << endl
template <class T> void debug(T a, T b) {
for (; a != b; ++a)
cerr << *a << ' ';
cerr << endl;
}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template <class T> void debug(T a, T b) { ; }
#endif
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
typedef long long int lint;
typedef pair<int, int> pi;
namespace std {
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &a) {
out << '(' << a.fr << ',' << a.sc << ')';
return out;
}
} // namespace std
const lint INF = 1e18;
int n;
int ar[200005];
lint dp[200005][4];
int main() {
cin >> n;
REP(i, n) cin >> ar[i];
REP(i, n + 1) REP(t, 5) dp[i][t] = INF;
REP(i, 5) dp[0][i] = 0;
REP(i, n) {
lint evmin = INF;
REP(t, 5) {
chmin(evmin, dp[i][t]);
if (t == 0)
dp[i + 1][t] = evmin + ar[i];
else if (t == 1 || t == 3)
dp[i + 1][t] = evmin + (ar[i] == 0 ? 2 : ar[i] % 2);
else if (t == 2)
dp[i + 1][t] = evmin + (1 - ar[i] % 2);
else if (t == 4)
dp[i + 1][t] = evmin + ar[i];
}
}
lint res = INF;
REP(i, 5) chmin(res, dp[n][i]);
cout << res << endl;
return 0;
}
| #define DEB
#include <bits/stdc++.h>
#define REP(i, m) for (int i = 0; i < (m); ++i)
#define REPN(i, m, in) for (int i = (in); i < (m); ++i)
#define ALL(t) (t).begin(), (t).end()
#define CLR(a) memset((a), 0, sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
using namespace std;
#ifdef DEB
#define dump(x) cerr << #x << " = " << (x) << endl
#define prl cerr << "called:" << __LINE__ << endl
#define dumpR(x) cerr << "\x1b[31m" << #x << " = " << (x) << "\x1b[39m" << endl
#define dumpY(x) cerr << "\x1b[33m" << #x << " = " << (x) << "\x1b[39m" << endl
#define dumpG(x) cerr << "\x1b[32m" << #x << " = " << (x) << "\x1b[39m" << endl
template <class T> void debug(T a, T b) {
for (; a != b; ++a)
cerr << *a << ' ';
cerr << endl;
}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template <class T> void debug(T a, T b) { ; }
#endif
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
typedef long long int lint;
typedef pair<int, int> pi;
namespace std {
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &a) {
out << '(' << a.fr << ',' << a.sc << ')';
return out;
}
} // namespace std
const lint INF = 1e18;
int n;
int ar[200005];
lint dp[200005][5];
int main() {
cin >> n;
REP(i, n) cin >> ar[i];
REP(i, n + 1) REP(t, 5) dp[i][t] = INF;
REP(i, 5) dp[0][i] = 0;
REP(i, n) {
lint evmin = INF;
REP(t, 5) {
chmin(evmin, dp[i][t]);
if (t == 0)
dp[i + 1][t] = evmin + ar[i];
else if (t == 1 || t == 3)
dp[i + 1][t] = evmin + (ar[i] == 0 ? 2 : ar[i] % 2);
else if (t == 2)
dp[i + 1][t] = evmin + (1 - ar[i] % 2);
else if (t == 4)
dp[i + 1][t] = evmin + ar[i];
}
}
lint res = INF;
REP(i, 5) chmin(res, dp[n][i]);
cout << res << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change"
] | 933,810 | 933,811 | u801556382 | cpp |
p03133 | #include <bits/stdc++.h>
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T b) {
if (a >= b)
return false;
a = b;
return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
if (a <= b)
return false;
a = b;
return true;
}
/*-------------------------------------------*/
constexpr int MAX_ROW = 510;
constexpr int MAX_COL = 510;
struct BitMatrix {
int H, W;
bitset<MAX_COL> val[MAX_ROW];
BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
inline bitset<MAX_COL> &operator[](const int &i) { return val[i]; }
};
int GaussJordan(BitMatrix &A, bool is_extended = false) {
int rank = 0;
rep(col, A.W) {
if (is_extended && col == A.W - 1)
break;
int pivot = -1;
rep(row, A.H) {
if (A[row][col]) {
pivot = row;
break;
}
}
if (pivot == -1)
continue;
swap(A[pivot], A[rank]);
rep(row, A.H) if (row != rank && A[row][col]) A[row] ^= A[rank];
rank++;
}
return rank;
}
template <int M> class ModInt {
int x;
public:
constexpr ModInt() : x(0) {}
constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
constexpr ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= M)
x -= M;
return *this;
}
constexpr ModInt &operator-=(const ModInt &p) {
if ((x += M - p.x) >= M)
x -= M;
return *this;
}
constexpr ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % M);
return *this;
}
constexpr ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
constexpr ModInt operator-() const { return ModInt(-x); }
constexpr ModInt operator+(const ModInt &p) const {
return ModInt(*this) += p;
}
constexpr ModInt operator-(const ModInt &p) const {
return ModInt(*this) -= p;
}
constexpr ModInt operator*(const ModInt &p) const {
return ModInt(*this) *= p;
}
constexpr ModInt operator/(const ModInt &p) const {
return ModInt(*this) /= p;
}
constexpr bool operator==(const ModInt &p) const { return x == p.x; }
constexpr bool operator!=(const ModInt &p) const { return x != p.x; }
constexpr ModInt inverse() const {
int a = x, b = M, u = 1, v = 0, t = 0;
while (b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
constexpr ModInt pow(const int64_t &n) const {
ModInt ret(1), mul(x);
int64_t k = n % (M - 1);
while (k > 0) {
if (k & 1)
ret *= mul;
mul *= mul;
k >>= 1;
}
return ret;
}
constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
return os << p.x;
}
constexpr friend istream &operator>>(istream &is, ModInt &a) {
int64_t t = 0;
is >> t;
a = ModInt(t);
return (is);
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
BitMatrix A(n, m);
rep(i, n) rep(j, m) {
int a;
cin >> a;
if (a)
A[i].set(j);
}
int r = GaussJordan(A);
using modint = ModInt<Mod>;
modint m2(2);
cout << m2.pow(n + m - 1) - m2.pow(n + m - r - 1) << endl;
return 0;
} | #include <bits/stdc++.h>
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T b) {
if (a >= b)
return false;
a = b;
return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
if (a <= b)
return false;
a = b;
return true;
}
/*-------------------------------------------*/
constexpr int MAX_ROW = 510;
constexpr int MAX_COL = 510;
struct BitMatrix {
int H, W;
bitset<MAX_COL> val[MAX_ROW];
BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
inline bitset<MAX_COL> &operator[](const int &i) { return val[i]; }
};
int GaussJordan(BitMatrix &A, bool is_extended = false) {
int rank = 0;
rep(col, A.W) {
if (is_extended && col == A.W - 1)
break;
int pivot = -1;
FOR(row, rank, A.H) {
if (A[row][col]) {
pivot = row;
break;
}
}
if (pivot == -1)
continue;
swap(A[pivot], A[rank]);
rep(row, A.H) if (row != rank && A[row][col]) A[row] ^= A[rank];
rank++;
}
return rank;
}
template <int M> class ModInt {
int x;
public:
constexpr ModInt() : x(0) {}
constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
constexpr ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= M)
x -= M;
return *this;
}
constexpr ModInt &operator-=(const ModInt &p) {
if ((x += M - p.x) >= M)
x -= M;
return *this;
}
constexpr ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % M);
return *this;
}
constexpr ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
constexpr ModInt operator-() const { return ModInt(-x); }
constexpr ModInt operator+(const ModInt &p) const {
return ModInt(*this) += p;
}
constexpr ModInt operator-(const ModInt &p) const {
return ModInt(*this) -= p;
}
constexpr ModInt operator*(const ModInt &p) const {
return ModInt(*this) *= p;
}
constexpr ModInt operator/(const ModInt &p) const {
return ModInt(*this) /= p;
}
constexpr bool operator==(const ModInt &p) const { return x == p.x; }
constexpr bool operator!=(const ModInt &p) const { return x != p.x; }
constexpr ModInt inverse() const {
int a = x, b = M, u = 1, v = 0, t = 0;
while (b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
constexpr ModInt pow(const int64_t &n) const {
ModInt ret(1), mul(x);
int64_t k = n % (M - 1);
while (k > 0) {
if (k & 1)
ret *= mul;
mul *= mul;
k >>= 1;
}
return ret;
}
constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
return os << p.x;
}
constexpr friend istream &operator>>(istream &is, ModInt &a) {
int64_t t = 0;
is >> t;
a = ModInt(t);
return (is);
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
BitMatrix A(n, m);
rep(i, n) rep(j, m) {
int a;
cin >> a;
if (a)
A[i].set(j);
}
int r = GaussJordan(A);
using modint = ModInt<Mod>;
modint m2(2);
cout << m2.pow(n + m - 1) - m2.pow(n + m - r - 1) << endl;
return 0;
} | [
"identifier.change",
"call.function.change",
"call.arguments.add"
] | 933,832 | 933,833 | u047554023 | cpp |
p03133 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::bitset;
using std::deque;
using std::iterator;
using std::map;
using std::multimap;
using std::multiset;
using std::pair;
using std::queue;
using std::set;
using std::stack;
using std::string;
using std::vector;
using std::fill;
using std::ios_base;
using std::max_element;
using std::min_element;
using std::reverse;
using std::sort;
using std::stable_sort;
using std::swap;
using std::unique;
using std::fixed;
using std::setprecision;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;
ll min(ll a, ll b) { return a < b ? a : b; }
ll min(int a, ll b) { return a < b ? a : b; }
ll min(ll a, int b) { return a < b ? a : b; }
ll min(int a, int b) { return a < b ? a : b; }
ll max(ll a, ll b) { return a > b ? a : b; }
ll max(int a, ll b) { return a > b ? a : b; }
ll max(ll a, int b) { return a > b ? a : b; }
ll max(int a, int b) { return a > b ? a : b; }
namespace MySpace {};
#define F(i, n) for (int(i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long
const int N = 333333;
const int MOD = 998244353;
int n, m;
vector<int> a[500];
vector<int> st[500];
long long inq(long long x, long long y) {
if (y == 0)
return 1;
long long l = inq(x, y / 2);
if (y % 2)
return l * l % MOD * x % MOD;
return l * l % MOD;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x;
cin >> x;
a[i].push_back(x);
}
}
int sz = 0;
for (int i = 0; i < n; i++) {
int t = -1;
for (int j = 0; j < m; j++) {
if (a[i][j] && st[j].size() == 0) {
t = j;
break;
} else {
if (a[i][j]) {
for (int k = 0; k < m; k++) {
a[i][j] = a[i][j] ^ st[j][k];
}
}
}
}
if (t > -1) {
st[t] = a[i];
sz++;
}
}
cout << inq(2, m - 1) * (inq(2, n) - inq(2, n - sz) + MOD) % MOD;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::bitset;
using std::deque;
using std::iterator;
using std::map;
using std::multimap;
using std::multiset;
using std::pair;
using std::queue;
using std::set;
using std::stack;
using std::string;
using std::vector;
using std::fill;
using std::ios_base;
using std::max_element;
using std::min_element;
using std::reverse;
using std::sort;
using std::stable_sort;
using std::swap;
using std::unique;
using std::fixed;
using std::setprecision;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;
ll min(ll a, ll b) { return a < b ? a : b; }
ll min(int a, ll b) { return a < b ? a : b; }
ll min(ll a, int b) { return a < b ? a : b; }
ll min(int a, int b) { return a < b ? a : b; }
ll max(ll a, ll b) { return a > b ? a : b; }
ll max(int a, ll b) { return a > b ? a : b; }
ll max(ll a, int b) { return a > b ? a : b; }
ll max(int a, int b) { return a > b ? a : b; }
namespace MySpace {};
#define F(i, n) for (int(i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long
const int N = 333333;
const int MOD = 998244353;
int n, m;
vector<int> a[500];
vector<int> st[500];
long long inq(long long x, long long y) {
if (y == 0)
return 1;
long long l = inq(x, y / 2);
if (y % 2)
return l * l % MOD * x % MOD;
return l * l % MOD;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x;
cin >> x;
a[i].push_back(x);
}
}
int sz = 0;
for (int i = 0; i < n; i++) {
int t = -1;
for (int j = 0; j < m; j++) {
if (a[i][j] && st[j].size() == 0) {
t = j;
break;
} else {
if (a[i][j]) {
for (int k = 0; k < m; k++) {
a[i][k] = a[i][k] ^ st[j][k];
}
}
}
}
if (t > -1) {
st[t] = a[i];
sz++;
}
}
// cout << sz << "\n";
cout << inq(2, m - 1) * (inq(2, n) - inq(2, n - sz) + MOD) % MOD;
}
| [
"assignment.variable.change",
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 933,834 | 933,835 | u798339690 | cpp |
p03133 | #include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
// const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL << 60;
// const int INF = INT_MAX;
const ll INF = 1 << 30; // 10^9
// ll MOD = 1000000007;
ll MOD = 998244353;
vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
void pres(double A, ll x = 20) {
cout << fixed << setprecision(x) << A << endl;
}
void BinarySay(ll x, ll y = 60) {
rep(i, y) cout << (x >> (y - 1 - i) & 1);
cout << endl;
}
ll cnt_bit(ll x) { return __builtin_popcountll(x); }
ll pow_long(ll x, ll k) {
ll res = 1;
while (k > 0) {
if (k % 2)
res *= x;
x *= x;
k /= 2;
}
return res;
}
ll pow_mod(ll x, ll k) {
ll res = 1;
while (k > 0) {
if (k % 2) {
res *= x;
res %= MOD;
}
x *= x;
x %= MOD;
k /= 2;
}
return res;
}
ll inverse(ll x) { return pow_mod(x, MOD - 2); };
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll x, ll y) {
ll res = x / gcd(x, y);
res *= y;
return res;
};
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
// facはn!,finvは1/n!
// invは逆元
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAXcomb; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll comb(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
}
const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N) {
if (kai_memo[N] != 0)
return kai_memo[N];
if (N <= 1)
return 1;
return kai_memo[N] = N * kai(N - 1) % MOD;
}
ll Rank(ll N, ll M, vector<vector<ll>> A) {
ll next = 0;
rep(i, M) {
for (ll j = next; j < N; j++) {
if (A[j][i]) {
swap(A[next], A[j]);
}
}
if (!A[next][i])
continue;
rep(j, N) if (j != next) {
if (A[j][i]) {
rep(k, M) A[j][k] ^= A[next][k];
}
}
next++;
if (next == N + 1)
break;
}
return next;
}
ll N, M;
vector<vector<ll>> A;
void solve() {
COMinit();
cin >> N >> M;
A.resize(N);
rep(i, N) A[i].resize(M);
rep(i, N) rep(j, M) cin >> A[i][j];
ll r = Rank(N, M, A);
ll ans = 0;
rep(i, r + 1) {
ll add = comb(r, i) * pow_mod(2, r - i) % MOD;
for (ll j = 1; j <= i; j += 2) {
ans += add * comb(i, j) % MOD;
ans %= MOD;
}
}
ans *= pow_mod(2, N + M - 2 * r);
ans %= MOD;
cout << ans << endl;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
}
| #include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
// const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL << 60;
// const int INF = INT_MAX;
const ll INF = 1 << 30; // 10^9
// ll MOD = 1000000007;
ll MOD = 998244353;
vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};
void pres(double A, ll x = 20) {
cout << fixed << setprecision(x) << A << endl;
}
void BinarySay(ll x, ll y = 60) {
rep(i, y) cout << (x >> (y - 1 - i) & 1);
cout << endl;
}
ll cnt_bit(ll x) { return __builtin_popcountll(x); }
ll pow_long(ll x, ll k) {
ll res = 1;
while (k > 0) {
if (k % 2)
res *= x;
x *= x;
k /= 2;
}
return res;
}
ll pow_mod(ll x, ll k) {
ll res = 1;
while (k > 0) {
if (k % 2) {
res *= x;
res %= MOD;
}
x *= x;
x %= MOD;
k /= 2;
}
return res;
}
ll inverse(ll x) { return pow_mod(x, MOD - 2); };
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll x, ll y) {
ll res = x / gcd(x, y);
res *= y;
return res;
};
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
// facはn!,finvは1/n!
// invは逆元
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAXcomb; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll comb(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
}
const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N) {
if (kai_memo[N] != 0)
return kai_memo[N];
if (N <= 1)
return 1;
return kai_memo[N] = N * kai(N - 1) % MOD;
}
ll Rank(ll N, ll M, vector<vector<ll>> A) {
ll next = 0;
rep(i, M) {
for (ll j = next; j < N; j++) {
if (A[j][i]) {
swap(A[next], A[j]);
}
}
if (!A[next][i])
continue;
rep(j, N) if (j != next) {
if (A[j][i]) {
rep(k, M) A[j][k] ^= A[next][k];
}
}
next++;
if (next == N)
break;
}
return next;
}
ll N, M;
vector<vector<ll>> A;
void solve() {
COMinit();
cin >> N >> M;
A.resize(N);
rep(i, N) A[i].resize(M);
rep(i, N) rep(j, M) cin >> A[i][j];
ll r = Rank(N, M, A);
ll ans = 0;
rep(i, r + 1) {
ll add = comb(r, i) * pow_mod(2, r - i) % MOD;
for (ll j = 1; j <= i; j += 2) {
ans += add * comb(i, j) % MOD;
ans %= MOD;
}
}
ans *= pow_mod(2, N + M - 2 * r);
ans %= MOD;
cout << ans << endl;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
}
| [
"expression.operation.binary.remove"
] | 933,838 | 933,839 | u633284019 | cpp |
p03133 | #include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 998244353;
const Int MAX = 1000;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
Int COM(Int n, Int k) {
if (n < k || n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
Int POW(Int n, Int m) {
if (m == 0)
return 1;
if (m % 2 == 0)
return POW(n * n % MOD, m / 2);
return n * POW(n, m - 1) % MOD;
}
int gaussian_elimination(vector<vector<int>> &A) {
int N = A.size(), M = A[0].size();
int t = 0;
for (int i = 0; i < N; i++) {
for (; t < M; t++) {
for (int j = i; j < N; j++) {
if (A[j][t]) {
swap(A[i], A[j]);
break;
}
}
if (A[i][t])
break;
}
if (t >= M)
return i;
for (int j = i + 1; j < N; j++) {
if (j != i && A[j][t]) {
for (int k = 0; k < M; k++)
A[j][k] ^= A[i][k];
}
}
t++;
}
return N;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
COMinit();
int N, M;
cin >> N >> M;
vector<vector<int>> A(N, vector<int>(M));
for (auto &row : A)
for (auto &a : row)
cin >> a;
int rank = gaussian_elimination(A);
Int ans = 0;
for (int i = 1; i <= rank; i++) {
for (int j = 1; j <= i; j += 2) {
ans = ans + COM(rank, i) * COM(i, j) % MOD * POW(2, M - j) % MOD;
}
}
ans %= MOD;
ans = ans * POW(2, N - rank) % MOD;
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 998244353;
const Int MAX = 1000;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
Int COM(Int n, Int k) {
if (n < k || n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
Int POW(Int n, Int m) {
if (m == 0)
return 1;
if (m % 2 == 0)
return POW(n * n % MOD, m / 2);
return n * POW(n, m - 1) % MOD;
}
int gaussian_elimination(vector<vector<int>> &A) {
int N = A.size(), M = A[0].size();
int t = 0;
for (int i = 0; i < N; i++) {
for (; t < M; t++) {
for (int j = i; j < N; j++) {
if (A[j][t]) {
swap(A[i], A[j]);
break;
}
}
if (A[i][t])
break;
}
if (t >= M)
return i;
for (int j = i + 1; j < N; j++) {
if (j != i && A[j][t]) {
for (int k = 0; k < M; k++)
A[j][k] ^= A[i][k];
}
}
t++;
}
return N;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
COMinit();
int N, M;
cin >> N >> M;
vector<vector<int>> A(N, vector<int>(M));
for (auto &row : A)
for (auto &a : row)
cin >> a;
int rank = gaussian_elimination(A);
Int ans = 0;
for (int i = 1; i <= rank; i++) {
for (int j = 1; j <= i; j += 2) {
ans = ans + COM(rank, i) * COM(i, j) % MOD * POW(2, M - i) % MOD;
}
}
ans %= MOD;
ans = ans * POW(2, N - rank) % MOD;
cout << ans << endl;
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 933,842 | 933,841 | u449722246 | cpp |
p03114 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, INV9 = (MOD + 1) / 9;
int dp[12][1 << 15 | 1], val[1 << 15 | 1], val0[1 << 15 | 1], N, Q, l[20],
r[20];
vector<int> lsh, coef;
int poww(long long a, int b) {
int times = 1;
while (b) {
if (b & 1)
times = times * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return times;
}
int main() {
cin >> N >> Q;
int mx = 0, tms = 1;
for (int i = 0; i < Q; ++i) {
cin >> l[i] >> r[i];
lsh.push_back(--l[i]);
lsh.push_back(r[i]);
mx = max(mx, r[i]);
}
sort(lsh.begin(), lsh.end());
lsh.resize(unique(lsh.begin(), lsh.end()) - lsh.begin());
coef.resize(lsh.size());
for (int i = 0; i < coef.size(); ++i) {
int t = (poww(10, lsh[i] - (i ? lsh[i - 1] : 0)) - 1ll) * INV9 % MOD;
coef[i] = (t + 1ll) * poww(t, MOD - 2) % MOD;
if (i)
tms = 1ll * tms * t % MOD;
}
for (int i = 0; i < Q; ++i) {
l[i] = lower_bound(lsh.begin(), lsh.end(), l[i]) - lsh.begin();
r[i] = lower_bound(lsh.begin(), lsh.end(), r[i]) - lsh.begin();
}
for (int i = 0; i < 1 << Q; ++i) {
bool vis[40] = {};
val[i] = 1;
for (int j = 0; j < Q; ++j) {
vis[l[j]] |= i >> j & 1;
vis[r[j]] |= i >> j & 1;
}
for (int j = 0; j < Q; ++j)
val[i] &= !(vis[l[j]] ^ vis[r[j]]);
for (int j = 1; j < coef.size(); ++j)
if (vis[j] && vis[j - 1])
val[i] = 1ll * val[i] * coef[j] % MOD;
if (lsh[0] == 0)
val0[i] = !vis[0] ? 0 : val[i];
else
val0[i] = !vis[0] ? val[i] : 1ll * val[i] * coef[0] % MOD;
}
dp[0][0] = 1;
for (int i = 0; i < 9; ++i)
for (int j = 0; j < 1 << Q; ++j)
if (dp[i][j]) {
int k = ((1 << Q) - 1) ^ j, s = k;
while (1) {
dp[i + 1][j | s] =
(dp[i + 1][j | s] + 1ll * dp[i][j] * (i ? val[s] : val0[s])) %
MOD;
if (!s)
break;
s = (s - 1) & k;
}
}
int ans = dp[9][(1 << Q) - 1];
tms = 1ll * tms * poww(10, N - mx) % MOD;
cout << 1ll * ans * tms % MOD;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, INV9 = (MOD + 1) / 9;
int dp[12][1 << 15 | 1], val[1 << 15 | 1], val0[1 << 15 | 1], N, Q, l[20],
r[20];
vector<int> lsh, coef;
int poww(long long a, int b) {
int times = 1;
while (b) {
if (b & 1)
times = times * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return times;
}
int main() {
cin >> N >> Q;
int mx = 0, tms = 1;
for (int i = 0; i < Q; ++i) {
cin >> l[i] >> r[i];
lsh.push_back(--l[i]);
lsh.push_back(r[i]);
mx = max(mx, r[i]);
}
sort(lsh.begin(), lsh.end());
lsh.resize(unique(lsh.begin(), lsh.end()) - lsh.begin());
coef.resize(lsh.size());
for (int i = 0; i < coef.size(); ++i) {
int t = (poww(10, lsh[i] - (i ? lsh[i - 1] : 0)) - 1ll) * INV9 % MOD;
coef[i] = (t + 1ll) * poww(t, MOD - 2) % MOD;
if (t)
tms = 1ll * tms * t % MOD;
}
for (int i = 0; i < Q; ++i) {
l[i] = lower_bound(lsh.begin(), lsh.end(), l[i]) - lsh.begin();
r[i] = lower_bound(lsh.begin(), lsh.end(), r[i]) - lsh.begin();
}
for (int i = 0; i < 1 << Q; ++i) {
bool vis[40] = {};
val[i] = 1;
for (int j = 0; j < Q; ++j) {
vis[l[j]] |= i >> j & 1;
vis[r[j]] |= i >> j & 1;
}
for (int j = 0; j < Q; ++j)
val[i] &= !(vis[l[j]] ^ vis[r[j]]);
for (int j = 1; j < coef.size(); ++j)
if (vis[j] && vis[j - 1])
val[i] = 1ll * val[i] * coef[j] % MOD;
if (lsh[0] == 0)
val0[i] = !vis[0] ? 0 : val[i];
else
val0[i] = !vis[0] ? val[i] : 1ll * val[i] * coef[0] % MOD;
}
dp[0][0] = 1;
for (int i = 0; i < 9; ++i)
for (int j = 0; j < 1 << Q; ++j)
if (dp[i][j]) {
int k = ((1 << Q) - 1) ^ j, s = k;
while (1) {
dp[i + 1][j | s] =
(dp[i + 1][j | s] + 1ll * dp[i][j] * (i ? val[s] : val0[s])) %
MOD;
if (!s)
break;
s = (s - 1) & k;
}
}
int ans = dp[9][(1 << Q) - 1];
tms = 1ll * tms * poww(10, N - mx) % MOD;
cout << 1ll * ans * tms % MOD;
return 0;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 933,879 | 933,880 | u563201135 | cpp |
p03114 | // by yjz
#include <bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it, s) \
for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); it++)
#ifndef LOCAL
#define cerr \
if (0) \
cout
#endif
typedef long long ll;
const int mod = 1e9 + 7;
// My i/o stream
struct fastio {
char s[100000];
int it, len;
fastio() { it = len = 0; }
inline char get() {
if (it < len)
return s[it++];
it = 0;
len = fread(s, 1, 100000, stdin);
if (len == 0)
return EOF;
else
return s[it++];
}
bool notend() {
char c = get();
while (c == ' ' || c == '\n')
c = get();
if (it > 0)
it--;
return c != EOF;
}
} _buff;
#define geti(x) x = getnum()
#define getii(x, y) geti(x), geti(y)
#define getiii(x, y, z) getii(x, y), geti(z)
#define puti(x) putnum(x), putchar(' ')
#define putii(x, y) puti(x), puti(y)
#define putiii(x, y, z) putii(x, y), puti(z)
#define putsi(x) putnum(x), putchar('\n')
#define putsii(x, y) puti(x), putsi(y)
#define putsiii(x, y, z) putii(x, y), putsi(z)
inline ll getnum() {
ll r = 0;
bool ng = 0;
char c;
c = _buff.get();
while (c != '-' && (c < '0' || c > '9'))
c = _buff.get();
if (c == '-')
ng = 1, c = _buff.get();
while (c >= '0' && c <= '9')
r = r * 10 + c - '0', c = _buff.get();
return ng ? -r : r;
}
template <class T> inline void putnum(T x) {
if (x < 0)
putchar('-'), x = -x;
register short a[20] = {}, sz = 0;
while (x)
a[sz++] = x % 10, x /= 10;
if (sz == 0)
putchar('0');
for (int i = sz - 1; i >= 0; i--)
putchar('0' + a[i]);
}
inline char getreal() {
char c = _buff.get();
while (c <= 32)
c = _buff.get();
return c;
}
ll qpow(ll x, ll k) {
return k == 0 ? 1
: 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;
}
int n, m, l;
vector<int> v;
int getid(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); }
pair<int, int> rtr[15];
vector<int> con[33];
int id[33];
void dfs(int x, int g) {
id[x] = g;
for (auto u : con[x]) {
if (id[u] == -1)
dfs(u, g);
}
}
int to_msk[1 << 15];
ll cnt1[1 << 15];
int w[33];
int calc_cost(int msk0, int msk1, int c) {
int ret = 1;
if (v[0] == 0) {
if ((msk1 & 1) && c != 0)
return 0;
} else {
if (msk1 & 1) {
if (c == 0)
ret = w[0] + 1;
else
ret = w[0];
}
}
for (int i = 1; i < l; i++) {
if (((msk1 >> id[i]) & 1) && ((msk0 >> id[i - 1]) & 1)) {
ret = 1ll * ret * w[i] % mod;
} else if (((msk0 >> id[i]) & 1) && ((msk1 >> id[i - 1]) & 1)) {
ret = 1ll * ret * w[i] % mod;
} else if (((msk1 >> id[i]) & 1) && ((msk1 >> id[i - 1]) & 1)) {
ret = 1ll * ret * (w[i] + 1) % mod;
}
}
return ret;
}
void init() {
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
l = v.size();
for (int i = 0; i < m; i++) {
int x = getid(rtr[i].FF), y = getid(rtr[i].SS);
/// cerr<<x<<"-"<<y<<endl;
con[x].PB(y);
con[y].PB(x);
}
memset(id, -1, sizeof(id));
n = 0;
for (int i = 0; i < l; i++)
if (id[i] == -1)
dfs(i, n++);
for (int i = 0; i < l; i++) {
int len = v[i] - (i == 0 ? 0 : v[i - 1]);
w[i] = 1ll * (qpow(10, len) + mod - 1) * qpow(9, mod - 2) % mod;
}
}
int dp[10][1 << 15];
int main() {
int L;
geti(L);
geti(m);
for (int i = 0; i < m; i++) {
int l, r;
getii(l, r);
l--;
rtr[i] = MP(l, r);
v.PB(l);
v.PB(r);
}
init();
assert(n <= 15);
dp[0][0] = 1;
for (int j = 0; j < (1 << n); j++) {
int MSK = (1 << n) - 1 - j;
int msk = MSK;
for (int i = 0; i < 9; i++) {
dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
// cerr<<i<<","<<j<<" "<<dp[i][j]<<endl;
}
while (msk > 0) {
if (j == 0) {
dp[1][j | msk] =
(dp[1][j | msk] + 1ll * dp[0][j] * calc_cost(j, msk, 0)) % mod;
}
int cost = calc_cost(j, msk, 1);
for (int i = 0; i < 9; i++) {
dp[i + 1][j | msk] = (dp[i + 1][j | msk] + 1ll * dp[i][j] * cost) % mod;
}
msk = (msk - 1) & MSK;
}
}
int ans = 1ll * dp[9][(1 << n) - 1] * qpow(10, L - v.back()) % mod;
cout << (ans + mod) % mod << endl;
return 0;
} | // by yjz
#include <bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it, s) \
for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); it++)
#ifndef LOCAL
#define cerr \
if (0) \
cout
#endif
typedef long long ll;
const int mod = 1e9 + 7;
// My i/o stream
struct fastio {
char s[100000];
int it, len;
fastio() { it = len = 0; }
inline char get() {
if (it < len)
return s[it++];
it = 0;
len = fread(s, 1, 100000, stdin);
if (len == 0)
return EOF;
else
return s[it++];
}
bool notend() {
char c = get();
while (c == ' ' || c == '\n')
c = get();
if (it > 0)
it--;
return c != EOF;
}
} _buff;
#define geti(x) x = getnum()
#define getii(x, y) geti(x), geti(y)
#define getiii(x, y, z) getii(x, y), geti(z)
#define puti(x) putnum(x), putchar(' ')
#define putii(x, y) puti(x), puti(y)
#define putiii(x, y, z) putii(x, y), puti(z)
#define putsi(x) putnum(x), putchar('\n')
#define putsii(x, y) puti(x), putsi(y)
#define putsiii(x, y, z) putii(x, y), putsi(z)
inline ll getnum() {
ll r = 0;
bool ng = 0;
char c;
c = _buff.get();
while (c != '-' && (c < '0' || c > '9'))
c = _buff.get();
if (c == '-')
ng = 1, c = _buff.get();
while (c >= '0' && c <= '9')
r = r * 10 + c - '0', c = _buff.get();
return ng ? -r : r;
}
template <class T> inline void putnum(T x) {
if (x < 0)
putchar('-'), x = -x;
register short a[20] = {}, sz = 0;
while (x)
a[sz++] = x % 10, x /= 10;
if (sz == 0)
putchar('0');
for (int i = sz - 1; i >= 0; i--)
putchar('0' + a[i]);
}
inline char getreal() {
char c = _buff.get();
while (c <= 32)
c = _buff.get();
return c;
}
ll qpow(ll x, ll k) {
return k == 0 ? 1
: 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;
}
int n, m, l;
vector<int> v;
int getid(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); }
pair<int, int> rtr[15];
vector<int> con[33];
int id[33];
void dfs(int x, int g) {
id[x] = g;
for (auto u : con[x]) {
if (id[u] == -1)
dfs(u, g);
}
}
int to_msk[1 << 15];
ll cnt1[1 << 15];
int w[33];
int calc_cost(int msk0, int msk1, int c) {
int ret = 1;
if (v[0] == 0) {
if ((msk1 & 1) && c != 0)
return 0;
} else {
if (msk1 & 1) {
if (c == 0)
ret = w[0] + 1;
else
ret = w[0];
}
}
for (int i = 1; i < l; i++) {
if (((msk1 >> id[i]) & 1) && ((msk0 >> id[i - 1]) & 1)) {
ret = 1ll * ret * w[i] % mod;
} else if (((msk0 >> id[i]) & 1) && ((msk1 >> id[i - 1]) & 1)) {
ret = 1ll * ret * w[i] % mod;
} else if (((msk1 >> id[i]) & 1) && ((msk1 >> id[i - 1]) & 1)) {
ret = 1ll * ret * (w[i] + 1) % mod;
}
}
return ret;
}
void init() {
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
l = v.size();
for (int i = 0; i < m; i++) {
int x = getid(rtr[i].FF), y = getid(rtr[i].SS);
/// cerr<<x<<"-"<<y<<endl;
con[x].PB(y);
con[y].PB(x);
}
memset(id, -1, sizeof(id));
n = 0;
for (int i = 0; i < l; i++)
if (id[i] == -1)
dfs(i, n++);
for (int i = 0; i < l; i++) {
int len = v[i] - (i == 0 ? 0 : v[i - 1]);
w[i] = 1ll * (qpow(10, len) + mod - 1) * qpow(9, mod - 2) % mod;
}
}
int dp[10][1 << 15];
int main() {
int L;
geti(L);
geti(m);
for (int i = 0; i < m; i++) {
int l, r;
getii(l, r);
l--;
rtr[i] = MP(l, r);
v.PB(l);
v.PB(r);
}
init();
assert(n <= 15);
dp[0][0] = 1;
for (int j = 0; j < (1 << n); j++) {
int MSK = (1 << n) - 1 - j;
int msk = MSK;
for (int i = 0; i < 9; i++) {
dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
// cerr<<i<<","<<j<<" "<<dp[i][j]<<endl;
}
while (msk > 0) {
if (j == 0) {
dp[1][j | msk] =
(dp[1][j | msk] + 1ll * dp[0][j] * calc_cost(j, msk, 0)) % mod;
}
int cost = calc_cost(j, msk, 1);
for (int i = 1; i < 9; i++) {
dp[i + 1][j | msk] = (dp[i + 1][j | msk] + 1ll * dp[i][j] * cost) % mod;
}
msk = (msk - 1) & MSK;
}
}
int ans = 1ll * dp[9][(1 << n) - 1] * qpow(10, L - v.back()) % mod;
cout << (ans + mod) % mod << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 933,883 | 933,884 | u563764376 | cpp |
p03114 | #include <bits/stdc++.h>
#define Q 22
#define ll long long
#define mo 1000000007
#define ni9 111111112
using namespace std;
template <typename T> void read(T &x) {
x = 0;
char c = getchar();
int fh = 1;
while (!isdigit(c)) {
if (c == '-')
fh = -1;
c = getchar();
}
while (isdigit(c))
x = x * 10 + c - '0', c = getchar();
x *= fh;
}
struct Info {
int nu, we, nn;
} a[Q * 2];
int n, q, f[Q * 2], bi[Q * 2], su[Q], ns, g[Q * 2], m, dp[33010][2], an[Q * 2];
vector<int> zh[33010], z1[33010];
bool comp(const Info &a, const Info &b) { return a.nu < b.nu; }
bool comp1(const Info &a, const Info &b) { return a.we < b.we; }
int que(int x) {
if (f[x] != x)
f[x] = que(f[x]);
return f[x];
}
void he(int x, int y) {
int nx = que(x), ny = que(y);
if (nx != ny)
f[nx] = ny;
}
ll po(ll x, ll y) {
ll z = 1;
while (y) {
if (y % 2)
z = x * z % mo;
x = x * x % mo;
y /= 2;
}
return z;
}
ll qu(int x, int y) {
int p = 0, q = 0;
ll ans = 1;
for (int i = 1; i <= ns; i++)
if ((x & (1 << (i - 1))) != 0)
p += su[i];
else if ((y & (1 << (i - 1))) != 0)
q += su[i];
for (int i = 1; i < m; i++) {
if ((q & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * (an[i] + 1) % mo;
if ((q & (1 << (i - 1))) != 0 && (p & (1 << i)) != 0)
ans = ans * an[i] % mo;
if ((p & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * an[i] % mo;
}
return ans;
}
ll qu1(int x, int y) {
int p = 0, q = 0;
ll ans = 1;
for (int i = 1; i <= ns; i++)
if ((x & (1 << (i - 1))) != 0)
p += su[i];
else if ((y & (1 << (i - 1))) != 0)
q += su[i];
for (int i = 1; i < m; i++) {
if ((q & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * (an[i] + 1) % mo;
if ((q & (1 << (i - 1))) != 0 && (p & (1 << i)) != 0)
ans = ans * an[i] % mo;
if ((p & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * an[i] % mo;
}
if (q % 2 == 1)
ans = ans * (an[0] + 1) % mo;
else
ans = ans * an[0] % mo;
return ans;
}
int main() {
read(n);
read(q);
for (int i = 1; i <= q; i++) {
read(a[i].nu);
a[i].nu--;
read(a[i + q].nu);
}
for (int i = 1; i <= q + q; i++)
a[i].we = i;
sort(a + 1, a + q + q + 1, comp);
for (int i = 1; i <= q + q; i++) {
a[i].nn = a[i - 1].nn + (i == 1 || a[i].nu != a[i - 1].nu);
g[a[i].nn] = a[i].nu;
}
m = a[q + q].nn;
sort(a + 1, a + q + q + 1, comp1);
for (int i = 1; i <= m; i++)
f[i] = i;
for (int i = 1; i <= q; i++)
he(a[i].nn, a[i + q].nn);
for (int i = 1; i <= m; i++)
if (f[i] == i)
bi[i] = ++ns;
for (int i = 1; i <= m; i++) {
int no = bi[que(i)];
su[no] += (1 << (i - 1));
}
for (int i = 0; i < m; i++)
an[i] = (po(10, g[i + 1] - g[i]) + mo - 1) * ni9 % mo;
for (int i = 0; i < (1 << ns); i++)
zh[0].push_back(i);
for (int i = 1; i < (1 << ns); i++)
for (int j = 0; j < zh[i / 2].size(); j++)
if ((zh[i / 2][j] & (1 << (ns - 1))) == 0) {
zh[i].push_back(zh[i / 2][j] * 2 + 1);
if (i % 2 == 0)
zh[i].push_back(zh[i / 2][j] * 2);
}
for (int i = 0; i < (1 << ns); i++)
for (int j = 0; j < zh[i].size(); j++)
z1[i].push_back(qu(i, zh[i][j]));
if (g[1] == 0 && m >= 1) {
int nu = 0;
for (int i = 1; i <= ns; i++)
if (su[i] % 2 == 1)
nu = i;
for (int i = 0; i < (1 << ns); i++)
if ((i & (1 << nu - 1)) != 0)
dp[i][0] = qu(0, i);
} else {
for (int i = 0; i < (1 << ns); i++)
dp[i][0] = qu1(0, i);
}
for (int ne = 1; ne <= 8; ne++) {
for (int j = 0; j < (1 << ns); j++)
if (dp[j][0])
for (int i = 0; i < zh[j].size(); i++)
dp[zh[j][i]][1] = (dp[zh[j][i]][1] + dp[j][0] * z1[j][i]) % mo;
for (int j = 0; j < (1 << ns); j++) {
dp[j][0] = dp[j][1];
dp[j][1] = 0;
}
}
ll ans = dp[(1 << ns) - 1][0];
cout << ans * po(10, n - g[m]) % mo << endl;
return 0;
}
/*
2 1
2 2
*/ | #include <bits/stdc++.h>
#define Q 22
#define ll long long
#define mo 1000000007
#define ni9 111111112
using namespace std;
template <typename T> void read(T &x) {
x = 0;
char c = getchar();
int fh = 1;
while (!isdigit(c)) {
if (c == '-')
fh = -1;
c = getchar();
}
while (isdigit(c))
x = x * 10 + c - '0', c = getchar();
x *= fh;
}
struct Info {
int nu, we, nn;
} a[Q * 2];
int n, q, f[Q * 2], bi[Q * 2], su[Q], ns, g[Q * 2], m;
ll dp[33010][2], an[Q * 2];
vector<int> zh[33010], z1[33010];
bool comp(const Info &a, const Info &b) { return a.nu < b.nu; }
bool comp1(const Info &a, const Info &b) { return a.we < b.we; }
int que(int x) {
if (f[x] != x)
f[x] = que(f[x]);
return f[x];
}
void he(int x, int y) {
int nx = que(x), ny = que(y);
if (nx != ny)
f[nx] = ny;
}
ll po(ll x, ll y) {
ll z = 1;
while (y) {
if (y % 2)
z = x * z % mo;
x = x * x % mo;
y /= 2;
}
return z;
}
ll qu(int x, int y) {
int p = 0, q = 0;
ll ans = 1;
for (int i = 1; i <= ns; i++)
if ((x & (1 << (i - 1))) != 0)
p += su[i];
else if ((y & (1 << (i - 1))) != 0)
q += su[i];
for (int i = 1; i < m; i++) {
if ((q & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * (an[i] + 1) % mo;
if ((q & (1 << (i - 1))) != 0 && (p & (1 << i)) != 0)
ans = ans * an[i] % mo;
if ((p & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * an[i] % mo;
}
return ans;
}
ll qu1(int x, int y) {
int p = 0, q = 0;
ll ans = 1;
for (int i = 1; i <= ns; i++)
if ((x & (1 << (i - 1))) != 0)
p += su[i];
else if ((y & (1 << (i - 1))) != 0)
q += su[i];
for (int i = 1; i < m; i++) {
if ((q & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * (an[i] + 1) % mo;
if ((q & (1 << (i - 1))) != 0 && (p & (1 << i)) != 0)
ans = ans * an[i] % mo;
if ((p & (1 << (i - 1))) != 0 && (q & (1 << i)) != 0)
ans = ans * an[i] % mo;
}
if (q % 2 == 1)
ans = ans * (an[0] + 1) % mo;
else
ans = ans * an[0] % mo;
return ans;
}
int main() {
read(n);
read(q);
for (int i = 1; i <= q; i++) {
read(a[i].nu);
a[i].nu--;
read(a[i + q].nu);
}
for (int i = 1; i <= q + q; i++)
a[i].we = i;
sort(a + 1, a + q + q + 1, comp);
for (int i = 1; i <= q + q; i++) {
a[i].nn = a[i - 1].nn + (i == 1 || a[i].nu != a[i - 1].nu);
g[a[i].nn] = a[i].nu;
}
m = a[q + q].nn;
sort(a + 1, a + q + q + 1, comp1);
for (int i = 1; i <= m; i++)
f[i] = i;
for (int i = 1; i <= q; i++)
he(a[i].nn, a[i + q].nn);
for (int i = 1; i <= m; i++)
if (f[i] == i)
bi[i] = ++ns;
for (int i = 1; i <= m; i++) {
int no = bi[que(i)];
su[no] += (1 << (i - 1));
}
for (int i = 0; i < m; i++)
an[i] = (po(10, g[i + 1] - g[i]) + mo - 1) * ni9 % mo;
for (int i = 0; i < (1 << ns); i++)
zh[0].push_back(i);
for (int i = 1; i < (1 << ns); i++)
for (int j = 0; j < zh[i / 2].size(); j++)
if ((zh[i / 2][j] & (1 << (ns - 1))) == 0) {
zh[i].push_back(zh[i / 2][j] * 2 + 1);
if (i % 2 == 0)
zh[i].push_back(zh[i / 2][j] * 2);
}
for (int i = 0; i < (1 << ns); i++)
for (int j = 0; j < zh[i].size(); j++)
z1[i].push_back(qu(i, zh[i][j]));
if (g[1] == 0 && m >= 1) {
int nu = 0;
for (int i = 1; i <= ns; i++)
if (su[i] % 2 == 1)
nu = i;
for (int i = 0; i < (1 << ns); i++)
if ((i & (1 << nu - 1)) != 0)
dp[i][0] = qu(0, i);
} else {
for (int i = 0; i < (1 << ns); i++)
dp[i][0] = qu1(0, i);
}
for (int ne = 1; ne <= 8; ne++) {
for (int j = 0; j < (1 << ns); j++)
if (dp[j][0])
for (int i = 0; i < zh[j].size(); i++)
dp[zh[j][i]][1] = (dp[zh[j][i]][1] + dp[j][0] * z1[j][i]) % mo;
for (int j = 0; j < (1 << ns); j++) {
dp[j][0] = dp[j][1];
dp[j][1] = 0;
}
}
ll ans = dp[(1 << ns) - 1][0];
cout << ans * po(10, n - g[m]) % mo << endl;
return 0;
}
/*
30 10
1 1
3 3
5 5
7 7
9 9
11 11
13 13
15 15
17 17
19 19
*/ | [] | 933,885 | 933,886 | u539443668 | cpp |
p03114 | /*{{{*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
#define CASET \
int ___T; \
scanf("%d", &___T); \
for (int cs = 1; cs <= ___T; cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
template <class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U> void R(T &head, U &...tail) {
_R(head);
R(tail...);
}
template <class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U> void _W(const pair<T, U> &x) {
_W(x.F);
putchar(' ');
_W(x.S);
}
template <class T> void _W(const vector<T> &x) {
for (auto i = x.begin(); i != x.end(); _W(*i++))
if (i != x.cbegin())
putchar(' ');
}
void W() {}
template <class T, class... U> void W(const T &head, const U &...tail) {
_W(head);
putchar(sizeof...(tail) ? ' ' : '\n');
W(tail...);
}
#ifdef HOME
#define DEBUG(...) \
{ \
printf("# "); \
printf(__VA_ARGS__); \
puts(""); \
}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
void ADD(LL &x, LL v) {
x = (x + v) % MOD;
if (x < 0)
x += MOD;
}
/*}}}*/
const int SIZE = 30;
LL mypow(LL x, LL y) {
x %= MOD;
LL res = 1 % MOD;
while (y) {
if (y & 1)
res = res * x % MOD;
y >>= 1;
x = x * x % MOD;
}
return res;
}
void my_mul(LL &x, LL v) { x = x * v % MOD; }
int get_bit(int x, int v) { return (x >> v) & 1; }
LL ten[33], one[33];
void init() {
ten[0] = 10;
one[0] = 1;
REPP(i, 1, 33) {
ten[i] = ten[i - 1] * ten[i - 1] % MOD;
one[i] = (one[i - 1] * ten[i - 1] + one[i - 1]) % MOD;
}
}
LL eleven(int n) {
LL now = 0;
for (int i = 0; n >> i; i++) {
if (get_bit(n, i)) {
now = (now * ten[i] + one[i]) % MOD;
}
}
return now;
}
int AA[SIZE];
VI aa[SIZE];
int type_num;
int e[SIZE][2];
int d[SIZE], dn;
int ee[SIZE];
int id[SIZE];
int ty[SIZE];
int N, Q;
LL mul[SIZE], mulmul[SIZE];
VI order, unorder;
LL dfs(int x, LL now, int num) {
if (x == SZ(order)) {
for (int y : unorder) {
LL val[9] = {};
fill(val, val + 9, 1);
LL for_all = 1;
for (int pos : aa[y]) {
if (id[pos - 1] != id[pos]) {
my_mul(for_all, mul[pos]);
my_mul(val[ty[id[pos - 1]]], mulmul[pos]);
}
if (pos + 1 < dn && id[pos + 1] != id[pos]) {
my_mul(for_all, mul[pos]);
my_mul(val[ty[id[pos + 1]]], mulmul[pos]);
}
}
LL ss = 0;
REP(i, 9) { ADD(ss, val[i]); }
my_mul(now, ss * for_all % MOD);
}
return now;
}
LL sum = 0;
FOR(v, 0, num) {
ty[order[x]] = v;
LL tmp = 1;
for (int pos : aa[order[x]]) {
if (pos && id[pos - 1] != id[pos] && ty[id[pos - 1]] != -1) {
my_mul(tmp, mul[pos] + (ty[id[pos - 1]] == v));
}
if (pos + 1 < dn && id[pos + 1] != id[pos] && ty[id[pos + 1]] != -1) {
my_mul(tmp, mul[pos + 1] + (ty[id[pos + 1]] == v));
}
}
if (v == num) {
if (num < 9)
ADD(sum, dfs(x + 1, now * tmp % MOD * (9 - num) % MOD, num + 1));
} else {
ADD(sum, dfs(x + 1, now * tmp % MOD, num));
}
}
ty[order[x]] = -1;
return sum;
}
int main() {
init();
R(N, Q);
REP(i, Q) {
int x, y;
R(x, y);
x--;
e[i][0] = x;
e[i][1] = y;
d[dn++] = x;
d[dn++] = y;
}
sort(d, d + dn);
dn = unique(d, d + dn) - d;
REPP(i, 1, dn) {
mul[i] = eleven(d[i] - d[i - 1]);
mulmul[i] = (mul[i] + 1) * mypow(mul[i], MOD - 2) % MOD;
}
REP(i, Q) {
REP(j, 2) e[i][j] = lower_bound(d, d + dn, e[i][j]) - d;
ee[e[i][0]] |= 1 << e[i][1];
ee[e[i][1]] |= 1 << e[i][0];
}
REP(k, dn) REP(i, dn) REP(j, dn) {
if (get_bit(ee[i], k) && get_bit(ee[k], j))
ee[i] |= 1 << j;
}
LL base = mypow(10, d[0] + N - d[dn - 1]);
int good_mask;
{
int need = 0;
REP(i, dn - 1) {
if (!get_bit(ee[i], i + 1))
need |= 1 << i;
else
my_mul(base, mul[i + 1] + 1);
}
int tmp = 0;
bool u[SIZE] = {};
REP(i, dn) {
if (!u[i]) {
REP(j, dn) {
if (get_bit(ee[i], j) || i == j) {
AA[tmp] |= 1 << j;
aa[tmp].PB(j);
u[j] = 1;
id[j] = tmp;
}
}
tmp++;
}
}
type_num = tmp;
int mi = 100;
for (int i = 1; i < (1 << type_num); i += 2) {
int me = AA[0] | (AA[0] >> 1);
REPP(j, 1, type_num) {
if (get_bit(i, j))
me |= AA[j] | (AA[j] >> 1);
}
if ((need & me) == need) {
int bn = __builtin_popcount(i);
if (bn < mi) {
mi = bn;
good_mask = i;
}
}
}
REP(i, type_num) {
if (get_bit(good_mask, i))
order.PB(i);
else
unorder.PB(i);
}
}
MS1(ty);
ty[0] = 0;
W(dfs(1, 1, 1) * base % MOD);
return 0;
}
| /*{{{*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
#define CASET \
int ___T; \
scanf("%d", &___T); \
for (int cs = 1; cs <= ___T; cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
template <class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U> void R(T &head, U &...tail) {
_R(head);
R(tail...);
}
template <class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U> void _W(const pair<T, U> &x) {
_W(x.F);
putchar(' ');
_W(x.S);
}
template <class T> void _W(const vector<T> &x) {
for (auto i = x.begin(); i != x.end(); _W(*i++))
if (i != x.cbegin())
putchar(' ');
}
void W() {}
template <class T, class... U> void W(const T &head, const U &...tail) {
_W(head);
putchar(sizeof...(tail) ? ' ' : '\n');
W(tail...);
}
#ifdef HOME
#define DEBUG(...) \
{ \
printf("# "); \
printf(__VA_ARGS__); \
puts(""); \
}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
void ADD(LL &x, LL v) {
x = (x + v) % MOD;
if (x < 0)
x += MOD;
}
/*}}}*/
const int SIZE = 30;
LL mypow(LL x, LL y) {
x %= MOD;
LL res = 1 % MOD;
while (y) {
if (y & 1)
res = res * x % MOD;
y >>= 1;
x = x * x % MOD;
}
return res;
}
void my_mul(LL &x, LL v) { x = x * v % MOD; }
int get_bit(int x, int v) { return (x >> v) & 1; }
LL ten[33], one[33];
void init() {
ten[0] = 10;
one[0] = 1;
REPP(i, 1, 33) {
ten[i] = ten[i - 1] * ten[i - 1] % MOD;
one[i] = (one[i - 1] * ten[i - 1] + one[i - 1]) % MOD;
}
}
LL eleven(int n) {
LL now = 0;
for (int i = 0; n >> i; i++) {
if (get_bit(n, i)) {
now = (now * ten[i] + one[i]) % MOD;
}
}
return now;
}
int AA[SIZE];
VI aa[SIZE];
int type_num;
int e[SIZE][2];
int d[SIZE], dn;
int ee[SIZE];
int id[SIZE];
int ty[SIZE];
int N, Q;
LL mul[SIZE], mulmul[SIZE];
VI order, unorder;
LL dfs(int x, LL now, int num) {
if (x == SZ(order)) {
for (int y : unorder) {
LL val[9] = {};
fill(val, val + 9, 1);
LL for_all = 1;
for (int pos : aa[y]) {
if (id[pos - 1] != id[pos]) {
my_mul(for_all, mul[pos]);
my_mul(val[ty[id[pos - 1]]], mulmul[pos]);
}
if (pos + 1 < dn && id[pos + 1] != id[pos]) {
my_mul(for_all, mul[pos + 1]);
my_mul(val[ty[id[pos + 1]]], mulmul[pos + 1]);
}
}
LL ss = 0;
REP(i, 9) { ADD(ss, val[i]); }
my_mul(now, ss * for_all % MOD);
}
return now;
}
LL sum = 0;
FOR(v, 0, num) {
ty[order[x]] = v;
LL tmp = 1;
for (int pos : aa[order[x]]) {
if (pos && id[pos - 1] != id[pos] && ty[id[pos - 1]] != -1) {
my_mul(tmp, mul[pos] + (ty[id[pos - 1]] == v));
}
if (pos + 1 < dn && id[pos + 1] != id[pos] && ty[id[pos + 1]] != -1) {
my_mul(tmp, mul[pos + 1] + (ty[id[pos + 1]] == v));
}
}
if (v == num) {
if (num < 9)
ADD(sum, dfs(x + 1, now * tmp % MOD * (9 - num) % MOD, num + 1));
} else {
ADD(sum, dfs(x + 1, now * tmp % MOD, num));
}
}
ty[order[x]] = -1;
return sum;
}
int main() {
init();
R(N, Q);
REP(i, Q) {
int x, y;
R(x, y);
x--;
e[i][0] = x;
e[i][1] = y;
d[dn++] = x;
d[dn++] = y;
}
sort(d, d + dn);
dn = unique(d, d + dn) - d;
REPP(i, 1, dn) {
mul[i] = eleven(d[i] - d[i - 1]);
mulmul[i] = (mul[i] + 1) * mypow(mul[i], MOD - 2) % MOD;
}
REP(i, Q) {
REP(j, 2) e[i][j] = lower_bound(d, d + dn, e[i][j]) - d;
ee[e[i][0]] |= 1 << e[i][1];
ee[e[i][1]] |= 1 << e[i][0];
}
REP(k, dn) REP(i, dn) REP(j, dn) {
if (get_bit(ee[i], k) && get_bit(ee[k], j))
ee[i] |= 1 << j;
}
LL base = mypow(10, d[0] + N - d[dn - 1]);
int good_mask;
{
int need = 0;
REP(i, dn - 1) {
if (!get_bit(ee[i], i + 1))
need |= 1 << i;
else
my_mul(base, mul[i + 1] + 1);
}
int tmp = 0;
bool u[SIZE] = {};
REP(i, dn) {
if (!u[i]) {
REP(j, dn) {
if (get_bit(ee[i], j) || i == j) {
AA[tmp] |= 1 << j;
aa[tmp].PB(j);
u[j] = 1;
id[j] = tmp;
}
}
tmp++;
}
}
type_num = tmp;
int mi = 100;
for (int i = 1; i < (1 << type_num); i += 2) {
int me = AA[0] | (AA[0] >> 1);
REPP(j, 1, type_num) {
if (get_bit(i, j))
me |= AA[j] | (AA[j] >> 1);
}
if ((need & me) == need) {
int bn = __builtin_popcount(i);
if (bn < mi) {
mi = bn;
good_mask = i;
}
}
}
REP(i, type_num) {
if (get_bit(good_mask, i))
order.PB(i);
else
unorder.PB(i);
}
}
MS1(ty);
ty[0] = 0;
W(dfs(1, 1, 1) * base % MOD);
return 0;
}
| [
"expression.operation.binary.add"
] | 933,889 | 933,890 | u284124505 | cpp |
p03114 | #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod = 1000000007;
const llint big = 2.19e18 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U> bool mineq(T &a, U b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool maxeq(T &a, U b) {
if (a < b) {
a = b;
return true;
}
return false;
}
llint gcd(llint a, llint b) {
if (a % b == 0) {
return b;
} else
return gcd(b, a % b);
}
llint lcm(llint a, llint b) {
if (a == 0) {
return b;
}
return a / gcd(a, b) * b;
}
template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); }
template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); }
template <class T> llint LBI(vector<T> &ar, T in) {
return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
template <class T> llint UBI(vector<T> &ar, T in) {
return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
llint qinv = 111111112;
llint cul(int keta) {
llint ans = 1;
llint bgen = 10;
for (int h = 0; h < 30; h++) {
if (keta & (1 << h)) {
ans *= bgen;
ans %= mod;
}
bgen *= bgen;
bgen %= mod;
}
ans--;
ans *= qinv;
ans %= mod;
return ans;
}
int main(void) {
int n, Q, i, j;
cin >> n >> Q;
vector<pair<int, int>> bas;
for (i = 0; i < Q; i++) {
int L, R;
cin >> L >> R;
bas.pub(mp(L - 1, i));
bas.pub(mp(R, i));
}
SO(bas);
//区間 numberを求める
vector<llint> kak(Q + Q - 1);
for (i = 0; i < Q + Q - 1; i++) {
kak[i] = cul(bas[i + 1].fir - bas[i].fir);
}
static llint dp[32768][10] = {0};
dp[0][0] = 1;
for (int bi = 0; bi < (1 << Q); bi++) {
// biにする
int ko = 1; // ko=0は遷移順を最後にする
while (ko < (1 << Q)) {
if (ko - (bi & ko) != 0) {
ko += ko - (bi & ko);
continue;
}
// cerr<<"bi="<<bi<<"ko="<<ko<<endl;
// bi-koにkoの内容を加える
llint bai = 1;
for (i = 0; i < Q + Q - 1; i++) {
int aaa = 0, bbb = 0;
if ((ko & (1 << bas[i].sec)) > 0) {
aaa = 2;
} else if ((bi & (1 << bas[i].sec)) > 0) {
aaa = 1;
}
if ((ko & (1 << bas[i + 1].sec)) > 0) {
bbb = 2;
} else if ((bi & (1 << bas[i + 1].sec)) > 0) {
bbb = 1;
}
if (aaa + bbb == 4) {
bai *= kak[i] + 1;
bai %= mod;
} else if (aaa + bbb == 3) {
bai *= kak[i];
bai %= mod;
}
}
for (int su = 0; su < 9; su++) {
dp[bi][su + 1] += bai * dp[bi - ko][su];
dp[bi][su + 1] %= mod;
}
ko++;
}
for (int su = 0; su < 9; su++) {
dp[bi][su + 1] += dp[bi][su];
dp[bi][su + 1] %= mod;
}
// cerr<<"bi="<<bi<<endl;
// for(int su=0;su<=9;su++){cerr<<"dp="<<dp[bi][su]<<endl;}
}
llint ans = dp[(1 << Q) - 1][9] * qinv % mod;
int nko = n - bas.back().fir + bas[0].fir;
ans *= (cul(nko) * 9 + 1) % mod;
ans %= mod;
cerr << ans << endl;
} | #include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod = 1000000007;
const llint big = 2.19e18 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U> bool mineq(T &a, U b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T, class U> bool maxeq(T &a, U b) {
if (a < b) {
a = b;
return true;
}
return false;
}
llint gcd(llint a, llint b) {
if (a % b == 0) {
return b;
} else
return gcd(b, a % b);
}
llint lcm(llint a, llint b) {
if (a == 0) {
return b;
}
return a / gcd(a, b) * b;
}
template <class T> void SO(T &ve) { sort(ve.begin(), ve.end()); }
template <class T> void REV(T &ve) { reverse(ve.begin(), ve.end()); }
template <class T> llint LBI(vector<T> &ar, T in) {
return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
template <class T> llint UBI(vector<T> &ar, T in) {
return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
llint qinv = 111111112;
llint cul(int keta) {
llint ans = 1;
llint bgen = 10;
for (int h = 0; h < 30; h++) {
if (keta & (1 << h)) {
ans *= bgen;
ans %= mod;
}
bgen *= bgen;
bgen %= mod;
}
ans--;
ans *= qinv;
ans %= mod;
return ans;
}
int main(void) {
int n, Q, i, j;
cin >> n >> Q;
vector<pair<int, int>> bas;
for (i = 0; i < Q; i++) {
int L, R;
cin >> L >> R;
bas.pub(mp(L - 1, i));
bas.pub(mp(R, i));
}
SO(bas);
//区間 numberを求める
vector<llint> kak(Q + Q - 1);
for (i = 0; i < Q + Q - 1; i++) {
kak[i] = cul(bas[i + 1].fir - bas[i].fir);
}
static llint dp[32768][10] = {0};
dp[0][0] = 1;
for (int bi = 0; bi < (1 << Q); bi++) {
// biにする
int ko = 1; // ko=0は遷移順を最後にする
while (ko < (1 << Q)) {
if (ko - (bi & ko) != 0) {
ko += ko - (bi & ko);
continue;
}
// cerr<<"bi="<<bi<<"ko="<<ko<<endl;
// bi-koにkoの内容を加える
llint bai = 1;
for (i = 0; i < Q + Q - 1; i++) {
int aaa = 0, bbb = 0;
if ((ko & (1 << bas[i].sec)) > 0) {
aaa = 2;
} else if ((bi & (1 << bas[i].sec)) > 0) {
aaa = 1;
}
if ((ko & (1 << bas[i + 1].sec)) > 0) {
bbb = 2;
} else if ((bi & (1 << bas[i + 1].sec)) > 0) {
bbb = 1;
}
if (aaa + bbb == 4) {
bai *= kak[i] + 1;
bai %= mod;
} else if (aaa + bbb == 3) {
bai *= kak[i];
bai %= mod;
}
}
for (int su = 0; su < 9; su++) {
dp[bi][su + 1] += bai * dp[bi - ko][su];
dp[bi][su + 1] %= mod;
}
ko++;
}
for (int su = 0; su < 9; su++) {
dp[bi][su + 1] += dp[bi][su];
dp[bi][su + 1] %= mod;
}
// cerr<<"bi="<<bi<<endl;
// for(int su=0;su<=9;su++){cerr<<"dp="<<dp[bi][su]<<endl;}
}
llint ans = dp[(1 << Q) - 1][9] * qinv % mod;
int nko = n - bas.back().fir + bas[0].fir;
ans *= (cul(nko) * 9 + 1) % mod;
ans %= mod;
cout << ans << endl;
return 0;
} | [
"identifier.change",
"io.output.change",
"control_flow.return.add",
"control_flow.return.0.add"
] | 933,891 | 933,892 | u483814783 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(0, 0);
}
V<V<pin>> qab(2);
int sz = ab.size();
qab[0].reserve(sz);
qab[1].reserve(sz);
for (pin &x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
int c = 0;
for (pin &x : qab[0]) {
int qc = (2 * x.first + x.second) % 3;
c ^= (qc + 1);
}
if (!c) {
pin ans = solve(qab[1], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second++;
return ans;
}
pin ans = solve(qab[0], ex - 1);
c = 0;
int d = 0;
for (pin &x : qab[1]) {
int qc = (2 * x.first + x.second) % 3;
c ^= (qc + 1);
int w = ans.second - x.second - 1;
if ((w & x.first) == w) {
c ^= 1;
}
}
if (!c) {
ans.first *= 2;
ans.second *= 2;
return ans;
}
ans.first *= 2;
ans.first++;
ans.second *= 2;
ans.second -= d;
return ans;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
long long inf = 1e17;
int n;
cin >> n;
V<pin> ab(n);
rep(i, n) {
long long a, b;
cin >> a >> b;
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 59);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(0, 0);
}
V<V<pin>> qab(2);
int sz = ab.size();
qab[0].reserve(sz);
qab[1].reserve(sz);
for (pin &x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
int c = 0;
for (pin &x : qab[0]) {
int qc = (2 * x.first + x.second) % 3;
c ^= (qc + 1);
}
if (!c) {
pin ans = solve(qab[1], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second++;
return ans;
}
pin ans = solve(qab[0], ex - 1);
c = 0;
int d = 0;
for (pin &x : qab[1]) {
int qc = (2 * x.first + x.second) % 3;
c ^= (qc + 1);
int w = ans.second - x.second - 1;
if ((w & x.first) == w) {
d ^= 1;
}
}
if (!c) {
ans.first *= 2;
ans.second *= 2;
return ans;
}
ans.first *= 2;
ans.first++;
ans.second *= 2;
ans.second -= d;
return ans;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
long long inf = 1e17;
int n;
cin >> n;
V<pin> ab(n);
rep(i, n) {
long long a, b;
cin >> a >> b;
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 59);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| [
"assignment.variable.change",
"identifier.change"
] | 933,920 | 933,921 | u021034020 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
int sz = ab.size();
qab[0].reserve(sz);
qab[1].reserve(sz);
for (pin &x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
rep(i, 2) {
int c;
for (pin &x : qab[1 - i]) {
int qc = (2 * x.first + x.second) % 3;
c ^= (qc + 1);
}
if (!c) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
int sz = ab.size();
qab[0].reserve(sz);
qab[1].reserve(sz);
for (pin &x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
rep(i, 2) {
int c = 0;
for (pin &x : qab[1 - i]) {
int qc = (2 * x.first + x.second) % 3;
c ^= (qc + 1);
}
if (!c) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| [
"variable_declaration.value.change"
] | 933,924 | 933,925 | u021034020 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
qab[0].reserve(10000);
qab[1].reserve(10000);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<V<bool>> c(2, V<bool>(2, false));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] = !c[i][0];
}
if (qc) {
c[i][1] != c[i][1];
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
} | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
qab[0].reserve(10000);
qab[1].reserve(10000);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<V<bool>> c(2, V<bool>(2, false));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] = !c[i][0];
}
if (qc) {
c[i][1] = !c[i][1];
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| [
"expression.operation.binary.change",
"expression.operation.unary.add"
] | 933,927 | 933,928 | u021034020 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
qab[0].reserve(10000);
qab[1].reserve(10000);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<V<bool>> c(2, V<bool>(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] = !c[i][0];
}
if (qc) {
c[i][1] != c[i][1];
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
qab[0].reserve(10000);
qab[1].reserve(10000);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<V<bool>> c(2, V<bool>(2, false));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] = !c[i][0];
}
if (qc) {
c[i][1] = !c[i][1];
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| [
"call.arguments.add",
"expression.operation.binary.change",
"expression.operation.unary.add"
] | 933,929 | 933,928 | u021034020 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
qab[0].reserve(10000);
qab[1].reserve(10000);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<V<bool>> c(2, V<bool>(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] = !c[i][0];
}
if (qc) {
c[i][1] != c[i][0];
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
qab[0].reserve(10000);
qab[1].reserve(10000);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<V<bool>> c(2, V<bool>(2, false));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] = !c[i][0];
}
if (qc) {
c[i][1] = !c[i][1];
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
}
| [
"call.arguments.add",
"expression.operation.binary.change",
"expression.operation.unary.add",
"literal.number.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 933,930 | 933,928 | u021034020 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
int sz = ab.size();
qab[0].reserve(sz);
qab[1].reserve(sz);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<vel> c(2, vel(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
c[i][0] ^= ((qc + 1) & 1);
c[i][1] ^= (qc & 1);
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
} | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
int sz = ab.size();
qab[0].reserve(sz);
qab[1].reserve(sz);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<vel> c(2, vel(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
c[i][0] ^= ((qc + 1) & 1);
c[i][1] ^= ((qc + 1) & 2);
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf << "\n";
} | [
"assignment.value.change",
"expression.operation.binary.change",
"assignment.change"
] | 933,931 | 933,932 | u021034020 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<vel> c(2, vel(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] ^= 1;
}
if (qc) {
c[i][1] ^= 1;
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 1e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 55);
cout << ret.first - inf << " " << ret.second - inf;
}
| #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<vel> c(2, vel(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] ^= 1;
}
if (qc) {
c[i][1] ^= 1;
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 1e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld", &a);
scanf("%lld", &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 60);
cout << ret.first - inf << " " << ret.second - inf;
} | [
"literal.number.change",
"call.arguments.change"
] | 933,933 | 933,934 | u021034020 | cpp |
p03116 | #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<vel> c(2, vel(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] ^= 1;
}
if (qc) {
c[i][1] ^= 1;
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld,%lld", &a, &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf;
}
| #include <iostream>
#include <vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define mkp make_pair
#define pin pair<int, int>
pin solve(V<pin> &ab, int ex) {
if (!ex) {
return mkp(1, 0);
}
V<V<pin>> qab(2);
for (pin x : ab) {
qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
if (x.first & 1) {
qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2));
}
}
V<vel> c(2, vel(2));
rep(i, 2) {
for (pin x : qab[i]) {
int qc = (2 * x.first + x.second) % 3;
if ((qc + 1) % 2) {
c[i][0] ^= 1;
}
if (qc) {
c[i][1] ^= 1;
}
}
}
rep(i, 2) {
if (!c[1 - i][0] && !c[1 - i][1]) {
pin ans = solve(qab[i], ex - 1);
ans.first *= 2;
ans.second *= 2;
ans.second += i;
return ans;
}
}
for (pin &v : ab) {
v.first++;
}
pin ans = solve(ab, ex);
ans.first--;
return ans;
}
signed main() {
long long inf = 2e17;
int n;
scanf("%lld", &n);
V<pin> ab(n);
rep(i, n) {
long long a, b;
scanf("%lld %lld", &a, &b);
ab[i] = {a + inf, b + inf};
}
pin ret = solve(ab, 70);
cout << ret.first - inf << " " << ret.second - inf;
} | [
"literal.string.change",
"call.arguments.change"
] | 933,935 | 933,936 | u021034020 | cpp |
p03121 | #ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
/*
ll pw(ll a, ll b) {
ll ans = 1; while (b) {
while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
ans = (ans * a) % MOD, --b;
} return ans;
}
*/
const int MAXN = 210000;
ll x[MAXN];
ll y[MAXN];
int n;
int cnk(ll a, ll b) {
if (b < 0 || b > a)
return 0;
return (a & b) == b;
}
int get(ll t) {
int ans = 0;
for (int i = 0; i < n; ++i) {
if (y[i] > 0) {
if (x[i] <= t && t <= x[i] + y[i]) {
ans ^= cnk(y[i] - 1, t - x[i]);
}
} else if (y[i] == 0) {
if (x[i] <= t)
ans ^= 1;
} else {
if (t >= x[i]) {
ans ^= cnk(-y[i] + (t - x[i]) + 1, t - x[i]);
}
}
}
return ans;
}
int main() {
#ifdef FASTIO
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
}
ll lb = -1e18;
ll rb = 1e18;
while (rb - lb > 1) {
ll mid = (lb + rb) >> 1;
if (get(mid) == 1)
rb = mid;
else
lb = mid;
}
cout << rb << "\n";
return 0;
}
| #ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
/*
ll pw(ll a, ll b) {
ll ans = 1; while (b) {
while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
ans = (ans * a) % MOD, --b;
} return ans;
}
*/
const int MAXN = 210000;
ll x[MAXN];
ll y[MAXN];
int n;
int cnk(ll a, ll b) {
if (b < 0 || b > a)
return 0;
return (a & b) == b;
}
int get(ll t) {
int ans = 0;
for (int i = 0; i < n; ++i) {
if (y[i] > 0) {
if (x[i] <= t && t <= x[i] + y[i]) {
ans ^= cnk(y[i] - 1, t - x[i]);
}
} else if (y[i] == 0) {
if (x[i] <= t)
ans ^= 1;
} else {
if (t >= x[i]) {
ans ^= cnk(-y[i] - 1 + (t - x[i]) + 1, t - x[i]);
}
}
}
return ans;
}
int main() {
#ifdef FASTIO
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
}
ll lb = -1e18;
ll rb = 1e18;
while (rb - lb > 1) {
ll mid = (lb + rb) >> 1;
// if (rb == 7629394531250)
// int a = 0;
if (get(mid) == 1)
rb = mid;
else
lb = mid;
}
// for (int i = -10; i <= 10; ++i)
// cerr << i << " " << get(i) << "\n";
cout << rb << "\n";
return 0;
}
| [
"assignment.change"
] | 933,947 | 933,948 | u953484888 | cpp |
p03125 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y);
#define chmin(x, y) x = min(x, y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;
int main() {
int a, b;
cin >> a >> b;
if (a % b == 0)
cout << a + b << endl;
else
cout << b - a << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y);
#define chmin(x, y) x = min(x, y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;
int main() {
int a, b;
cin >> a >> b;
if (b % a == 0)
cout << a + b << endl;
else
cout << b - a << endl;
return 0;
} | [
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 933,953 | 933,954 | u005006157 | cpp |
p03125 | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if (b % a == 0)
cout << a + b << endl;
else
cout << a - b << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if (b % a == 0)
cout << a + b << endl;
else
cout << b - a << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 933,957 | 933,958 | u818967913 | cpp |
p03125 | #include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define perl(i, r, l) for (ll i = r - 1; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(), (x).end()
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1};
using Graph = vector<vector<int>>;
// dijkstra
struct edge {
ll to, cost;
};
typedef pair<ll, ll> P;
struct graph {
ll V;
vector<vector<edge>> G;
vector<ll> d;
graph(ll n) { init(n); }
void init(ll n) {
V = n;
G.resize(V);
d.resize(V);
rep(i, V) { d[i] = INF; }
}
void add_edge(ll s, ll t, ll cost) {
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s) {
rep(i, V) { d[i] = INF; }
d[s] = 0;
priority_queue<P, vector<P>, greater<P>> que;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top();
que.pop();
ll v = p.second;
if (d[v] < p.first)
continue;
for (auto e : G[v]) {
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
}
};
// dijkstra end
class UnionFind {
public:
ll par[100005];
ll depth[100005];
ll nGroup[100005];
UnionFind(ll n) { init(n); }
void init(ll n) {
for (ll i = 0; i < n; i++) {
par[i] = i;
depth[i] = 0;
nGroup[i] = 1;
}
}
ll root(ll x) {
if (par[x] == x) {
return x;
} else {
return par[x] = root(par[x]);
}
}
bool same(ll x, ll y) { return root(x) == root(y); }
void unite(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (depth[x] < depth[y]) {
par[x] = y;
nGroup[y] += nGroup[x];
nGroup[x] = 0;
} else {
par[y] = x;
nGroup[x] += nGroup[y];
nGroup[y] = 0;
if (depth[x] == depth[y])
depth[x]++;
}
}
};
// unionfind end
// nCr
const ll MAX = 500010;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// nCr end
// tree DP
vector<ll> depth;
vector<ll> f;
vector<ll> g;
void dfs(const Graph &G, ll v, ll p, ll d) {
depth[v] = d;
for (auto nv : G[v]) {
if (nv == p)
continue;
dfs(G, nv, v, d + 1);
}
f[v] = 1;
g[v] = 1;
for (auto c : G[v]) {
if (c == p)
continue;
f[v] *= g[c];
f[v] %= MOD;
g[v] *= f[c];
g[v] %= MOD;
}
f[v] += g[v];
f[v] %= MOD;
}
// tree DP end
template <ll MOD> struct Fp {
ll val;
constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr ll getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
ll a = r.val, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<MOD>;
mint calc(ll N, ll K) {
mint res = 1;
for (ll n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
mint COM(ll n, ll k) {
if (k == 0)
return 1;
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int a, b;
cin >> a >> b;
if (b % a == 0) {
cout << a + b << endl;
} else
cout << a - b << endl;
return 0;
}
| #include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define perl(i, r, l) for (ll i = r - 1; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(), (x).end()
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1};
using Graph = vector<vector<int>>;
// dijkstra
struct edge {
ll to, cost;
};
typedef pair<ll, ll> P;
struct graph {
ll V;
vector<vector<edge>> G;
vector<ll> d;
graph(ll n) { init(n); }
void init(ll n) {
V = n;
G.resize(V);
d.resize(V);
rep(i, V) { d[i] = INF; }
}
void add_edge(ll s, ll t, ll cost) {
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s) {
rep(i, V) { d[i] = INF; }
d[s] = 0;
priority_queue<P, vector<P>, greater<P>> que;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top();
que.pop();
ll v = p.second;
if (d[v] < p.first)
continue;
for (auto e : G[v]) {
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
}
};
// dijkstra end
class UnionFind {
public:
ll par[100005];
ll depth[100005];
ll nGroup[100005];
UnionFind(ll n) { init(n); }
void init(ll n) {
for (ll i = 0; i < n; i++) {
par[i] = i;
depth[i] = 0;
nGroup[i] = 1;
}
}
ll root(ll x) {
if (par[x] == x) {
return x;
} else {
return par[x] = root(par[x]);
}
}
bool same(ll x, ll y) { return root(x) == root(y); }
void unite(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (depth[x] < depth[y]) {
par[x] = y;
nGroup[y] += nGroup[x];
nGroup[x] = 0;
} else {
par[y] = x;
nGroup[x] += nGroup[y];
nGroup[y] = 0;
if (depth[x] == depth[y])
depth[x]++;
}
}
};
// unionfind end
// nCr
const ll MAX = 500010;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// nCr end
// tree DP
vector<ll> depth;
vector<ll> f;
vector<ll> g;
void dfs(const Graph &G, ll v, ll p, ll d) {
depth[v] = d;
for (auto nv : G[v]) {
if (nv == p)
continue;
dfs(G, nv, v, d + 1);
}
f[v] = 1;
g[v] = 1;
for (auto c : G[v]) {
if (c == p)
continue;
f[v] *= g[c];
f[v] %= MOD;
g[v] *= f[c];
g[v] %= MOD;
}
f[v] += g[v];
f[v] %= MOD;
}
// tree DP end
template <ll MOD> struct Fp {
ll val;
constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
if (val < 0)
val += MOD;
}
constexpr ll getmod() { return MOD; }
constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
constexpr Fp &operator+=(const Fp &r) noexcept {
val += r.val;
if (val >= MOD)
val -= MOD;
return *this;
}
constexpr Fp &operator-=(const Fp &r) noexcept {
val -= r.val;
if (val < 0)
val += MOD;
return *this;
}
constexpr Fp &operator*=(const Fp &r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp &operator/=(const Fp &r) noexcept {
ll a = r.val, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
constexpr bool operator==(const Fp &r) const noexcept {
return this->val == r.val;
}
constexpr bool operator!=(const Fp &r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
if (n == 0)
return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1)
t = t * a;
return t;
}
};
using mint = Fp<MOD>;
mint calc(ll N, ll K) {
mint res = 1;
for (ll n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
mint COM(ll n, ll k) {
if (k == 0)
return 1;
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
int a, b;
cin >> a >> b;
if (b % a == 0) {
cout << a + b << endl;
} else
cout << b - a << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 933,963 | 933,964 | u722640678 | cpp |
p03125 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
int A, B;
cin >> A >> B;
if (B % A == 0) {
cout << A + B << endl;
} else {
cout << A - B << endl;
}
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
int A, B;
cin >> A >> B;
if (B % A == 0) {
cout << A + B << endl;
} else {
cout << B - A << endl;
}
}
| [
"expression.operation.binary.remove"
] | 933,967 | 933,968 | u312172322 | cpp |
p03135 | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (double)b / a;
return 0;
}
| #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (double)a / b;
return 0;
}
| [
"expression.operation.binary.remove"
] | 933,974 | 933,975 | u818967913 | cpp |
p03135 | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << b / a;
return 0;
} | #include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (double)a / b;
return 0;
}
| [
"expression.operation.binary.add"
] | 933,976 | 933,975 | u818967913 | cpp |
p03135 | #include <iostream>
using namespace std;
int main() {
int X, T;
cin >> X >> T;
cout << double(T) / double(X);
return 0;
} | #include <iostream>
using namespace std;
int main() {
int X, T;
cin >> T >> X;
cout << double(T) / double(X);
return 0;
} | [
"expression.operation.binary.remove"
] | 933,977 | 933,978 | u337949146 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
int t, x;
cin >> t >> x;
cout << fixed << setprecision(4) << t / x << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
double t, x;
cin >> t >> x;
cout << fixed << setprecision(4) << t / x << endl;
}
| [
"variable_declaration.type.primitive.change"
] | 933,979 | 933,980 | u298768617 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
double c;
c = a / b;
cout << c << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
double c;
c = a / b;
cout << c << endl;
} | [
"variable_declaration.type.primitive.change"
] | 933,985 | 933,986 | u946082956 | cpp |
p03135 | #include "bits/stdc++.h"
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cout << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cout << " " << v[i]; \
cout << endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
#define pb push_back
template <class T> void print(const T &x) { cout << x << endl; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
int main() {
int t, x;
cin >> t >> x;
double ans = t / x;
cout << ans << endl;
return 0;
}
| #include "bits/stdc++.h"
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v) \
cout << #v << ":"; \
for (int i = 0; i < v.size(); i++) \
cout << " " << v[i]; \
cout << endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout << setprecision(15) << fixed << p << endl;
#define pb push_back
template <class T> void print(const T &x) { cout << x << endl; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
int main() {
int t, x;
cin >> t >> x;
double ans = (double)t / x;
cout << ans << endl;
return 0;
}
| [
"type_conversion.add"
] | 933,987 | 933,988 | u531436689 | cpp |
p03135 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (double)b / a << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (double)a / b << endl;
return 0;
}
| [
"expression.operation.binary.remove"
] | 933,989 | 933,990 | u123745130 | cpp |
p03135 | /*
author : nishi5451
created: 11.08.2020 21:18:57
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int t, x;
cin >> t >> x;
double ans;
ans = t / x;
printf("%.12lf", ans);
return 0;
}
| /*
author : nishi5451
created: 11.08.2020 21:18:57
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int t, x;
cin >> t >> x;
double ans;
ans = (double)t / x;
printf("%.12lf", ans);
return 0;
}
| [
"type_conversion.add"
] | 933,991 | 933,992 | u033937898 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a / b;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
cout << a / b << endl;
}
| [
"variable_declaration.type.primitive.change",
"io.output.newline.add"
] | 933,995 | 933,996 | u025773431 | cpp |
p03135 | #include <iostream>
using namespace std;
int main() {
int t, x;
double a;
cin >> t >> x;
a = t / x;
cout << a;
} | #include <iostream>
using namespace std;
int main() {
double t, x, a;
cin >> t >> x;
a = t / x;
cout << a;
} | [
"variable_declaration.type.primitive.change"
] | 933,997 | 933,998 | u691856718 | cpp |
p03135 | #include <bits/stdc++.h>
#include <cstdio> // popen, pclose, fgets
#include <cstdlib>
#include <iostream>
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; // long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
const double PI = 3.14159265358979323846;
//小数点以下を指定したい時 →→→→ cout << fixed << setprecision();
// int→string
// string→int int num = atoi(numStr.c_str());
int main() {
int a, b, ans;
cin >> a >> b;
ans = a / b;
cout << ans << endl;
} | #include <bits/stdc++.h>
#include <cstdio> // popen, pclose, fgets
#include <cstdlib>
#include <iostream>
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; // long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
const double PI = 3.14159265358979323846;
//小数点以下を指定したい時 →→→→ cout << fixed << setprecision();
// int→string
// string→int int num = atoi(numStr.c_str());
int main() {
double a, b, ans;
cin >> a >> b;
ans = a / b;
cout << ans << endl;
} | [
"variable_declaration.type.primitive.change"
] | 933,999 | 934,000 | u680574634 | cpp |
p03135 | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int T, X;
cin >> T >> X;
double time = T / X;
cout << fixed << setprecision(3) << time << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int T, X;
cin >> T >> X;
double time = T * 1.0 / X;
cout << fixed << setprecision(3) << time << endl;
return 0;
} | [
"assignment.change"
] | 934,003 | 934,004 | u260525363 | cpp |
p03135 | // c++ テンプレ
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
typedef long double ld;
typedef pair<int, int> P;
#define inf 1e9
#define mod 1000000007
#define sort(v) sort(v.begin(), v.end())
#define reverse(v) reverse(v.begin(), v.end())
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
void solve() {
int t, x;
cin >> t >> x;
double ans = t / x;
printf("%.10f\n", ans);
}
int main() {
solve();
return 0;
}
| // c++ テンプレ
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
typedef long double ld;
typedef pair<int, int> P;
#define inf 1e9
#define mod 1000000007
#define sort(v) sort(v.begin(), v.end())
#define reverse(v) reverse(v.begin(), v.end())
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
void solve() {
double t, x;
cin >> t >> x;
double ans = t / x;
printf("%.10f\n", ans);
}
int main() {
solve();
return 0;
}
| [
"variable_declaration.type.primitive.change"
] | 934,017 | 934,018 | u332253305 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
int A, B;
cin >> A >> B;
double C = A / B;
cout << C << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
double A, B;
cin >> A >> B;
double C = A / B;
cout << C << endl;
} | [
"variable_declaration.type.primitive.change"
] | 934,019 | 934,020 | u991713078 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
float ans;
int t, x;
cin >> t >> x;
ans = t / x;
cout << setprecision(10) << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
double ans, t, x;
cin >> t >> x;
ans = t / x;
cout << setprecision(10) << ans << endl;
return 0;
}
| [
"variable_declaration.type.primitive.change"
] | 934,038 | 934,039 | u124676202 | cpp |
p03135 | #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin()) // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
cin.tie(0); \
ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v) \
cerr << "[debugV] " << #v << ":"; \
rep(i, v.size()) cerr << " " << v[i]; \
cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) { return x == 0 ? 1 : log10(x) + 1; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
vector<P> factorize(ll n) {
vector<P> result;
for (ll i = 2; i * i <= n; ++i) {
if (n % i == 0) {
result.pb({i, 0});
while (n % i == 0) {
n /= i;
result.back().second++;
}
}
}
if (n != 1) {
result.pb({n, 1});
}
return result;
}
vll divisor(ll n) {
vll ret;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
SORT(ret);
return (ret);
}
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;
}
signed main() {
init();
ll T, X;
cin >> T >> X;
ld ans = T / X;
COUTF(ans);
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin()) // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
cin.tie(0); \
ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v) \
cerr << "[debugV] " << #v << ":"; \
rep(i, v.size()) cerr << " " << v[i]; \
cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) { return x == 0 ? 1 : log10(x) + 1; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
vector<P> factorize(ll n) {
vector<P> result;
for (ll i = 2; i * i <= n; ++i) {
if (n % i == 0) {
result.pb({i, 0});
while (n % i == 0) {
n /= i;
result.back().second++;
}
}
}
if (n != 1) {
result.pb({n, 1});
}
return result;
}
vll divisor(ll n) {
vll ret;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
SORT(ret);
return (ret);
}
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;
}
signed main() {
init();
ld T, X;
cin >> T >> X;
ld ans = T / X;
COUTF(ans);
return 0;
} | [
"variable_declaration.type.change"
] | 934,040 | 934,041 | u297738015 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
int main() {
int t, x;
cin >> t >> x;
cout << t * x << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
int main() {
double t, x;
cin >> t >> x;
cout << t / x << endl;
return 0;
} | [
"variable_declaration.type.primitive.change",
"expression.operator.arithmetic.change",
"io.output.change"
] | 934,044 | 934,045 | u191484928 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a / b << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
cout << a / b << endl;
}
| [
"variable_declaration.type.primitive.change"
] | 934,046 | 934,047 | u751515087 | cpp |
p03135 | #include <bits/stdc++.h>
#define int long long int
#define gif(a, b) (a / b + (a % b ? 1 : 0))
#define pi 3.14159265358
#define watch(x) cout << (#x) << " is " << (x) << "\n";
#define float long double
using namespace std;
int32_t main() {
cin.tie(NULL);
std::ios::sync_with_stdio(false);
int y, m, d;
cin >> y >> m;
cout << y / m;
return 0;
}
| #include <bits/stdc++.h>
#define int long long int
#define gif(a, b) (a / b + (a % b ? 1 : 0))
#define pi 3.14159265358
#define watch(x) cout << (#x) << " is " << (x) << "\n";
#define float long double
using namespace std;
int32_t main() {
cin.tie(NULL);
std::ios::sync_with_stdio(false);
int y, m, d;
cin >> y >> m;
cout << (float)y / m;
return 0;
}
| [
"type_conversion.add"
] | 934,051 | 934,052 | u735675333 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
int t, x;
cin >> t >> x;
cout << setprecision(10) << (double)x / t << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int t, x;
cin >> t >> x;
cout << setprecision(10) << (double)t / x << endl;
}
| [
"expression.operation.binary.remove"
] | 934,053 | 934,054 | u449303900 | cpp |
p03135 | #include <bits/stdc++.h>
using namespace std;
int main() {
int T, X;
cin >> T >> X;
cout << T / X;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
double T, X;
cin >> T >> X;
cout << T / X;
}
| [
"variable_declaration.type.primitive.change"
] | 934,074 | 934,075 | u884647366 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.