Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p03073
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < N; i++) typedef long long ll; int main() { string s; cin >> s; int cnta = 0, cntb = 0; bool turn = false; for (int i = 0; i < s.size() - 1; i++) { if (s.at(i) != s.at(i + 1) && !turn) cnta++; else if (s.at(i) != s.at(i + 1) && turn) cntb++; else if (s.at(i) == s.at(i + 1)) { if (turn) { cnta++; turn = !turn; } else { cntb++; turn = !turn; } } } int ans = s.size() - max(cnta, cntb) - 1; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < N; i++) typedef long long ll; int main() { string s; cin >> s; int cnta = 1, cntb = 0; bool turn = false; for (int i = 0; i < s.size() - 1; i++) { if (s.at(i) != s.at(i + 1) && !turn) cnta++; else if (s.at(i) != s.at(i + 1) && turn) cntb++; else if (s.at(i) == s.at(i + 1)) { if (turn) { cnta++; turn = !turn; } else { cntb++; turn = !turn; } } } int ans = s.size() - max(cnta, cntb); cout << ans << endl; }
[ "literal.number.change", "variable_declaration.value.change", "expression.operation.binary.remove" ]
883,939
883,940
u343935874
cpp
p03073
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; string S; int main() { cin >> S; int p1, p2 = 0; // 0始まり rep(i, S.size()) { if (i % 2 == 0 && S[i] != '0') p1++; if (i % 2 == 1 && S[i] != '1') p1++; } // 1始まり rep(i, S.size()) { if (i % 2 == 0 && S[i] != '1') p2++; if (i % 2 == 1 && S[i] != '0') p2++; } printf("%d\n", min(p1, p2)); }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; string S; int main() { cin >> S; int p1 = 0, p2 = 0; // 0始まり rep(i, S.size()) { if (i % 2 == 0 && S[i] != '0') p1++; if (i % 2 == 1 && S[i] != '1') p1++; } // 1始まり rep(i, S.size()) { if (i % 2 == 0 && S[i] != '1') p2++; if (i % 2 == 1 && S[i] != '0') p2++; } printf("%d\n", min(p1, p2)); }
[ "variable_declaration.value.change" ]
883,941
883,942
u455366471
cpp
p03073
#include <algorithm> #include <iostream> using namespace std; int main() { string s; cin >> s; int ans = s.size(); for (int i = 0; i < 2; i++) { int cnt = 0; for (int j = 0; j < s.size(); j++) { if ((j % 2 == 0) ^ (s[i] == i + '0')) cnt++; } ans = min(ans, cnt); } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { string s; cin >> s; int ans = s.size(); for (int i = 0; i < 2; i++) { int cnt = 0; for (int j = 0; j < s.size(); j++) { if ((j % 2 == 0) ^ (s[j] == i + '0')) cnt++; } ans = min(ans, cnt); } cout << ans << endl; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
883,943
883,944
u633402865
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> s; n = s.size(); int no, ne; ne = n / 2; if (n % 2 == 0) no = n / 2; else no = (n / 2) + 1; int a = 0, b = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (s.at(i) == '1') b++; //偶数番目にある1の数を数える } else { if (s.at(i) == '1') a++; //奇数番目にある1の数を数える } } cout << min(no - a + b, ne + a - b) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> s; n = s.size(); int no, ne; ne = n / 2; if (n % 2 == 0) no = n / 2; else no = (n / 2) + 1; int a = 0, b = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (s.at(i) == '1') a++; //奇数番目にある1の数を数える } else { if (s.at(i) == '1') b++; //偶数番目にある1の数を数える } } cout << min(no - a + b, ne + a - b) << endl; }
[ "identifier.change" ]
883,949
883,950
u013069672
cpp
p03073
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; typedef long long ll; const int MOD = 1000000007; int main() { string S; cin >> S; int ans = S.size(); rep(i, 2) { int cnt = 0; // 変える必要のあるタイルの数 rep(j, S.size()) { // (char) (0 + '0') => '0' // (char) (1 + '0') => '0' if (j % 2 == 0 && S[i] != (char)(i + '0')) cnt++; if (j % 2 == 1 && S[i] == (char)(i + '0')) cnt++; } ans = min(ans, cnt); } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; typedef long long ll; const int MOD = 1000000007; int main() { string S; cin >> S; int ans = S.size(); rep(i, 2) { int cnt = 0; // 変える必要のあるタイルの数 rep(j, S.size()) { // (char) (0 + '0') => '0' // (char) (1 + '0') => '0' if (j % 2 == 0 && S[j] != (char)(i + '0')) cnt++; if (j % 2 == 1 && S[j] == (char)(i + '0')) cnt++; } ans = min(ans, cnt); } cout << ans << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
883,953
883,954
u976045502
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans0 = 0; int ans1 = 0; int ans = 0; // 0start string s0 = s; if (s0[0] == '1') ans0++; s0.replace(0, 1, "0"); for (int i = 1; i < s.size(); i++) { if (s0[i - 1] == s0[i]) { ans0++; if (s0[i] == '0') { s0.replace(i, 1, "1"); } else if (s0[i] == '1') { s0.replace(i, 1, "0"); } } } // 1start string s1 = s; if (s0[0] == '0') ans1++; s1.replace(0, 1, "1"); for (int i = 1; i < s.size(); i++) { if (s1[i - 1] == s1[i]) { ans1++; if (s1[i] == '0') { s1.replace(i, 1, "1"); } else if (s1[i] == '1') { s1.replace(i, 1, "0"); } } } ans = min(ans0, ans1); cout << ans << endl; // cout << s << endl; // cout << s0 << endl; // cout << s1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans0 = 0; int ans1 = 0; int ans = 0; // 0start string s0 = s; if (s0[0] == '1') ans0++; s0.replace(0, 1, "0"); for (int i = 1; i < s.size(); i++) { if (s0[i - 1] == s0[i]) { ans0++; if (s0[i] == '0') { s0.replace(i, 1, "1"); } else if (s0[i] == '1') { s0.replace(i, 1, "0"); } } } // 1start string s1 = s; if (s1[0] == '0') ans1++; s1.replace(0, 1, "1"); for (int i = 1; i < s.size(); i++) { if (s1[i - 1] == s1[i]) { ans1++; if (s1[i] == '0') { s1.replace(i, 1, "1"); } else if (s1[i] == '1') { s1.replace(i, 1, "0"); } } } ans = min(ans0, ans1); cout << ans << endl; // cout << s << endl; // cout << s0 << endl; // cout << s1 << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
883,959
883,960
u785334194
cpp
p03073
#include <iostream> #include <vector> using namespace std; int main() { string s, c; cin >> s; c.resize(100000); int sum1 = 0; for (int i = 0; i < s.size(); i++) { if (i % 2 == 0) { c[i] = '0'; } else { c[i] = '1'; } if (s[i] == c[i]) { sum1++; } else { } } if (sum1 < s.size() / 2) { cout << sum1 << endl; } else { cout << s.size() - sum1 << endl; } return 0; }
#include <iostream> #include <vector> using namespace std; int main() { string s, c; cin >> s; c.resize(100000); int sum1 = 0; for (int i = 0; i < s.size(); i++) { if (i % 2 == 0) { c[i] = '0'; } else { c[i] = '1'; } if (s[i] == c[i]) { sum1++; } else { } } if (2 * sum1 <= s.size()) { cout << sum1 << endl; } else { cout << s.size() - sum1 << endl; } return 0; }
[ "control_flow.branch.if.condition.change", "expression.operator.compare.change", "expression.operation.binary.remove" ]
883,961
883,962
u519899937
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { int i, co; string s; cin >> s; co = 0; for (i = 0; i < s.size(); ++i) { if (i == 1) { if (s[i - 1] == s[i]) { if (s[i - 1] == '0') { s[i] = 1; } else { s[i] = 0; } co = co + 1; } } if (s[i] != s[i % 2]) { s[i] = s[i % 2]; co = co + 1; } } cout << co << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, co; string s; cin >> s; co = 0; for (i = 0; i < s.size(); ++i) { if (i == 1) { if (s[i - 1] == s[i]) { if (s[i - 1] == '0') { s[i] = '1'; } else { s[i] = '0'; } co = co + 1; } } if (s[i] != s[i % 2]) { s[i] = s[i % 2]; co = co + 1; } } cout << co << endl; return 0; }
[]
883,967
883,968
u144029820
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; int main() { int ok = 0; string S; cin >> S; for (int i = 0; i < S.size(); i++) { if (i % 2 == '0') { if (S.at(i) == 0) { ok++; } } else { if (S.at(i) == '1') { ok++; } } } int a = S.size(); cout << min(a - ok, ok) << endl; }
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; int main() { int ok = 0; string S; cin >> S; for (int i = 0; i < S.size(); i++) { if (i % 2 == 0) { if (S.at(i) == '0') { ok++; } } else { if (S.at(i) == '1') { ok++; } } } int a = S.size(); cout << min(a - ok, ok) << endl; }
[ "control_flow.branch.if.condition.change" ]
883,971
883,972
u028572059
cpp
p03073
#include <iostream> using namespace std; int main() { string s; cin >> s; int a = 0; int b = 0; for (int i = 0; i < s.size(); i++) { if (i % 2 == 0) { if (s[i] != '1') { a++; } if (s[i] != '0') { b++; } } else { if (s[i] != '1') { a++; } if (s[i] != '0') { b++; } } } if (a >= b) { cout << b << endl; } else { cout << a << endl; } return 0; }
#include <iostream> using namespace std; int main() { string s; cin >> s; int a = 0; int b = 0; for (int i = 0; i < s.size(); i++) { if (i % 2 == 0) { if (s[i] != '1') { a++; } if (s[i] != '0') { b++; } } else { if (s[i] != '0') { a++; } if (s[i] != '1') { b++; } } } if (a >= b) { cout << b << endl; } else { cout << a << endl; } return 0; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
883,985
883,986
u683667335
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int res = 1 << 30; for (int i = 0; i <= 1; i++) { int start = i; int count = 0; for (int j = 0; j < s.size(); j++) { if (s[i] - '0' != start) count++; start = 1 - start; } res = min(res, count); } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int res = 1 << 30; for (int i = 0; i <= 1; i++) { int start = i; int count = 0; for (int j = 0; j < s.size(); j++) { if (s[j] - '0' != start) count++; start = 1 - start; } res = min(res, count); } cout << res << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
883,991
883,992
u089528214
cpp
p03073
#include <bits/stdc++.h> using namespace std; //#define ONLINE_JUDGE #define ll long long #define PI 3.14159265359 #define fore(i, l, r) for (int i = int(l); i < int(r); ++i) #define pb(a) push_back(a) //////////// Solution ///////////////////////////////// const int MAXN = 1e5 + 1; char s1[MAXN], s2[MAXN]; void solve() { string s; cin >> s; int n = (int)s.length(); char c = 0; for (int i = 0; i < n; ++i) { s1[i] = (char)('0' + c); s2[i] = (char)('0' + (1 - c)); c = 1 - c; } int n1 = 0, n2 = 0; for (int i = 0; i < n; ++i) { if (s[i] != s1[i]) { ++n1; } if (s[i] != s2[i]) { ++n2; } } cout << min(n1, n2) << '\n'; } /////////// End Solution /////////////////////////////////////// //////// Initialization //////////////////////////////////// int main() { #ifndef ONLINE_JUDGE FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin); clock_t time_start = clock(); #endif ios::sync_with_stdio(false); cin.tie(NULL); solve(); #ifndef ONLINE_JUDGE fclose(FIN); cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock() - time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m"; #endif return 0; } //////// End Initialization ///////////////////////////////////////
#include <bits/stdc++.h> using namespace std; #define ONLINE_JUDGE #define ll long long #define PI 3.14159265359 #define fore(i, l, r) for (int i = int(l); i < int(r); ++i) #define pb(a) push_back(a) //////////// Solution ///////////////////////////////// const int MAXN = 1e5 + 1; char s1[MAXN], s2[MAXN]; void solve() { string s; cin >> s; int n = (int)s.length(); char c = 0; for (int i = 0; i < n; ++i) { s1[i] = (char)('0' + c); s2[i] = (char)('0' + (1 - c)); c = 1 - c; } int n1 = 0, n2 = 0; for (int i = 0; i < n; ++i) { if (s[i] != s1[i]) { ++n1; } if (s[i] != s2[i]) { ++n2; } } cout << min(n1, n2) << '\n'; } /////////// End Solution /////////////////////////////////////// //////// Initialization //////////////////////////////////// int main() { #ifndef ONLINE_JUDGE FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin); clock_t time_start = clock(); #endif ios::sync_with_stdio(false); cin.tie(NULL); solve(); #ifndef ONLINE_JUDGE fclose(FIN); cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock() - time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m"; #endif return 0; } //////// End Initialization ///////////////////////////////////////
[]
884,009
884,010
u361383723
cpp
p03073
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { long count_1 = 0, count_0 = 0; string s; cin >> s; char b[100010]; for (int i = 0; i < s.size(); i++) { b[i] = s[i]; if ((i % 2 == 0) && s[i] == '1') { count_0++; } else if ((i % 2 == 0) && s[i] == '0') { count_1++; } else if ((i % 2 == 1) && s[i] == '0') { count_1++; } else if ((i % 2 == 1) && s[i] == '1') { count_0++; } } cout << min(count_1, count_0); }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { long count_1 = 0, count_0 = 0; string s; cin >> s; char b[100010]; for (int i = 0; i < s.size(); i++) { b[i] = s[i]; if ((i % 2 == 0) && s[i] == '1') { count_0++; } else if ((i % 2 == 0) && s[i] == '0') { count_1++; } else if ((i % 2 == 1) && s[i] == '1') { count_1++; } else if ((i % 2 == 1) && s[i] == '0') { count_0++; } } cout << min(count_1, count_0); }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
884,013
884,014
u352604942
cpp
p03073
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { long count_1 = 0, count_0 = 0; string s; cin >> s; char b[100010]; for (int i = 0; i < s.size(); i++) { b[i] = s[i]; if ((i % 2 == 0) && s[i] == '1') { count_0++; } else if ((i % 2 == 0) && s[i] == '0') { count_0++; } else if ((i % 2 == 1) && s[i] == '0') { count_1++; } else if ((i % 2 == 1) && s[i] == '1') { count_0++; } } cout << min(count_1, count_0); }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { long count_1 = 0, count_0 = 0; string s; cin >> s; char b[100010]; for (int i = 0; i < s.size(); i++) { b[i] = s[i]; if ((i % 2 == 0) && s[i] == '1') { count_0++; } else if ((i % 2 == 0) && s[i] == '0') { count_1++; } else if ((i % 2 == 1) && s[i] == '1') { count_1++; } else if ((i % 2 == 1) && s[i] == '0') { count_0++; } } cout << min(count_1, count_0); }
[ "expression.unary.arithmetic.remove", "expression.unary.arithmetic.add", "control_flow.branch.if.add" ]
884,015
884,014
u352604942
cpp
p03073
#include <iostream> #include <string> #include <vector> using namespace std; int main(void) { string s; cin >> s; char exs = s[0]; if (s[0] == '0') exs = '1'; else exs = '0'; bool flag = false; int c = 0; for (const auto &i : s) { if (flag ^ (exs == i)) c++; if (flag) flag = !flag; exs = i; } if (c > s.size() - c) c = s.size() - c; cout << c; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main(void) { string s; cin >> s; char exs = s[0]; if (s[0] == '0') exs = '1'; else exs = '0'; bool flag = false; int c = 0; for (const auto &i : s) { if (flag ^ (exs == i)) c++; if (exs == i) flag = !flag; exs = i; } if (c > s.size() - c) c = s.size() - c; cout << c; return 0; }
[ "control_flow.branch.if.condition.change" ]
884,024
884,025
u884966843
cpp
p03073
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <istream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> #define rep0(i, n) for (long long int i = 0; i <= (n); ++i) #define rep1(i, n) for (long long int i = 1; i <= (n); ++i) #define REP(a, b) for (long long int i = a; i <= (b); ++i) #define ps push_back #define MOD 1000000007 using namespace std; typedef long long ll; int main() { string s; cin >> s; int count = 0; string ans; if (s[0] == '1') { rep0(i, s.size() - 1) { if (i % 2 != 0) ans += '0'; else ans += '1'; } } else { rep0(j, s.size() - 1) { if (j % 2 != 0) ans += '0'; else ans += '1'; } } rep0(k, s.size() - 1) { if (s[k] != ans[k]) ++count; } cout << count << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <istream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> #define rep0(i, n) for (long long int i = 0; i <= (n); ++i) #define rep1(i, n) for (long long int i = 1; i <= (n); ++i) #define REP(a, b) for (long long int i = a; i <= (b); ++i) #define ps push_back #define MOD 1000000007 using namespace std; typedef long long ll; int main() { string s; cin >> s; int count = 0; string ans; if (s[0] == '1') { rep0(i, s.size() - 1) { if (i % 2 != 0) ans += '0'; else ans += '1'; } } else { rep0(j, s.size() - 1) { if (j % 2 != 0) ans += '1'; else ans += '0'; } } rep0(k, s.size() - 1) { if (s[k] != ans[k]) ++count; } cout << count << endl; return 0; }
[ "control_flow.branch.else.remove", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "assignment.add" ]
884,036
884,037
u820341516
cpp
p03073
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define irep(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; #define intv vector<int> #define llv vector<long long> #define intvv vector<vector<int>> #define llvv vector<vector<long long>> using namespace std; int main() { string s; cin >> s; int n = s.size(); int ans1, ans2; rep(i, n) { if (i % 2 != s[i] - '0') ans1++; else ans2++; } cout << min(ans1, ans2) << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define irep(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; #define intv vector<int> #define llv vector<long long> #define intvv vector<vector<int>> #define llvv vector<vector<long long>> using namespace std; int main() { string s; cin >> s; int n = s.size(); int ans1 = 0, ans2 = 0; rep(i, n) { if (i % 2 != s[i] - '0') ans1++; else ans2++; } cout << min(ans1, ans2) << endl; }
[ "variable_declaration.value.change" ]
884,039
884,040
u379440427
cpp
p03073
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define irep(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; #define intv vector<int> #define llv vector<long long> #define intvv vector<vector<int>> #define llvv vector<vector<long long>> using namespace std; int main() { string s; cin >> s; int n = s.size(); int ans1, ans2; rep(i, n) { if (i % 2 == s[i] - '0') ans1++; else ans2++; } cout << min(ans1, ans2) << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define irep(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; #define intv vector<int> #define llv vector<long long> #define intvv vector<vector<int>> #define llvv vector<vector<long long>> using namespace std; int main() { string s; cin >> s; int n = s.size(); int ans1 = 0, ans2 = 0; rep(i, n) { if (i % 2 != s[i] - '0') ans1++; else ans2++; } cout << min(ans1, ans2) << endl; }
[ "variable_declaration.value.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,041
884,040
u379440427
cpp
p03073
#include <iostream> #include <algorithm> #include <cstdio> #include <fstream> #include <iomanip> #include <map> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REP2(i, s, n) for (int i = s; i < n; i++) #define REP_1(i, n) for (int i = 1; i < n + 1; i++) #define bitSearch(bit, n) for (int bit = 0; bit < (1 << N); bit++) using namespace std; void printAns(int a) { cout << a << endl; } void yesno(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; } void YESNO(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; } typedef long long ll; typedef unsigned long ul; typedef long double ld; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll INF = 10000000; ll mod = 1000000007; // 10^9+7 //番号ズレ注意!! int main() { string S; cin >> S; int N = S.size(); int ans1 = 0, ans2 = 0; if (N % 2 == 0) { for (int i = 0; i < N; i += 2) { if (S[i] == '1') ans1++; if (S[i + 1] == '0') ans1++; } for (int i = 0; i < N; i += 2) { if (S[i] == '0') ans2++; if (S[i + 1] == '1') ans2++; } } else { for (int i = 0; i < N - 1; i += 2) { if (S[i] == '1') ans1++; if (S[i + 1] == '0') ans1++; } if (S[N - 1] == '1') ans1++; for (int i = 0; i < N - 1; i += 2) { if (S[i] == '0') ans2++; if (S[i + 1] == '1') ans2++; } if (S[N - 1] == '1') ans2++; } int ans = min(ans1, ans2); printAns(ans); }
#include <iostream> #include <algorithm> #include <cstdio> #include <fstream> #include <iomanip> #include <map> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REP2(i, s, n) for (int i = s; i < n; i++) #define REP_1(i, n) for (int i = 1; i < n + 1; i++) #define bitSearch(bit, n) for (int bit = 0; bit < (1 << N); bit++) using namespace std; void printAns(int a) { cout << a << endl; } void yesno(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; } void YESNO(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; } typedef long long ll; typedef unsigned long ul; typedef long double ld; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll INF = 10000000; ll mod = 1000000007; // 10^9+7 //番号ズレ注意!! int main() { string S; cin >> S; int N = S.size(); int ans1 = 0, ans2 = 0; if (N % 2 == 0) { for (int i = 0; i < N; i += 2) { if (S[i] == '1') ans1++; if (S[i + 1] == '0') ans1++; } for (int i = 0; i < N; i += 2) { if (S[i] == '0') ans2++; if (S[i + 1] == '1') ans2++; } } else { for (int i = 0; i < N - 1; i += 2) { if (S[i] == '1') ans1++; if (S[i + 1] == '0') ans1++; } if (S[N - 1] == '1') ans1++; for (int i = 0; i < N - 1; i += 2) { if (S[i] == '0') ans2++; if (S[i + 1] == '1') ans2++; } if (S[N - 1] == '0') ans2++; } int ans = min(ans1, ans2); printAns(ans); }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
884,052
884,053
u741556152
cpp
p03073
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> #define INF 1000000009; using namespace std; int gcd(int a, int b) { while (a % b != 0) { int c = 0; c = a % b; a = b; b = c; } return b; } string names; string karuta[100100]; int nn[400]; vector<pair<int, int>> workk; long long summ; int main() { string manji; int counto = 0; cin >> manji; for (int i = 0; i < manji.size(); i++) { if (i % 2 == 0) { if (manji[i] == '0') { counto++; } } else { if (manji[i] == '1') { counto++; } } } if (counto < manji.size() / 2) { cout << counto << endl; return 0; } else { cout << manji.size() - counto << endl; } return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> #define INF 1000000009; using namespace std; int gcd(int a, int b) { while (a % b != 0) { int c = 0; c = a % b; a = b; b = c; } return b; } string names; string karuta[100100]; int nn[400]; vector<pair<int, int>> workk; long long summ; int main() { string manji; int counto = 0; cin >> manji; for (int i = 0; i < manji.size(); i++) { if (i % 2 == 0) { if (manji[i] == '0') { counto++; } } else { if (manji[i] == '1') { counto++; } } } if (counto <= manji.size() / 2) { cout << counto << endl; return 0; } else { cout << manji.size() - counto << endl; } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,058
884,059
u019465635
cpp
p03073
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> #define INF 1000000009; using namespace std; int gcd(int a, int b) { while (a % b != 0) { int c = 0; c = a % b; a = b; b = c; } return b; } string names; string karuta[100100]; int nn[400]; vector<pair<int, int>> workk; long long summ; int main() { string manji; int counto = 0; cin >> manji; for (int i = 0; i < manji.size(); i++) { if (i % 2 == 0) { if (manji[i] == 'w') { counto++; } } else { if (manji[i] == 'b') { counto++; } } } if (counto < manji.size() / 2) { cout << counto << endl; return 0; } else { cout << manji.size() - counto << endl; } return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> #define INF 1000000009; using namespace std; int gcd(int a, int b) { while (a % b != 0) { int c = 0; c = a % b; a = b; b = c; } return b; } string names; string karuta[100100]; int nn[400]; vector<pair<int, int>> workk; long long summ; int main() { string manji; int counto = 0; cin >> manji; for (int i = 0; i < manji.size(); i++) { if (i % 2 == 0) { if (manji[i] == '0') { counto++; } } else { if (manji[i] == '1') { counto++; } } } if (counto <= manji.size() / 2) { cout << counto << endl; return 0; } else { cout << manji.size() - counto << endl; } return 0; }
[ "literal.string.change", "control_flow.branch.if.condition.change", "expression.operator.compare.change" ]
884,060
884,059
u019465635
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define f first #define s second #define all(container) container.begin(), container.end() #define fast \ ios::sync_with_stdio(0); \ cin.tie(0) int32_t main() { fast; string s; cin >> s; int t1[s.size()]; int t2[s.size()]; for (int i = 0; i < s.size(); i++) { t1[i] = s[i] - '0'; t2[i] = s[i] - '0'; } int c1 = 0, c2 = 0; if (t1[0] != 0) { t1[0] = 0; c1++; } if (t2[0] != 1) { t1[0] = 1; c2++; } // for(auto k : t1) cout << k << " "; // cout << '\n'; // for(auto k : t2) cout << k << " "; // cout << '\n'; for (int i = 1; i < s.size(); i++) { if (t1[i] != t1[i - 1]) { c1++; t1[i] = !t1[i]; } if (t2[i] != t2[i - 1]) { c2++; t2[i] = !t2[i]; } } cout << min(c1, c2); return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define f first #define s second #define all(container) container.begin(), container.end() #define fast \ ios::sync_with_stdio(0); \ cin.tie(0) int32_t main() { fast; string s; cin >> s; int t1[s.size()]; int t2[s.size()]; for (int i = 0; i < s.size(); i++) { t1[i] = s[i] - '0'; t2[i] = s[i] - '0'; } int c1 = 0, c2 = 0; if (t1[0] != 0) { t1[0] = 0; c1++; } if (t2[0] != 1) { t2[0] = 1; c2++; } for (int i = 1; i < s.size(); i++) { if (t1[i] == t1[i - 1]) { c1++; t1[i] = !t1[i]; } if (t2[i] == t2[i - 1]) { c2++; t2[i] = !t2[i]; } } // cout << "c1 " << c1 << " " << c2 << '\n'; cout << min(c1, c2); return 0; }
[ "assignment.variable.change", "identifier.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,078
884,079
u153896700
cpp
p03073
#include "bits/stdc++.h" using namespace std; int main() { string s; cin >> s; int ans1 = 0, ans2 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] - '0' == i % 2) ans1++; else ans2++; } cout << max(ans1, ans2) << endl; }
#include "bits/stdc++.h" using namespace std; int main() { string s; cin >> s; int ans1 = 0, ans2 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] - '0' == i % 2) ans1++; else ans2++; } cout << min(ans1, ans2) << endl; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
884,082
884,083
u887207211
cpp
p03073
// author: Saman Mahdanian #include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; const int MOD = 1e9 + 7; int _sum(int, int); int _mul(int, int); int _pow(int, int); int gcd(int, int); int dp[N][3]; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = s.size(); dp[0][0] = dp[1][0] = 1; dp[0][int(s[0] - '0')] = 0; for (int i = 1; i < n; i++) for (int c : {0, 1}) dp[i][c] = dp[i - 1][1 ^ c] + (s[i] == '0' + c ? 0 : 1); cout << min(dp[n - 1][0], dp[n - 1][1]) << endl; } int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } // int choose (int r, int k) { // return _mul (f[k], _mul(inv[r], inv[k - r])); // } int _sum(int a, int b) { return a + b - (a + b >= MOD ? MOD : 0); } int _mul(int a, int b) { return 1LL * a * b % MOD; } int _pow(int a, int b) { if (!b) return 1; int res = _pow(a, b >> 1); res = _mul(res, res); if (b & 1) res = _mul(res, a); return res; } // SamMHD :: Jun27-2019 :: Another Day with Shayan...
// author: Saman Mahdanian #include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; const int MOD = 1e9 + 7; int _sum(int, int); int _mul(int, int); int _pow(int, int); int gcd(int, int); int dp[N][3]; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = s.size(); dp[0][0] = dp[0][1] = 1; dp[0][int(s[0] - '0')] = 0; for (int i = 1; i < n; i++) for (int c : {0, 1}) dp[i][c] = dp[i - 1][1 ^ c] + (s[i] == '0' + c ? 0 : 1); cout << min(dp[n - 1][0], dp[n - 1][1]) << endl; } int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } // int choose (int r, int k) { // return _mul (f[k], _mul(inv[r], inv[k - r])); // } int _sum(int a, int b) { return a + b - (a + b >= MOD ? MOD : 0); } int _mul(int a, int b) { return 1LL * a * b % MOD; } int _pow(int a, int b) { if (!b) return 1; int res = _pow(a, b >> 1); res = _mul(res, res); if (b & 1) res = _mul(res, a); return res; } // SamMHD :: Jun27-2019 :: Another Day with Shayan...
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change" ]
884,086
884,087
u599788181
cpp
p03073
#include <algorithm> #include <assert.h> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; /*********************Contest Template***********************/ typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<int, int> Cord; #define FASTIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); struct S { int a, b; S() {} S(int _a, int _b) { a = _a; b = _b; } const bool operator<(const S &o) const { return a < o.a; } }; priority_queue<int, vector<int>, greater<int>> mpq; #define SPACE 0 #define NL 1 inline void showAll(vector<int> &v, int NL_or_space) { // 0 is space, 1 is NL for (int &here : v) { printf("%d", here); printf("%c", (NL_or_space) ? '\n' : ' '); } } /*********************Contest Template***********************/ const int SIZE = 100009; char str[SIZE]; int main() { scanf("%s", str + 1); int cnt1 = 0, cnt2 = 0; for (int i = 1; str[i]; i++) { if (i & 1 && str[i] == '0') cnt1++; if (i % 2 == 0 && str[i] == '1') cnt1++; if (i % 1 && str[i] == '1') cnt2++; if (i % 2 == 0 && str[i] == '0') cnt2++; } printf("%d\n", min(cnt1, cnt2)); return 0; }
#include <algorithm> #include <assert.h> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using namespace std; /*********************Contest Template***********************/ typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<int, int> Cord; #define FASTIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); struct S { int a, b; S() {} S(int _a, int _b) { a = _a; b = _b; } const bool operator<(const S &o) const { return a < o.a; } }; priority_queue<int, vector<int>, greater<int>> mpq; #define SPACE 0 #define NL 1 inline void showAll(vector<int> &v, int NL_or_space) { // 0 is space, 1 is NL for (int &here : v) { printf("%d", here); printf("%c", (NL_or_space) ? '\n' : ' '); } } /*********************Contest Template***********************/ const int SIZE = 100009; char str[SIZE]; int main() { scanf("%s", str + 1); int cnt1 = 0, cnt2 = 0; for (int i = 1; str[i]; i++) { if (i & 1 && str[i] == '0') cnt1++; if (i % 2 == 0 && str[i] == '1') cnt1++; if (i & 1 && str[i] == '1') cnt2++; if (i % 2 == 0 && str[i] == '0') cnt2++; } printf("%d\n", min(cnt1, cnt2)); return 0; }
[ "control_flow.branch.if.condition.change" ]
884,088
884,089
u009387624
cpp
p03073
#include <bits/stdc++.h> using namespace std; // 方針 // 全体として、クリアできるパターンが // 1,白黒白黒白 パターン 10101 // 2,黒白黒白黒 パターン 01010 // の2通りしかない。 // なので、総当りでこれにすればよさそう。 // Sは高々10^5なので、O(N)ならいける。 // とりあえず1番ルートで終わる過程でforループをまわす。 // 010101010 に一致しているか一文字づつチェックして、一致していない数をカウント。 // そのカウント数nが n >= |S|/2 // で場合わけして、超えてなかったらカウントした数が答え。 // 超えてたら、2番のパターンなので、S-n が答えになる。 // これはO(N)のはず。 int main() { string S; cin >> S; int count = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') { if (i % 2 == 0) { // 偶数個目 continue; } else { // 奇数個目 count += 1; } } else if (S[i] == '1') { if (i % 2 == 0) { count += 1; // 偶数 } else { // 奇数 continue; } } } if (count >= (S.size() / 2)) { cout << S.size() - count << endl; } else { cout << count << endl; } }
#include <bits/stdc++.h> using namespace std; // 方針 // 全体として、クリアできるパターンが // 1,白黒白黒白 パターン 10101 // 2,黒白黒白黒 パターン 01010 // の2通りしかない。 // なので、総当りでこれにすればよさそう。 // Sは高々10^5なので、O(N)ならいける。 // とりあえず1番ルートで終わる過程でforループをまわす。 // 010101010 に一致しているか一文字づつチェックして、一致していない数をカウント。 // そのカウント数nが n >= |S|/2 // で場合わけして、超えてなかったらカウントした数が答え。 // 超えてたら、2番のパターンなので、S-n が答えになる。 // これはO(N)のはず。 int main() { string S; cin >> S; int count = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') { if (i % 2 == 0) { // 偶数個目 continue; } else { // 奇数個目 count += 1; } } else if (S[i] == '1') { if (i % 2 == 0) { count += 1; // 偶数 } else { // 奇数 continue; } } } if (count > (S.size() / 2)) { cout << S.size() - count << endl; } else { cout << count << endl; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,092
884,093
u587857074
cpp
p03073
#include <algorithm> #include <cctype> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <regex> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) typedef int long long ll; using namespace std; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; const ll MOD = 1e9 + 7; int main() { string s; cin >> s; string sc = s; if (s.size() == 1) { cout << 0 << endl; return 0; } int ans1 = 0; for (int i = 1; i < s.size(); i++) { if (s[i] != s[i - 1]) { } else { char c = (s[i] == '1' ? '0' : '1'); s[i] = c; ans1++; } } int ans2 = 0; for (int i = sc.size() - 2; i >= 0; i--) { if (sc[i] != sc[i + 1]) { } else { char c = (sc[i] == 1 ? '0' : '1'); sc[i] = c; ans2++; } } // cout<<ans1<<ans2<<endl; cout << min(ans1, ans2) << endl; return 0; }
#include <algorithm> #include <cctype> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <regex> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) typedef int long long ll; using namespace std; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; const ll MOD = 1e9 + 7; int main() { string s; cin >> s; string sc = s; if (s.size() == 1) { cout << 0 << endl; return 0; } int ans1 = 0; for (int i = 1; i < s.size(); i++) { if (s[i] != s[i - 1]) { } else { char c = (s[i] == '1' ? '0' : '1'); s[i] = c; ans1++; } } int ans2 = 0; for (int i = sc.size() - 2; i >= 0; i--) { if (sc[i] != sc[i + 1]) { } else { char c = (sc[i] == '1' ? '0' : '1'); sc[i] = c; ans2++; } } // cout<<ans1<<ans2<<endl; cout << min(ans1, ans2) << endl; return 0; }
[ "control_flow.branch.if.condition.change" ]
884,100
884,101
u031448582
cpp
p03073
#include <stdio.h> int main(void) { char s[100000] = {0}; int kai = 0; int i = 0; scanf("%s", s); for (i = 0; i <= 100000; i++) { if (s[i] == 'i' && i % 2 != 0) { kai++; } if (s[i] == '0' && i % 2 == 0) { kai++; } if (s[i] == '\0') { break; } } if (kai * 2 < i) { printf("%d", kai); } else { printf("%d", i - kai); } return 0; }
#include <stdio.h> int main(void) { char s[100000] = {0}; int kai = 0; int i = 0; scanf("%s", s); for (i = 0; i <= 100000; i++) { if (s[i] == '1' && i % 2 != 0) { kai++; } if (s[i] == '0' && i % 2 == 0) { kai++; } if (s[i] == '\0') { break; } } if (kai * 2 < i) { printf("%d", kai); } else { printf("%d", i - kai); } return 0; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
884,104
884,105
u770491983
cpp
p03073
#include <iostream> using namespace std; int main() { string s; cin >> s; int step = 0; for (int i = 1; i < s.length() - 1; i++) { if (s[i] == s[i - 1]) { if (s[i] == '1') { s[i] = '0'; } else { s[i] = '1'; } step++; } } cout << step; }
#include <iostream> using namespace std; int main() { string s; cin >> s; int step = 0; for (int i = 1; i < s.length(); i++) { if (s[i] == s[i - 1]) { if (s[i] == '1') { s[i] = '0'; } else { s[i] = '1'; } step++; } } cout << step; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
884,119
884,120
u014321021
cpp
p03073
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; char str[maxn]; int main() { #ifdef HOME freopen("input.txt", "r", stdin); #endif int n; n = strlen(fgets(str, 100010, stdin)); int cnt = 0; char ch = '0'; for (int i = 0; i < n; ++i) { if (ch != str[i]) ++cnt; ch = ch == '0' ? '1' : '0'; // cout << i << ' ' << ch << ' ' << cnt << endl; } int ans = 0; ch = '1'; for (int i = 0; i < n; ++i) { if (ch != str[i]) ++ans; ch = ch == '0' ? '1' : '0'; // cout << i << ' ' << ch << ' ' << ans << endl; } cout << min(ans, cnt); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; char str[maxn]; int main() { #ifdef HOME freopen("input.txt", "r", stdin); #endif int n; n = strlen(fgets(str, 100010, stdin)); --n; int cnt = 0; char ch = '0'; for (int i = 0; i < n; ++i) { if (ch != str[i]) ++cnt; ch = ch == '0' ? '1' : '0'; // cout << i << ' ' << ch << ' ' << cnt << endl; } int ans = 0; ch = '1'; for (int i = 0; i < n; ++i) { if (ch != str[i]) ++ans; ch = ch == '0' ? '1' : '0'; // cout << i << ' ' << ch << ' ' << ans << endl; } cout << min(ans, cnt); return 0; }
[ "expression.unary.arithmetic.add" ]
884,124
884,125
u209067041
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define endl '\n' #define fcin \ ios::sync_with_stdio(false); \ cin.tie(nullptr); #define inf 0x3f3f3f3f // 000 ou 111 -> left == i and right == i -> pinta i // 100 ou 110 -> left == i -> pinta left // 001 ou 011 -> right == i -> pinta right /* 10010010 10110010 */ char inverse(char c) { return (c == '0' ? '1' : '0'); } int main() { fcin; string str; cin >> str; int ans = 0; for (int i = 1; i < str.size() - 1; i++) { if (str[i] == str[i - 1] and str[i] == str[i + 1]) { str[i] = inverse(str[i]); ans++; } else if (str[i] == str[i - 1]) { str[i - 1] = inverse(str[i - 1]); ans++; } else if (str[i] == str[i + 1]) { str[i + 1] = inverse(str[i + 1]); ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define endl '\n' #define fcin \ ios::sync_with_stdio(false); \ cin.tie(nullptr); #define inf 0x3f3f3f3f // 000 ou 111 -> left == i and right == i -> pinta i // 100 ou 110 -> left == i -> pinta left // 001 ou 011 -> right == i -> pinta right /* 10010010 10110010 */ char inverse(char c) { return (c == '0' ? '1' : '0'); } int main() { fcin; string str; cin >> str; int ans = 0; for (int i = 0; i < str.size(); i++) { if (str[i] == str[i - 1] and str[i] == str[i + 1]) { str[i] = inverse(str[i]); ans++; } else if (str[i] == str[i - 1]) { str[i - 1] = inverse(str[i - 1]); ans++; } else if (str[i] == str[i + 1]) { str[i + 1] = inverse(str[i + 1]); ans++; } } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
884,131
884,132
u189873906
cpp
p03073
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { string s; cin >> s; //初期値は大きい値 int ans = s.size(); // iは最初に使う色(0か1) for (int i = 0; i < 2; i++) { int cnt = 0; for (int j = 0; j < s.size(); j++) { if ((j % 2 == 0) ^ (s[i] != (char)(i + '0'))) cnt++; } ans = min(ans, cnt); } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> using namespace std; int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { string s; cin >> s; //初期値は大きい値 int ans = s.size(); // iは最初に使う色(0か1) for (int i = 0; i < 2; i++) { int cnt = 0; for (int j = 0; j < s.size(); j++) { if ((j % 2 == 0) ^ (s[j] != (char)(i + '0'))) cnt++; } ans = min(ans, cnt); } cout << ans << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
884,138
884,139
u373164102
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int color_exchanged = 0; int odd_color_white = 0; int odd_color_brack = 0; for (int i = 0; i < S.size() / 2 + S.size() % 2; i++) { if (S.at(2 * i) == 1) { odd_color_white++; } else { odd_color_brack++; } } int even_color_white = 0; int even_color_brack = 0; for (int i = 0; i < S.size() / 2; i++) { if (S.at(2 * i + 1) == 1) { even_color_white++; } else { even_color_brack++; } } cout << min(odd_color_white + even_color_brack, odd_color_brack + even_color_white) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int color_exchanged = 0; int odd_color_white = 0; int odd_color_brack = 0; for (int i = 0; i < S.size() / 2 + S.size() % 2; i++) { if (S.at(2 * i) == '1') { odd_color_white++; } else { odd_color_brack++; } } int even_color_white = 0; int even_color_brack = 0; for (int i = 0; i < S.size() / 2; i++) { if (S.at(2 * i + 1) == '1') { even_color_white++; } else { even_color_brack++; } } cout << min(odd_color_white + even_color_brack, odd_color_brack + even_color_white) << endl; }
[ "control_flow.branch.if.condition.change" ]
884,144
884,145
u830811818
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int count = 0; for (int i = 0; i < sizeof(S) - 1; i++) { if (S[i] == '0' && S[i + 1] != '1') { S[i + 1] = '1'; count++; } else if (S[i] == '1' && S[i + 1] != '0') { S[i + 1] = '0'; count++; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int count = 0; for (int i = 0; i < S.length() - 1; i++) { if (S[i] == '0' && S[i + 1] != '1') { S[i + 1] = '1'; count++; } else if (S[i] == '1' && S[i + 1] != '0') { S[i + 1] = '0'; count++; } } cout << count << endl; }
[ "control_flow.loop.for.condition.change", "call.add" ]
884,146
884,147
u006721330
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int count_z = 0; int count_o = 0; for (int i = 0; i < S.size(); i++) { if (i % 2 == 1) { if (S.at(i) == '0') count_o++; else count_z++; } else { if (S.at(i) == '0') count_z++; else count_o++; } } cout << max(count_z, count_o) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int count_z = 0; int count_o = 0; for (int i = 0; i < S.size(); i++) { if (i % 2 == 1) { if (S.at(i) == '0') count_o++; else count_z++; } else { if (S.at(i) == '0') count_z++; else count_o++; } } cout << min(count_z, count_o) << endl; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
884,148
884,149
u826764011
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { // input string n; int a, b; cin >> n; for (int i = 0; i < n.size(); i++) { if (i % 2 == 0) { if (n[i] == '0') { a++; } else { b++; } } else { if (n[i] == '0') { b++; } else { a++; } } } if (a > b) { cout << b << endl; } else { cout << a << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { // input string n; int a = 0, b = 0; cin >> n; for (int i = 0; i < n.size(); i++) { if (i % 2 == 0) { if (n[i] == '0') { a++; } else { b++; } } else { if (n[i] == '0') { b++; } else { a++; } } } if (a > b) { cout << b << endl; } else { cout << a << endl; } return 0; }
[ "variable_declaration.value.change" ]
884,157
884,158
u843574076
cpp
p03073
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; cin >> s; int b_start = 0; int w_start = 0; for (int i = 0; i < s.length(); i++) { if (i % 2) { if (s[i] == '0') { b_start++; } else { w_start++; } } else { if (s[i] == 'w') { b_start++; } else { w_start++; } } } cout << min(b_start, w_start) << endl; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; cin >> s; int b_start = 0; int w_start = 0; for (int i = 0; i < s.length(); i++) { if (i % 2) { if (s[i] == '0') { b_start++; } else { w_start++; } } else { if (s[i] == '1') { b_start++; } else { w_start++; } } } cout << min(b_start, w_start) << endl; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
884,163
884,164
u412550879
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int c1, c2; for (int i = 0; i < S.size(); i++) { if (i % 2 == 0) { if (S.at(i) != '0') c1++; if (S.at(i) != '1') c2++; } else { if (S.at(i) != '1') c1++; if (S.at(i) != '0') c2++; } } cout << min(c1, c2) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int c1 = 0, c2 = 0; for (int i = 0; i < S.size(); i++) { if (i % 2 == 0) { if (S.at(i) != '0') c1++; if (S.at(i) != '1') c2++; } else { if (S.at(i) != '1') c1++; if (S.at(i) != '0') c2++; } } cout << min(c1, c2) << endl; return 0; }
[ "variable_declaration.value.change" ]
884,167
884,168
u127361799
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int c1, c2; for (int i = 0; i < S.size(); i++) { if (i % 2 != 0) { if (S.at(i) != '0') c1++; if (S.at(i) != '1') c2++; } else { if (S.at(i) != '1') c1++; if (S.at(i) != '0') c2++; } } cout << min(c1, c2) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int c1 = 0, c2 = 0; for (int i = 0; i < S.size(); i++) { if (i % 2 == 0) { if (S.at(i) != '0') c1++; if (S.at(i) != '1') c2++; } else { if (S.at(i) != '1') c1++; if (S.at(i) != '0') c2++; } } cout << min(c1, c2) << endl; return 0; }
[ "variable_declaration.value.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,169
884,168
u127361799
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { int n, x; string S; cin >> S; x = 0; n = S.size(); for (int i = 0; i < n / 2; i++) { if (S.at(2 * i) == '1') { x++; } if (S.at(2 * i + 1) == '0') { x++; } } if (n % 2 == 1) { if (S.at(n - 1) = '1') { x++; } } if (x <= n / 2) { cout << x << endl; } else { cout << n - x << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, x; string S; cin >> S; x = 0; n = S.size(); for (int i = 0; i < n / 2; i++) { if (S.at(2 * i) == '1') { x++; } if (S.at(2 * i + 1) == '0') { x++; } } if (n % 2 == 1) { if (S.at(n - 1) == '1') { x++; } } if (x <= n / 2) { cout << x << endl; } else { cout << n - x << endl; } }
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
884,178
884,179
u201743726
cpp
p03073
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { string s; cin >> s; int n = s.length(); int ans_a = 0; int ans_b = 0; //奇数0,偶数1 for (int i = 0; i < n; i++) { if (i % 2 == 1) { if (s[i] == '0') { ans_a++; } } if (i % 2 == 0) { if (s[i] == '1') { ans_a++; } } } //奇数0,偶数1 for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (s[i] == '0') { ans_b++; } } if (i % 2 == 1) { if (s[i] == '1') { ans_b++; } } } cout << max({ans_a, ans_b}) << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { string s; cin >> s; int n = s.length(); int ans_a = 0; int ans_b = 0; //奇数0,偶数1 for (int i = 0; i < n; i++) { if (i % 2 == 1) { if (s[i] == '0') { ans_a++; } } if (i % 2 == 0) { if (s[i] == '1') { ans_a++; } } } //奇数0,偶数1 for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (s[i] == '0') { ans_b++; } } if (i % 2 == 1) { if (s[i] == '1') { ans_b++; } } } cout << min({ans_a, ans_b}) << endl; return 0; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
884,186
884,187
u407416173
cpp
p03073
#include <algorithm> #include <iostream> #include <string> using namespace std; const int black = 48; const int white = 49; int main() { string S; cin >> S; int N = S.length(); int ans_w = 0; for (int i = 0; i < N; ++i) { int _01 = (i / 2 == 0 ? white : black); if (S[i] != _01) { ans_w++; } } int ans_b = 0; for (int i = 0; i < N; ++i) { int _01 = (i / 2 == 0 ? black : white); if (S[i] != _01) { ans_b++; } } cout << min(ans_b, ans_w) << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; const int black = 48; const int white = 49; int main() { string S; cin >> S; int N = S.length(); int ans_w = 0; for (int i = 0; i < N; ++i) { int _01 = (i % 2 == 0 ? white : black); if (S[i] != _01) { ans_w++; } } int ans_b = 0; for (int i = 0; i < N; ++i) { int _01 = (i % 2 == 0 ? black : white); if (S[i] != _01) { ans_b++; } } cout << min(ans_b, ans_w) << endl; }
[ "expression.operator.arithmetic.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
884,212
884,213
u128142352
cpp
p03073
#include <iostream> using namespace std; int main() { int sum = 0, ans = 0; string a; cin >> a; for (int i = 1; i <= a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '1') { sum++; } else if (i % 2 == 1 && a[i] == '0') { sum++; } } for (int i = 1; i <= a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '0') { ans++; } else if (i % 2 == 1 && a[i] == '1') { ans++; } } cout << min(ans, sum); }
#include <iostream> using namespace std; int main() { int sum = 0, ans = 0; string a; cin >> a; for (int i = 0; i <= a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '1') { sum++; } else if (i % 2 == 1 && a[i] == '0') { sum++; } } for (int i = 0; i <= a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '0') { ans++; } else if (i % 2 == 1 && a[i] == '1') { ans++; } } cout << min(ans, sum); }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
884,228
884,229
u526508003
cpp
p03073
#include <iostream> using namespace std; int main() { int sum = 0, ans = 0; string a; cin >> a; for (int i = 1; i < a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '1') { sum++; } else if (i % 2 == 1 && a[i] == '0') { sum++; } } for (int i = 0; i < a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '0') { ans++; } else if (i % 2 == 1 && a[i] == '1') { ans++; } } cout << max(ans, sum); }
#include <iostream> using namespace std; int main() { int sum = 0, ans = 0; string a; cin >> a; for (int i = 0; i <= a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '1') { sum++; } else if (i % 2 == 1 && a[i] == '0') { sum++; } } for (int i = 0; i <= a.size() - 1; i++) { if (i % 2 == 0 && a[i] == '0') { ans++; } else if (i % 2 == 1 && a[i] == '1') { ans++; } } cout << min(ans, sum); }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "misc.opposites", "identifier.change", "call.func...
884,230
884,229
u526508003
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1e9; for (int i = 0; i < 2; i++) { int cnt = 0; for (int j = 0; j < s.size(); j++) { if (s[i] != (char)('0' + (j + i) % 2)) cnt++; } ans = min(ans, cnt); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1e9; for (int i = 0; i < 2; i++) { int cnt = 0; for (int j = 0; j < s.size(); j++) { if (s[j] != (char)('0' + (j + i) % 2)) cnt++; } ans = min(ans, cnt); } cout << ans << endl; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
884,233
884,234
u426657245
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int l = S.length(); int a = 0, b = 0; for (int i = 0; i < l; ++i) { if (i % 2 == 0) { if (S[i] == 0) { ++b; } else { ++a; } } else { if (S[i] == 0) { ++a; } else { ++b; } } } cout << min(a, b) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int l = S.length(); int a = 0, b = 0; for (int i = 0; i < l; ++i) { if (i % 2 == 0) { if (S[i] == '0') { ++b; } else { ++a; } } else { if (S[i] == '0') { ++a; } else { ++b; } } } cout << min(a, b) << endl; }
[ "control_flow.branch.if.condition.change" ]
884,235
884,236
u430974466
cpp
p03073
#include "bits/stdc++.h" using namespace std; #define sp(x) cout << setprecision(x); #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define all(a) (a).begin(), (a).end() #define inf 10000000 #define linf INT64_MAX * 0.99 #define print(s) cout << (s) << endl #define lint long long #define yes "Yes" #define no "No" typedef pair<int, int> P; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; string t = s; int anss = 0; int anst = 0; FOR(i, 1, s.length()) { if (s[i - 1] == s[i]) { if (s[i - 1] == '1') s[i] = '0'; else s[i] = '1'; anss++; } } if (t[0] == '0') t[0] = '1'; else t[0] = '0'; FOR(i, 1, t.length()) { if (t[i - 1] == t[i]) { if (t[i - 1] == '1') t[i] = '0'; else t[i] = '1'; anst++; } } int ans = min(anst, anss); print(ans); return 0; }
#include "bits/stdc++.h" using namespace std; #define sp(x) cout << setprecision(x); #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define all(a) (a).begin(), (a).end() #define inf 10000000 #define linf INT64_MAX * 0.99 #define print(s) cout << (s) << endl #define lint long long #define yes "Yes" #define no "No" typedef pair<int, int> P; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; string t = s; int anss = 0; int anst = 1; FOR(i, 1, s.length()) { if (s[i - 1] == s[i]) { if (s[i - 1] == '1') s[i] = '0'; else s[i] = '1'; anss++; } } if (t[0] == '0') t[0] = '1'; else t[0] = '0'; FOR(i, 1, t.length()) { if (t[i - 1] == t[i]) { if (t[i - 1] == '1') t[i] = '0'; else t[i] = '1'; anst++; } } int ans = min(anst, anss); print(ans); return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
884,239
884,240
u601825761
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #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 all(i) (i).begin(), (i).end() å #define rall(i) (i).begin(), (i).end(), greater<int>() #define elif else if #define eb emplace_back #define pb push_back #define mp make_pair #define fst first #define sec second template <typename T> void print(T x) { std::cout << x << '\n'; } // typedef long long ll; #define TENNINE 1000000005 #define TENFIVE 100005 //#define int long long signed main() { string S; cin >> S; int x, y; int cnt = 0; int ans = S.size(); for (int i = 0; i < 2; i++) { for (int j = 0; j < S.size(); j++) { if ((j % 2 == 0) ^ (S[j] == (char)(i + '0'))) { cnt++; } } ans = min(ans, cnt); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #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 all(i) (i).begin(), (i).end() å #define rall(i) (i).begin(), (i).end(), greater<int>() #define elif else if #define eb emplace_back #define pb push_back #define mp make_pair #define fst first #define sec second template <typename T> void print(T x) { std::cout << x << '\n'; } // typedef long long ll; #define TENNINE 1000000005 #define TENFIVE 100005 //#define int long long signed main() { string S; cin >> S; int x, y; int cnt = 0; int ans = S.size(); for (int i = 0; i < 2; i++) { cnt = 0; for (int j = 0; j < S.size(); j++) { if ((j % 2 == 0) ^ (S[j] == (char)(i + '0'))) { cnt++; } } ans = min(ans, cnt); } cout << ans << endl; return 0; }
[ "assignment.add" ]
884,256
884,257
u888717396
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #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 all(i) (i).begin(), (i).end() å #define rall(i) (i).begin(), (i).end(), greater<int>() #define elif else if #define eb emplace_back #define pb push_back #define mp make_pair #define fst first #define sec second template <typename T> void print(T x) { std::cout << x << '\n'; } // typedef long long ll; #define TENNINE 1000000005 #define TENFIVE 100005 //#define int long long signed main() { string S; cin >> S; int x, y; int cnt = 0; int ans = S.size(); for (int i = 0; i < 2; i++) { for (int j = 0; j < S.size(); j++) { if ((j % 2 == 0) ^ (S[i] == (char)(i + '0'))) { cnt++; } } ans = min(ans, cnt); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define MOD 1000000007 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #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 all(i) (i).begin(), (i).end() å #define rall(i) (i).begin(), (i).end(), greater<int>() #define elif else if #define eb emplace_back #define pb push_back #define mp make_pair #define fst first #define sec second template <typename T> void print(T x) { std::cout << x << '\n'; } // typedef long long ll; #define TENNINE 1000000005 #define TENFIVE 100005 //#define int long long signed main() { string S; cin >> S; int x, y; int cnt = 0; int ans = S.size(); for (int i = 0; i < 2; i++) { cnt = 0; for (int j = 0; j < S.size(); j++) { if ((j % 2 == 0) ^ (S[j] == (char)(i + '0'))) { cnt++; } } ans = min(ans, cnt); } cout << ans << endl; return 0; }
[ "assignment.add", "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
884,258
884,257
u888717396
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s; int n = s.size(); int c1 = 0; for (int i = 0; i < n - 1; i++) { if (s.at(i) == s.at(i + 1)) { c1++; if (s.at(i) == '0') { s.at(i + 1) = '1'; } else { s.at(i + 1) = '0'; } } } int c2 = 0; for (int i = 0; i < n - 1; i++) { if (t.at(n - 1 - i) == t.at(n - 1 - i - 1)) { c2++; if (t.at(n - 1 - i) == '0') { t.at(n - 1 - i - 1) = '1'; } else { t.at(n - 1 - i - 1) = '0'; } } } cout << min(c1, c2) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s; t = s; int n = s.size(); int c1 = 0; for (int i = 0; i < n - 1; i++) { if (s.at(i) == s.at(i + 1)) { c1++; if (s.at(i) == '0') { s.at(i + 1) = '1'; } else { s.at(i + 1) = '0'; } } } int c2 = 0; for (int i = 0; i < n - 1; i++) { if (t.at(n - 1 - i) == t.at(n - 1 - i - 1)) { c2++; if (t.at(n - 1 - i) == '0') { t.at(n - 1 - i - 1) = '1'; } else { t.at(n - 1 - i - 1) = '0'; } } } cout << min(c1, c2) << endl; }
[ "assignment.add" ]
884,264
884,265
u704064492
cpp
p03073
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int a = 0; int S_size; string S; cin >> S; rep(i, S.size()) { if (S[i] % 2) { a++; } } S_size = S.size(); cout << min(a, S_size - a) << endl; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int a = 0; int S_size; string S; cin >> S; rep(i, S.size()) { if ((S[i] - i) % 2) { a++; } } S_size = S.size(); cout << min(a, S_size - a) << endl; }
[ "control_flow.branch.if.condition.change" ]
884,266
884,267
u352228045
cpp
p03073
#include <iostream> #include <string> int main(void) { int start_1 = 0; int start_0 = 0; std::string str; std::cin >> str; bool trans = true; for (int i = 0; i < str.size(); ++i) { if (trans) { if (str[i] == '0') ++start_1; if (str[i] == '1') ++start_0; } else { if (str[i] == '1') ++start_1; if (str[i] == '0') ++start_0; } trans = !trans; } start_0 > start_1 ? std::cout << start_0 : std::cout << start_1; return 0; }
#include <iostream> #include <string> int main(void) { int start_1 = 0; int start_0 = 0; std::string str; std::cin >> str; bool trans = true; for (int i = 0; i < str.size(); ++i) { if (trans) { if (str[i] == '0') ++start_1; if (str[i] == '1') ++start_0; } else { if (str[i] == '1') ++start_1; if (str[i] == '0') ++start_0; } trans = !trans; } start_0 < start_1 ? std::cout << start_0 : std::cout << start_1; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
884,272
884,273
u481584122
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<char> restr1(s.size(), '1'); for (int i = 0; i < s.size(); i++) if (i % 2 == 1) restr1.at(i) == '0'; vector<char> restr0(s.size(), '0'); for (int i = 0; i < s.size(); i++) if (i % 2 == 1) restr0.at(i) == '1'; int ans0 = 0; for (int i = 0; i < s.size(); i++) { if (s.at(i) != restr0.at(i)) ans0++; } int ans1 = 0; for (int i = 0; i < s.size(); i++) { if (s.at(i) != restr1.at(i)) ans1++; } cout << min(ans0, ans1) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<char> restr1(s.size(), '1'); for (int i = 0; i < s.size(); i++) if (i % 2 == 1) restr1.at(i) = '0'; vector<char> restr0(s.size(), '0'); for (int i = 0; i < s.size(); i++) if (i % 2 == 1) restr0.at(i) = '1'; int ans0 = 0; for (int i = 0; i < s.size(); i++) { if (s.at(i) != restr0.at(i)) ans0++; } int ans1 = 0; for (int i = 0; i < s.size(); i++) { if (s.at(i) != restr1.at(i)) ans1++; } cout << min(ans0, ans1) << endl; }
[ "expression.operation.compare.replace.remove", "assignment.replace.add", "misc.typo" ]
884,281
884,282
u716917908
cpp
p03073
#include "bits/stdc++.h" using namespace std; int main() { string S; cin >> S; const int N = S.length(); int ans = (int)1e9; for (int i = 0; i < 2; i++) { int pre = 0; for (int j = 0; j < N; j++) { const char cur = '0' + (i + j) % 2; if (cur != S[i]) pre++; } ans = min(ans, pre); } cout << ans << endl; }
#include "bits/stdc++.h" using namespace std; int main() { string S; cin >> S; const int N = S.length(); int ans = (int)1e9; for (int i = 0; i < 2; i++) { int pre = 0; for (int j = 0; j < N; j++) { const char cur = '0' + (i + j) % 2; if (cur != S[j]) pre++; } ans = min(ans, pre); } cout << ans << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
884,300
884,301
u443010331
cpp
p03073
#include <iostream> using namespace std; int main() { string s; cin >> s; int z = 0, o = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != ('0' + i % 2)) { z++; } if (s[i] != ('1' - i % 2)) { o++; } } cout << max(z, o) << endl; }
#include <iostream> using namespace std; int main() { string s; cin >> s; int z = 0, o = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != ('0' + i % 2)) { z++; } if (s[i] != ('1' - i % 2)) { o++; } } cout << min(z, o) << endl; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
884,304
884,305
u159335277
cpp
p03073
#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; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; const int INF = 100000000; const long long LINF = 1LL << 60; const int MOD = (int)1e9 + 7; const double EPS = 1e-6; using pii = std::pair<int, int>; using pLL = std::pair<long long, long long>; using ll = long long; #define SORT(v) std::sort(v.begin(), v.end()) #define rSORT(v) std::sort(v.begin(), v.end(), std::greater<int>()) int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int ans1 = 0, ans2 = 0; if (count(s.begin(), s.end(), s[0]) == s.size()) { cout << s.size() / 2 << endl; return 0; } for (size_t i = 0; i < s.size(); ++i) { if ((i % 2 == 0 && s[i] != '1') || (i % 2 == 1 && s[i] == '0')) { ans1++; } if ((i % 2 == 0 && s[i] != '0') || (i % 2 == 1 && s[i] == '1')) { ans2++; } } cout << min(ans1, ans2) << 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; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; const int INF = 100000000; const long long LINF = 1LL << 60; const int MOD = (int)1e9 + 7; const double EPS = 1e-6; using pii = std::pair<int, int>; using pLL = std::pair<long long, long long>; using ll = long long; #define SORT(v) std::sort(v.begin(), v.end()) #define rSORT(v) std::sort(v.begin(), v.end(), std::greater<int>()) int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int ans1 = 0, ans2 = 0; if (count(s.begin(), s.end(), s[0]) == s.size()) { cout << s.size() / 2 << endl; return 0; } for (size_t i = 0; i < s.size(); ++i) { if ((i % 2 == 0 && s[i] != '1') || (i % 2 == 1 && s[i] != '0')) { ans1++; } if ((i % 2 == 0 && s[i] != '0') || (i % 2 == 1 && s[i] != '1')) { ans2++; } } cout << min(ans1, ans2) << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,308
884,309
u199371251
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s, s1, x, x1; cin >> s; s1 = s; int h = 0; for (int i = 0; i < s.size(); i++) { x += (char)(h % 2 + '0'); x1 += (char)(h % 2 + 1 + '0'); h++; } int ans = 0, ans1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != x[i]) ans++; } for (int i = 0; i < s1.size(); i++) { if (s1[i] != x1[i]) ans1++; } cout << min(ans, ans1); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s, s1, x, x1; cin >> s; s1 = s; int h = 0; for (int i = 0; i < s.size(); i++) { x += (char)(h % 2 + '0'); x1 += (char)(1 ^ h % 2 + '0'); h++; } int ans = 0, ans1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != x[i]) ans++; } for (int i = 0; i < s1.size(); i++) { if (s1[i] != x1[i]) ans1++; } cout << min(ans, ans1); return 0; }
[ "assignment.change", "expression.operation.binary.remove" ]
884,310
884,311
u265392294
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) int main() { int answer_w = 0; int answer_b = 0; string S; cin >> S; REP(i, S.size()) { if (i % 2 == 1) { if (S[i] == '1') { answer_w++; } else { answer_b++; } } else { if (S[i] == '0') { answer_b++; } else { answer_w++; } } } cout << min(answer_b, answer_w) << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) int main() { int answer_w = 0; int answer_b = 0; string S; cin >> S; REP(i, S.size()) { if (i % 2 == 1) { if (S[i] == '0') { answer_w++; } else { answer_b++; } } else { if (S[i] == '0') { answer_b++; } else { answer_w++; } } } cout << min(answer_b, answer_w) << endl; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
884,322
884,323
u973995516
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define INCANT cin.tie(0), ios::sync_with_stdio(false) #define int long long #define double long double #define pb push_back #define mp make_pair #define mt make_tuple #define gcd __gcd #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define sz(x) x.size() #define all(x) (x).begin(), (x).end() #define sortv(v) sort(all(v)) #define sortvg(v) sort(all(v), greater<int>()) #define countv(v, c) count(all(v), c) #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__) #define _rev(i, n) revi(i, n, 0) #define revi(i, a, b) for (int i = (int)(a - 1); i >= (int)(b); i--) #define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__) #define each(i, n) for (auto &&i : n) #define inv(x) each(i, x) in(i) #define out(x) cout << (x) #define space() cout << " " #define indent() cout << '\n' #define print(x) out(x), indent() #define printv(x) \ each(i, x) out(i), space(); \ indent() #define debug(x, ...) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n' #define YN(x) out((x) ? "YES" : "NO"), indent() #define Yn(x) out((x) ? "Yes" : "No"), indent() #define yn(x) out((x) ? "yes" : "no"), indent() void in() {} template <typename F, typename... R> void in(F &f, R &...r) { cin >> f, in(r...); } const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001, S_LIMIT = 101; const int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1}, dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1}; const string alphabet = "abcdefghijklmnopqrstuvwxyz"; const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int g[S_LIMIT][S_LIMIT] = {}; int lcm(int a, int b) { return a / gcd(a, b) * b; } int modpow(int x, int n) { return n < 2 ? x : modpow(x * x % MOD, n / 2) * (n % 2 ? x : 1) % MOD; } int factorial(int a) { return a < 2 ? 1 : factorial(a - 1) * a; } int modfact(int a) { return a < 2 ? 1 : factorial(a - 1) * a % MOD; } int summation(int a) { return a < 1 ? 0 : (a * a + a) / 2; } int combination(int n, int r) { int res = 1; rep(i, 1, r + 1) { res *= n--, res /= i; } return res; } int modcomb(int n, int r) { return modfact(n) * modpow(modfact(r), MOD - 2) % MOD * modpow(modfact(n - r), MOD - 2) % MOD; } bool isPrime(int n) { rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } if (!(n % i)) { return false; } } return true; } void warshall(int n) { rep(i, n) { rep(j, n) { rep(k, n) { chmin(g[j][k], g[j][i] + g[i][k]); } } } } vector<int> divisor(int n) { vector<int> ans; rep(i, 1, sqrt(n) + 1) { if (!(n % i)) { ans.pb(i); if (i * i < n) { ans.pb(n / i); } } } return ans; } map<int, int> factorization(int n) { map<int, int> ans; rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } while (!(n % i)) { ans[i]++, n /= i; } } if (n > 1) { ans[n]++; } return ans; } struct UF { vector<int> t; UF(int size) : t(size, -1) {} int root(int x) { return t[x] < 0 ? x : t[x] = root(t[x]); } int size(int x) { return -t[root(x)]; } bool isSame(int x, int y) { return root(x) == root(y); } bool unite(int x, int y) { x = root(x), y = root(y); if (x != y) { if (t[y] < t[x]) { swap(x, y); } t[x] += t[y], t[y] = x; } return x != y; } }; int a, b, c, k, n, m, l, r, x, y, h, w, res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF; string s, t; main() { INCANT; in(s); t = s; rep(i, 1, t.size()) { if (t[i] == t[i - 1]) { t[i] = t[i - 1] == '0' ? '1' : '0'; cnt++; } } s[0] = s[0] == '0' ? '1' : '0'; rep(i, 1, s.size()) { if (s[i] == s[i - 1]) { s[i] = s[i - 1] == '0' ? '1' : '0'; res++; } } out(min(res, cnt)); }
#include <bits/stdc++.h> using namespace std; #define INCANT cin.tie(0), ios::sync_with_stdio(false) #define int long long #define double long double #define pb push_back #define mp make_pair #define mt make_tuple #define gcd __gcd #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define sz(x) x.size() #define all(x) (x).begin(), (x).end() #define sortv(v) sort(all(v)) #define sortvg(v) sort(all(v), greater<int>()) #define countv(v, c) count(all(v), c) #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__) #define _rev(i, n) revi(i, n, 0) #define revi(i, a, b) for (int i = (int)(a - 1); i >= (int)(b); i--) #define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__) #define each(i, n) for (auto &&i : n) #define inv(x) each(i, x) in(i) #define out(x) cout << (x) #define space() cout << " " #define indent() cout << '\n' #define print(x) out(x), indent() #define printv(x) \ each(i, x) out(i), space(); \ indent() #define debug(x, ...) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n' #define YN(x) out((x) ? "YES" : "NO"), indent() #define Yn(x) out((x) ? "Yes" : "No"), indent() #define yn(x) out((x) ? "yes" : "no"), indent() void in() {} template <typename F, typename... R> void in(F &f, R &...r) { cin >> f, in(r...); } const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001, S_LIMIT = 101; const int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1}, dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1}; const string alphabet = "abcdefghijklmnopqrstuvwxyz"; const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int g[S_LIMIT][S_LIMIT] = {}; int lcm(int a, int b) { return a / gcd(a, b) * b; } int modpow(int x, int n) { return n < 2 ? x : modpow(x * x % MOD, n / 2) * (n % 2 ? x : 1) % MOD; } int factorial(int a) { return a < 2 ? 1 : factorial(a - 1) * a; } int modfact(int a) { return a < 2 ? 1 : factorial(a - 1) * a % MOD; } int summation(int a) { return a < 1 ? 0 : (a * a + a) / 2; } int combination(int n, int r) { int res = 1; rep(i, 1, r + 1) { res *= n--, res /= i; } return res; } int modcomb(int n, int r) { return modfact(n) * modpow(modfact(r), MOD - 2) % MOD * modpow(modfact(n - r), MOD - 2) % MOD; } bool isPrime(int n) { rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } if (!(n % i)) { return false; } } return true; } void warshall(int n) { rep(i, n) { rep(j, n) { rep(k, n) { chmin(g[j][k], g[j][i] + g[i][k]); } } } } vector<int> divisor(int n) { vector<int> ans; rep(i, 1, sqrt(n) + 1) { if (!(n % i)) { ans.pb(i); if (i * i < n) { ans.pb(n / i); } } } return ans; } map<int, int> factorization(int n) { map<int, int> ans; rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } while (!(n % i)) { ans[i]++, n /= i; } } if (n > 1) { ans[n]++; } return ans; } struct UF { vector<int> t; UF(int size) : t(size, -1) {} int root(int x) { return t[x] < 0 ? x : t[x] = root(t[x]); } int size(int x) { return -t[root(x)]; } bool isSame(int x, int y) { return root(x) == root(y); } bool unite(int x, int y) { x = root(x), y = root(y); if (x != y) { if (t[y] < t[x]) { swap(x, y); } t[x] += t[y], t[y] = x; } return x != y; } }; int a, b, c, k, n, m, l, r, x, y, h, w, res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF; string s, t; main() { INCANT; in(s); t = s; rep(i, 1, t.size()) { if (t[i] == t[i - 1]) { t[i] = t[i - 1] == '0' ? '1' : '0'; cnt++; } } s[0] = s[0] == '0' ? '1' : '0'; res = 1; rep(i, 1, s.size()) { if (s[i] == s[i - 1]) { s[i] = s[i - 1] == '0' ? '1' : '0'; res++; } } out(min(res, cnt)); }
[ "assignment.add" ]
884,328
884,329
u303059352
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s; int a, b; cin >> s; for (int i = 0; i < s.size(); i++) { if (i % 2 == 1) { if (s.at(i) == '0') b++; else a++; } else { if (s.at(i) == '0') a++; else b++; } } if (a > b) cout << b << endl; else cout << a << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int a = 0, b = 0; cin >> s; for (int i = 0; i < s.size(); i++) { if (i % 2 == 1) { if (s.at(i) == '0') b++; else a++; } else { if (s.at(i) == '0') a++; else b++; } } if (a > b) cout << b << endl; else cout << a << endl; }
[ "variable_declaration.value.change" ]
884,332
884,333
u952865396
cpp
p03073
#include <algorithm> #include <iostream> using namespace std; int main() { string s; cin >> s; int sl = s.length(); string hoge = ""; string fuga = ""; for (int i = 0; i < sl; i++) { if (i % 2 == 0) { hoge += "0"; } else { hoge += "1"; } } for (int i = 0; i < sl; i++) { if (i % 2 == 0) { fuga += "1"; } else { fuga += "0"; } } int c_hoge = 0; int c_fuga = 0; for (int i = 0; i < sl; i++) { if (s[i] == hoge[i]) { c_hoge += 1; } } for (int i = 0; i < sl; i++) { if (s[i] == fuga[i]) { c_fuga += 1; } } if (c_hoge < c_fuga) { cout << c_hoge << endl; } if (c_hoge > c_fuga) { cout << c_fuga << endl; } }
#include <algorithm> #include <iostream> using namespace std; int main() { string s; cin >> s; int sl = s.length(); string hoge = ""; string fuga = ""; for (int i = 0; i < sl; ++i) { if (i % 2 == 0) { hoge += "0"; } else { hoge += "1"; } } for (int i = 0; i < sl; ++i) { if (i % 2 == 0) { fuga += "1"; } else { fuga += "0"; } } int c_hoge = 0; int c_fuga = 0; for (int i = 0; i < sl; i++) { if (s[i] == hoge[i]) { c_hoge += 1; } } for (int i = 0; i < sl; i++) { if (s[i] == fuga[i]) { c_fuga += 1; } } if (c_hoge < c_fuga) { cout << c_hoge << endl; } if (c_hoge >= c_fuga) { cout << c_fuga << endl; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,343
884,344
u947071639
cpp
p03073
#include <iostream> using namespace std; int main() { string S; cin >> S; int ans1, ans2; for (int i = 0; i < S.length(); ++i) { if (S[i] - '0' != i % 2) ans1++; if (S[i] - '0' != (i + 1) % 2) ans2++; } cout << min(ans1, ans2); }
#include <iostream> using namespace std; int main() { string S; cin >> S; int ans1 = 0; int ans2 = 0; for (int i = 0; i < S.length(); ++i) { if (S[i] - '0' != i % 2) ans1++; if (S[i] - '0' != (i + 1) % 2) ans2++; } cout << min(ans1, ans2); }
[ "variable_declaration.add" ]
884,345
884,346
u494284451
cpp
p03073
#include <iostream> using namespace std; int main() { string S; cin >> S; int ans1, ans2; for (int i = 0; i < S.length(); ++i) { if (S[i] - '0' != i % 2) ans1++; if (S[i] - '0' != (i + 1) % 2) ans2++; } cout << min(ans1, ans2); }
#include <iostream> using namespace std; int main() { string S; cin >> S; int ans1 = 0; int ans2 = 0; for (int i = 0; i < S.length(); ++i) { if (S[i] - '0' != i % 2) ans1++; if (S[i] - '0' != (i + 1) % 2) ans2++; } cout << min(ans1, ans2); }
[ "variable_declaration.add" ]
884,347
884,346
u494284451
cpp
p03073
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char *gen_10_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 0 ? '1' : '0'; } return bit_s; } char *gen_01_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 1 ? '1' : '0'; } return bit_s; } int hamm_dist(char *s0, const char *s1, const char *s2) { int n; if (!*s1 && !*s2) { *s0 = '\0'; return 0; } if (!*s1 || !*s2 || (n = hamm_dist(s0 + 1, s1 + 1, s2 + 1)) == -1) return -1; if (*s1 == *s2) *s0 = ' '; else { *s0 = '|'; ++n; } return n; } int main(void) { int A, B; int i; int l; int flag_msb_0 = 0; int res1, res2; char N[1000000]; char s[1000000]; scanf("%s", N); /* if(list[0] == '0'){ flag_msb_0 = 1; } */ l = strlen(N); res1 = hamm_dist(s, gen_01_bits(l), N); res2 = hamm_dist(s, gen_10_bits(l), N); if (res1 > res2) { printf("%d\n", res1); } else { printf("%d\n", res2); } return 0; }
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char *gen_10_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 0 ? '1' : '0'; } return bit_s; } char *gen_01_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 1 ? '1' : '0'; } return bit_s; } int hamm_dist(char *s0, const char *s1, const char *s2) { int n; if (!*s1 && !*s2) { *s0 = '\0'; return 0; } if (!*s1 || !*s2 || (n = hamm_dist(s0 + 1, s1 + 1, s2 + 1)) == -1) return -1; if (*s1 == *s2) *s0 = ' '; else { *s0 = '|'; ++n; } return n; } int main(void) { int A, B; int i; int l; int flag_msb_0 = 0; int res1, res2; char N[1000000]; char s[1000000]; scanf("%s", N); /* if(list[0] == '0'){ flag_msb_0 = 1; } */ l = strlen(N); res1 = hamm_dist(s, gen_01_bits(l), N); res2 = hamm_dist(s, gen_10_bits(l), N); if (res1 < res2) { printf("%d\n", res1); } else { printf("%d\n", res2); } return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,350
884,351
u231798544
cpp
p03073
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char *gen_10_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 0 ? '1' : '0'; } return bit_s; } char *gen_01_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 0 ? '1' : '0'; } return bit_s; } int hamm_dist(char *s0, const char *s1, const char *s2) { int n; if (!*s1 && !*s2) { *s0 = '\0'; return 0; } if (!*s1 || !*s2 || (n = hamm_dist(s0 + 1, s1 + 1, s2 + 1)) == -1) return -1; if (*s1 == *s2) *s0 = ' '; else { *s0 = '|'; ++n; } return n; } int main(void) { int A, B; int i; int l; int flag_msb_0 = 0; int res1, res2; char N[1000000]; char s[1000000]; scanf("%s", N); /* if(list[0] == '0'){ flag_msb_0 = 1; } */ l = strlen(N); res1 = hamm_dist(s, gen_01_bits(l), N); res2 = hamm_dist(s, gen_10_bits(l), N); if (res1 > res2) { printf("%d\n", res1); } else { printf("%d\n", res2); } return 0; }
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char *gen_10_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 0 ? '1' : '0'; } return bit_s; } char *gen_01_bits(int len) { int i; char *bit_s; bit_s = (char *)malloc(sizeof(char) * len); for (i = 0; i < len; i++) { bit_s[i] = i % 2 == 1 ? '1' : '0'; } return bit_s; } int hamm_dist(char *s0, const char *s1, const char *s2) { int n; if (!*s1 && !*s2) { *s0 = '\0'; return 0; } if (!*s1 || !*s2 || (n = hamm_dist(s0 + 1, s1 + 1, s2 + 1)) == -1) return -1; if (*s1 == *s2) *s0 = ' '; else { *s0 = '|'; ++n; } return n; } int main(void) { int A, B; int i; int l; int flag_msb_0 = 0; int res1, res2; char N[1000000]; char s[1000000]; scanf("%s", N); /* if(list[0] == '0'){ flag_msb_0 = 1; } */ l = strlen(N); res1 = hamm_dist(s, gen_01_bits(l), N); res2 = hamm_dist(s, gen_10_bits(l), N); if (res1 < res2) { printf("%d\n", res1); } else { printf("%d\n", res2); } return 0; }
[ "literal.number.change", "assignment.value.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,352
884,351
u231798544
cpp
p03073
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <set> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define swap(a, b) \ a ^= b; \ b ^= a; \ a ^= b; //#define for(i,a,b) for (ll i=(a);i<(ll)b; i++) #define print(x) std::cout << x << std::endl; using namespace std; typedef long long ll; template <class T, class U> std::string replace(std::string s, const T &target, const U &replacement, bool replace_first = 0, bool replace_empty = 0); bool isContain(int value, int under, int top); vector<int> range(int x); int main(void) { // Program Start string S; cin >> S; int N = S.length(); int count = 0; int res1 = 0; for (int i = 0; i < N; i++) { count++; count %= 2; if (to_string(count)[0] != S[i]) res1++; } count = 1; int res2 = 0; for (int i = 1; i < N; i++) { count++; count %= 2; if (to_string(count)[0] != S[i]) res2++; } cout << min(res1, res2) << endl; ProgramEndPointLabel:; // Program End system("pause"); return 0; } vector<int> range(int y) { vector<int> result(y); for (int i = 0; i < y; i++) result[i] = i; return result; } bool isContain(int value, int under, int top) { if (under <= value && value <= top) return true; return false; } template <class T, class U> std::string replace(std::string s, const T &target, const U &replacement, bool replace_first, bool replace_empty) { using S = std::string; using C = std::string::value_type; using N = std::string::size_type; struct { auto len(const S &s) { return s.size(); } auto len(const C *p) { return std::char_traits<C>::length(p); } auto len(const C c) { return 1; } auto sub(S *s, const S &t, N pos, N len) { s->replace(pos, len, t); } auto sub(S *s, const C *t, N pos, N len) { s->replace(pos, len, t); } auto sub(S *s, const C t, N pos, N len) { s->replace(pos, len, 1, t); } auto ins(S *s, const S &t, N pos) { s->insert(pos, t); } auto ins(S *s, const C *t, N pos) { s->insert(pos, t); } auto ins(S *s, const C t, N pos) { s->insert(pos, 1, t); } } util; N target_length = util.len(target); N replacement_length = util.len(replacement); if (target_length == 0) { if (!replace_empty || replacement_length == 0) return s; N n = s.size() + replacement_length * (1 + s.size()); s.reserve(!replace_first ? n : s.size() + replacement_length); for (N i = 0; i < n; i += 1 + replacement_length) { util.ins(&s, replacement, i); if (replace_first) break; } return s; } N pos = 0; while ((pos = s.find(target, pos)) != std::string::npos) { util.sub(&s, replacement, pos, target_length); if (replace_first) return s; pos += replacement_length; } return s; }
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <set> #include <stdio.h> #include <stdlib.h> #include <string> #include <vector> #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define swap(a, b) \ a ^= b; \ b ^= a; \ a ^= b; //#define for(i,a,b) for (ll i=(a);i<(ll)b; i++) #define print(x) std::cout << x << std::endl; using namespace std; typedef long long ll; template <class T, class U> std::string replace(std::string s, const T &target, const U &replacement, bool replace_first = 0, bool replace_empty = 0); bool isContain(int value, int under, int top); vector<int> range(int x); int main(void) { // Program Start string S; cin >> S; int N = S.length(); int count = 0; int res1 = 0; for (int i = 0; i < N; i++) { count++; count %= 2; if (to_string(count)[0] != S[i]) res1++; } count = 1; int res2 = 0; for (int i = 0; i < N; i++) { count++; count %= 2; if (to_string(count)[0] != S[i]) res2++; } cout << min(res1, res2) << endl; ProgramEndPointLabel:; // Program End system("pause"); return 0; } vector<int> range(int y) { vector<int> result(y); for (int i = 0; i < y; i++) result[i] = i; return result; } bool isContain(int value, int under, int top) { if (under <= value && value <= top) return true; return false; } template <class T, class U> std::string replace(std::string s, const T &target, const U &replacement, bool replace_first, bool replace_empty) { using S = std::string; using C = std::string::value_type; using N = std::string::size_type; struct { auto len(const S &s) { return s.size(); } auto len(const C *p) { return std::char_traits<C>::length(p); } auto len(const C c) { return 1; } auto sub(S *s, const S &t, N pos, N len) { s->replace(pos, len, t); } auto sub(S *s, const C *t, N pos, N len) { s->replace(pos, len, t); } auto sub(S *s, const C t, N pos, N len) { s->replace(pos, len, 1, t); } auto ins(S *s, const S &t, N pos) { s->insert(pos, t); } auto ins(S *s, const C *t, N pos) { s->insert(pos, t); } auto ins(S *s, const C t, N pos) { s->insert(pos, 1, t); } } util; N target_length = util.len(target); N replacement_length = util.len(replacement); if (target_length == 0) { if (!replace_empty || replacement_length == 0) return s; N n = s.size() + replacement_length * (1 + s.size()); s.reserve(!replace_first ? n : s.size() + replacement_length); for (N i = 0; i < n; i += 1 + replacement_length) { util.ins(&s, replacement, i); if (replace_first) break; } return s; } N pos = 0; while ((pos = s.find(target, pos)) != std::string::npos) { util.sub(&s, replacement, pos, target_length); if (replace_first) return s; pos += replacement_length; } return s; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
884,358
884,359
u040251933
cpp
p03073
#include <iostream> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; int main(void) { int a[2], sw = 0; a[0] = a[1] = 0; string S; cin >> S; int length = S.length(); char before = S[0]; a[0]++; for (int i = 1; i < length; i++) { if (S[i] != before) { a[sw]++; } else { sw = 1 - sw; a[sw]++; } before = S[i]; } if (a[0] > a[1]) cout << a[0]; else cout << a[1]; return 0; }
#include <iostream> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) using namespace std; int main(void) { int a[2], sw = 0; a[0] = a[1] = 0; string S; cin >> S; int length = S.length(); char before = S[0]; a[0]++; for (int i = 1; i < length; i++) { if (S[i] != before) { a[sw]++; } else { sw = 1 - sw; a[sw]++; } before = S[i]; } if (a[0] > a[1]) cout << a[1]; else cout << a[0]; return 0; }
[ "control_flow.branch.else.remove", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add" ]
884,364
884,365
u130128796
cpp
p03073
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <math.h> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; // spring s; cin >> s; // cout << res << endl; // --------write my code!!!!!----------// int main() { string A; cin >> A; int countA = 0; int countB = 0; int dp_now = A[0]; int first = dp_now; for (int i = 0; i < A.length() - 1; i++) { if (dp_now == A[i]) { countA++; if (dp_now == 48) dp_now = 49; else dp_now = 48; } else dp_now = A[i]; } if (first == 48) dp_now = 49; else dp_now = 48; for (int i = 0; i < A.length() - 1; i++) { if (dp_now == A[i]) { countB++; if (dp_now == 48) dp_now = 49; else dp_now = 48; } else dp_now = A[i]; } cout << min(countA, countB) << endl; }
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <math.h> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; // spring s; cin >> s; // cout << res << endl; // --------write my code!!!!!----------// int main() { string A; cin >> A; int countA = 0; int countB = 0; int dp_now = A[0]; int first = dp_now; for (int i = 0; i < A.length(); i++) { if (dp_now == A[i]) { countA++; if (dp_now == 48) dp_now = 49; else dp_now = 48; } else dp_now = A[i]; } if (first == 48) dp_now = 49; else dp_now = 48; for (int i = 0; i < A.length(); i++) { if (dp_now == A[i]) { countB++; if (dp_now == 48) dp_now = 49; else dp_now = 48; } else dp_now = A[i]; } cout << min(countA, countB) << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
884,366
884,367
u496074393
cpp
p03073
#include <algorithm> #include <cassert> #include <cstring> #include <iostream> #include <math.h> #include <stdexcept> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n; i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) typedef long long int lld; typedef vector<lld> vl; typedef vector<int> vi; typedef vector<string> vs; // int arr[N] ////sort(arr,arr +N) // vector <int> hoge ////sort(hoge.begin(),hoge.end()); /// min_element(hoge.begin(),hoge.end(); 最小値   最大値はmax_element(); int main() { string s; int a, b; cin >> s; int len = s.length(); // 0 1 0 1 rep(i, len) { if (i % 2 == 1) { if (s[i] == '0') a++; } else { if (s[i] == '1') a++; } } rep(i, len) { if (i % 2 == 1) { if (s[i] == '1') b++; } else { if (s[i] == '0') b++; } } cout << min(a, b); return 0; }
#include <algorithm> #include <cassert> #include <cstring> #include <iostream> #include <math.h> #include <stdexcept> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <utility> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n; i > 0; i--) #define REP(i, a, b) for (int i = a; i < b; i++) typedef long long int lld; typedef vector<lld> vl; typedef vector<int> vi; typedef vector<string> vs; // int arr[N] ////sort(arr,arr +N) // vector <int> hoge ////sort(hoge.begin(),hoge.end()); /// min_element(hoge.begin(),hoge.end(); 最小値   最大値はmax_element(); int main() { string s; int a = 0, b = 0; cin >> s; int len = s.length(); // 0 1 0 1 rep(i, len) { if (i % 2 == 1) { if (s[i] == '0') a++; } else { if (s[i] == '1') a++; } } // 1 0 1 0 rep(i, len) { if (i % 2 == 1) { if (s[i] == '1') b++; } else { if (s[i] == '0') b++; } } // cout<<a<<"\n"<<b<<"\n"; cout << min(a, b); return 0; }
[ "variable_declaration.value.change" ]
884,373
884,374
u696415377
cpp
p03073
#include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; int p = 0, b = 1; int s1 = 0, s2 = 0; for (int i = 1; i < s.size(); ++i) { p ^= 1; b ^= 1; if (s[i] - '0' != p) ++s1; if (s[i] - '0' != b) ++s2; } printf("%d", min(s1, s2)); // cout<<s; return 0; }
#include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; int p = 0, b = 1; int s1 = 0, s2 = 0; for (int i = 0; i < s.size(); ++i) { p ^= 1; b ^= 1; if (s[i] - '0' != p) ++s1; if (s[i] - '0' != b) ++s2; } printf("%d", min(s1, s2)); // cout<<s; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
884,375
884,376
u761827806
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int n = a.size(); int ans1 = 0; int ans2 = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (a[i] == 0) { ans1++; } else { ans2++; } } else { if (a[i] == 0) { ans2++; } else { ans1++; } } } cout << min(ans1, ans2) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int n = a.size(); int ans1 = 0; int ans2 = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { if (a[i] == '0') { ans1++; } else { ans2++; } } else { if (a[i] == '0') { ans2++; } else { ans1++; } } } cout << min(ans1, ans2) << endl; }
[ "control_flow.branch.if.condition.change" ]
884,379
884,380
u942393279
cpp
p03073
#include <bits/stdc++.h> using namespace std; string s; int dp[100005][2]; int main() { ios::sync_with_stdio(false); cin >> s; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; dp[0][1] = 1; for (int i = 1; i < s.length(); i++) { if (s[i] == s[i - 1]) dp[i][1] = min(dp[i][1], dp[i - 1][0] + 1), dp[i][0] = min(dp[i][0], dp[i - 1][1]); else dp[i][0] = min(dp[i - 1][0], dp[i][0]), dp[i][1] = min(dp[i - 1][1], dp[i][1]); } int n = s.length() - 1; cout << min(dp[n][0], dp[n][1]); }
#include <bits/stdc++.h> using namespace std; string s; int dp[100005][2]; int main() { ios::sync_with_stdio(false); cin >> s; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; dp[0][1] = 1; for (int i = 1; i < s.length(); i++) { if (s[i] == s[i - 1]) dp[i][1] = min(dp[i][1], dp[i - 1][0] + 1), dp[i][0] = min(dp[i][0], dp[i - 1][1]); else dp[i][0] = min(dp[i - 1][0], dp[i][0]), dp[i][1] = min(dp[i - 1][1] + 1, dp[i][1]); } int n = s.length() - 1; cout << min(dp[n][0], dp[n][1]); }
[ "assignment.change" ]
884,383
884,384
u777892860
cpp
p03073
#include <bits/stdc++.h> using namespace std; string s; int dp[100005][2]; int main() { ios::sync_with_stdio(false); cin >> s; memset(dp, 0, sizeof(dp)); dp[0][0] = 0; dp[0][1] = 1; for (int i = 1; i < s.length(); i++) { if (s[i] == s[i - 1]) dp[i][1] = min(dp[i][1], dp[i - 1][0] + 1), dp[i][0] = min(dp[i][0], dp[i - 1][1]); else dp[i][0] = min(dp[i - 1][0], dp[i][0]), dp[i][1] = min(dp[i - 1][1], dp[i][1]); } int n = s.length() - 1; cout << min(dp[n][0], dp[n][1]); }
#include <bits/stdc++.h> using namespace std; string s; int dp[100005][2]; int main() { ios::sync_with_stdio(false); cin >> s; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; dp[0][1] = 1; for (int i = 1; i < s.length(); i++) { if (s[i] == s[i - 1]) dp[i][1] = min(dp[i][1], dp[i - 1][0] + 1), dp[i][0] = min(dp[i][0], dp[i - 1][1]); else dp[i][0] = min(dp[i - 1][0], dp[i][0]), dp[i][1] = min(dp[i - 1][1] + 1, dp[i][1]); } int n = s.length() - 1; cout << min(dp[n][0], dp[n][1]); }
[ "call.arguments.change", "assignment.change" ]
884,385
884,384
u777892860
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N = S.size(); // string current; char current; char begin; // string begin; begin = '0'; current = begin; // vector<string> A(N); int ans_a = 0; for (int i = 1; i < N; ++i) { if (S[i] == current) { ans_a++; if (current == '0') { current = '1'; } else { current = '0'; } } else { current = S[i]; } } begin = '1'; current = begin; // vector<string> A(N); int ans_b = 0; for (int i = 1; i < N; ++i) { if (S[i] == current) { ans_b++; if (current == '0') { current = '1'; } else { current = '0'; } } else { current = S[i]; } } int ans; if (ans_a >= ans_b) { ans = ans_b; } else { ans = ans_a; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N = S.size(); // string current; char current; char begin; // string begin; begin = '0'; current = begin; // vector<string> A(N); int ans_a = 0; for (int i = 0; i < N; ++i) { if (S[i] == current) { ans_a++; if (current == '0') { current = '1'; } else { current = '0'; } } else { current = S[i]; } } begin = '1'; current = begin; // vector<string> A(N); int ans_b = 0; for (int i = 0; i < N; ++i) { if (S[i] == current) { ans_b++; if (current == '0') { current = '1'; } else { current = '0'; } } else { current = S[i]; } } int ans; if (ans_a >= ans_b) { ans = ans_b; } else { ans = ans_a; } cout << ans << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
884,395
884,396
u307834890
cpp
p03073
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { string S; cin >> S; char prev; int count; for (int i = 0; i < S.size(); i++) { if (i == 0) { prev = S[i]; continue; } if (prev == S[i]) { if (S[i] == '0') { prev = '1'; } else { prev = '0'; } count++; } else { prev = S[i]; } } cout << count << endl; return 0; }
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { string S; cin >> S; char prev; int count = 0; for (int i = 0; i < S.size(); i++) { if (i == 0) { prev = S[i]; continue; } if (prev == S[i]) { if (S[i] == '0') { prev = '1'; } else { prev = '0'; } count++; } else { prev = S[i]; } } cout << count << endl; return 0; }
[ "variable_declaration.value.change" ]
884,403
884,404
u375619974
cpp
p03073
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { string s; cin >> s; int n; n = s.size(); int count_0 = 0; int count_1 = 0; for (int i = 0; i < n; i++) { int b = i % 2; if (b == 0) { if (s[i] == '0') count_1++; else count_0++; } else { if (s[i] == '1') count_0++; else count_1++; } } cout << min(count_0, count_1) << endl; }
#include <algorithm> #include <cmath> #include <iostream> using namespace std; int main() { string s; cin >> s; int n; n = s.size(); int count_0 = 0; int count_1 = 0; for (int i = 0; i < n; i++) { int b = i % 2; if (b == 0) { if (s[i] == '0') count_1++; else count_0++; } else { if (s[i] == '0') count_0++; else count_1++; } } cout << min(count_0, count_1) << endl; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
884,405
884,406
u189404681
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define pb push_back typedef long long ll; int main() { string s; cin >> s; int ans1 = 0; int ans2 = 0; // first is 0 // 偶数 is 0 if (s[0] == '1') { ++ans1; } if (s[1] == '0') { ++ans1; } if (s.size() > 1) { FOR(i, 2, s.size()) { if (i % 2 == 0) { if (s[i] == '0') { ++ans1; } // 奇数 } else { if (s[i] == '1') { ++ans1; } } } } // first is 1 // 奇数 is 0 if (s[0] == '0') { ++ans2; } if (s[1] == '1') { ++ans2; } if (s.size() > 1) { FOR(i, 2, s.size()) { if (i % 2 == 0) { if (s[i] == '1') { ++ans2; } // 奇数 } else { if (s[i] == '0') { ++ans2; } } } } cout << min(ans1, ans2) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define pb push_back typedef long long ll; int main() { string s; cin >> s; int ans1 = 0; int ans2 = 0; // first is 0 // 偶数 is 0 if (s[0] == '1') { ++ans1; } if (s[1] == '0') { ++ans1; } if (s.size() > 1) { FOR(i, 2, s.size()) { if (i % 2 == 0) { if (s[i] == '1') { ++ans1; } // 奇数 } else { if (s[i] == '0') { ++ans1; } } } } // first is 1 // 奇数 is 0 if (s[0] == '0') { ++ans2; } if (s[1] == '1') { ++ans2; } if (s.size() > 1) { FOR(i, 2, s.size()) { if (i % 2 == 0) { if (s[i] == '0') { ++ans2; } // 奇数 } else { if (s[i] == '1') { ++ans2; } } } } cout << min(ans1, ans2) << endl; return 0; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
884,407
884,408
u349293635
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define pb push_back typedef long long ll; int main() { string s; cin >> s; int ans1 = 0; int ans2 = 0; // first is 0 // 偶数 is 0 if (s[0] == '1') { ++ans1; } if (s[1] == '0') { ++ans1; } if (s.size() > 1) { FOR(i, 1, s.size()) { if (i % 2 == 0) { if (s[i] == '0') { ++ans1; } // 奇数 } else { if (s[i] == '1') { ++ans1; } } } } // first is 1 // 奇数 is 0 if (s[0] == '0') { ++ans2; } if (s[1] == '1') { ++ans2; } if (s.size() > 1) { FOR(i, 2, s.size()) { if (i % 2 == 0) { if (s[i] == '1') { ++ans2; } // 奇数 } else { if (s[i] == '0') { ++ans2; } } } } cout << min(ans1, ans2) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = n - 1; i >= 0; --i) #define pb push_back typedef long long ll; int main() { string s; cin >> s; int ans1 = 0; int ans2 = 0; // first is 0 // 偶数 is 0 if (s[0] == '1') { ++ans1; } if (s[1] == '0') { ++ans1; } if (s.size() > 1) { FOR(i, 2, s.size()) { if (i % 2 == 0) { if (s[i] == '1') { ++ans1; } // 奇数 } else { if (s[i] == '0') { ++ans1; } } } } // first is 1 // 奇数 is 0 if (s[0] == '0') { ++ans2; } if (s[1] == '1') { ++ans2; } if (s.size() > 1) { FOR(i, 2, s.size()) { if (i % 2 == 0) { if (s[i] == '0') { ++ans2; } // 奇数 } else { if (s[i] == '1') { ++ans2; } } } } cout << min(ans1, ans2) << endl; return 0; }
[ "literal.number.change", "call.arguments.change", "literal.string.change", "control_flow.branch.if.condition.change" ]
884,409
884,408
u349293635
cpp
p03073
#include <algorithm> #include <bits/stdc++.h> #include <stdint.h> using namespace std; int main() { string S; cin >> S; int ans = 0; for (int i = 0; i < S.size(); i++) { // cout << "dbg " << i << ", " << S.at(i) << " "; if (i % 2) { if (S.at(i) == '0') ans++; // cout << ans << endl; } else { if (S.at(i) == '1') ans; // cout << ans << endl; } } if (ans > (S.size() / 2)) { cout << (S.size() - ans) << endl; } else { cout << ans << endl; } return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <stdint.h> using namespace std; int main() { string S; cin >> S; int ans = 0; for (int i = 0; i < S.size(); i++) { // cout << "dbg " << i << ", " << S.at(i) << " "; if (i % 2) { if (S.at(i) == '0') ans++; // cout << ans << endl; } else { if (S.at(i) == '1') ans++; // cout << ans << endl; } } // cout << "result " << ans << endl; if (ans > (S.size() / 2)) { cout << (S.size() - ans) << endl; } else { cout << ans << endl; } return 0; }
[]
884,414
884,415
u641922479
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl; #define REP(i, n) for (long long i = 0; i < (n); i++) int main() { string S; cin >> S; string St = S; int ans = 0; if (St[0] == '1') { ans++; St[0] = '0'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; ans++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] == '0'; ans++; } } int anst = 0; St = S; if (St[0] == '0') { anst++; St[0] == '1'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; anst++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] = '0'; anst++; } } ans = min(ans, anst); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl; #define REP(i, n) for (long long i = 0; i < (n); i++) int main() { string S; cin >> S; string St = S; int ans = 0; if (St[0] == '1') { ans++; St[0] = '0'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; ans++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] = '0'; ans++; } } int anst = 0; St = S; if (St[0] == '0') { anst++; St[0] = '1'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; anst++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] = '0'; anst++; } } ans = min(ans, anst); cout << ans << endl; return 0; }
[ "expression.operation.compare.replace.remove", "assignment.replace.add", "misc.typo" ]
884,422
884,423
u353542198
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl; #define REP(i, n) for (long long i = 0; i < (n); i++) int main() { string S; cin >> S; string St = S; int ans = 0; if (St[0] == '1') { ans++; St[0] = '0'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; ans++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] == '0'; ans++; } } int anst = 0; St = S; if (St[0] == '0') { ans++; St[0] == '1'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; anst++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] = '0'; anst++; } } ans = min(ans, anst); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl; #define REP(i, n) for (long long i = 0; i < (n); i++) int main() { string S; cin >> S; string St = S; int ans = 0; if (St[0] == '1') { ans++; St[0] = '0'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; ans++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] = '0'; ans++; } } int anst = 0; St = S; if (St[0] == '0') { anst++; St[0] = '1'; } for (int i = 1; i < St.size(); i++) { if (St[i - 1] == '0' && St[i] == '0') { St[i] = '1'; anst++; } else if (St[i - 1] == '1' && St[i] == '1') { St[i] = '0'; anst++; } } ans = min(ans, anst); cout << ans << endl; return 0; }
[ "expression.operation.compare.replace.remove", "assignment.replace.add", "misc.typo", "identifier.change" ]
884,424
884,423
u353542198
cpp
p03073
#include <bits/stdc++.h> using namespace std; const int maxn = 100007; int n, m, k, ans1, ans2; bool h[maxn]; char str[maxn]; int main() { // freopen("in.txt","r",stdin); scanf("%s", str); int len = strlen(str); ans1 = ans2 = 0; char bef, aft; if (len == 1) { printf("0\n"); return 0; } bef = str[0]; for (int i = 1; i < len; i++) { aft = str[i]; if (bef == aft) { ans1++; // printf("i = %d,str[%d] = %c\n",i,i,str[i]); if (aft == '1') bef = '0'; else bef = '1'; } else bef = aft; } bef = str[len - 1]; for (int i = len - 2; i >= 0; i--) { aft = str[i]; if (bef == aft) { ans2++; if (aft == '1') bef = '0'; else bef = '1'; } } printf("%d\n", min(ans1, ans2)); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100007; int n, m, k, ans1, ans2; bool h[maxn]; char str[maxn]; int main() { // freopen("in.txt","r",stdin); scanf("%s", str); int len = strlen(str); ans1 = ans2 = 0; char bef, aft; if (len == 1) { printf("0\n"); return 0; } bef = str[0]; for (int i = 1; i < len; i++) { aft = str[i]; if (bef == aft) { ans1++; // printf("ans 1 i = %d,str[%d] = %c\n",i,i,str[i]); if (aft == '1') bef = '0'; else bef = '1'; } else bef = aft; } bef = str[len - 1]; for (int i = len - 2; i >= 0; i--) { aft = str[i]; if (bef == aft) { ans2++; // printf("ans 2 i = %d,str[%d] = %c\n",i,i,str[i]); if (aft == '1') bef = '0'; else bef = '1'; } else bef = aft; } printf("%d\n", min(ans1, ans2)); return 0; }
[ "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "assignment.add" ]
884,425
884,426
u069164832
cpp
p03073
#include <algorithm> #include <chrono> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; constexpr int WALL = 1000000007; struct Point { int x; int y; Point() {} Point(int _x, int _y) : x(_x), y(_y) {} }; int lab[50 + 1][50 + 1]; bool isNotSearched(int x, int y) { return lab[y][x] == 0; } int get(Point p) { return lab[p.y][p.x]; } int main() { // cin.tie(0); // ios::sync_with_stdio(false); string S; cin >> S; int len = S.size(); int a = 0; int b = 0; int f = 0; for (int i = 0; i < len; ++i) { // S[i == 1] if (f != (S[i] - '0')) ++a; else ++b; } cout << min(a, b) << endl; return 0; }
#include <algorithm> #include <chrono> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; constexpr int WALL = 1000000007; struct Point { int x; int y; Point() {} Point(int _x, int _y) : x(_x), y(_y) {} }; int lab[50 + 1][50 + 1]; bool isNotSearched(int x, int y) { return lab[y][x] == 0; } int get(Point p) { return lab[p.y][p.x]; } int main() { // cin.tie(0); // ios::sync_with_stdio(false); string S; cin >> S; int len = S.size(); int a = 0; int b = 0; int f = 0; for (int i = 0; i < len; ++i) { // S[i == 1] if (f != (S[i] - '0')) ++a; else ++b; f ^= 1; } cout << min(a, b) << endl; return 0; }
[ "assignment.add" ]
884,427
884,428
u577747009
cpp
p03073
#include <cstdio> #include <iostream> using namespace std; int main() { string s; cin >> s; int sum[2] = {0, 0}; for (int j = 0; j <= 1; j++) { int start = j; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { if (start == 1) sum[j]++; } if (s[i] == '1') { if (start == 0) sum[j]++; } start = (start == 0) ? 1 : 0; } } if (sum[0] < sum[1]) cout << sum[0] << endl; if (sum[0] > sum[1]) cout << sum[1] << endl; return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { string s; cin >> s; int sum[2] = {0, 0}; for (int j = 0; j <= 1; j++) { int start = j; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { if (start == 1) sum[j]++; } if (s[i] == '1') { if (start == 0) sum[j]++; } start = (start == 0) ? 1 : 0; } } if (sum[0] <= sum[1]) cout << sum[0] << endl; if (sum[0] > sum[1]) cout << sum[1] << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,429
884,430
u128456980
cpp
p03073
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i)) #define rer(i, l, u) for (int(i) = (int)(l); (i) <= (int)(u); ++(i)) #define reu(i, l, u) for (int(i) = (int)(l); (i) < (int)(u); ++(i)) #define INF (int)1e9 + 7 static const int dy[4] = {0, 1, 0, -1}; static const int dx[4] = {1, 0, -1, 0}; typedef long long ll; using namespace std; int main() { string s; const string s1 = "10"; const string s2 = "01"; string a, b; cin >> s; rep(i, s.size() / 2) { a += s1; b += s2; } int cnt1 = 0; int cnt2 = 0; rep(i, s.size()) { if (s[i] != a[i]) { cnt1++; } if (s[i] != b[i]) { cnt2++; } } cout << min(cnt1, cnt2) << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i)) #define rer(i, l, u) for (int(i) = (int)(l); (i) <= (int)(u); ++(i)) #define reu(i, l, u) for (int(i) = (int)(l); (i) < (int)(u); ++(i)) #define INF (int)1e9 + 7 static const int dy[4] = {0, 1, 0, -1}; static const int dx[4] = {1, 0, -1, 0}; typedef long long ll; using namespace std; int main() { string s; const string s1 = "10"; const string s2 = "01"; string a, b; cin >> s; rep(i, (s.size() + 1) / 2) { a += s1; b += s2; } int cnt1 = 0; int cnt2 = 0; rep(i, s.size()) { if (s[i] != a[i]) { cnt1++; } if (s[i] != b[i]) { cnt2++; } } cout << min(cnt1, cnt2) << endl; return 0; }
[ "call.arguments.change" ]
884,433
884,434
u484962958
cpp
p03073
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 999999999 #define llong long long using namespace std; int main() { string s; cin >> s; int c1 = 0; int c2 = 0; int N = s.size(); for (int i = 0; i < N; i++) { if (i % 2 == 0) { if (s[i] == '0') { c2++; } else if (s[i] == 1) { c1++; } } else { if (s[i] == '0') { c1++; } else if (s[i] == 1) { c2++; } } } int min; if (c1 > c2) { min = c2; } else { min = c1; } cout << min << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define INF 999999999 #define llong long long using namespace std; int main() { string s; cin >> s; int c1 = 0; int c2 = 0; int N = s.size(); for (int i = 0; i < N; i++) { if (i % 2 == 0) { if (s[i] == '0') { c2++; } else if (s[i] == '1') { c1++; } } else { if (s[i] == '0') { c1++; } else if (s[i] == '1') { c2++; } } } int min; if (c1 > c2) { min = c2; } else { min = c1; } cout << min << endl; return 0; }
[ "control_flow.branch.if.condition.change" ]
884,435
884,436
u831416184
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int sum = 0; int sum2 = 0; for (int i = 1; i < s.size(); i += 2) { if (s[i - 1] == '1') sum++; if (i > s.size()) break; if (s[i] == '0') sum++; } for (int i = 1; i < s.size(); i += 2) { if (s[i - 1] == '0') sum2++; if (i > s.size()) break; if (s[i] == '1') sum2++; } cout << min(sum, sum2) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int sum = 0; int sum2 = 0; for (int i = 1; i <= s.size(); i += 2) { if (s[i - 1] == '1') sum++; if (i >= s.size()) break; if (s[i] == '0') sum++; } for (int i = 1; i <= s.size(); i += 2) { if (s[i - 1] == '0') sum2++; if (i >= s.size()) break; if (s[i] == '1') sum2++; } cout << min(sum, sum2) << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
884,439
884,440
u876558178
cpp
p03073
#define REP(i, n) for (int i = 0; i < n; i++) #define INF 2e9 #define ll long long #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define ALL(v) v.begin(), v.end() #include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n10 = 0, n01 = 0; if (s.size() == 1) cout << 0 << endl; else { // 1010101010... REP(i, s.size() / 2) { if (s.at(2 * i) == s.at(2 * i + 1)) { n10++; n01++; } else if (s.at(2 * i) == '1') { n01 += 2; } else n10 += 2; // cout << n10 << " " << n01 << endl; } if (s.size() % 2 != 0) { if (s.at(s.size() - 1) == '1') n01++; else n10++; } } // cout << n10 << " " << n01 << endl; cout << min(n10, n01) << endl; }
#define REP(i, n) for (int i = 0; i < n; i++) #define INF 2e9 #define ll long long #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define ALL(v) v.begin(), v.end() #include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n10 = 0, n01 = 0; if (s.size() == 1) cout << 0 << endl; else { // 1010101010... REP(i, s.size() / 2) { if (s.at(2 * i) == s.at(2 * i + 1)) { n10++; n01++; } else if (s.at(2 * i) == '1') { n01 += 2; } else n10 += 2; // cout << n10 << " " << n01 << endl; } if (s.size() % 2 != 0) { if (s.at(s.size() - 1) == '1') n01++; else n10++; } cout << min(n10, n01) << endl; } }
[]
884,443
884,444
u128196936
cpp
p03073
#include <iostream> #include <string> int main() { std::string s; std::cin >> s; auto p = s.front(); int n1 = 0; for (int i = 0; i < s.size(); i += 2) { if (s[i] != '0') { n1++; } } int n2 = 0; for (int i = 1; i < s.size(); i += 2) { if (s[i] != '0') { n2++; } } auto n1b = s.size() / 2 - n2; auto n2b = s.size() / 2 - n1; auto n11 = n1 + n1b; auto n22 = n2 + n2b; std::cout << std::min(n11, n22) << std::endl; }
#include <iostream> #include <string> int main() { std::string s; std::cin >> s; auto p = s.front(); int n1 = 0; for (int i = 0; i < s.size(); i += 2) { if (s[i] != '0') { n1++; } } int n2 = 0; for (int i = 1; i < s.size(); i += 2) { if (s[i] != '0') { n2++; } } auto n1b = s.size() / 2 - n2; auto n2b = (s.size() + 1) / 2 - n1; auto n11 = n1 + n1b; auto n22 = n2 + n2b; std::cout << std::min(n11, n22) << std::endl; }
[ "assignment.change" ]
884,445
884,446
u099124596
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { // freopen("in.txt","r",stdin); string s, sc; cin >> s; sc = s; int l = s.length(); int cnt1 = 0, cnt2 = 0; for (int i = 1; i < l; i++) { if (s[i] == s[i - 1]) { cnt1++; if (s[i] == '1') s[i] = '0'; else s[i] = '1'; } } if (sc[0] == '0') sc[0] = '1'; else sc[0] = '0'; s = sc; for (int i = 1; i < l; i++) { if (s[i] == s[i - 1]) { cnt2++; if (s[i] == '1') s[i] = '0'; else s[i] = '1'; } } if (cnt2 > cnt1) cnt2 = cnt1; printf("%d", cnt2); // fclose(stdin); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { // freopen("in.txt","r",stdin); string s, sc; cin >> s; sc = s; int l = s.length(); int cnt1 = 0, cnt2 = 1; for (int i = 1; i < l; i++) { if (s[i] == s[i - 1]) { cnt1++; if (s[i] == '1') s[i] = '0'; else s[i] = '1'; } // cout << s<<endl<<cnt1<<endl; } if (sc[0] == '0') sc[0] = '1'; else sc[0] = '0'; s = sc; for (int i = 1; i < l; i++) { if (s[i] == s[i - 1]) { cnt2++; if (s[i] == '1') s[i] = '0'; else s[i] = '1'; } // cout << s <<endl << cnt2<<endl; } if (cnt2 > cnt1) cnt2 = cnt1; printf("%d", cnt2); // fclose(stdin); return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
884,451
884,452
u202078305
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N; N = S.size(); int count = 0; for (int i = 1; i < S.size() - 1; i++) { if (S.at(i) == '1' && S.at(i + 1) == '1') { S.at(i + 1) = 0; count = count + 1; } else if (S.at(i) == '0' && S.at(i + 1) == '0') { S.at(i + 1) = 1; count = count + 1; } else { } } cout << min(count, N - count) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N; N = S.size(); int count = 0; for (int i = 0; i < S.size() - 1; i++) { if (S.at(i) == '1' && S.at(i + 1) == '1') { S.at(i + 1) = '0'; count = count + 1; } else if (S.at(i) == '0' && S.at(i + 1) == '0') { S.at(i + 1) = '1'; count = count + 1; } else { } } cout << min(count, N - count) << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
884,457
884,458
u028061225
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { string s; cin >> s; int cnt1 = 0, cnt2 = 0; rep(i, s.size()) { if (i % 2 == 0) if (s[i] == '0') cnt1++; else if (s[i] == '1') cnt1++; } rep(i, s.size()) { if (i % 2 == 0) { if (s[i] == '1') cnt2++; } else { if (s[i] == '0') cnt2++; } } cout << s.size() - max(cnt1, cnt2) << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { string s; cin >> s; int cnt1 = 0, cnt2 = 0; rep(i, s.size()) { if (i % 2 == 0) { if (s[i] == '0') cnt1++; } else { if (s[i] == '1') cnt1++; } } rep(i, s.size()) { if (i % 2 == 0) { if (s[i] == '1') cnt2++; } else { if (s[i] == '0') cnt2++; } } cout << s.size() - max(cnt1, cnt2) << endl; }
[]
884,461
884,462
u083190434
cpp
p03073
#include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef vector<string> VS; // container util #define SORT(c) sort((c).begin(), (c).end()) // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) int main(void) { string S; cin >> S; int len = S.length(); int ans = 1 << 30; int cnt = 0; FOR(i, 1, len) { int x = S[i] - '0'; if (x != i % 2) cnt++; } ans = min(ans, cnt); cnt = 0; FOR(i, 1, len) { int x = S[i] - '0'; if (x != (i + 1) % 2) cnt++; } ans = min(ans, cnt); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef vector<string> VS; // container util #define SORT(c) sort((c).begin(), (c).end()) // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) int main(void) { string S; cin >> S; int len = S.length(); int ans = 1 << 30; int cnt = 0; REP(i, len) { int x = S[i] - '0'; if (x != i % 2) cnt++; } ans = min(ans, cnt); cnt = 0; REP(i, len) { int x = S[i] - '0'; if (x != (i + 1) % 2) cnt++; } ans = min(ans, cnt); cout << ans << endl; return 0; }
[ "call.arguments.change" ]
884,463
884,464
u594140666
cpp
p03073
#include <algorithm> #include <iostream> using namespace std; int h[100005][3] = {0}; int main() { int n = 0; for (int i = 1; i <= 100004; i++) { if (i % 2 == 0) { h[i][1] = 1; h[i][2] = 0; } else { h[i][1] = 0; h[i][2] = 1; } } char a; while (cin >> a) { n++; if (a == '0' && h[n][1] == 1) h[0][1]++; else if (a == '0') h[0][2]++; if (a == '1' && h[n][2] == 1) h[0][2]++; else if (a == '1') h[0][2]++; } cout << min(h[0][1], h[0][2]) << endl; }
#include <algorithm> #include <iostream> using namespace std; int h[100005][3] = {0}; int main() { int n = 0; for (int i = 1; i <= 100004; i++) { if (i % 2 == 0) { h[i][1] = 1; h[i][2] = 0; } else { h[i][1] = 0; h[i][2] = 1; } } char a; while (cin >> a) { n++; if (a == '0' && h[n][1] == 1) h[0][1]++; else if (a == '0') h[0][2]++; if (a == '1' && h[n][2] == 0) h[0][2]++; else if (a == '1') h[0][1]++; } cout << min(h[0][1], h[0][2]) << endl; }
[ "literal.number.change", "control_flow.branch.if.condition.change", "variable_access.subscript.index.change" ]
884,465
884,466
u791146764
cpp
p03073
#include <bits/stdc++.h> using namespace std; #define MD 1000000007 typedef long long int ll; typedef pair<ll, ll> P; template <typename T> std::string tostr(const T &t) { std::ostringstream os; os << t; return os.str(); } int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int main() { string s; cin >> s; int ans = 0, cnt = 0; char flag = '1'; for (int i = 0; i < s.length(); i++) { // 1010 if (flag != s[i]) { ans++; } if (flag == '0') { flag = '1'; } else { flag = '0'; } } for (int i = 0; i < s.length(); i++) { // 0101 if (flag != s[i]) { cnt++; } if (flag == '0') { flag = '1'; } else { flag = '0'; } } ans = min(ans, cnt); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define MD 1000000007 typedef long long int ll; typedef pair<ll, ll> P; template <typename T> std::string tostr(const T &t) { std::ostringstream os; os << t; return os.str(); } int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int main() { string s; cin >> s; int ans = 0, cnt = 0; char flag = '1'; for (int i = 0; i < s.length(); i++) { // 1010 if (flag != s[i]) { ans++; } if (flag == '0') { flag = '1'; } else { flag = '0'; } } flag = '0'; for (int i = 0; i < s.length(); i++) { // 0101 if (flag != s[i]) { cnt++; } if (flag == '0') { flag = '1'; } else { flag = '0'; } } ans = min(ans, cnt); cout << ans << endl; return 0; }
[ "assignment.add" ]
884,490
884,491
u287060310
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string s; cin >> s; for (int a = 1; a < s.size(); a++) { if (s.at(a - 1) + s.at(a) - '0' - '0' != 1) { if (s.at(a) = '0') s.at(a)++; else s.at(a)--; ans++; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string s; cin >> s; for (int a = 1; a < s.size(); a++) { if (s.at(a - 1) + s.at(a) - '0' - '0' != 1) { if (s.at(a) == '0') s.at(a)++; else s.at(a)--; ans++; } } cout << ans; }
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
884,494
884,495
u250952439
cpp
p03073
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string s; cin >> s; for (int a = 1; a < s.size(); a++) { if (s.at(a - 1) + s.at(a) - '0' - '0' != 0) { if (s.at(a) = '0') s.at(a)++; else s.at(a)--; ans++; } } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string s; cin >> s; for (int a = 1; a < s.size(); a++) { if (s.at(a - 1) + s.at(a) - '0' - '0' != 1) { if (s.at(a) == '0') s.at(a)++; else s.at(a)--; ans++; } } cout << ans; }
[ "literal.number.change", "control_flow.branch.if.condition.change", "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
884,496
884,495
u250952439
cpp
p03073
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define RFOR(i, a, b) for (int i = (a); i >= (b); --i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = (n); i > 0; --i) #define CI cin >> #define CO cout << #define EN << endl #define all(x) (x).begin(), (x).end() #define asn ans using namespace std; template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } using ll = long long; int main() { string s; CI s; int ans = 0; int len = s.length() - 1; if (s[0] == '0') { string ori = s; int tmp = 0; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = tmp; ori = s; ori[0] = '1'; tmp = 0; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = min(ans, tmp); } if (s[0] == '1') { string ori = s; int tmp = 0; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = tmp; ori = s; ori[0] = '0'; tmp = 0; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = min(ans, tmp); } CO ans EN; return 0; }
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define RFOR(i, a, b) for (int i = (a); i >= (b); --i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define RREP(i, n) for (int i = (n); i > 0; --i) #define CI cin >> #define CO cout << #define EN << endl #define all(x) (x).begin(), (x).end() #define asn ans using namespace std; template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } using ll = long long; int main() { string s; CI s; int ans = 0; int len = s.length() - 1; if (s[0] == '0') { string ori = s; int tmp = 0; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = tmp; ori = s; ori[0] = '1'; tmp = 1; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = min(ans, tmp); } if (s[0] == '1') { string ori = s; int tmp = 0; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = tmp; ori = s; ori[0] = '0'; tmp = 1; for (int i = 1; i < len + 1; i++) { if (ori[i] == ori[i - 1]) { tmp++; if (ori[i] == '1') ori[i] = '0'; else ori[i] = '1'; } } ans = min(ans, tmp); } CO ans EN; return 0; }
[ "literal.number.change", "assignment.value.change" ]
884,501
884,502
u165567408
cpp
p03073
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using P = pair<int, int>; using PL = pair<ll, ll>; using vp = vector<P>; const int INF = 1 << 30, MOD = 1000000007; const ll LINF = 1ll << 60; #define _ol3(_1, _2, _3, name, ...) name #define _rep(i, n) _repi(i, 0, n) #define _repi(i, a, b) for (int i = a, i##_l = (b); i < i##_l; ++i) #define REP(...) _ol3(__VA_ARGS__, _repi, _rep, )(__VA_ARGS__) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define REPA(i, v) REP(i, v.size()) #define all(v) (v).begin(), (v).end() #define bit(n) (1ll << (n)) #define clamp(n, mi, ma) max(min(n, ma), mi) #define uniq(v) \ sort(all(v)); \ v.erase(unique(all(v)), v.end()) #define pb push_back #define F first #define S second #define endl '\n' #define cho(n, a, b) cout << ((n) ? a : b) << endl #define YES(n) cho(n, "YES", "NO") #define Yes(n) cho(n, "Yes", "No") #define Poss(n) cho(n, "Possible", "Impossible") 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; } template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { for (const T &i : v) o << i << ' '; return o; } template <class T> istream &operator>>(istream &i, vector<T> &v) { for (T &j : v) i >> j; return i; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &p) { return o << p.F << ' ' << p.S; } template <class T, class U> istream &operator>>(istream &i, pair<T, U> &p) { return i >> p.F >> p.S; } template <class T> ostream &operator<<(ostream &o, const set<T> &v) { for (const T &i : v) o << i << ' '; return o; } template <class T> ostream &operator<(ostream &o, const T &t) { return o << t; } template <class T> istream &operator>(istream &i, T &t) { return i >> t; } #ifndef LOCAL struct ostdmy { template <class T> ostdmy &operator<<(const T &t) { return *this; } template <class T> ostdmy &operator<(const T &t) { return *this; } }; ostdmy cer_; #define cerr cer_ #endif int main() { cin.tie(0); ios::sync_with_stdio(0); string s; cin > s; int n = s.size(); int mi = INF; int c = 0; REP(i, 1, n) { if ((s[i] == '1') == i % 2) c++; } chmin(mi, c); c = 0; REP(i, 1, n) { if ((s[i] == '1') != i % 2) c++; } chmin(mi, c); cout < mi < endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using P = pair<int, int>; using PL = pair<ll, ll>; using vp = vector<P>; const int INF = 1 << 30, MOD = 1000000007; const ll LINF = 1ll << 60; #define _ol3(_1, _2, _3, name, ...) name #define _rep(i, n) _repi(i, 0, n) #define _repi(i, a, b) for (int i = a, i##_l = (b); i < i##_l; ++i) #define REP(...) _ol3(__VA_ARGS__, _repi, _rep, )(__VA_ARGS__) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define REPA(i, v) REP(i, v.size()) #define all(v) (v).begin(), (v).end() #define bit(n) (1ll << (n)) #define clamp(n, mi, ma) max(min(n, ma), mi) #define uniq(v) \ sort(all(v)); \ v.erase(unique(all(v)), v.end()) #define pb push_back #define F first #define S second #define endl '\n' #define cho(n, a, b) cout << ((n) ? a : b) << endl #define YES(n) cho(n, "YES", "NO") #define Yes(n) cho(n, "Yes", "No") #define Poss(n) cho(n, "Possible", "Impossible") 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; } template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { for (const T &i : v) o << i << ' '; return o; } template <class T> istream &operator>>(istream &i, vector<T> &v) { for (T &j : v) i >> j; return i; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &p) { return o << p.F << ' ' << p.S; } template <class T, class U> istream &operator>>(istream &i, pair<T, U> &p) { return i >> p.F >> p.S; } template <class T> ostream &operator<<(ostream &o, const set<T> &v) { for (const T &i : v) o << i << ' '; return o; } template <class T> ostream &operator<(ostream &o, const T &t) { return o << t; } template <class T> istream &operator>(istream &i, T &t) { return i >> t; } #ifndef LOCAL struct ostdmy { template <class T> ostdmy &operator<<(const T &t) { return *this; } template <class T> ostdmy &operator<(const T &t) { return *this; } }; ostdmy cer_; #define cerr cer_ #endif int main() { cin.tie(0); ios::sync_with_stdio(0); string s; cin > s; int n = s.size(); int mi = INF; int c = 0; REP(i, n) { if ((s[i] == '1') == i % 2) c++; } chmin(mi, c); c = 0; REP(i, n) { if ((s[i] == '1') != i % 2) c++; } chmin(mi, c); cout < mi < endl; return 0; }
[ "call.arguments.change" ]
884,507
884,508
u502709453
cpp
p03073
#include <stdio.h> int main(void) { char s[100000]; scanf("%s", s); int counta = 0, countb = 0; for (int i = 0; i < 100000; i++) { if (s[i] != '\0') { if (i % 2 == 0 && s[i] == '1') counta++; if (i % 2 == 1 && s[i] == '0') counta++; if (i % 2 == 0 && s[i] == '0') countb++; if (i % 2 == 1 && s[i] == '1') countb++; } else break; } if (counta > countb) printf("%d", counta); else printf("%d", countb); }
#include <stdio.h> int main(void) { char s[100000]; scanf("%s", s); int counta = 0, countb = 0; for (int i = 0; i < 100000; i++) { if (s[i] != '\0') { if (i % 2 == 0 && s[i] == '1') counta++; if (i % 2 == 1 && s[i] == '0') counta++; if (i % 2 == 0 && s[i] == '0') countb++; if (i % 2 == 1 && s[i] == '1') countb++; } else break; } if (counta < countb) printf("%d", counta); else printf("%d", countb); }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
884,511
884,512
u872031579
cpp