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
p03107
#include <iostream> using namespace std; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == 1) b++; else r++; } cout << 2 * min(r, b) << endl; }
#include <iostream> using namespace std; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '1') b++; else r++; } cout << 2 * min(r, b) << endl; }
[ "control_flow.branch.if.condition.change" ]
917,469
917,470
u525137785
cpp
p03107
#include <iostream> using namespace std; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i]) b++; else r++; } cout << 2 * min(r, b) << endl; }
#include <iostream> using namespace std; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '1') b++; else r++; } cout << 2 * min(r, b) << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
917,471
917,470
u525137785
cpp
p03107
#include <iostream> using namespace std; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i]) b++; else r++; } cout << 2 * max(r, b) << endl; }
#include <iostream> using namespace std; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '1') b++; else r++; } cout << 2 * min(r, b) << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
917,472
917,470
u525137785
cpp
p03107
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <unordered_map> #include <unordered_set> #endif #define y0 qvya13579 #define y1 qvyb24680 #define j0 qvja13579 #define j1 qvjb24680 #define next qvne13579xt #define prev qvpr13579ev #define INF 1000000007 #define MOD 1000000007 #define PI acos(-1.0) #define endl "\n" #define IOS \ cin.tie(0); \ ios::sync_with_stdio(false) #define M_P make_pair #define PU_B push_back #define PU_F push_front #define PO_B pop_back #define PO_F pop_front #define U_B upper_bound #define L_B lower_bound #define B_S binary_search #define PR_Q priority_queue #define FIR first #define SEC second #if __cplusplus < 201103L #define stoi(argument_string) atoi((argument_string).c_str()) #endif #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i) #define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i) #define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define SIZ(x) ((int)(x).size()) #define COUT(x) cout << (x) << endl #define CIN(x) cin >> (x) #define CIN2(x, y) cin >> (x) >> (y) #define CIN3(x, y, z) cin >> (x) >> (y) >> (z) #define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w) #define SCAND(x) scanf("%d", &(x)) #define SCAND2(x, y) scanf("%d%d", &(x), &(y)) #define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z)) #define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w)) #define SCANLLD(x) scanf("%lld", &(x)) #define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y)) #define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z)) #define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w)) #define PRINTD(x) printf("%d\n", (x)) #define PRINTLLD(x) printf("%lld\n", (x)) typedef long long int lli; using namespace std; bool compare_by_2nd(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } else { return a.first < b.first; } } int ctoi(char c) { if (c >= '0' and c <= '9') { return (int)(c - '0'); } return -1; } int alphabet_pos(char c) { if (c >= 'a' and c <= 'z') { return (int)(c - 'a'); } return -1; } int alphabet_pos_capital(char c) { if (c >= 'A' and c <= 'Z') { return (int)(c - 'A'); } return -1; } vector<string> split(string str, char ch) { int first = 0; int last = str.find_first_of(ch); if (last == string::npos) { last = SIZ(str); } vector<string> result; while (first < SIZ(str)) { string Ssubstr(str, first, last - first); result.push_back(Ssubstr); first = last + 1; last = str.find_first_of(ch, first); if (last == string::npos) { last = SIZ(str); } } return result; } int gcd(int a, int b) // assuming a,b >= 1 { if (a < b) { return gcd(b, a); } if (a % b == 0) { return b; } return gcd(b, a % b); } int lcm(int a, int b) // assuming a,b >= 1 { return a * b / gcd(a, b); } /*------------------ the end of the template -----------------------*/ int main() { IOS; /* making cin faster */ string S; CIN(S); int n0 = 0; REP(i, SIZ(S)) { if (S[i] == '0') { ++n0; } } PRINTD(max(n0, SIZ(S) - n0) - min(n0, SIZ(S) - n0)); }
#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <unordered_map> #include <unordered_set> #endif #define y0 qvya13579 #define y1 qvyb24680 #define j0 qvja13579 #define j1 qvjb24680 #define next qvne13579xt #define prev qvpr13579ev #define INF 1000000007 #define MOD 1000000007 #define PI acos(-1.0) #define endl "\n" #define IOS \ cin.tie(0); \ ios::sync_with_stdio(false) #define M_P make_pair #define PU_B push_back #define PU_F push_front #define PO_B pop_back #define PO_F pop_front #define U_B upper_bound #define L_B lower_bound #define B_S binary_search #define PR_Q priority_queue #define FIR first #define SEC second #if __cplusplus < 201103L #define stoi(argument_string) atoi((argument_string).c_str()) #endif #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i) #define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i) #define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i) #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define SIZ(x) ((int)(x).size()) #define COUT(x) cout << (x) << endl #define CIN(x) cin >> (x) #define CIN2(x, y) cin >> (x) >> (y) #define CIN3(x, y, z) cin >> (x) >> (y) >> (z) #define CIN4(x, y, z, w) cin >> (x) >> (y) >> (z) >> (w) #define SCAND(x) scanf("%d", &(x)) #define SCAND2(x, y) scanf("%d%d", &(x), &(y)) #define SCAND3(x, y, z) scanf("%d%d%d", &(x), &(y), &(z)) #define SCAND4(x, y, z, w) scanf("%d%d%d%d", &(x), &(y), &(z), &(w)) #define SCANLLD(x) scanf("%lld", &(x)) #define SCANLLD2(x, y) scanf("%lld%lld", &(x), &(y)) #define SCANLLD3(x, y, z) scanf("%lld%lld%lld", &(x), &(y), &(z)) #define SCANLLD4(x, y, z, w) scanf("%lld%lld%lld%lld", &(x), &(y), &(z), &(w)) #define PRINTD(x) printf("%d\n", (x)) #define PRINTLLD(x) printf("%lld\n", (x)) typedef long long int lli; using namespace std; bool compare_by_2nd(pair<int, int> a, pair<int, int> b) { if (a.second != b.second) { return a.second < b.second; } else { return a.first < b.first; } } int ctoi(char c) { if (c >= '0' and c <= '9') { return (int)(c - '0'); } return -1; } int alphabet_pos(char c) { if (c >= 'a' and c <= 'z') { return (int)(c - 'a'); } return -1; } int alphabet_pos_capital(char c) { if (c >= 'A' and c <= 'Z') { return (int)(c - 'A'); } return -1; } vector<string> split(string str, char ch) { int first = 0; int last = str.find_first_of(ch); if (last == string::npos) { last = SIZ(str); } vector<string> result; while (first < SIZ(str)) { string Ssubstr(str, first, last - first); result.push_back(Ssubstr); first = last + 1; last = str.find_first_of(ch, first); if (last == string::npos) { last = SIZ(str); } } return result; } int gcd(int a, int b) // assuming a,b >= 1 { if (a < b) { return gcd(b, a); } if (a % b == 0) { return b; } return gcd(b, a % b); } int lcm(int a, int b) // assuming a,b >= 1 { return a * b / gcd(a, b); } /*------------------ the end of the template -----------------------*/ int main() { IOS; /* making cin faster */ string S; CIN(S); int n0 = 0; REP(i, SIZ(S)) { if (S[i] == '0') { ++n0; } } PRINTD(SIZ(S) - max(n0, SIZ(S) - n0) + min(n0, SIZ(S) - n0)); }
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
917,473
917,474
u900727536
cpp
p03107
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == '0') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count >= S.size() / 2) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == '0') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count > S.size() / 2) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,477
917,478
u298413997
cpp
p03107
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == '0') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count >= S.size()) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == '0') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count > S.size() / 2) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,479
917,478
u298413997
cpp
p03107
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == 'o') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count >= S.size()) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == '0') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count > S.size() / 2) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
[ "misc.typo", "literal.string.change", "control_flow.branch.if.condition.change", "expression.operator.compare.change" ]
917,480
917,478
u298413997
cpp
p03107
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == 'o') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count > S.size()) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; // vector <int> A; int count = 0; // the number of 0s cin >> S; // A.resize(S.size()); for (int i = 0; i < S.size(); i++) { // S[i]がoならば0 if (S[i] == '0') { // A[i] = 0; count++; } /*else{ A[i] = 1; }*/ } if (count > S.size() / 2) { count = S.size() - count; } cout << 2 * count << endl; return 0; }
[ "misc.typo", "literal.string.change", "control_flow.branch.if.condition.change" ]
917,481
917,478
u298413997
cpp
p03107
#include <iostream> using namespace std; int main() { string S; cin >> S; int C0, C1; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') C0 += 1; else if (S[i] == '1') C1 += 1; } cout << 2 * min(C0, C1) << endl; return 0; }
#include <iostream> using namespace std; int main() { string S; cin >> S; int C0 = 0, C1 = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') C0 += 1; else if (S[i] == '1') C1 += 1; } cout << 2 * min(C0, C1) << endl; return 0; }
[ "variable_declaration.value.change" ]
917,484
917,485
u456950583
cpp
p03107
#include <iostream> #include <string> using namespace std; int main() { long long count, i; count = 0; string S; cin >> S; for (i = 0; i < S.length(); i++) { if (S[i] == '0') count += 1; } cout << ((count < (S.length() / 2)) ? (2 * count) : (2 * (S.length() - count))); return 0; }
#include <iostream> #include <string> using namespace std; int main() { int count, i; count = 0; string S; cin >> S; for (i = 0; i < S.length(); i++) { if (S[i] == '0') count += 1; } cout << ((count < ((double)S.length() / 2)) ? (2 * count) : (2 * (S.length() - count))); return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.narrow.change" ]
917,489
917,490
u059790365
cpp
p03107
#include <iostream> #include <string> using namespace std; int main() { int count, i; count = 0; string S; cin >> S; for (i = 0; i < S.length(); i++) { if (S[i] == '0') count += 1; } cout << ((count < (S.length() / 2)) ? (2 * count) : (2 * (S.length() - count))); return 0; }
#include <iostream> #include <string> using namespace std; int main() { int count, i; count = 0; string S; cin >> S; for (i = 0; i < S.length(); i++) { if (S[i] == '0') count += 1; } cout << ((count < ((double)S.length() / 2)) ? (2 * count) : (2 * (S.length() - count))); return 0; }
[ "type_conversion.add" ]
917,491
917,490
u059790365
cpp
p03107
#include <iostream> #include <string> using namespace std; int main() { int count, i; count = 0; string S; cin >> S; for (i = 0; i < S.length(); i++) { if (S[i] = '0') count += 1; } cout << ((count < (S.length() / 2)) ? (2 * count) : (2 * (S.length() - count))); return 0; }
#include <iostream> #include <string> using namespace std; int main() { int count, i; count = 0; string S; cin >> S; for (i = 0; i < S.length(); i++) { if (S[i] == '0') count += 1; } cout << ((count < ((double)S.length() / 2)) ? (2 * count) : (2 * (S.length() - count))); return 0; }
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
917,492
917,490
u059790365
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int red = 0, blue = 0; string S; cin >> S; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') red++; else blue++; } cout << S.size() - 2 * min(red, blue) << '\n'; cout << flush; // for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}} }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int red = 0, blue = 0; string S; cin >> S; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') red++; else blue++; } cout << 2 * min(red, blue) << '\n'; cout << flush; // for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}} }
[ "expression.operation.binary.remove" ]
917,495
917,496
u496254754
cpp
p03107
#include <bits/stdc++.h> #define ld long double #define int long long using namespace std; const int N = 2e5 + 50; const int mod = 1e9 + 7; const int inf = 1e17; int dx[] = {0, 1, -1, 0, -1, 1, 1, -1}; int dy[] = {1, 0, 0, -1, -1, 1, -1, 1}; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; stack<char> st; int ans = 0; for (auto v : s) { if (st.empty()) { st.push(v); } else { if (v == '0' && st.top() == '1') { st.pop(); ans += 2; } else if (v == '1' && st.top() == '0') { ans += 2; } else { st.push(v); } } } cout << ans; }
#include <bits/stdc++.h> #define ld long double #define int long long using namespace std; const int N = 2e5 + 50; const int mod = 1e9 + 7; const int inf = 1e17; int dx[] = {0, 1, -1, 0, -1, 1, 1, -1}; int dy[] = {1, 0, 0, -1, -1, 1, -1, 1}; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; stack<char> st; int ans = 0; for (auto v : s) { if (st.empty()) { st.push(v); } else { if (v == '0' && st.top() == '1') { st.pop(); ans += 2; } else if (v == '1' && st.top() == '0') { st.pop(); ans += 2; } else { st.push(v); } } } cout << ans; }
[ "call.add" ]
917,499
917,500
u715191077
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main(void) { string S; cin >> S; int count0 = 0; int count1 = 1; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') count0++; else count1++; } cout << min(count0, count1) * 2 << endl; }
#include <bits/stdc++.h> using namespace std; int main(void) { string S; cin >> S; int count0 = 0; int count1 = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') count0++; else count1++; } cout << min(count0, count1) * 2 << endl; }
[ "literal.number.change", "variable_declaration.value.change" ]
917,505
917,506
u503870829
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n, m; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') n++; else m++; } cout << 2 * min(n, m) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = 0, m = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') n++; else m++; } cout << 2 * min(n, m) << endl; return 0; }
[ "variable_declaration.value.change" ]
917,509
917,510
u526708273
cpp
p03107
//#pragma once #include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef pair<long long, long long> pl; long long N, M, k, a, b, c, d, e, H, W, X; long long A[200001] = {}; long long B[200002] = {}; long long tt[20000] = {}; bool f; bool ff; string S, SS; set<long long> sll; pl buf; vector<long long> vpl; int main() { cin >> S; d = 0; a = 0; b = 0; for (long i = 0; i < S.size(); i++) { if (S[i] == '1') { a++; } else { b++; } } cout << (max(a, b)) * 2 << endl; return 0; }
//#pragma once #include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef pair<long long, long long> pl; long long N, M, k, a, b, c, d, e, H, W, X; long long A[200001] = {}; long long B[200002] = {}; long long tt[20000] = {}; bool f; bool ff; string S, SS; set<long long> sll; pl buf; vector<long long> vpl; int main() { cin >> S; d = 0; a = 0; b = 0; for (long i = 0; i < S.size(); i++) { if (S[i] == '1') { a++; } else { b++; } } cout << (min(a, b)) * 2 << endl; return 0; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
917,521
917,522
u058317639
cpp
p03107
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define int64 long long using namespace std; int main() { string s; cin >> s; int count0, count1; rep(i, s.length()) { if (s[i] == '0') { count0++; } else { count1++; } } cout << 2 * min(count0, count1) << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define int64 long long using namespace std; int main() { string s; cin >> s; int count0 = 0, count1 = 0; rep(i, s.length()) { if (s[i] == '0') { count0++; } else { count1++; } } cout << 2 * min(count0, count1) << endl; }
[ "variable_declaration.value.change" ]
917,527
917,528
u170301438
cpp
p03107
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define rc(x) return cout << x << endl, 0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define sz size() #define x first #define y second #define pi pair<int, int> #define pii pair<pi, pi> #define vi vector<int> #define PI 3.14159265 const ll mod = 998244353; int ans, vf = -1, l[100001]; string s; int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> s; for (int i = 0; i < s.size(); i++) { if (vf != -1 && s[l[vf]] == s[i]) { ans++; vf--; } else l[++vf] = i; } cout << ans * 2; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define rc(x) return cout << x << endl, 0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define sz size() #define x first #define y second #define pi pair<int, int> #define pii pair<pi, pi> #define vi vector<int> #define PI 3.14159265 const ll mod = 998244353; int ans, vf = -1, l[100001]; string s; int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> s; for (int i = 0; i < s.size(); i++) { if (vf != -1 && s[l[vf]] != s[i]) { ans++; vf--; } else l[++vf] = i; } cout << ans * 2; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,529
917,530
u392848063
cpp
p03107
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define rc(x) return cout << x << endl, 0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define sz size() #define x first #define y second #define int ll #define pi pair<int, int> #define pii pair<pi, pi> #define vi vector<int> #define in insert #define er erase #define fd find string s; int ans1, ans2; int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> s; for (int i = 0; i < s.sz; i++) { if (s[i] = '0') ans1++; else ans2++; } cout << 2 * min(ans1, ans2); }
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define rc(x) return cout << x << endl, 0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define sz size() #define x first #define y second #define int ll #define pi pair<int, int> #define pii pair<pi, pi> #define vi vector<int> #define in insert #define er erase #define fd find string s; int ans1, ans2; int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> s; for (int i = 0; i < s.sz; i++) { if (s[i] == '0') ans1++; else ans2++; } cout << 2 * min(ans1, ans2); }
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
917,531
917,532
u392848063
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; deque<int> ar; for (int i = 0; i < s.length(); i++) { int m = ar.size(); if (!ar.empty() && ar[m] ^ (s[i] - '0')) { ar.pop_back(); ans += 2; } else ar.push_back(s[i] - '0'); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 0; deque<int> ar; for (int i = 0; i < s.length(); i++) { int m = ar.size() - 1; if (!ar.empty() && (ar[m] ^ (s[i] - '0'))) { ar.pop_back(); ans += 2; } else ar.push_back(s[i] - '0'); } cout << ans << endl; }
[ "control_flow.branch.if.condition.change" ]
917,533
917,534
u723145084
cpp
p03107
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; // find_by_order gives kth-largest element // order_of_key gives the number of items in the set that are strictly smaller!! // OT.find_by_order(k-1) // typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define db(x) cerr << #x << "=" << x << endl #define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl #define db3(x, y, z) \ cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \ << endl #define db4(x, y, z, w) \ cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \ << "," << #w << "=" << w << endl #define ll long long #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define mp make_pair #define X first #define Y second #define sz(x) (int)((x).size()) #define pii pair<int, int> #define MOD (ll)(998244353) #define rep(i, n) for (int i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define repD(i, a, n) for (int i = a; i >= (n); --i) #define trav(a, x) for (auto &a : x) typedef vector<int> vi; #define inf (ll)(1e18) #define double long double #define int long long ////////////////////// const int N = 2005; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string st; cin >> st; int c0, c1; rep(i, sz(st)) { if (st[i] == '0') c0++; else c1++; } cout << 2 * min(c0, c1) << '\n'; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; // find_by_order gives kth-largest element // order_of_key gives the number of items in the set that are strictly smaller!! // OT.find_by_order(k-1) // typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define db(x) cerr << #x << "=" << x << endl #define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl #define db3(x, y, z) \ cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \ << endl #define db4(x, y, z, w) \ cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \ << "," << #w << "=" << w << endl #define ll long long #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define mp make_pair #define X first #define Y second #define sz(x) (int)((x).size()) #define pii pair<int, int> #define MOD (ll)(998244353) #define rep(i, n) for (int i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define repD(i, a, n) for (int i = a; i >= (n); --i) #define trav(a, x) for (auto &a : x) typedef vector<int> vi; #define inf (ll)(1e18) #define double long double #define int long long ////////////////////// const int N = 2005; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string st; cin >> st; int c0 = 0, c1 = 0; rep(i, sz(st)) { if (st[i] == '0') c0++; else c1++; } cout << 2 * min(c0, c1) << '\n'; }
[ "variable_declaration.value.change" ]
917,535
917,536
u325189601
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int len = s.size(); int i = 0; while (i < s.size() - 1) { if (s.at(i) != s.at(i + 1)) { s.erase(s.begin() + i, s.begin() + i + 2); if (s.size() != 0) break; if (i != 0) i--; } else { i++; } } int ans = len - s.size(); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int len = s.size(); int i = 0; while (i < s.size() - 1) { if (s.at(i) != s.at(i + 1)) { s.erase(s.begin() + i, s.begin() + i + 2); if (s.size() == 0) break; if (i != 0) i--; } else { i++; } } int ans = len - s.size(); cout << ans << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,543
917,544
u303454114
cpp
p03107
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = int64_t; using ull = uint64_t; constexpr ll INF = 1e+15; void solve(istream &cin) { string s; cin >> s; if (!cin) return; ll ans = min(count(s.begin(), s.end(), '0'), count(s.begin(), s.end(), '1')); cout << ans << endl; } int main(int argc, char *argv[]) { cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(16) << scientific; #ifdef DEBUG cerr << "DEBUG MODE" << endl; string test_cases = "test.txt"; auto fs = fstream(test_cases, fstream::in); while (fs) { solve(fs); } #else solve(cin); #endif return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = int64_t; using ull = uint64_t; constexpr ll INF = 1e+15; void solve(istream &cin) { string s; cin >> s; if (!cin) return; ll ans = 2 * min(count(s.begin(), s.end(), '0'), count(s.begin(), s.end(), '1')); cout << ans << endl; } int main(int argc, char *argv[]) { cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(16) << scientific; #ifdef DEBUG cerr << "DEBUG MODE" << endl; string test_cases = "test.txt"; auto fs = fstream(test_cases, fstream::in); while (fs) { solve(fs); } #else solve(cin); #endif return 0; }
[ "assignment.change" ]
917,547
917,548
u896838289
cpp
p03107
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int out = 0; for (int i = 1; i < s.size(); i++) { if ((s[i - 1] == '0' && s[i] == '1') || (s[i - 1] == '1' && s[i] == '1')) { s.erase(i - 1, 2); out += 2; i -= 2; } } cout << out << endl; }
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int out = 0; for (int i = 1; i < s.size(); i++) { if ((s[i - 1] == '0' && s[i] == '1') || (s[i - 1] == '1' && s[i] == '0')) { s.erase(i - 1, 2); out += 2; i -= 2; } } cout << out << endl; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
917,553
917,554
u598869726
cpp
p03107
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int cnt0 = 0; int cnt1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') cnt0++; if (s[i] == '1') cnt1++; } cout << min(cnt0, cnt1) << endl; }
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int cnt0 = 0; int cnt1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') cnt0++; if (s[i] == '1') cnt1++; } cout << min(cnt0, cnt1) * 2 << endl; }
[ "expression.operation.binary.add" ]
917,555
917,556
u032189172
cpp
p03107
#include "bits/stdc++.h" #define in std::cin #define out std::cout #define rep(i, N) for (LL i = 0; i < N; ++i) typedef long long int LL; int main() { std::string S; LL cnt = 0; rep(i, S.length()) if (S[i] == '0')++ cnt; out << std::min<LL>(cnt, S.length() - cnt) * 2 << std::endl; }
#include "bits/stdc++.h" #define in std::cin #define out std::cout #define rep(i, N) for (LL i = 0; i < N; ++i) typedef long long int LL; int main() { std::string S; in >> S; LL cnt = 0; rep(i, S.length()) if (S[i] == '0')++ cnt; out << std::min<LL>(cnt, S.length() - cnt) * 2 << std::endl; }
[]
917,557
917,558
u660613376
cpp
p03107
// ABC120_C #include <algorithm> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { // input(sunippets: inpv, inpn) string S; cin >> S; // calculation // 最終的に 0, 1 どちらかだけになる ll zero = 0, one = 0; for (ll i = 1; i < S.size(); ++i) { if (S[i] == '0') ++zero; else ++one; } cout << min(zero, one) * 2 << "\n"; return 0; }
// ABC120_C #include <algorithm> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { // input(sunippets: inpv, inpn) string S; cin >> S; // calculation // 最終的に 0, 1 どちらかだけになる ll zero = 0, one = 0; for (ll i = 0; i < S.size(); ++i) { if (S[i] == '0') ++zero; else ++one; } cout << min(zero, one) * 2 << "\n"; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
917,561
917,562
u870998297
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; size_t cnt = count(s.begin(), s.end(), '1'); cout << min(cnt, s.size() - cnt); }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; size_t cnt = count(s.begin(), s.end(), '1'); cout << min(cnt, s.size() - cnt) * 2; }
[ "expression.operation.binary.add" ]
917,565
917,566
u873627575
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n_0 = 0, n_1 = 1; for (char c : s) { if (c == '0') n_0 += 1; else n_1 += 1; } cout << 2 * min(n_0, n_1) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n_0 = 0, n_1 = 0; for (char c : s) { if (c == '0') n_0 += 1; else n_1 += 1; } cout << 2 * min(n_0, n_1) << endl; }
[ "literal.number.change", "variable_declaration.value.change" ]
917,575
917,576
u227951688
cpp
p03107
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string S; cin >> S; int zero = 0, one = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') zero++; else one++; } cout << min(zero, one) << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string S; cin >> S; int zero = 0, one = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') zero++; else one++; } cout << min(zero, one) * 2 << endl; }
[ "expression.operation.binary.add" ]
917,577
917,578
u879581330
cpp
p03107
#include <cstdio> #include <iostream> #include <queue> #include <stack> #include <vector> using namespace std; int main(int argc, const char *argv[]) { string s; cin >> s; int zero = 0, one = 0; for (int i = 0; i < s.size(); i++) { if (s.at(i) == '0') { zero++; } else { one++; } cout << 2 * min(zero, one); } }
#include <cstdio> #include <iostream> #include <queue> #include <stack> #include <vector> using namespace std; int main(int argc, const char *argv[]) { string s; cin >> s; int zero = 0, one = 0; for (int i = 0; i < s.size(); i++) { if (s.at(i) == '0') { zero++; } else { one++; } } cout << 2 * min(zero, one); }
[]
917,581
917,582
u477204532
cpp
p03107
#include <algorithm> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { ll a, b, c, d, e, k, l, m, n, o = 0, p, q, x, y, z, max1 = 0, ans, o0 = 0, o1 = 0; string s, t, u; cin >> s; for (ll i = 0; i < s.size(); i++) { if (s[i] == 0) { o0++; } else o1++; } cout << min(o1, o0) << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { ll a, b, c, d, e, k, l, m, n, o = 0, p, q, x, y, z, max1 = 0, ans, o0 = 0, o1 = 0; string s, t, u; cin >> s; for (ll i = 0; i < s.size(); i++) { if (s[i] == '0') { o0++; } else o1++; } cout << min(o1, o0) * 2 << endl; }
[ "control_flow.branch.if.condition.change" ]
917,589
917,590
u953532675
cpp
p03107
#include <algorithm> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { ll a, b, c, d, e, k, l, m, n, o = 0, p, q, x, y, z, max1 = 0, ans, o0 = 0, o1 = 0; string s, t, u; cin >> s; for (ll i = 0; i < s.size(); i++) { if (s[i] == 0) { o0++; } else o1++; } cout << max(o1, o0) << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; using ll = long long; int main() { ll a, b, c, d, e, k, l, m, n, o = 0, p, q, x, y, z, max1 = 0, ans, o0 = 0, o1 = 0; string s, t, u; cin >> s; for (ll i = 0; i < s.size(); i++) { if (s[i] == '0') { o0++; } else o1++; } cout << min(o1, o0) * 2 << endl; }
[ "control_flow.branch.if.condition.change", "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
917,591
917,590
u953532675
cpp
p03107
#include <iostream> #include <string> using namespace std; int main() { char S[100000]; int i, A = 0, B = 0; cin >> S; for (i = 0; i < 100000; i++) { if (S[i] == '1') A += 1; else if (S[i] == '0') B += 1; } if (A > B) cout << B * 2 << endl; else cout << A * 2 << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { char S[100000]; int i, A = 0, B = 0; cin >> S; for (i = 0; i < 100000; i++) { if (S[i] == '1') A += 1; else if (S[i] == '0') B += 1; else break; } if (A > B) cout << B * 2 << endl; else cout << A * 2 << endl; return 0; }
[ "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add" ]
917,597
917,598
u839537391
cpp
p03107
#include <iostream> using namespace std; int main() { char ch; int c[2] = {0, 0}; while (cin >> ch) { c[ch - '0']++; } cout << (c[0] < c[1] ? c[0] : c[1]) << endl; return 0; }
#include <iostream> using namespace std; int main() { char ch; int c[2] = {0, 0}; while (cin >> ch) { c[ch - '0']++; } cout << 2 * (c[0] < c[1] ? c[0] : c[1]) << endl; return 0; }
[ "expression.operation.binary.add" ]
917,602
917,603
u587665681
cpp
p03107
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string S; cin >> S; int n = S.length(), num_0 = 0, num_1 = 0; for (int i = 0; i < n; i++) { if (S[i]) num_1++; else num_0++; } cout << 2 * min(num_1, num_0) << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string S; cin >> S; int n = S.length(), num_0 = 0, num_1 = 0; for (int i = 0; i < n; i++) { if (S[i] == '1') num_1++; else num_0++; } cout << 2 * min(num_1, num_0) << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
917,608
917,609
u124314853
cpp
p03107
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define all(v) (v).begin(), (v).end() #define fi first #define se second typedef vector<int> vint; typedef pair<int, int> pint; typedef vector<pint> vpint; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } string S; signed main() { cin >> S; int a = count(all(S), '0'); int b = S.size() - a; cout << abs(a - b) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define pb push_back #define all(v) (v).begin(), (v).end() #define fi first #define se second typedef vector<int> vint; typedef pair<int, int> pint; typedef vector<pint> vpint; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } string S; signed main() { cin >> S; int a = count(all(S), '0'); int b = S.size() - a; cout << min(a, b) * 2 << endl; return 0; }
[ "identifier.change", "call.function.change", "io.output.change" ]
917,622
917,623
u685892567
cpp
p03107
#include <iostream> int main() { std::string S; std::cin >> S; int count0 = 0, count1 = 0; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') { count0++; } else { count1++; } } std::cout << std::min(count0, count1); return 0; }
#include <iostream> int main() { std::string S; std::cin >> S; int count0 = 0, count1 = 0; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') { count0++; } else { count1++; } } std::cout << std::min(count0, count1) * 2; return 0; }
[ "expression.operation.binary.add" ]
917,630
917,631
u261279477
cpp
p03107
#include <iostream> #include <math.h> #include <string> using namespace std; int main() { string l; cin >> l; int a = 0; int b = 0; for (int i = 0; i < l.size(); i++) { if (l[i] == '0') { a++; } else { b++; } } cout << min(a, b) << endl; return 0; }
#include <iostream> #include <math.h> #include <string> using namespace std; int main() { string l; cin >> l; int a = 0; int b = 0; for (int i = 0; i < l.size(); i++) { if (l[i] == '0') { a++; } else { b++; } } cout << 2 * min(a, b) << endl; return 0; }
[ "expression.operation.binary.add" ]
917,637
917,638
u023751250
cpp
p03107
#include <iostream> #include <math.h> #include <string> using namespace std; int main() { string l; cin >> l; int a = 0; int b = 0; for (int i = 0; i < l.size(); i++) { if (l[i] == '0') { a++; } else { b++; } } cout << max(a, b) << endl; return 0; }
#include <iostream> #include <math.h> #include <string> using namespace std; int main() { string l; cin >> l; int a = 0; int b = 0; for (int i = 0; i < l.size(); i++) { if (l[i] == '0') { a++; } else { b++; } } cout << 2 * min(a, b) << endl; return 0; }
[ "identifier.replace.remove", "literal.replace.add", "io.output.change" ]
917,639
917,638
u023751250
cpp
p03107
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <vector> using namespace std; int main() { string a; cin >> a; vector<char> vec; for (int i = 0; i < a.size(); i++) { if (!vec.empty() && a[i] == vec.back()) { vec.pop_back(); } else vec.push_back(a[i]); } cout << a.size() - vec.size() << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <vector> using namespace std; int main() { string a; cin >> a; vector<char> vec; for (int i = 0; i < a.size(); i++) { if (!vec.empty() && a[i] != vec.back()) { vec.pop_back(); } else vec.push_back(a[i]); } cout << a.size() - vec.size() << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,648
917,649
u957188497
cpp
p03107
#include <algorithm> #include <iostream> #include <stack> #include <string> #define int long long using namespace std; signed main() { string s; cin >> s; stack<char> st; for (int i = 0; i < s.size(); i++) { if (st.size() == 0 || st.top() != s[i]) st.push(s[i]); else st.pop(); } cout << s.size() - st.size() << endl; }
#include <algorithm> #include <iostream> #include <stack> #include <string> #define int long long using namespace std; signed main() { string s; cin >> s; stack<char> st; for (int i = 0; i < s.size(); i++) { if (st.size() == 0 || st.top() == s[i]) st.push(s[i]); else st.pop(); } cout << s.size() - st.size() << endl; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,652
917,653
u141968173
cpp
p03107
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; int a = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') a++; else b++; } cout << min(a, b) << endl; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; int a = 0, b = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '0') a++; else b++; } cout << 2 * min(a, b) << endl; return 0; }
[ "expression.operation.binary.add" ]
917,660
917,661
u189870205
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { int m, n, i; int x0 = 0; // number of 0 int x1 = 0; // number of 1 string str; cin >> str; m = str.size(); // m=str long for (i = 0; i < m; i++) { n = str[i]; // n is ascii // cout << n << " "; if (n == 48) { x0 = x0 + 1; } else if (n == 49) { x1 = x1 + 1; } } if (x0 >= x1) { cout << x1; } else { cout << x0; } // cout << "\n "<< m; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int m, n, i; int x0 = 0; // number of 0 int x1 = 0; // number of 1 string str; cin >> str; m = str.size(); // m=str long for (i = 0; i < m; i++) { n = str[i]; // n is ascii // cout << n << " "; if (n == 48) { x0 = x0 + 1; } else if (n == 49) { x1 = x1 + 1; } } if (x0 >= x1) { cout << x1 * 2; } else { cout << x0 * 2; } // cout << "\n "<< m; return 0; }
[ "expression.operation.binary.add" ]
917,662
917,663
u312470849
cpp
p03107
#include <iostream> #include <stack> using namespace std; string s; int sum = 0; stack<int> sta; int main() { cin >> s; sta.push(s[0]); for (int i = 1; i < s.length(); i++) { if (sta.empty() && sta.top() != s[i]) { sta.pop(); sum += 2; } else sta.push(s[i]); } cout << sum; return 0; }
#include <iostream> #include <stack> using namespace std; string s; int sum = 0; stack<int> sta; int main() { cin >> s; sta.push(s[0]); for (int i = 1; i < s.length(); i++) { if (!sta.empty() && sta.top() != s[i]) { sta.pop(); sum += 2; } else sta.push(s[i]); } cout << sum; return 0; }
[ "expression.operation.unary.add", "control_flow.branch.if.condition.change" ]
917,664
917,665
u808738521
cpp
p03107
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <set> #include <stdbool.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; int main(void) { string str; cin >> str; int c0 = count(str.cbegin(), str.cend(), '0'); int c1 = count(str.cbegin(), str.cend(), '1'); cout << (c0 < c1 ? c0 : c1) << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <set> #include <stdbool.h> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; int main(void) { string str; cin >> str; int c0 = count(str.cbegin(), str.cend(), '0'); int c1 = count(str.cbegin(), str.cend(), '1'); cout << (2 * (c0 < c1 ? c0 : c1)) << endl; return 0; }
[]
917,666
917,667
u583248280
cpp
p03107
#include <iostream> #include <math.h> #include <stack> #include <stdio.h> #include <string> #include <vector> int main() { std::stack<char> st; std::string s; std::cin >> s; int cnt = 0; for (auto &it : s) { if (st.size() && st.top() == it) { st.pop(); cnt++; } else { st.push(it); } } std::cout << cnt * 2; return 0; }
#include <iostream> #include <math.h> #include <stack> #include <stdio.h> #include <string> #include <vector> int main() { std::stack<char> st; std::string s; std::cin >> s; int cnt = 0; for (auto &it : s) { if (st.size() && st.top() != it) { st.pop(); cnt++; } else { st.push(it); } } std::cout << cnt * 2; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,668
917,669
u228807040
cpp
p03107
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 using ll = long long; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') { r++; } else { b++; } } cout << min(r, b); return 0; }
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 using ll = long long; int main() { string S; cin >> S; int r = 0, b = 0; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') { r++; } else { b++; } } cout << min(r, b) * 2; return 0; }
[ "expression.operation.binary.add" ]
917,688
917,689
u590088474
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N, count, nocount; N = S.size(); count = 0, nocount = 0; for (int i = 0; i < N; i++) { if (S[i] == '0') { count++; } else { nocount++; } } cout << max(count, nocount) - min(count, nocount) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N, count, nocount; N = S.size(); count = 0, nocount = 0; for (int i = 0; i < N; i++) { if (S[i] == '0') { count++; } else { nocount++; } } cout << N - (max(count, nocount) - min(count, nocount)) << endl; }
[ "expression.operation.binary.add" ]
917,693
917,694
u902787159
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int i1 = 0, i2 = 0; for (int i = 0; i < s.length(); i++) if (s[i] == '1') i1++; else i2++; cout << 2 * (max(i1, i2)); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int i1 = 0, i2 = 0; for (int i = 0; i < s.length(); i++) if (s[i] == '1') i1++; else i2++; cout << 2 * (min(i1, i2)); return 0; }
[ "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
917,695
917,696
u803994812
cpp
p03107
#include "bits/stdc++.h" using namespace std; #define COUNTOF(array) (sizeof(array) / sizeof(array[0])) #define OUT(P) cout << (P) << endl #define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl #define PRINT_ARRAY(P) \ for (int i = 0; i < P.size(); i++) \ cout << P[i] << endl; #define PRINT_ARRAY_INLINE(P) \ do { \ for (int i = 0; i < P.size(); i++) \ cout << P[i] << " "; \ cout << endl; \ } while (0) #define PRINT_ARRAY_WITH_LABEL(L, P) \ do { \ cout << L << ": "; \ PRINT_ARRAY_INLINE(P); \ cout << endl; \ } while (0) typedef long long ll; int sum_digits(int num); template <class T> vector<T> copy_vector(vector<T> vec); int gcd(int a, int b); #define RED '0' #define BLUE '1' void exe_stack(int *count, int *num_stack, int *other_num_stack) { if (*num_stack > 0) { *num_stack--; *count += 2; } else { *other_num_stack += 1; } } int main() { string s; cin >> s; int n = s.size(); int count = 0; int stacked_red = 0; int stacked_blue = 0; for (int i = 0; i < n; i++) { if (s[i] == RED) { exe_stack(&count, &stacked_blue, &stacked_red); } else { // BLUEのとき exe_stack(&count, &stacked_red, &stacked_blue); } } cout << count << endl; return 0; } /******************************/ /***** DECRARED FUNCTIONS *****/ /******************************/ int sum_digits(int num) { int rtn = 0; while (num != 0) { int tmp = num % 10; rtn += tmp; num /= 10; } return rtn; } // int sum_digits(int num) { // int rtn = 0; // string num_str = to_string(num); // for(int i=0; i<num_str.size(); i++) { // rtn += num_str[i] - '0'; // } // return rtn; //} // vectorのコピー template <class T> vector<T> copy_vector(vector<T> vec) { vector<T> rtn; rtn.reserve(vec.size()); copy(vec.begin(), vec.end(), back_inserter(rtn)); return rtn; } // ユークリウッドの互除法 int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); }
#include "bits/stdc++.h" using namespace std; #define COUNTOF(array) (sizeof(array) / sizeof(array[0])) #define OUT(P) cout << (P) << endl #define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl #define PRINT_ARRAY(P) \ for (int i = 0; i < P.size(); i++) \ cout << P[i] << endl; #define PRINT_ARRAY_INLINE(P) \ do { \ for (int i = 0; i < P.size(); i++) \ cout << P[i] << " "; \ cout << endl; \ } while (0) #define PRINT_ARRAY_WITH_LABEL(L, P) \ do { \ cout << L << ": "; \ PRINT_ARRAY_INLINE(P); \ cout << endl; \ } while (0) typedef long long ll; int sum_digits(int num); template <class T> vector<T> copy_vector(vector<T> vec); int gcd(int a, int b); #define RED '0' #define BLUE '1' void exe_stack(int *count, int *num_stack, int *other_num_stack) { if (*num_stack > 0) { (*num_stack)--; *count += 2; } else { (*other_num_stack)++; } } int main() { string s; cin >> s; int n = s.size(); int count = 0; int stacked_red = 0; int stacked_blue = 0; for (int i = 0; i < n; i++) { if (s[i] == RED) { exe_stack(&count, &stacked_blue, &stacked_red); } else { // BLUEのとき exe_stack(&count, &stacked_red, &stacked_blue); } } cout << count << endl; return 0; } /******************************/ /***** DECRARED FUNCTIONS *****/ /******************************/ int sum_digits(int num) { int rtn = 0; while (num != 0) { int tmp = num % 10; rtn += tmp; num /= 10; } return rtn; } // int sum_digits(int num) { // int rtn = 0; // string num_str = to_string(num); // for(int i=0; i<num_str.size(); i++) { // rtn += num_str[i] - '0'; // } // return rtn; //} // vectorのコピー template <class T> vector<T> copy_vector(vector<T> vec) { vector<T> rtn; rtn.reserve(vec.size()); copy(vec.begin(), vec.end(), back_inserter(rtn)); return rtn; } // ユークリウッドの互除法 int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); }
[]
917,711
917,712
u026686258
cpp
p03107
#include <cmath> #include <iostream> using namespace std; int a, b; string s; main() { cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') a++; else b++; } cout << abs(a - b) << endl; }
#include <cmath> #include <iostream> using namespace std; int a, b; string s; main() { cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') a++; else b++; } cout << s.size() - abs(a - b) << endl; }
[ "expression.operation.binary.add" ]
917,723
917,724
u572456887
cpp
p03107
#include <cmath> #include <iostream> #include <string> using namespace std; int main() { string S; cin >> S; int N = S.length(); int red = 0; int blue = 0; for (int i = 0; i < N; i++) { if (S[i] == 0) { red++; } else { blue++; } } int ans = min(red, blue) * 2; cout << ans << endl; return 0; }
#include <cmath> #include <iostream> #include <string> using namespace std; int main() { string S; cin >> S; int N = S.length(); int red = 0; int blue = 0; for (int i = 0; i < N; i++) { if (S[i] == '0') { red++; } else { blue++; } } int ans = min(red, blue) * 2; cout << ans << endl; return 0; }
[ "control_flow.branch.if.condition.change" ]
917,730
917,731
u828664775
cpp
p03107
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, a, b) for (ll i = (a); i <= (b); i++) #define REP(i, n) FOR(i, 0, n - 1) #define NREP(i, n) FOR(i, 1, n) using ll = long long; using pii = pair<int, int>; using piii = pair<pii, pii>; const int dx[4] = {0, -1, 1, 0}; const int dy[4] = {-1, 0, 0, 1}; const int INF = 1e9 + 7; int gcd(int x, int y) { if (x < y) swap(x, y); if (y == 0) return x; return gcd(y, x % y); } template <class T1, class T2> void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <class T1, class T2> void chmax(T1 &a, T2 b) { if (a < b) a = b; } template <class T> void Add(T &a, const T &b, const T &mod = 1000000007) { int val = ((a % mod) + (b % mod)) % mod; if (val < 0) { val += mod; } a = val; } //////////////////////////////////////// int main() { string S; int count = 0; cin >> S; vector<int> V; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') { V.push_back(0); } else { V.push_back(1); } } while (true) { bool can = false; if (V.size() == 1) break; for (int i = 0; i < V.size() - 1; ++i) { if (V[i] != V[i + 1]) { can = true; V.erase(V.begin() + i + 1); V.erase(V.begin() + i); count += 2; break; } } if (!can) break; } cout << count << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define FOR(i, a, b) for (ll i = (a); i <= (b); i++) #define REP(i, n) FOR(i, 0, n - 1) #define NREP(i, n) FOR(i, 1, n) using ll = long long; using pii = pair<int, int>; using piii = pair<pii, pii>; const int dx[4] = {0, -1, 1, 0}; const int dy[4] = {-1, 0, 0, 1}; const int INF = 1e9 + 7; int gcd(int x, int y) { if (x < y) swap(x, y); if (y == 0) return x; return gcd(y, x % y); } template <class T1, class T2> void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <class T1, class T2> void chmax(T1 &a, T2 b) { if (a < b) a = b; } template <class T> void Add(T &a, const T &b, const T &mod = 1000000007) { int val = ((a % mod) + (b % mod)) % mod; if (val < 0) { val += mod; } a = val; } //////////////////////////////////////// int main() { string S; int count = 0; cin >> S; vector<int> V; for (int i = 0; i < S.size(); ++i) { if (S[i] == '0') { V.push_back(0); } else { V.push_back(1); } } while (true) { bool can = false; if (V.size() == 0) break; for (int i = 0; i < V.size() - 1; ++i) { if (V[i] != V[i + 1]) { can = true; V.erase(V.begin() + i + 1); V.erase(V.begin() + i); count += 2; break; } } if (!can) break; } cout << count << endl; return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
917,732
917,733
u406158207
cpp
p03107
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define int long long #define vec(a, n) vector<int>(a)((n)) #define Vec(a, n) vector<string>(a)((n)) #define twovec(a, n, m) vector<vector<int>> a(n, vector<int>(m, 0)) #define Twovec(a, n, m) vector<vector<double>> a(n, vector<double>(m, 0)) #define P pair<int, int> #define All(a) (a).begin(), (a).end() #define Sort(a) sort(All(a)) #define Reverse(a) reverse(All(a)) #define PQ(n) priority_queue<P, vector<P>, greater<P>>(n) #define pq(n) priority_queue<int>(n) using namespace std; int max_int = 1000000007; void Debug(auto a); int nibutan(auto a, auto b); class Modulo { public: int val; static const int mod = 1e9 + 7; vector<int> factable = {1}; vector<int> invtable = {1}; int pro(int x, int y) { return ((x % mod) * (y % mod)) % mod; } int sum(int x, int y) { return ((x % mod) + (y % mod)) % mod; } int dif(int x, int y) { int d = ((x % mod) - (y % mod)) % mod; if (d >= 0) { return d; } else { return d + mod; } } int quo(int x, int y) { return pro(x, pow(y, mod - 2)); } int pow(int x, int y) { if (y <= 0) { return 1; } if (y % 2 == 0) { int d = pow(x, y / 2); return ((d % mod) * (d % mod)) % mod; } else { return (x * pow(x, y - 1)) % mod; } } void operator=(int n) { this->val = n % mod; } int operator+(int n) { return sum(this->val, n); } int operator-(int n) { return dif(this->val, n); } int operator*(int n) { return pro(this->val, n); } int operator/(int n) { return quo(this->val, n); } void operator+=(int n) { this->val = sum(this->val, n); } void operator-=(int n) { this->val = dif(this->val, n); } void operator*=(int n) { this->val = pro(this->val, n); } void operator/=(int n) { this->val = quo(this->val, n); } int fac(int x) { // x! mod mod if (factable.size() <= x) { int s = factable.size(); FOR(i, s, x + 1) { factable.push_back(pro(i, factable.back())); invtable.push_back(quo(1, factable.back())); } } if (x < 0) return 1; else return factable[x]; } int facinv(int x) { if (invtable.size() <= x) { int s = invtable.size(); FOR(i, s, x + 1) { factable.push_back(pro(i, factable.back())); invtable.push_back(quo(1, factable.back())); } } if (x < 0) return 1; else return invtable[x]; } int com(int x, int y) { // xCy mod mod = x!/((x-y)!*y!) mod mod if (x - y < y) return com(x, x - y); return pro(fac(x), pro(facinv(x - y), facinv(y))); } }; signed main() { string s; cin >> s; int zero = 0, iti = 1; REP(i, s.size()) { if (s[i] == '0') zero++; else iti++; } cout << min(zero, iti) * 2 << endl; return 0; } void Debug(auto a) { cout << "{ "; for (auto b : a) { cout << b << " "; } cout << "}" << endl; } int nibutan(auto a, auto b) { int x = lower_bound(All(a), b) - a.begin(); return x - 1; }
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define int long long #define vec(a, n) vector<int>(a)((n)) #define Vec(a, n) vector<string>(a)((n)) #define twovec(a, n, m) vector<vector<int>> a(n, vector<int>(m, 0)) #define Twovec(a, n, m) vector<vector<double>> a(n, vector<double>(m, 0)) #define P pair<int, int> #define All(a) (a).begin(), (a).end() #define Sort(a) sort(All(a)) #define Reverse(a) reverse(All(a)) #define PQ(n) priority_queue<P, vector<P>, greater<P>>(n) #define pq(n) priority_queue<int>(n) using namespace std; int max_int = 1000000007; void Debug(auto a); int nibutan(auto a, auto b); class Modulo { public: int val; static const int mod = 1e9 + 7; vector<int> factable = {1}; vector<int> invtable = {1}; int pro(int x, int y) { return ((x % mod) * (y % mod)) % mod; } int sum(int x, int y) { return ((x % mod) + (y % mod)) % mod; } int dif(int x, int y) { int d = ((x % mod) - (y % mod)) % mod; if (d >= 0) { return d; } else { return d + mod; } } int quo(int x, int y) { return pro(x, pow(y, mod - 2)); } int pow(int x, int y) { if (y <= 0) { return 1; } if (y % 2 == 0) { int d = pow(x, y / 2); return ((d % mod) * (d % mod)) % mod; } else { return (x * pow(x, y - 1)) % mod; } } void operator=(int n) { this->val = n % mod; } int operator+(int n) { return sum(this->val, n); } int operator-(int n) { return dif(this->val, n); } int operator*(int n) { return pro(this->val, n); } int operator/(int n) { return quo(this->val, n); } void operator+=(int n) { this->val = sum(this->val, n); } void operator-=(int n) { this->val = dif(this->val, n); } void operator*=(int n) { this->val = pro(this->val, n); } void operator/=(int n) { this->val = quo(this->val, n); } int fac(int x) { // x! mod mod if (factable.size() <= x) { int s = factable.size(); FOR(i, s, x + 1) { factable.push_back(pro(i, factable.back())); invtable.push_back(quo(1, factable.back())); } } if (x < 0) return 1; else return factable[x]; } int facinv(int x) { if (invtable.size() <= x) { int s = invtable.size(); FOR(i, s, x + 1) { factable.push_back(pro(i, factable.back())); invtable.push_back(quo(1, factable.back())); } } if (x < 0) return 1; else return invtable[x]; } int com(int x, int y) { // xCy mod mod = x!/((x-y)!*y!) mod mod if (x - y < y) return com(x, x - y); return pro(fac(x), pro(facinv(x - y), facinv(y))); } }; signed main() { string s; cin >> s; int zero = 0, iti = 0; REP(i, s.size()) { if (s[i] == '0') zero++; else iti++; } cout << min(zero, iti) * 2 << endl; return 0; } void Debug(auto a) { cout << "{ "; for (auto b : a) { cout << b << " "; } cout << "}" << endl; } int nibutan(auto a, auto b) { int x = lower_bound(All(a), b) - a.begin(); return x - 1; }
[ "literal.number.change", "variable_declaration.value.change" ]
917,736
917,737
u607741489
cpp
p03107
#include <algorithm> #include <iostream> #include <math.h> #include <numeric> #include <string> #include <vector> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<ULL> VULL; class MYCP { public: //数値を区切って文字列にする static string MakeString_LongLong(vector<long long> const &numbers, string const &str) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += str; result += to_string(numbers[i]); } return result; } //空白で区切る為のオーバーロード static string MakeString_LongLong(vector<long long> const &numbers) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += " "; result += to_string(numbers[i]); } return result; } //文字列の配列を改行を挟んでまとめる static string MakeString_VectorString(vector<string> const &str) { string result = ""; for (long long i = 0; i < str.size(); i++) { result += str[i] + "\n"; } return result; } //文字列を必要な個数だけ読み取る static vector<string> MyReadLineSplit(LL n) { vector<string> str(n); for (long long i = 0; i < n; i++) { std::cin >> str[i]; } return str; } //数値を必要な個数だけ読み取る static vector<long long> ReadInts(long long number) { vector<long long> a(number); for (int i = 0; i < number; i++) { std::cin >> a[i]; } return a; } //渡された自然数が素数ならtureを返す static bool PrimeCheck_Int(long long number) { if (number < 2) return false; for (ULL i = 2; i * i <= number; i++) { if (number % i == 0) return false; } return true; } //渡された数値以下の素数表を作る static vector<long long> MakePrimeList(long long n) { vector<long long> list; LL i, j, p; bool flag; for (i = 2; i <= n; i++) { flag = true; for (j = 0; j < list.size(); j++) { if (!(list[j] * list[j] <= i)) break; if (i % list[j] == 0) { flag = false; break; } } if (flag) list.push_back(i); } return list; } //文字列の分割 static vector<string> split(string const &str, char sep) { vector<std::string> v; // 分割結果を格納するベクター auto first = str.begin(); // テキストの最初を指すイテレータ while (first != str.end()) { // テキストが残っている間ループ auto last = first; // 分割文字列末尾へのイテレータ while (last != str.end() && *last != sep) // 末尾 or セパレータ文字まで進める last++; v.push_back(string(first, last)); // 分割文字を出力 if (last != str.end()) last++; first = last; // 次の処理のためにイテレータを設定 } return v; } //合計を求める static LL Sum(vector<LL> a) { LL i, sum = 0; for (i = 0; i < a.size(); i++) { sum += a[i]; } return sum; } //小文字ならtrueを返す static bool Komoji(char a) { if (a >= 'a' && a <= 'z') return true; return false; } //大文字ならtrueを返す static bool Oomoji(char a) { if (a >= 'A' && a <= 'Z') return true; return false; } static LL GreatestCommonFactor(LL a, LL b) { LL temp; if (a < b) { temp = b; b = a; a = temp; } while (true) { temp = a % b; a = b; b = temp; if (b == 0) break; } return a; } static LL LeastCommonMultiple(LL a, LL b) { return (a / GreatestCommonFactor(a, b)) * b; } }; //累積和を求めるクラス class Syakutori { private: vector<LL> list; public: void MakeArray(vector<LL> data) { LL i; list = data; list.push_back(0); list[0] = 0; for (i = 1; i < list.size(); i++) { list[i] = list[i - 1] + data[i - 1]; } } LL Sum(LL start, LL end) { if (end < start) { cout << "startがendより大きいです"; return 0; } if (start < 0 || end >= list.size()) { cout << "範囲が異常"; return 0; } return list[end] - list[start]; } }; string strnum = "0123456789"; string alpS = "abcdefghijklmnopqrstuvwxyz"; string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int sizealp = (int)(alpS.size()); int mod = 1e9 + 7; #define SORT(x) sort(x.begin(), x.end()) #define REVE(x) reverse(x.begin(), x.end()) #define rep(i, n) for (int i = 0; i < n; i++) #define COUT(x) cout << x << endl double pai = 3.1415926535; string atc = "atcoder"; typedef pair<long long, long long> data_t; int main(void) { int count = 0; int sum = 0; int flag = 0; string s; cin >> s; int count0 = 0, count1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 0) count0++; else count1++; } cout << min(count0, count1) * 2 << endl; }
#include <algorithm> #include <iostream> #include <math.h> #include <numeric> #include <string> #include <vector> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<ULL> VULL; class MYCP { public: //数値を区切って文字列にする static string MakeString_LongLong(vector<long long> const &numbers, string const &str) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += str; result += to_string(numbers[i]); } return result; } //空白で区切る為のオーバーロード static string MakeString_LongLong(vector<long long> const &numbers) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += " "; result += to_string(numbers[i]); } return result; } //文字列の配列を改行を挟んでまとめる static string MakeString_VectorString(vector<string> const &str) { string result = ""; for (long long i = 0; i < str.size(); i++) { result += str[i] + "\n"; } return result; } //文字列を必要な個数だけ読み取る static vector<string> MyReadLineSplit(LL n) { vector<string> str(n); for (long long i = 0; i < n; i++) { std::cin >> str[i]; } return str; } //数値を必要な個数だけ読み取る static vector<long long> ReadInts(long long number) { vector<long long> a(number); for (int i = 0; i < number; i++) { std::cin >> a[i]; } return a; } //渡された自然数が素数ならtureを返す static bool PrimeCheck_Int(long long number) { if (number < 2) return false; for (ULL i = 2; i * i <= number; i++) { if (number % i == 0) return false; } return true; } //渡された数値以下の素数表を作る static vector<long long> MakePrimeList(long long n) { vector<long long> list; LL i, j, p; bool flag; for (i = 2; i <= n; i++) { flag = true; for (j = 0; j < list.size(); j++) { if (!(list[j] * list[j] <= i)) break; if (i % list[j] == 0) { flag = false; break; } } if (flag) list.push_back(i); } return list; } //文字列の分割 static vector<string> split(string const &str, char sep) { vector<std::string> v; // 分割結果を格納するベクター auto first = str.begin(); // テキストの最初を指すイテレータ while (first != str.end()) { // テキストが残っている間ループ auto last = first; // 分割文字列末尾へのイテレータ while (last != str.end() && *last != sep) // 末尾 or セパレータ文字まで進める last++; v.push_back(string(first, last)); // 分割文字を出力 if (last != str.end()) last++; first = last; // 次の処理のためにイテレータを設定 } return v; } //合計を求める static LL Sum(vector<LL> a) { LL i, sum = 0; for (i = 0; i < a.size(); i++) { sum += a[i]; } return sum; } //小文字ならtrueを返す static bool Komoji(char a) { if (a >= 'a' && a <= 'z') return true; return false; } //大文字ならtrueを返す static bool Oomoji(char a) { if (a >= 'A' && a <= 'Z') return true; return false; } static LL GreatestCommonFactor(LL a, LL b) { LL temp; if (a < b) { temp = b; b = a; a = temp; } while (true) { temp = a % b; a = b; b = temp; if (b == 0) break; } return a; } static LL LeastCommonMultiple(LL a, LL b) { return (a / GreatestCommonFactor(a, b)) * b; } }; //累積和を求めるクラス class Syakutori { private: vector<LL> list; public: void MakeArray(vector<LL> data) { LL i; list = data; list.push_back(0); list[0] = 0; for (i = 1; i < list.size(); i++) { list[i] = list[i - 1] + data[i - 1]; } } LL Sum(LL start, LL end) { if (end < start) { cout << "startがendより大きいです"; return 0; } if (start < 0 || end >= list.size()) { cout << "範囲が異常"; return 0; } return list[end] - list[start]; } }; string strnum = "0123456789"; string alpS = "abcdefghijklmnopqrstuvwxyz"; string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int sizealp = (int)(alpS.size()); int mod = 1e9 + 7; #define SORT(x) sort(x.begin(), x.end()) #define REVE(x) reverse(x.begin(), x.end()) #define rep(i, n) for (int i = 0; i < n; i++) #define COUT(x) cout << x << endl double pai = 3.1415926535; string atc = "atcoder"; typedef pair<long long, long long> data_t; int main(void) { int count = 0; int sum = 0; int flag = 0; string s; cin >> s; int count0 = 0, count1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') count0++; else count1++; } cout << min(count0, count1) * 2 << endl; }
[ "control_flow.branch.if.condition.change" ]
917,738
917,739
u196798307
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int R_count = 0; int B_count = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') R_count++; else B_count++; } int ans = min(R_count, B_count); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int R_count = 0; int B_count = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') R_count++; else B_count++; } int ans = min(R_count, B_count); cout << ans * 2 << endl; }
[ "expression.operation.binary.add" ]
917,740
917,741
u314008046
cpp
p03107
#include <algorithm> #include <climits> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; template <class T> ostream &operator<<(ostream &os, vector<T> &v) { for (auto i = v.begin(); i != v.end(); i++) { os << *i << " "; } return os; } using ll = long long int; int main(void) { string s; string t; int c = 0; cin >> s; t.push_back(s[0]); for (auto i = s.begin() + 1; i != s.end(); i++) { if (t.size() == 0 or s[0] == *i) { t.push_back(*i); } else { t.pop_back(); c++; } } std::cout << c * 2 << std::endl; return 0; }
#include <algorithm> #include <climits> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; template <class T> ostream &operator<<(ostream &os, vector<T> &v) { for (auto i = v.begin(); i != v.end(); i++) { os << *i << " "; } return os; } using ll = long long int; int main(void) { string s; string t; int c = 0; cin >> s; t.push_back(s[0]); for (auto i = s.begin() + 1; i != s.end(); i++) { if (t.size() == 0 or t[0] == *i) { t.push_back(*i); } else { t.pop_back(); c++; } } std::cout << c * 2 << std::endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
917,750
917,751
u131340563
cpp
p03107
#include <algorithm> #include <cstdbool> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> typedef long long ll; #define rep(i, n) for (ll 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 = 1000000000000000; typedef pair<int, int> P; ll ma = 1000000000 + 7; ll h, w, n, m; char maze[60][60]; int dis[60][60]; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { string s; cin >> s; int z, o; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { z++; } else { o++; } } cout << min(z, o) * 2 << endl; }
#include <algorithm> #include <cstdbool> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> typedef long long ll; #define rep(i, n) for (ll 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 = 1000000000000000; typedef pair<int, int> P; ll ma = 1000000000 + 7; ll h, w, n, m; char maze[60][60]; int dis[60][60]; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int main() { string s; cin >> s; int z = 0; int o = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { z++; } else { o++; } } cout << min(z, o) * 2 << endl; }
[ "variable_declaration.add" ]
917,779
917,780
u240031669
cpp
p03107
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; #define INF 1000000007 int main() { string s; cin >> s; int l = s.size(); int c0 = 0, c1 = 0; for (int i = 0; i < l; i++) { if (s[i] == '0') c0++; else c1++; } cout << min(c0, c1) << "\n"; return 0; }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; #define INF 1000000007 int main() { string s; cin >> s; int l = s.size(); int c0 = 0, c1 = 0; for (int i = 0; i < l; i++) { if (s[i] == '0') c0++; else c1++; } cout << 2 * min(c0, c1) << "\n"; return 0; }
[ "expression.operation.binary.add" ]
917,784
917,785
u170650966
cpp
p03107
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define lint long long #define MAX 100'000 int main() { string S; cin >> S; int one = 0; int zero = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '1') { one++; } else { zero++; } } cout << S.size() - max(one, zero) - min(one, zero) << endl; return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define lint long long #define MAX 100'000 int main() { string S; cin >> S; int one = 0; int zero = 0; for (int i = 0; i < S.size(); i++) { if (S[i] == '1') { one++; } else { zero++; } } cout << S.size() - (max(one, zero) - min(one, zero)) << endl; return 0; }
[]
917,786
917,787
u426397594
cpp
p03107
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; vector<char> V; for (int i = 0; i < S.size(); i++) { V.push_back(S[i]); } int ans = 0; for (int i = 0; i < V.size() - 1; i++) { if (V[i] != V[i + 1]) { V.erase(V.begin() + i, V.begin() + i + 2); ans += 2; i = 0; } } cout << ans << '\n'; return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; vector<char> V; for (int i = 0; i < S.size(); i++) { V.push_back(S[i]); } int ans = 0; for (int i = 0; i + 1 < V.size(); i++) { if (V[i] != V[i + 1]) { V.erase(V.begin() + i, V.begin() + i + 2); ans += 2; i = -1; } } cout << ans << '\n'; return 0; }
[ "control_flow.loop.for.condition.change", "misc.off_by_one", "expression.operation.binary.remove", "literal.number.change", "assignment.value.change" ]
917,797
917,798
u293072892
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int c0 = 0; int c1 = 1; for (char c : s) { if (c == '0') c0++; else c1++; } cout << 2 * min(c0, c1) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int c0 = 0; int c1 = 0; for (char c : s) { if (c == '0') c0++; else c1++; } cout << 2 * min(c0, c1) << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
917,799
917,800
u506320030
cpp
p03107
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; int main() { string s; cin >> s; int ans = 0, c0 = 0, c1 = 1; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { if (c1 > 0) { c1--; ans += 2; } else { c0++; } } else { if (c0 > 0) { c0--; ans += 2; } else { c1++; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; int main() { string s; cin >> s; int ans = 0, c0 = 0, c1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { if (c1 > 0) { c1--; ans += 2; } else { c0++; } } else { if (c0 > 0) { c0--; ans += 2; } else { c1++; } } } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
917,803
917,804
u480806810
cpp
p03107
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; int main() { string s; cin >> s; int ans = 0, c0 = 0, c1 = 1; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { if (c1 > 1) { c1--; ans += 2; } else { c0++; } } else { if (c0 > 1) { c0--; ans += 2; } else { c1++; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <utility> #include <vector> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; int main() { string s; cin >> s; int ans = 0, c0 = 0, c1 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { if (c1 > 0) { c1--; ans += 2; } else { c0++; } } else { if (c0 > 0) { c0--; ans += 2; } else { c1++; } } } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.branch.if.condition.change" ]
917,805
917,804
u480806810
cpp
p03107
#include <bits/stdc++.h> #define lson (o << 1) #define rson (o << 1 | 1) #define fi first #define sc second #define dbg(x) cout << #x << " = " << (x) << endl; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; using namespace std; const double pi = acos(-1); const double eps = 1e-6; inline int lowbit(int x) { return x & (-x); } inline int read() { int f = 1, x = 0; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9'); do { x = x * 10 + ch - '0'; ch = getchar(); } while (ch >= '0' && ch <= '9'); return f * x; } template <typename T> inline T max(T x, T y, T z) { return max(max(x, y), z); } template <typename T> inline T min(T x, T y, T z) { return min(min(x, y), z); } template <typename T> inline T sqr(T x) { return x * x; } template <typename T> inline void checkmax(T &x, T y) { x = max(x, y); } template <typename T> inline void checkmin(T &x, T y) { x = min(x, y); } template <typename T> inline void read(T &x) { x = 0; T f = 1; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9'); do x = x * 10 + ch - '0', ch = getchar(); while (ch <= '9' && ch >= '0'); x *= f; } template <typename A, typename B, typename C> inline A fpow(A x, B p, C yql) { A ans = 1; for (; p; p >>= 1, x = 1LL * x * x % yql) if (p & 1) ans = 1LL * x * ans % yql; return ans; } struct FastIO { static const int S = 1310720; int wpos; char wbuf[S]; FastIO() : wpos(0) {} inline int xchar() { static char buf[S]; static int len = 0, pos = 0; if (pos == len) pos = 0, len = fread(buf, 1, S, stdin); if (pos == len) return -1; return buf[pos++]; } inline int read() { int c = xchar(), x = 0; while (c <= 32 && ~c) c = xchar(); if (c == -1) return -1; for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0'; return x; } } io; //#define read io.read int main() { string s; int x1 = 0, x2 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '1') x1++; if (s[i] == '0') x2++; } cout << min(x1, x2) * 2; return 0; }
#include <bits/stdc++.h> #define lson (o << 1) #define rson (o << 1 | 1) #define fi first #define sc second #define dbg(x) cout << #x << " = " << (x) << endl; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; using namespace std; const double pi = acos(-1); const double eps = 1e-6; inline int lowbit(int x) { return x & (-x); } inline int read() { int f = 1, x = 0; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9'); do { x = x * 10 + ch - '0'; ch = getchar(); } while (ch >= '0' && ch <= '9'); return f * x; } template <typename T> inline T max(T x, T y, T z) { return max(max(x, y), z); } template <typename T> inline T min(T x, T y, T z) { return min(min(x, y), z); } template <typename T> inline T sqr(T x) { return x * x; } template <typename T> inline void checkmax(T &x, T y) { x = max(x, y); } template <typename T> inline void checkmin(T &x, T y) { x = min(x, y); } template <typename T> inline void read(T &x) { x = 0; T f = 1; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch < '0' || ch > '9'); do x = x * 10 + ch - '0', ch = getchar(); while (ch <= '9' && ch >= '0'); x *= f; } template <typename A, typename B, typename C> inline A fpow(A x, B p, C yql) { A ans = 1; for (; p; p >>= 1, x = 1LL * x * x % yql) if (p & 1) ans = 1LL * x * ans % yql; return ans; } struct FastIO { static const int S = 1310720; int wpos; char wbuf[S]; FastIO() : wpos(0) {} inline int xchar() { static char buf[S]; static int len = 0, pos = 0; if (pos == len) pos = 0, len = fread(buf, 1, S, stdin); if (pos == len) return -1; return buf[pos++]; } inline int read() { int c = xchar(), x = 0; while (c <= 32 && ~c) c = xchar(); if (c == -1) return -1; for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0'; return x; } } io; //#define read io.read int main() { string s; cin >> s; int x1 = 0, x2 = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '1') x1++; if (s[i] == '0') x2++; } cout << min(x1, x2) * 2; return 0; }
[]
917,810
917,811
u302794558
cpp
p03107
#include <bits/stdc++.h> //↓✟MLE魔、TLE魔✟ #define int long long //↑✟MLE魔、TLE魔✟ #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } signed main() { string s; int a, b; cin >> s; rep(i, s.size()) { if (s[i] == '1') a++; else b++; } cout << min(a, b) * 2 << endl; return 0; }
#include <bits/stdc++.h> //↓✟MLE魔、TLE魔✟ #define int long long //↑✟MLE魔、TLE魔✟ #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } signed main() { string s; int a = 0, b = 0; cin >> s; rep(i, s.size()) { if (s[i] == '1') a++; else b++; } cout << min(a, b) * 2 << endl; return 0; }
[ "variable_declaration.value.change" ]
917,814
917,815
u073057072
cpp
p03107
/* URL https:// SCORE 0 AC false WA false TLE false MLE false TASK_TYPE FAILURE_TYPE NOTES */ #include <algorithm> #include <cstdint> #include <experimental/optional> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> /* import STL */ // stream using std::cerr; using std::cin; using std::cout; using std::endl; using std::flush; // basic types using std::nullptr_t; using std::pair; using std::string; using std::tuple; using std::experimental::optional; // function for basic types using std::get; using std::make_pair; using std::make_tuple; using std::experimental::make_optional; /* TODO remove them */ using std::queue; using std::stack; using std::vector; // algorithms using std::accumulate; using std::lower_bound; using std::max_element; using std::min_element; using std::nth_element; using std::upper_bound; /* macros */ // loops #define REP(i, n) for (i64 i = 0; i < static_cast<decltype(i)>(n); ++i) #define REPR(i, n) for (i64 i = (n)-1; i >= static_cast<decltype(i)>(0); --i) #define FOR(i, n, m) for (i64 i = (n); i < static_cast<decltype(i)>(m); ++i) #define FORR(i, n, m) for (i64 i = (m)-1; i >= static_cast<decltype(i)>(n); --i) #define EACH(x, xs) for (auto &x : (xs)) #define EACH_V(x, xs) for (auto x : (xs)) // helpers #define CTR(x) (x).begin(), (x).end() /* utils for std::tuple */ namespace internal { namespace tuple_utils { // TODO rename to "internal::tuple" template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Tuple, size_t... Is> void read(std::istream &stream, Tuple &t, seq<Is...>) { static_cast<void>((int[]){0, (void(stream >> get<Is>(t)), 0)...}); } template <class Tuple, size_t... Is> void print(std::ostream &stream, Tuple const &t, seq<Is...>) { static_cast<void>( (int[]){0, (void(stream << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}); } template <size_t I, class F, class A, class... Elems> struct ForEach { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } }; template <class F, class A, class... Elems> struct ForEach<0, F, A, Elems...> { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<0>(t)); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<0>(t)); } }; template <class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> const &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } template <class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } } // namespace tuple_utils } // namespace internal /* utils for Matrix (definition of Matrix) */ namespace internal { namespace matrix { template <typename V, int N> struct matrix_t { using type = std::vector<typename matrix_t<V, N - 1>::type>; }; template <typename V> struct matrix_t<V, 0> { using type = V; }; template <typename V, int N> using Matrix = typename matrix_t<V, N>::type; template <typename V, typename It, int N> struct matrix_helper { static Matrix<V, N> create(const It &begin, const It &end, const V &default_value) { return Matrix<V, N>(*begin, matrix_helper<V, It, N - 1>::create( begin + 1, end, default_value)); } }; template <typename V, typename It> struct matrix_helper<V, It, 0> { static Matrix<V, 0> create(const It &begin __attribute__((unused)), const It &end __attribute__((unused)), const V &default_value) { return default_value; } }; } // namespace matrix } // namespace internal /* Primitive types */ using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using usize = size_t; /* Data structure type */ template <typename T> using Vector = std::vector<T>; template <typename V> using OrderedSet = std::set<V>; template <typename V> using HashSet = std::unordered_set<V>; template <typename K, typename V> using OrderedMap = std::map<K, V>; template <typename K, typename V> using HashMap = std::unordered_map<K, V>; template <typename T, int N> using Matrix = internal::matrix::Matrix<T, N>; template <typename T, typename Compare = std::less<T>, typename Container = std::vector<T>> using PriorityQueue = std::priority_queue<T, Container, Compare>; /* utils for Vector */ template <typename V> Vector<V> make_pre_allocated_vector(size_t N) { Vector<V> retval; retval.reserve(N); return retval; } /* utils for Matrix */ template <class V, int N> Matrix<V, N> make_matrix(const std::array<size_t, N> &shape, V default_value = V()) { return internal::matrix::matrix_helper<V, decltype(shape.begin()), N>::create( shape.begin(), shape.end(), default_value); } /* utils for STL iterators */ namespace internal { template <typename Iterator, typename F> struct MappedIterator { MappedIterator(const Iterator &it, const F &function) : it(it), function(function) {} auto operator*() const { return this->function(this->it); } void operator++() { ++this->it; } void operator+=(size_t n) { this->it += n; } auto operator+(size_t n) const { return MappedIterator<Iterator, F>(this->it + n, this->function); } bool operator==(const MappedIterator<Iterator, F> &rhs) const { return this->it == rhs.it; } bool operator!=(const MappedIterator<Iterator, F> &rhs) const { return !(*this == rhs); } private: Iterator it; F function; }; template <typename Iterator, typename P> struct FilteredIterator { FilteredIterator(const Iterator &it, const Iterator &end, const P &predicate) : it(it), end(end), predicate(predicate) { if (this->it != end) { if (!predicate(this->it)) { this->increment(); } } } decltype(auto) operator*() const { return *this->it; } auto operator->() const { return this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP(i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FilteredIterator<Iterator, P> &rhs) const { return this->it == rhs.it; } bool operator!=(const FilteredIterator<Iterator, P> &rhs) const { return !(*this == rhs); } private: void increment() { if (this->it == this->end) { return; } ++this->it; while (this->it != this->end && !this->predicate(this->it)) { ++this->it; } } Iterator it; Iterator end; P predicate; }; template <typename Iterator, typename ElementIterator> struct FlattenedIterator { FlattenedIterator(const Iterator &it, const Iterator &end) : it(make_pair(it, ElementIterator())), end(end) { if (this->it.first != this->end) { this->it.second = it->begin(); } this->find_valid(); } decltype(auto) operator*() const { return this->it; } const pair<Iterator, ElementIterator> *operator->() const { return &this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP(i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { if (this->it.first != rhs.it.first) { return false; } if (this->it.first == this->end || rhs.it.first == rhs.end) { if (this->end == rhs.end) { return true; } else { return false; } } else { return this->it.second == rhs.it.second; } } bool operator!=(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { return !(*this == rhs); } private: bool is_end() const { return this->it.first == this->end; } bool is_valid() const { if (this->is_end()) return false; if (this->it.second == this->it.first->end()) return false; return true; } void _increment() { if (this->it.second == this->it.first->end()) { ++this->it.first; if (this->it.first != this->end) { this->it.second = this->it.first->begin(); } } else { ++this->it.second; } } void find_valid() { while (!this->is_end() && !this->is_valid()) { this->_increment(); } } void increment() { this->_increment(); while (!this->is_end() && !this->is_valid()) { this->_increment(); } } pair<Iterator, ElementIterator> it; Iterator end; }; } // namespace internal template <class Iterator> struct Container { Container(const Iterator &begin, const Iterator &end) : m_begin(begin), m_end(end) {} const Iterator &begin() const { return this->m_begin; } const Iterator &end() const { return this->m_end; } Iterator m_begin; Iterator m_end; }; template <typename C, typename F> auto iterator_map(const C &c, F function) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::MappedIterator<Iterator, F>>( internal::MappedIterator<Iterator, F>(c.begin(), function), internal::MappedIterator<Iterator, F>(c.end(), function)); } template <typename C, typename P> auto iterator_filter(const C &c, P predicate) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::FilteredIterator<Iterator, P>>( internal::FilteredIterator<Iterator, P>(c.begin(), c.end(), predicate), internal::FilteredIterator<Iterator, P>(c.end(), c.end(), predicate)); } template <typename C> auto iterator_flatten(const C &c) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; using ElementIterator = std::remove_const_t< std::remove_reference_t<decltype(c.begin()->begin())>>; return Container<internal::FlattenedIterator<Iterator, ElementIterator>>( internal::FlattenedIterator<Iterator, ElementIterator>(c.begin(), c.end()), internal::FlattenedIterator<Iterator, ElementIterator>(c.end(), c.end())); } /* input */ template <class F, class S> std::istream &operator>>(std::istream &stream, pair<F, S> &pair) { stream >> pair.first; stream >> pair.second; return stream; } template <class... Args> std::istream &operator>>(std::istream &stream, tuple<Args...> &tuple) { internal::tuple_utils::read( stream, tuple, internal::tuple_utils::gen_seq<sizeof...(Args)>()); return stream; } template <class T> T read() { T t; cin >> t; return t; } template <class F, class S> pair<F, S> read() { pair<F, S> p; cin >> p; return p; } template <class T1, class T2, class T3, class... Args> tuple<T1, T2, T3, Args...> read() { tuple<T1, T2, T3, Args...> t; cin >> t; return t; } template <typename T, typename F = std::function<T()>> Vector<T> read(const usize length, F r) { auto retval = make_pre_allocated_vector<T>(length); REP(i, length) { retval.emplace_back(r()); } return retval; } template <class T> Vector<T> read(const usize length) { return read<T>(length, [] { return read<T>(); }); } template <class F, class S> Vector<pair<F, S>> read(const usize length) { return read<pair<F, S>>(length); } template <class T1, class T2, class T3, class... Args> Vector<tuple<T1, T2, T3, Args...>> read(const usize length) { return read<tuple<T1, T2, T3, Args...>>(length); } namespace internal { template <typename T> struct oneline { std::string operator()(const T &t) const { std::ostringstream oss; oss << t; return oss.str(); } }; template <typename F, typename S> struct oneline<pair<F, S>> { std::string operator()(const pair<F, S> &p) const { std::ostringstream oss; oss << "{" << oneline<F>()(p.first) << ", " << oneline<S>()(p.second) << "}"; return oss.str(); } }; template <typename... Args> struct oneline<tuple<Args...>> { struct oneline_tuple { template <class V> void operator()(Vector<std::string> &strs, const V &v) const { strs.emplace_back(oneline<V>()(v)); } }; std::string operator()(const tuple<Args...> &t) const { std::ostringstream oss; Vector<std::string> strs; internal::tuple_utils::for_each<oneline_tuple, Vector<std::string>, Args...>(strs, t); oss << "{"; REPR(i, strs.size()) { oss << strs[i]; if (i != 0) { oss << ", "; } } oss << "}"; return oss.str(); } }; template <> struct oneline<bool> { std::string operator()(const bool b) const { return b ? "true" : "false"; } }; template <typename X> struct oneline<Vector<X>> { std::string operator()(const Vector<X> &vec) const { std::string retval = "["; auto f = oneline<X>(); REP(i, vec.size()) { retval += f(vec[i]); if (i != static_cast<i64>(vec.size() - 1)) { retval += ", "; } } retval += "]"; return retval; } }; template <typename X> struct oneline<OrderedSet<X>> { std::string operator()(const OrderedSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH(x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename X> struct oneline<HashSet<X>> { std::string operator()(const HashSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH(x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<OrderedMap<K, V>> { std::string operator()(const OrderedMap<K, V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH(x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<HashMap<K, V>> { std::string operator()(const HashMap<K, V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH(x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename V> struct keys { /* no implementation */ }; template <typename X> struct keys<std::vector<X>> { Vector<size_t> operator()(const Vector<X> &v) const { Vector<size_t> keys; REP(i, v.size()) { keys.emplace_back(i); } return keys; } }; template <typename K, typename V> struct keys<OrderedMap<K, V>> { Vector<K> operator()(const OrderedMap<K, V> &c) const { Vector<K> keys; EACH(elem, c) { keys.emplace_back(elem.first); } return keys; } }; template <typename K, typename V> struct keys<HashMap<K, V>> { Vector<K> operator()(const HashMap<K, V> &c) const { Vector<K> keys; EACH(elem, c) { keys.emplace_back(elem.first); } return keys; } }; } // namespace internal template <typename T> void dump(const T &t) { using namespace internal; std::cerr << oneline<T>()(t) << std::endl; } template <typename V1, typename V2, typename... Args> void dump(const V1 &v1, const V2 &v2, const Args &...args) { using namespace internal; using F = typename oneline<tuple<V1, V2, Args...>>::oneline_tuple; auto x = std::make_tuple(v1, v2, args...); Vector<std::string> strs; internal::tuple_utils::for_each<F, Vector<std::string>, V1, V2, Args...>(strs, x); REPR(i, strs.size()) { std::cerr << strs[i]; if (i != 0) { std::cerr << ", "; } } std::cerr << std::endl; } template <typename C> std::string as_set(const C &ctr) { Vector<std::string> values; using namespace internal; EACH(x, ctr) { values.emplace_back(oneline<decltype(x)>()(x)); } std::string retval = "---\n"; REP(i, values.size()) { retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_map(const C &ctr) { using namespace internal; auto ks = keys<C>()(ctr); Vector<std::string> keys; Vector<std::string> values; EACH(key, ks) { keys.emplace_back(oneline<decltype(key)>()(key)); values.emplace_back(oneline<decltype(ctr.at(key))>()(ctr.at(key))); } size_t l = 0; EACH(key, keys) { l = std::max(l, key.size()); } std::string retval = "---\n"; REP(i, values.size()) { retval += keys[i]; REP(j, l - keys[i].size()) { retval += " "; } retval += ": "; retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_table(const C &ctr) { using namespace internal; auto rkeys = keys<C>()(ctr); auto ckeys = OrderedSet<std::string>(); auto values = Vector<pair<std::string, OrderedMap<std::string, std::string>>>(); /* Stringify all data */ EACH(rkey, rkeys) { auto rkey_str = oneline<decltype(rkey)>()(rkey); values.emplace_back(rkey_str, OrderedMap<std::string, std::string>()); auto row = ctr.at(rkey); auto ks = keys<decltype(row)>()(row); EACH(ckey, ks) { auto ckey_str = oneline<decltype(ckey)>()(ckey); ckeys.emplace(ckey_str); values.back().second.emplace( ckey_str, oneline<decltype(row.at(ckey))>()(row.at(ckey))); } } /* Calculate string length */ size_t max_row_key_length = 0; EACH(value, values) { max_row_key_length = std::max(max_row_key_length, value.first.size()); } OrderedMap<std::string, size_t> max_col_length; EACH(ckey, ckeys) { max_col_length.emplace(ckey, ckey.size()); } EACH(value, values) { EACH(elem, value.second) { auto ckey = elem.first; auto value = elem.second; max_col_length[ckey] = std::max(max_col_length[ckey], value.size()); } } std::string retval = "---\n"; /* Header */ REP(i, max_row_key_length) { retval += " "; } retval += " "; size_t cnt = 0; EACH(ckey, ckeys) { retval += ckey; REP(j, max_col_length[ckey] - ckey.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n------\n"; /* Values */ EACH(value, values) { retval += value.first; REP(i, max_row_key_length - value.first.size()) { retval += " "; } retval += "| "; size_t cnt = 0; EACH(ckey, ckeys) { auto v = std::string(""); if (value.second.find(ckey) != value.second.end()) { v = value.second.at(ckey); } retval += v; REP(j, max_col_length[ckey] - v.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n"; } retval += "---"; return retval; } // Hash namespace std { template <class F, class S> struct hash<pair<F, S>> { size_t operator()(const pair<F, S> &p) const { return hash<F>()(p.first) ^ hash<S>()(p.second); } }; template <class... Args> struct hash<tuple<Args...>> { struct hash_for_element { template <class V> void operator()(size_t &size, const V &v) const { size ^= std::hash<V>()(v); } }; size_t operator()(const tuple<Args...> &t) const { size_t retval = 0; internal::tuple_utils::for_each<hash_for_element, size_t, Args...>(retval, t); return retval; } }; } // namespace std #define MAIN void body(); // main function (DO NOT EDIT) int main(int argc, char **argv) { cin.tie(0); std::ios_base::sync_with_stdio(false); cout << std::fixed; body(); return 0; } void body() { auto S = read<string>(); // dp[i][j] := S[0..i]????j??????????????????? auto dp = make_matrix<i64, 2>({S.size() + 1, 2}, 0); i64 ans = 0; REP(i, S.size()) { // dp[i + 1]??? if (S[i] == '1') { if (dp[i][0] > 0) { ans += 2; dp[i + 1][0] = dp[i][0] - 1; // ???????? dp[i + 1][1] = dp[i][1]; } else { dp[i + 1][0] = dp[i][0]; dp[i + 1][1] = dp[i][1] + 1; } } else { if (dp[i][0] > 0) { ans += 2; dp[i + 1][0] = dp[i][0]; dp[i + 1][1] = dp[i][1] - 1; // ???????? } else { dp[i + 1][0] = dp[i][0] + 1; dp[i + 1][1] = dp[i][1]; } } } dump(ans); cout << ans << endl << endl; }
/* URL https:// SCORE 0 AC false WA false TLE false MLE false TASK_TYPE FAILURE_TYPE NOTES */ #include <algorithm> #include <cstdint> #include <experimental/optional> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> /* import STL */ // stream using std::cerr; using std::cin; using std::cout; using std::endl; using std::flush; // basic types using std::nullptr_t; using std::pair; using std::string; using std::tuple; using std::experimental::optional; // function for basic types using std::get; using std::make_pair; using std::make_tuple; using std::experimental::make_optional; /* TODO remove them */ using std::queue; using std::stack; using std::vector; // algorithms using std::accumulate; using std::lower_bound; using std::max_element; using std::min_element; using std::nth_element; using std::upper_bound; /* macros */ // loops #define REP(i, n) for (i64 i = 0; i < static_cast<decltype(i)>(n); ++i) #define REPR(i, n) for (i64 i = (n)-1; i >= static_cast<decltype(i)>(0); --i) #define FOR(i, n, m) for (i64 i = (n); i < static_cast<decltype(i)>(m); ++i) #define FORR(i, n, m) for (i64 i = (m)-1; i >= static_cast<decltype(i)>(n); --i) #define EACH(x, xs) for (auto &x : (xs)) #define EACH_V(x, xs) for (auto x : (xs)) // helpers #define CTR(x) (x).begin(), (x).end() /* utils for std::tuple */ namespace internal { namespace tuple_utils { // TODO rename to "internal::tuple" template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Tuple, size_t... Is> void read(std::istream &stream, Tuple &t, seq<Is...>) { static_cast<void>((int[]){0, (void(stream >> get<Is>(t)), 0)...}); } template <class Tuple, size_t... Is> void print(std::ostream &stream, Tuple const &t, seq<Is...>) { static_cast<void>( (int[]){0, (void(stream << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}); } template <size_t I, class F, class A, class... Elems> struct ForEach { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<I>(t)); ForEach<I - 1, F, A, Elems...>()(arg, t); } }; template <class F, class A, class... Elems> struct ForEach<0, F, A, Elems...> { void operator()(A &arg, tuple<Elems...> const &t) const { F()(arg, get<0>(t)); } void operator()(A &arg, tuple<Elems...> &t) const { F()(arg, get<0>(t)); } }; template <class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> const &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } template <class F, class A, class... Elems> void for_each(A &arg, tuple<Elems...> &t) { ForEach<std::tuple_size<tuple<Elems...>>::value - 1, F, A, Elems...>()(arg, t); } } // namespace tuple_utils } // namespace internal /* utils for Matrix (definition of Matrix) */ namespace internal { namespace matrix { template <typename V, int N> struct matrix_t { using type = std::vector<typename matrix_t<V, N - 1>::type>; }; template <typename V> struct matrix_t<V, 0> { using type = V; }; template <typename V, int N> using Matrix = typename matrix_t<V, N>::type; template <typename V, typename It, int N> struct matrix_helper { static Matrix<V, N> create(const It &begin, const It &end, const V &default_value) { return Matrix<V, N>(*begin, matrix_helper<V, It, N - 1>::create( begin + 1, end, default_value)); } }; template <typename V, typename It> struct matrix_helper<V, It, 0> { static Matrix<V, 0> create(const It &begin __attribute__((unused)), const It &end __attribute__((unused)), const V &default_value) { return default_value; } }; } // namespace matrix } // namespace internal /* Primitive types */ using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using usize = size_t; /* Data structure type */ template <typename T> using Vector = std::vector<T>; template <typename V> using OrderedSet = std::set<V>; template <typename V> using HashSet = std::unordered_set<V>; template <typename K, typename V> using OrderedMap = std::map<K, V>; template <typename K, typename V> using HashMap = std::unordered_map<K, V>; template <typename T, int N> using Matrix = internal::matrix::Matrix<T, N>; template <typename T, typename Compare = std::less<T>, typename Container = std::vector<T>> using PriorityQueue = std::priority_queue<T, Container, Compare>; /* utils for Vector */ template <typename V> Vector<V> make_pre_allocated_vector(size_t N) { Vector<V> retval; retval.reserve(N); return retval; } /* utils for Matrix */ template <class V, int N> Matrix<V, N> make_matrix(const std::array<size_t, N> &shape, V default_value = V()) { return internal::matrix::matrix_helper<V, decltype(shape.begin()), N>::create( shape.begin(), shape.end(), default_value); } /* utils for STL iterators */ namespace internal { template <typename Iterator, typename F> struct MappedIterator { MappedIterator(const Iterator &it, const F &function) : it(it), function(function) {} auto operator*() const { return this->function(this->it); } void operator++() { ++this->it; } void operator+=(size_t n) { this->it += n; } auto operator+(size_t n) const { return MappedIterator<Iterator, F>(this->it + n, this->function); } bool operator==(const MappedIterator<Iterator, F> &rhs) const { return this->it == rhs.it; } bool operator!=(const MappedIterator<Iterator, F> &rhs) const { return !(*this == rhs); } private: Iterator it; F function; }; template <typename Iterator, typename P> struct FilteredIterator { FilteredIterator(const Iterator &it, const Iterator &end, const P &predicate) : it(it), end(end), predicate(predicate) { if (this->it != end) { if (!predicate(this->it)) { this->increment(); } } } decltype(auto) operator*() const { return *this->it; } auto operator->() const { return this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP(i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FilteredIterator<Iterator, P> &rhs) const { return this->it == rhs.it; } bool operator!=(const FilteredIterator<Iterator, P> &rhs) const { return !(*this == rhs); } private: void increment() { if (this->it == this->end) { return; } ++this->it; while (this->it != this->end && !this->predicate(this->it)) { ++this->it; } } Iterator it; Iterator end; P predicate; }; template <typename Iterator, typename ElementIterator> struct FlattenedIterator { FlattenedIterator(const Iterator &it, const Iterator &end) : it(make_pair(it, ElementIterator())), end(end) { if (this->it.first != this->end) { this->it.second = it->begin(); } this->find_valid(); } decltype(auto) operator*() const { return this->it; } const pair<Iterator, ElementIterator> *operator->() const { return &this->it; } void operator++() { this->increment(); } void operator+=(size_t n) { REP(i, n) { this->increment(); } } auto operator+(size_t n) const { auto retval = *this; retval += n; return retval; } bool operator==(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { if (this->it.first != rhs.it.first) { return false; } if (this->it.first == this->end || rhs.it.first == rhs.end) { if (this->end == rhs.end) { return true; } else { return false; } } else { return this->it.second == rhs.it.second; } } bool operator!=(const FlattenedIterator<Iterator, ElementIterator> &rhs) const { return !(*this == rhs); } private: bool is_end() const { return this->it.first == this->end; } bool is_valid() const { if (this->is_end()) return false; if (this->it.second == this->it.first->end()) return false; return true; } void _increment() { if (this->it.second == this->it.first->end()) { ++this->it.first; if (this->it.first != this->end) { this->it.second = this->it.first->begin(); } } else { ++this->it.second; } } void find_valid() { while (!this->is_end() && !this->is_valid()) { this->_increment(); } } void increment() { this->_increment(); while (!this->is_end() && !this->is_valid()) { this->_increment(); } } pair<Iterator, ElementIterator> it; Iterator end; }; } // namespace internal template <class Iterator> struct Container { Container(const Iterator &begin, const Iterator &end) : m_begin(begin), m_end(end) {} const Iterator &begin() const { return this->m_begin; } const Iterator &end() const { return this->m_end; } Iterator m_begin; Iterator m_end; }; template <typename C, typename F> auto iterator_map(const C &c, F function) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::MappedIterator<Iterator, F>>( internal::MappedIterator<Iterator, F>(c.begin(), function), internal::MappedIterator<Iterator, F>(c.end(), function)); } template <typename C, typename P> auto iterator_filter(const C &c, P predicate) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; return Container<internal::FilteredIterator<Iterator, P>>( internal::FilteredIterator<Iterator, P>(c.begin(), c.end(), predicate), internal::FilteredIterator<Iterator, P>(c.end(), c.end(), predicate)); } template <typename C> auto iterator_flatten(const C &c) { using Iterator = std::remove_const_t<std::remove_reference_t<decltype(c.begin())>>; using ElementIterator = std::remove_const_t< std::remove_reference_t<decltype(c.begin()->begin())>>; return Container<internal::FlattenedIterator<Iterator, ElementIterator>>( internal::FlattenedIterator<Iterator, ElementIterator>(c.begin(), c.end()), internal::FlattenedIterator<Iterator, ElementIterator>(c.end(), c.end())); } /* input */ template <class F, class S> std::istream &operator>>(std::istream &stream, pair<F, S> &pair) { stream >> pair.first; stream >> pair.second; return stream; } template <class... Args> std::istream &operator>>(std::istream &stream, tuple<Args...> &tuple) { internal::tuple_utils::read( stream, tuple, internal::tuple_utils::gen_seq<sizeof...(Args)>()); return stream; } template <class T> T read() { T t; cin >> t; return t; } template <class F, class S> pair<F, S> read() { pair<F, S> p; cin >> p; return p; } template <class T1, class T2, class T3, class... Args> tuple<T1, T2, T3, Args...> read() { tuple<T1, T2, T3, Args...> t; cin >> t; return t; } template <typename T, typename F = std::function<T()>> Vector<T> read(const usize length, F r) { auto retval = make_pre_allocated_vector<T>(length); REP(i, length) { retval.emplace_back(r()); } return retval; } template <class T> Vector<T> read(const usize length) { return read<T>(length, [] { return read<T>(); }); } template <class F, class S> Vector<pair<F, S>> read(const usize length) { return read<pair<F, S>>(length); } template <class T1, class T2, class T3, class... Args> Vector<tuple<T1, T2, T3, Args...>> read(const usize length) { return read<tuple<T1, T2, T3, Args...>>(length); } namespace internal { template <typename T> struct oneline { std::string operator()(const T &t) const { std::ostringstream oss; oss << t; return oss.str(); } }; template <typename F, typename S> struct oneline<pair<F, S>> { std::string operator()(const pair<F, S> &p) const { std::ostringstream oss; oss << "{" << oneline<F>()(p.first) << ", " << oneline<S>()(p.second) << "}"; return oss.str(); } }; template <typename... Args> struct oneline<tuple<Args...>> { struct oneline_tuple { template <class V> void operator()(Vector<std::string> &strs, const V &v) const { strs.emplace_back(oneline<V>()(v)); } }; std::string operator()(const tuple<Args...> &t) const { std::ostringstream oss; Vector<std::string> strs; internal::tuple_utils::for_each<oneline_tuple, Vector<std::string>, Args...>(strs, t); oss << "{"; REPR(i, strs.size()) { oss << strs[i]; if (i != 0) { oss << ", "; } } oss << "}"; return oss.str(); } }; template <> struct oneline<bool> { std::string operator()(const bool b) const { return b ? "true" : "false"; } }; template <typename X> struct oneline<Vector<X>> { std::string operator()(const Vector<X> &vec) const { std::string retval = "["; auto f = oneline<X>(); REP(i, vec.size()) { retval += f(vec[i]); if (i != static_cast<i64>(vec.size() - 1)) { retval += ", "; } } retval += "]"; return retval; } }; template <typename X> struct oneline<OrderedSet<X>> { std::string operator()(const OrderedSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH(x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename X> struct oneline<HashSet<X>> { std::string operator()(const HashSet<X> &s) const { std::string retval = "{"; auto f = oneline<X>(); size_t ctr = 0; EACH(x, s) { retval += f(x); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<OrderedMap<K, V>> { std::string operator()(const OrderedMap<K, V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH(x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename K, typename V> struct oneline<HashMap<K, V>> { std::string operator()(const HashMap<K, V> &s) const { std::string retval = "{"; auto f1 = oneline<K>(); auto f2 = oneline<V>(); size_t ctr = 0; EACH(x, s) { retval += f1(x.first); retval += ": "; retval += f2(x.second); ctr += 1; if (ctr != s.size()) { retval += ", "; } } retval += "}"; return retval; } }; template <typename V> struct keys { /* no implementation */ }; template <typename X> struct keys<std::vector<X>> { Vector<size_t> operator()(const Vector<X> &v) const { Vector<size_t> keys; REP(i, v.size()) { keys.emplace_back(i); } return keys; } }; template <typename K, typename V> struct keys<OrderedMap<K, V>> { Vector<K> operator()(const OrderedMap<K, V> &c) const { Vector<K> keys; EACH(elem, c) { keys.emplace_back(elem.first); } return keys; } }; template <typename K, typename V> struct keys<HashMap<K, V>> { Vector<K> operator()(const HashMap<K, V> &c) const { Vector<K> keys; EACH(elem, c) { keys.emplace_back(elem.first); } return keys; } }; } // namespace internal template <typename T> void dump(const T &t) { using namespace internal; std::cerr << oneline<T>()(t) << std::endl; } template <typename V1, typename V2, typename... Args> void dump(const V1 &v1, const V2 &v2, const Args &...args) { using namespace internal; using F = typename oneline<tuple<V1, V2, Args...>>::oneline_tuple; auto x = std::make_tuple(v1, v2, args...); Vector<std::string> strs; internal::tuple_utils::for_each<F, Vector<std::string>, V1, V2, Args...>(strs, x); REPR(i, strs.size()) { std::cerr << strs[i]; if (i != 0) { std::cerr << ", "; } } std::cerr << std::endl; } template <typename C> std::string as_set(const C &ctr) { Vector<std::string> values; using namespace internal; EACH(x, ctr) { values.emplace_back(oneline<decltype(x)>()(x)); } std::string retval = "---\n"; REP(i, values.size()) { retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_map(const C &ctr) { using namespace internal; auto ks = keys<C>()(ctr); Vector<std::string> keys; Vector<std::string> values; EACH(key, ks) { keys.emplace_back(oneline<decltype(key)>()(key)); values.emplace_back(oneline<decltype(ctr.at(key))>()(ctr.at(key))); } size_t l = 0; EACH(key, keys) { l = std::max(l, key.size()); } std::string retval = "---\n"; REP(i, values.size()) { retval += keys[i]; REP(j, l - keys[i].size()) { retval += " "; } retval += ": "; retval += values[i]; retval += "\n"; } retval += "---"; return retval; } template <typename C> std::string as_table(const C &ctr) { using namespace internal; auto rkeys = keys<C>()(ctr); auto ckeys = OrderedSet<std::string>(); auto values = Vector<pair<std::string, OrderedMap<std::string, std::string>>>(); /* Stringify all data */ EACH(rkey, rkeys) { auto rkey_str = oneline<decltype(rkey)>()(rkey); values.emplace_back(rkey_str, OrderedMap<std::string, std::string>()); auto row = ctr.at(rkey); auto ks = keys<decltype(row)>()(row); EACH(ckey, ks) { auto ckey_str = oneline<decltype(ckey)>()(ckey); ckeys.emplace(ckey_str); values.back().second.emplace( ckey_str, oneline<decltype(row.at(ckey))>()(row.at(ckey))); } } /* Calculate string length */ size_t max_row_key_length = 0; EACH(value, values) { max_row_key_length = std::max(max_row_key_length, value.first.size()); } OrderedMap<std::string, size_t> max_col_length; EACH(ckey, ckeys) { max_col_length.emplace(ckey, ckey.size()); } EACH(value, values) { EACH(elem, value.second) { auto ckey = elem.first; auto value = elem.second; max_col_length[ckey] = std::max(max_col_length[ckey], value.size()); } } std::string retval = "---\n"; /* Header */ REP(i, max_row_key_length) { retval += " "; } retval += " "; size_t cnt = 0; EACH(ckey, ckeys) { retval += ckey; REP(j, max_col_length[ckey] - ckey.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n------\n"; /* Values */ EACH(value, values) { retval += value.first; REP(i, max_row_key_length - value.first.size()) { retval += " "; } retval += "| "; size_t cnt = 0; EACH(ckey, ckeys) { auto v = std::string(""); if (value.second.find(ckey) != value.second.end()) { v = value.second.at(ckey); } retval += v; REP(j, max_col_length[ckey] - v.size()) { retval += " "; } cnt += 1; if (cnt != ckeys.size()) { retval += ", "; } } retval += "\n"; } retval += "---"; return retval; } // Hash namespace std { template <class F, class S> struct hash<pair<F, S>> { size_t operator()(const pair<F, S> &p) const { return hash<F>()(p.first) ^ hash<S>()(p.second); } }; template <class... Args> struct hash<tuple<Args...>> { struct hash_for_element { template <class V> void operator()(size_t &size, const V &v) const { size ^= std::hash<V>()(v); } }; size_t operator()(const tuple<Args...> &t) const { size_t retval = 0; internal::tuple_utils::for_each<hash_for_element, size_t, Args...>(retval, t); return retval; } }; } // namespace std #define MAIN void body(); // main function (DO NOT EDIT) int main(int argc, char **argv) { cin.tie(0); std::ios_base::sync_with_stdio(false); cout << std::fixed; body(); return 0; } void body() { auto S = read<string>(); // dp[i][j] := S[0..i]????j??????????????????? auto dp = make_matrix<i64, 2>({S.size() + 1, 2}, 0); i64 ans = 0; REP(i, S.size()) { // dp[i + 1]??? if (S[i] == '1') { if (dp[i][0] > 0) { ans += 2; dp[i + 1][0] = dp[i][0] - 1; // ???????? dp[i + 1][1] = dp[i][1]; } else { dp[i + 1][0] = dp[i][0]; dp[i + 1][1] = dp[i][1] + 1; } } else { if (dp[i][1] > 0) { ans += 2; dp[i + 1][0] = dp[i][0]; dp[i + 1][1] = dp[i][1] - 1; // ???????? } else { dp[i + 1][0] = dp[i][0] + 1; dp[i + 1][1] = dp[i][1]; } } } cout << ans << endl << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "call.remove" ]
917,818
917,819
u071730284
cpp
p03107
#include <algorithm> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <math.h> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (long(i) = 0; (i) < (long)(n); (i)++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, a, b) for (long i = (a); i < (b); i++) #define rrep1(i, a, b) for (long i = (a); i <= (b); i++) #define rrrep(i, a, b) for (long i = (a); i >= (b); i--) #define define pb push_back #define ALL(obj) (obj).begin(), (obj).end() #define X first #define Y second #define vi vector<int> #define vl vector<ll> #define vvi vector<vector<int>> #define vpl vector<pair<long, long>> #define vppl vector<pair<long, pair<long, long>>> const int INF = 100100100; const long LONG_INF = 2147483647; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; const ll LINF = 1e18; int pow(int x) { if (x == 0) { return 1; } else { return pow(x - 1) * 2; } } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); string x; cin >> x; int count = 0; rep(i, x.length() - 1) { if (x.substr(i, 1) == x.substr(i + 1, 1)) { count += 2; x = x.substr(0, i) + x.substr(i + 2, x.length() - i - 1); i--; if (i >= 0) { i--; } } } cout << count << endl; return 0; }
#include <algorithm> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <math.h> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (long(i) = 0; (i) < (long)(n); (i)++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, a, b) for (long i = (a); i < (b); i++) #define rrep1(i, a, b) for (long i = (a); i <= (b); i++) #define rrrep(i, a, b) for (long i = (a); i >= (b); i--) #define define pb push_back #define ALL(obj) (obj).begin(), (obj).end() #define X first #define Y second #define vi vector<int> #define vl vector<ll> #define vvi vector<vector<int>> #define vpl vector<pair<long, long>> #define vppl vector<pair<long, pair<long, long>>> const int INF = 100100100; const long LONG_INF = 2147483647; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; const ll LINF = 1e18; int pow(int x) { if (x == 0) { return 1; } else { return pow(x - 1) * 2; } } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); string x; cin >> x; int count = 0; rep(i, x.length() - 1) { if (x.substr(i, 1) != x.substr(i + 1, 1)) { count += 2; x = x.substr(0, i) + x.substr(i + 2, x.length() - i - 1); i--; if (i >= 0) { i--; } } } cout << count << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
917,822
917,823
u060896757
cpp
p03107
#include <cmath> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string S; stack<int> st; cin >> S; for (int i = 0; i < S.length(); i++) { if (st.empty()) { st.push(S[i]); continue; } else if (st.top() != S[i] - '0') { st.pop(); } else { st.push(S[i] - '0'); } } cout << S.length() - st.size() << endl; }
#include <cmath> #include <iostream> #include <stack> #include <string> using namespace std; int main() { string S; stack<int> st; cin >> S; for (int i = 0; i < S.length(); i++) { if (st.empty()) { st.push(S[i] - '0'); continue; } else if (st.top() != S[i] - '0') { st.pop(); } else { st.push(S[i] - '0'); } } cout << S.length() - st.size() << endl; }
[ "expression.operation.binary.add" ]
917,830
917,831
u601256797
cpp
p03107
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e6 + 6; typedef long long ll; const int mod = 1e9 + 7; char s[maxn]; int q[maxn]; int main() { scanf("%s", s); int l = strlen(s); int cnt = 0; int ans = 0; for (int i = 0; i < l; i++) { if (cnt == 0) q[cnt++] = s[i] - '0'; else { if (q[cnt - 1] != s[i] - '0') ans += 2; else q[cnt++] = s[i] - '0'; } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e6 + 6; typedef long long ll; const int mod = 1e9 + 7; char s[maxn]; int q[maxn]; int main() { scanf("%s", s); int l = strlen(s); int cnt = 0; int ans = 0; for (int i = 0; i < l; i++) { if (cnt == 0) q[cnt++] = s[i] - '0'; else { if (q[cnt - 1] != s[i] - '0') ans += 2, cnt--; else q[cnt++] = s[i] - '0'; } } printf("%d\n", ans); return 0; }
[]
917,832
917,833
u940396739
cpp
p03107
#include <algorithm> #include <cstdlib> //絶対値利用のため #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; #define fr(i, n) for (int i = 0; i < n; i++) #define ifr(i, n) for (int i = n - 1; i >= 0; i--) // const int INF = INT_MAX / 2; int main() { string S; cin >> S; int counter = 0; for (int i = 0; i < S.length(); i++) { if (S[i] == '1') counter++; } int s = S.length(); cout << abs(s - counter) << endl; return 0; }
#include <algorithm> #include <cstdlib> //絶対値利用のため #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; #define fr(i, n) for (int i = 0; i < n; i++) #define ifr(i, n) for (int i = n - 1; i >= 0; i--) // const int INF = INT_MAX / 2; int main() { string S; cin >> S; int counter = 0; for (int i = 0; i < S.length(); i++) { if (S[i] == '1') counter++; } int s = S.length(); cout << s - abs(counter - (s - counter)) << endl; return 0; }
[ "call.arguments.add", "call.arguments.change" ]
917,838
917,839
u534417782
cpp
p03107
#include <bits/stdc++.h> using namespace std; int main() { string S; int num_0 = 0, num_1 = 0; cin >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == '1') num_1++; else num_0++; } cout << min(num_0, num_1) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; int num_0 = 0, num_1 = 0; cin >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == '1') num_1++; else num_0++; } cout << 2 * min(num_0, num_1) << endl; }
[ "expression.operation.binary.add" ]
917,845
917,846
u738835924
cpp
p03107
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("mmx,avx,fma") //#pragma GCC optimize ("unroll-loops") using namespace __gnu_pbds; using namespace std; template <class T> istream &operator>>(istream &in, vector<T> &v) { for (auto &e : v) { in >> e; } return in; } template <char d = ' ', class T> ostream &operator<<(ostream &out, vector<T> &v) { for (auto &e : v) { out << e << d; } return out; } template <char d = ' ', class T> ostream &operator<<(ostream &out, set<T> &v) { for (auto &e : v) { out << e << d; } return out; } #define pb push_back #define mk make_pair #define X first #define Y second #define cont continue #define ret return #define For(i, a, b) for (int i = a; i < b; i++) #define forn(i, a) for (int i = 0; i < a; i++) #define ford(i, a, b) for (int i = b - 1; i >= a; i--) #define fordn(i, a) for (int i = a - 1; i >= 0; i--) #define forr(x, arr) for (auto &x : arr) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define endl '\n' #define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin()) #define int long long typedef double dd; typedef long double ldd; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<string> vs; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef map<int, int> mii; typedef map<string, int> msi; typedef set<int> si; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } template <typename T> std::string toString(T val) { std::ostringstream oss; oss << val; return oss.str(); } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; // const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1}; // const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1}; // const int dx[8] = {2, 2, 1, 1, -1, -1, -2, -2}; // const int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1}; const int mod = 1e9 + 7; // int powq(int a, int n) { // int res = 1; // while (n){ // if (n & 1) { // res *= a; // res %= mod; // --n; // } // else { // a *= a; // a %= mod; // n >>= 1; // } // // } // res %= mod; // return res; //} signed main() { // ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef KULA freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #else // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); #endif char x; cin >> x; deque<char> q; q.pb(x); int gg = 0; while (cin >> x) { if (!q.size() && q.back() != x) { gg += 2; q.pop_front(); } else q.pb(x); } cout << gg; return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("mmx,avx,fma") //#pragma GCC optimize ("unroll-loops") using namespace __gnu_pbds; using namespace std; template <class T> istream &operator>>(istream &in, vector<T> &v) { for (auto &e : v) { in >> e; } return in; } template <char d = ' ', class T> ostream &operator<<(ostream &out, vector<T> &v) { for (auto &e : v) { out << e << d; } return out; } template <char d = ' ', class T> ostream &operator<<(ostream &out, set<T> &v) { for (auto &e : v) { out << e << d; } return out; } #define pb push_back #define mk make_pair #define X first #define Y second #define cont continue #define ret return #define For(i, a, b) for (int i = a; i < b; i++) #define forn(i, a) for (int i = 0; i < a; i++) #define ford(i, a, b) for (int i = b - 1; i >= a; i--) #define fordn(i, a) for (int i = a - 1; i >= 0; i--) #define forr(x, arr) for (auto &x : arr) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define endl '\n' #define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin()) #define int long long typedef double dd; typedef long double ldd; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<string> vs; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef map<int, int> mii; typedef map<string, int> msi; typedef set<int> si; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } template <typename T> std::string toString(T val) { std::ostringstream oss; oss << val; return oss.str(); } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; // const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1}; // const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1}; // const int dx[8] = {2, 2, 1, 1, -1, -1, -2, -2}; // const int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1}; const int mod = 1e9 + 7; // int powq(int a, int n) { // int res = 1; // while (n){ // if (n & 1) { // res *= a; // res %= mod; // --n; // } // else { // a *= a; // a %= mod; // n >>= 1; // } // // } // res %= mod; // return res; //} signed main() { // ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef KULA freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #else // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); #endif char x; cin >> x; deque<char> q; q.pb(x); int gg = 0; while (cin >> x) { if (q.size() && q.back() != x) { gg += 2; q.pop_front(); } else q.pb(x); } cout << gg; return 0; }
[ "expression.operation.unary.logical.remove", "control_flow.branch.if.condition.change" ]
917,847
917,848
u283958128
cpp
p03107
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("mmx,avx,fma") //#pragma GCC optimize ("unroll-loops") using namespace __gnu_pbds; using namespace std; template <class T> istream &operator>>(istream &in, vector<T> &v) { for (auto &e : v) { in >> e; } return in; } template <char d = ' ', class T> ostream &operator<<(ostream &out, vector<T> &v) { for (auto &e : v) { out << e << d; } return out; } template <char d = ' ', class T> ostream &operator<<(ostream &out, set<T> &v) { for (auto &e : v) { out << e << d; } return out; } #define pb push_back #define mk make_pair #define X first #define Y second #define cont continue #define ret return #define For(i, a, b) for (int i = a; i < b; i++) #define forn(i, a) for (int i = 0; i < a; i++) #define ford(i, a, b) for (int i = b - 1; i >= a; i--) #define fordn(i, a) for (int i = a - 1; i >= 0; i--) #define forr(x, arr) for (auto &x : arr) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define endl '\n' #define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin()) #define int long long typedef double dd; typedef long double ldd; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<string> vs; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef map<int, int> mii; typedef map<string, int> msi; typedef set<int> si; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } template <typename T> std::string toString(T val) { std::ostringstream oss; oss << val; return oss.str(); } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; // const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1}; // const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1}; // const int dx[8] = {2, 2, 1, 1, -1, -1, -2, -2}; // const int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1}; const int mod = 1e9 + 7; // int powq(int a, int n) { // int res = 1; // while (n){ // if (n & 1) { // res *= a; // res %= mod; // --n; // } // else { // a *= a; // a %= mod; // n >>= 1; // } // // } // res %= mod; // return res; //} signed main() { // ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef KULA freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #else // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); #endif char x; cin >> x; deque<char> q; q.pb(x); int gg = 0; while (cin >> x) { if (q.back() != x) { gg += 2; q.pop_front(); } else q.pb(x); } cout << gg; return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("mmx,avx,fma") //#pragma GCC optimize ("unroll-loops") using namespace __gnu_pbds; using namespace std; template <class T> istream &operator>>(istream &in, vector<T> &v) { for (auto &e : v) { in >> e; } return in; } template <char d = ' ', class T> ostream &operator<<(ostream &out, vector<T> &v) { for (auto &e : v) { out << e << d; } return out; } template <char d = ' ', class T> ostream &operator<<(ostream &out, set<T> &v) { for (auto &e : v) { out << e << d; } return out; } #define pb push_back #define mk make_pair #define X first #define Y second #define cont continue #define ret return #define For(i, a, b) for (int i = a; i < b; i++) #define forn(i, a) for (int i = 0; i < a; i++) #define ford(i, a, b) for (int i = b - 1; i >= a; i--) #define fordn(i, a) for (int i = a - 1; i >= 0; i--) #define forr(x, arr) for (auto &x : arr) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define endl '\n' #define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin()) #define int long long typedef double dd; typedef long double ldd; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<string> vs; typedef vector<pii> vpi; typedef vector<vi> vvi; typedef map<int, int> mii; typedef map<string, int> msi; typedef set<int> si; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } template <typename T> std::string toString(T val) { std::ostringstream oss; oss << val; return oss.str(); } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; // const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1}; // const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1}; // const int dx[8] = {2, 2, 1, 1, -1, -1, -2, -2}; // const int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1}; const int mod = 1e9 + 7; // int powq(int a, int n) { // int res = 1; // while (n){ // if (n & 1) { // res *= a; // res %= mod; // --n; // } // else { // a *= a; // a %= mod; // n >>= 1; // } // // } // res %= mod; // return res; //} signed main() { // ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef KULA freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #else // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); #endif char x; cin >> x; deque<char> q; q.pb(x); int gg = 0; while (cin >> x) { if (q.size() && q.back() != x) { gg += 2; q.pop_front(); } else q.pb(x); } cout << gg; return 0; }
[ "control_flow.branch.if.condition.change" ]
917,849
917,848
u283958128
cpp
p03107
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++) #define REP(i, n) FOR(i, 0, n) #define SORT(a) sort(a.begin(), a.end()) #define ll long long #define INF 1000000000000000000 #include <algorithm> #include <cmath> #include <iomanip> #include <ios> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; int blue = 0; int red = 0; REP(i, S.length()) { if (S[i] == 0) { red++; } else { blue++; } } cout << min(red, blue) * 2 << endl; return 0; }
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++) #define REP(i, n) FOR(i, 0, n) #define SORT(a) sort(a.begin(), a.end()) #define ll long long #define INF 1000000000000000000 #include <algorithm> #include <cmath> #include <iomanip> #include <ios> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main() { string S; cin >> S; int blue = 0; int red = 0; REP(i, S.length()) { if (S[i] == '0') { red++; } else { blue++; } } cout << min(red, blue) * 2 << endl; return 0; }
[ "control_flow.branch.if.condition.change" ]
917,858
917,859
u489197691
cpp
p03107
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define vel vector<long long> #define vvel vector<vel> #define vvvel vector<vvel> int root1(vel &par, int ser, vel &path) { if (par[ser] == -1) { for (int i = 0; i < path.size(); i++) { par[path[i]] = ser; } return ser; } path.push_back(ser); return root1(par, par[ser], path); } int root(vel &par, int ser) { vel emp(0); return root1(par, ser, emp); } void uni(int x, int y, vel &par, vel &rank) { x = root(par, x); y = root(par, y); if (x != y) { if (rank[x] < rank[y]) { par[x] = y; } else if (rank[x] == rank[y]) { par[x] = y; rank[x]++; } else { par[y] = x; } } } bool issame(int x, int y, vel &par) { return root(par, x) == root(par, y); } signed main() { string s; cin >> s; int c0 = 0; int c1 = 1; int ans = 0; int n = s.size(); for (int i = 0; i < n; i++) { if (s[i] == '0') { c0++; } else { c1++; } } cout << 2 * min(c0, c1) << endl; }
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; #define int long long #define vel vector<long long> #define vvel vector<vel> #define vvvel vector<vvel> int root1(vel &par, int ser, vel &path) { if (par[ser] == -1) { for (int i = 0; i < path.size(); i++) { par[path[i]] = ser; } return ser; } path.push_back(ser); return root1(par, par[ser], path); } int root(vel &par, int ser) { vel emp(0); return root1(par, ser, emp); } void uni(int x, int y, vel &par, vel &rank) { x = root(par, x); y = root(par, y); if (x != y) { if (rank[x] < rank[y]) { par[x] = y; } else if (rank[x] == rank[y]) { par[x] = y; rank[x]++; } else { par[y] = x; } } } bool issame(int x, int y, vel &par) { return root(par, x) == root(par, y); } signed main() { string s; cin >> s; int c0 = 0; int c1 = 0; int ans = 0; int n = s.size(); for (int i = 0; i < n; i++) { if (s[i] == '0') { c0++; } else { c1++; } } cout << 2 * min(c0, c1) << endl; }
[ "literal.number.change", "variable_declaration.value.change" ]
917,869
917,870
u021034020
cpp
p03107
#include <iostream> int main() { std::string s; std::cin >> s; unsigned long count = 0; for (char c : s) { if (c == '1') { count++; } } int t = std::min(count, (s.length() - count)); t /= 2; std::cout << t * 4 << std::endl; }
#include <iostream> int main() { std::string s; std::cin >> s; unsigned long count = 0; for (char c : s) { if (c == '1') { count++; } } int t = std::min(count, (s.length() - count)); std::cout << t * 2 << std::endl; }
[ "literal.number.change", "expression.operation.binary.change" ]
917,875
917,876
u718277423
cpp
p03106
#include <iostream> using namespace std; int main() { int A, B, K, i; cin >> A >> B >> K; for (i = 1; K; ++i) if ((A % i == 0) && (B % i == 0)) --K; cout << i; return 0; }
#include <iostream> using namespace std; int main() { int A, B, K, i; cin >> A >> B >> K; for (i = B; K; --i) if ((A % i == 0) && (B % i == 0)) --K; cout << ++i; return 0; }
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change" ]
917,880
917,881
u550314572
cpp
p03106
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; const int INF = 1e9, MOD = 1e9 + 7; const ll LINF = 1e18; using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define rrep(i, a, b) for (int i = (a); i < (b); i++) #define rrrep(i, a, b) for (int i = (a); i >= (b); i--) #define all(v) (v).begin(), (v).end() #define Size(n) (n).size() #define Cout(x) cout << (x) << endl #define fi first #define se second #define int long long // template // main signed main() { int A, B, K; cin >> A >> B >> K; int k = 0, ans = 0; for (int i = 100; i > 0; i--) { if (A % i == 0 || B % i == 0) { k++; if (k == K) ans = i; } } Cout(ans); }
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; const int INF = 1e9, MOD = 1e9 + 7; const ll LINF = 1e18; using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++) #define rrep(i, a, b) for (int i = (a); i < (b); i++) #define rrrep(i, a, b) for (int i = (a); i >= (b); i--) #define all(v) (v).begin(), (v).end() #define Size(n) (n).size() #define Cout(x) cout << (x) << endl #define fi first #define se second #define int long long // template // main signed main() { int A, B, K; cin >> A >> B >> K; int k = 0, ans = 0; for (int i = 100; i > 0; i--) { if (A % i == 0 && B % i == 0) { k++; if (k == K) ans = i; } } Cout(ans); }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
917,882
917,883
u942774736
cpp
p03106
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int A, B, K; //--------------------------------------------------------------------------------------------------- void _main() { cin >> A >> B >> K; vector<int> v; rep(i, 1, 101) if (A % i == 0 and B % i == 0) v.push_back(i); cout << v[K - 1] << endl; }
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int A, B, K; //--------------------------------------------------------------------------------------------------- void _main() { cin >> A >> B >> K; vector<int> v; rrep(i, 100, 1) if (A % i == 0 and B % i == 0) v.push_back(i); cout << v[K - 1] << endl; }
[ "identifier.change", "call.function.change", "literal.number.change", "call.arguments.change" ]
917,913
917,914
u141378465
cpp
p03106
#include <iostream> using namespace std; int main() { int A, B, K; cin >> A; cin >> B; cin >> K; int count = 0; int i = 1; for (int i = 100; i > 0; i--) { if (A % i == 0 && B % i == 0) count++; } if (count == K) { cout << i << endl; return 0; } return 0; }
#include <iostream> using namespace std; int main() { int A, B, K; cin >> A; cin >> B; cin >> K; int count = 0; int i = 1; for (int i = 100; i > 0; i--) { if (A % i == 0 && B % i == 0) count++; if (count == K) { cout << i << endl; break; } } return 0; }
[ "control_flow.return.remove", "control_flow.break.add" ]
917,915
917,916
u761510695
cpp
p03106
#include <iostream> using namespace std; void swap(int &a, int &b) { int t = a; a = b; b = t; } int euc(int a, int b) { if (b < a) swap(a, b); while (a) { b = b % a; swap(a, b); } return b; } int main() { int A, B, K; cin >> A >> B >> K; int t = euc(A, B); int j = t; for (int i = 0; i < K - 1;) { if (!(t % j)) i--; j--; } cout << j + 1 << endl; }
#include <iostream> using namespace std; void swap(int &a, int &b) { int t = a; a = b; b = t; } int euc(int a, int b) { if (b < a) swap(a, b); while (a) { b = b % a; swap(a, b); } return b; } int main() { int A, B, K; cin >> A >> B >> K; int t = euc(A, B); int j = t; for (int i = 0; i < K;) { if (!(t % j)) i++; j--; } cout << j + 1 << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
917,923
917,924
u058186113
cpp
p03106
#include <iostream> using namespace std; int main() { int a, b, k, s, l, n, m; n = 0; int p[70], q[70]; cin >> a >> b >> k; if (b >= a) { s = a; l = b; } else { s = b; l = a; } for (int i = 1; i <= s; i++) { if ((s % i) == 0) { p[n] = i; n++; } } m = 0; for (int j = 0; j < n; j++) { if ((l % p[j]) == 0) { q[m] = p[j]; m++; } } cout << q[k - 1]; return 0; }
#include <iostream> using namespace std; int main() { int a, b, k, s, l, n, m; n = 0; int p[100], q[100]; cin >> a >> b >> k; if (b >= a) { s = a; l = b; } else { s = b; l = a; } for (int i = 1; i <= s; i++) { if ((s % i) == 0) { p[n] = i; n++; } } m = 0; for (int j = 0; j < n; j++) { if ((l % p[j]) == 0) { q[m] = p[j]; m++; } } cout << q[m - k]; return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "identifier.change", "variable_access.subscript.index.change", "io.output.change", "identifier.replace.add", "literal.replace.remove" ]
917,937
917,938
u448058760
cpp
p03106
#include <iostream> using namespace std; int main() { int a, b, k, s, l, n, m; n = 0; int p[100], q[100]; cin >> a >> b >> k; if (b >= a) { s = a; l = b; } else { s = b; l = a; } for (int i = 1; i <= s; i++) { if ((s % i) == 0) { p[n] = i; n++; } } m = 0; for (int j = 0; j < n; j++) { if ((l % p[j]) == 0) { q[m] = p[j]; m++; } } cout << q[k - 1]; return 0; }
#include <iostream> using namespace std; int main() { int a, b, k, s, l, n, m; n = 0; int p[100], q[100]; cin >> a >> b >> k; if (b >= a) { s = a; l = b; } else { s = b; l = a; } for (int i = 1; i <= s; i++) { if ((s % i) == 0) { p[n] = i; n++; } } m = 0; for (int j = 0; j < n; j++) { if ((l % p[j]) == 0) { q[m] = p[j]; m++; } } cout << q[m - k]; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "io.output.change", "identifier.replace.add", "literal.replace.remove" ]
917,939
917,938
u448058760
cpp
p03106
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { int a, b, c; cin >> a >> b >> c; int ans = 0; while (c > 1) { ++ans; if (a % ans == 0 && b % ans == 0) { --c; } } cout << ans << endl; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int main() { int a, b, c; cin >> a >> b >> c; int ans = 200; while (c) { --ans; if (a % ans == 0 && b % ans == 0) { --c; } } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "expression.operation.binary.remove" ]
917,947
917,948
u352642493
cpp
p03106
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int a, b, k; cin >> a >> b >> k; int waru[100], kazu; kazu = 0; for (int i = min(a, b); i >= 0; i--) { if (a % i == 0 && b % i == 0) { kazu++; waru[kazu] = i; } } cout << waru[k] << endl; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int a, b, k; cin >> a >> b >> k; int waru[100], kazu; kazu = 0; for (int i = min(a, b); i >= 1; i--) { if (a % i == 0 && b % i == 0) { kazu++; waru[kazu] = i; } } cout << waru[k] << endl; }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
917,953
917,954
u356117208
cpp
p03106
#include <algorithm> #include <functional> #include <iostream> #include <vector> using namespace std; int main() { int a, b, k, r; cin >> a >> b >> k; swap(a, b); while ((r = a % b)) { a = b; b = r; } vector<int> ans; for (int i = 1; i < b; i++) { if (b % i == 0) ans.push_back(i); } sort(ans.begin(), ans.end(), greater<int>()); cout << ans[k - 1] << endl; return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <vector> using namespace std; int main() { int a, b, k, r; cin >> a >> b >> k; swap(a, b); while ((r = a % b)) { a = b; b = r; } vector<int> ans; for (int i = 1; i <= b; i++) { if (b % i == 0) ans.push_back(i); } sort(ans.begin(), ans.end(), greater<int>()); cout << ans[k - 1] << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
917,964
917,965
u911027648
cpp
p03106
#include <algorithm> #include <functional> #include <iostream> #include <vector> using namespace std; int main() { int a, b, k, r; cin >> a >> b >> k; swap(a, b); while ((r = a % b)) { a = b; b = r; } vector<int> ans; for (int i = 1; i < b; i++) { if (b % i == 0) ans.push_back(i); } sort(ans.begin(), ans.end(), greater<int>()); cout << ans[k] << endl; return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <vector> using namespace std; int main() { int a, b, k, r; cin >> a >> b >> k; swap(a, b); while ((r = a % b)) { a = b; b = r; } vector<int> ans; for (int i = 1; i <= b; i++) { if (b % i == 0) ans.push_back(i); } sort(ans.begin(), ans.end(), greater<int>()); cout << ans[k - 1] << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
917,966
917,965
u911027648
cpp
p03106
#include <bits/stdc++.h> typedef long long int ll; using namespace std; int main() { int A, B, K; cin >> A >> B >> K; int m = min(A, B); int c = 0; for (int i = m; i > 1; --i) { if (A % i == 0 && B % i == 0) c++; if (c == K) { cout << i; return 0; } } }
#include <bits/stdc++.h> typedef long long int ll; using namespace std; int main() { int A, B, K; cin >> A >> B >> K; int m = min(A, B); int c = 0; for (int i = m; i >= 1; --i) { if (A % i == 0 && B % i == 0) c++; if (c == K) { cout << i; return 0; } } cout << 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
917,969
917,970
u208073493
cpp
p03106
// Codeforces: ganariya // AtCoder: ganariya2525 // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMHBYYYWMMMM#BYYTTTYWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMB9O1==?????zzCC111>>;;;;;;;;;;;<?TMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM9Olll=l======??????????>>>>>>;;;;;;;;;:;?TMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMM9ttlllllllll=l=======?????????>>>>>>;;;;;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMBOttOtttttltlllllllll=======??????????>>>>>>>;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMBttwOtttttttttttttlllllllll========?????????>>>>>>;;;;;<TMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMBrwZrttttttttttttttttttlllllllllll======???????????>>>>>>;;?HMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMSw0trtrrtrtrttrtttttttttttttlllOllllll========????<<zz??>>>>>>ZMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMX0ttrtrOOttrttrttOOttttttttttttltwllllllllll========??wy?????>>>vZMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMM0ttrI+wV1rtttttttwZtttttttltttOwylOXOllllllllllll=l====1dkz???????vZdMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMSrrwrtwZCjttttttttwSttOlllltllllwtXOlZkOlllllllllllllll==z+dk===?????X2JMMMMMMMMMMMMM // MMMMMMMMMMMMMBrtwwtrw0<jttttttttOXllOttltllttllOZwHOtXkyltlllllllllllllll<+XZ======?dk?JMMMMMMMMMMMM // MMMMMMMMMMMMStwdZtwXC<+ttttttOOOd6ltZlltllllttllStWWOOHWytttttltltOllltllz:zHllll===zX=?dMMMMMMMMMMM // MMMMMMMMMMBrwdKOtwW3;;zrttttwZwXRlldOllltltlltttwlXvktdXWytltttttttOttlttl<<dklllllllZ===dMMMMMMMMMM // MMMMMMMMM8tQM#ttwW3;;;1trttwSwfUOlORltllltlllllldtX>dktDOWOtlttltttOOttltO<;+WOllllllXlllzMMMMMMMMMM // MMMMMMMM9OdM#Ottd$;;;;;<?1z0OKjRltd0llltOllllllldZX>?WOw_WWOtttttttttOttI<;;<dkttttllllllldMMMMMMMMM // MMMMMMM9wMMMSttwS<;;;;>;;;J<j>(I<?U111zltllllllld0X>~dkwl(WkttlttlOOwWk<;;:;;zHttttttwOllllMMMMMMMMM // MMMMMMBdMMM8tttdI+zttttttdSXt~dlzXwlllzzOzzzzzlldkW<~?kOk~?sx++++jdHmH6+++<;;jdZtttttdkOtlldMMMMMMMM // MMMMM#dMMM#tttw0+tttttttdKdf((RsdfRllllldZllltlldWK~~_W0w_~OWOlOdgg9ZtOWOtttz+wktttttdpktttwMMMMMMMM // MMMMMWMMMMSlttdIttttttOdWHH>~(IzWDRll=llzRlllzlldk$>++dkd<~_XkdgH9tttttdktttt+OkrttrtdfpkttOMMMMMMMM // MMMMNWMMM#Zttlk=tttttOXWWd$_.(IdW1R=llll=SlllzOldK<_._(kd6+-(MM9lltttttrWktttztWZttrwXppWttrMMMMMMMM // MMMMNMMMM#lltwDzttllOXyW0X:..(OXk<Rl=ll=lwOlllOld3<``.(Rd>~?CdklllltttttXdXttzOWktrwwWpfpkrtMMMMMMMM // MMMMMMMMM@ltldIzlttOXyW$w$```(OyD(Rl==llldZ=llIlw;~```-Xd:~~~~UkylltttAyHdgSrzObRtOXwpfppWrrMMMMMMMM // MMMMMMMMM@llldtlllldVyW+d>```.wZ$ wl==lI=wRl=ll=w<```` // dd_..~~(RZXOQdggHH9ZwrzwHWrdXXppfppkrMMMMMMMM // MMMMMMMMM#llldlltlwyyyD(S-...,Wk] zI=l=llzWzl=l=P~```` // jZ``...~zQkH@MBUtrZtrtldHRdSdpfpffpkwMMMMMMMM // MMMMNMMMMNZllXtllldVyW3(Mf=<ONMHP~(k===l=zdk=lld3```...(C````..(M96lttttrrtrrtdHWHXpfpppfpRwMMMMMMMM // MMMMMMMMMMNzzWZllzyyyy(W@` =~MWK6 jz=lzlzvRz=lZ`.I+JgkWm&-. // `..(ZltlttttrtttrWWHppfppfpppSdMMMMMMMM MMMMMMMMMMMkAWRllzVyyS_(b // .MNHU-(Uz=lI={XkzO>.dVT7<TMHMNHHx-.(kwZyltttrtrrdHHpfppfpffpp0dMMMMMMMM // MMMMMMMMMMMMKyWzOzyyyk.`<! hdWMH]``(S==t=l(kX2 ?_` // WMMHH#HH+.XwkwOttttrwrZ~(HfpfpppfpWwXMMMMMMMM MMMMMMMMMMMMMHWROOyyyW;` `. // (WVM#b```(0=zzz wX!``` a.dM#NM@N(4WhXkXkWtttttwd3O_(HpffpfpfWwSMMMMMMMM // MMMMMMMMMMMMNZvWzXXyyXP```-_ ?o+?!````.4=Z=`(:```` HpbNNMHHH // (C=XXyWZWttrdwf:(>.dfppffppSXSMMMMMMMM // MMMMMMMMMMMMMRzuHzXyZXH.``````````````` ?zz ``````` ZKvTHHbWt `` // XZyyHZWOdSZ<::~`(fpfpfffXp0WMMMMMMM // MMMMMMMMMMMMMKzyyHvyZZW____.`````````````.I_```````` // ?nJzX7^````.WXWyyHyWKZ<:::_`Jffpfpfpfp0WMMMMMMM // MMMMMMMMMMMMM@zZyZWwWyXo-_~(~ ```````````` `````````````` // _`````.WXkyyVWmWc::<~ .HffppfffffkXMMMMMMM // MMMMMMMMMMMMMKzZZZZXkUXr~....```````....```````````` ... // ````..JXWWyyW83vXx~..WfffVfWVffffkdMMMMMMM // MMMMMMMMMMMMMRzZZZZZZZZb````````````<````````````./<~._<_.____`(WfdyW3<:~~(XWkVVVVVVVHVVVVV0dMMMMMMM // MMMMMMMMMMMMMSzZZZZZZZWX-```````````````````````````.......~~._j9jX=_~~_(XZyVHHkyyyyWHyyykykOMMMMMMM // MMMMMMMMMMMMMSzuuuuuZXWZW,```````````````````````````````.``..(3<! // ...JWyyXWyyyWHkyyWHyyyHyklMMMMMMM MMMMMMMMMMMMNXzuuuXXuXSuuXh,```````` .... // ```````````````````_~ .JWyyyyZyy0HyyZyyZyZXWZZZWHZIdMMMMMM // MMMMMMMMMMMMNwtuuuXkuXXuuuuXh,``````(:::~<?71(,``````````````.(UMNUkZZZZZZZHZZ0ZZZZZWWZZZWNXIdMMMMMM // MMMMMMMMMMMMNKOzuzXkuXuuuuuXuXW, ```` // _~~~:~~(}```````````.(YC;::<kCfZZZZXO#ZZVZZZZZMZZuuMMNXzMMMMMM // MMMMMMMMMMMMHKOzzuXkzdzzzzuXXzuuU&.``````````````````` // .JY>::::;;J=:dZuZuZd#uuruuuud#uuuXMMMNXdMMMMM // MMMMMMMMMMMMMNOvzzXkvMRzzzzXKzuzzzXh, // `````````````..JC<;:;;:;;+7<:~(HHuXIdNuuzuuuXMSuuuWMMMMROMMMMM // MMMMMMMMMMMMMNvvvrdkvM#vzzzzHzzzzzuzzUG. ``` // ...JdY<:;:;:::;;+v<~~~:(HpHmzMNXZzuzzd#zzzdMMMMMMRdMMMM // MMMMMMMMMMMMMNwrrvdRrMNwvvvvdRvvvzwkzzzzXWWHY=~~O+::::::::<+<~~~~~~~dppppWMMkZzzzwM#zzdMMMMMMMMNMMMM // MMMMMMMMMMMMMM#rrrwRrMMbOrrOZNkrvvvXwvvvvvwX;.~._W_:::::(?!~~~~~~~~(HpppppppHWdvwM#XwdMMMMMMMMMMNMMM // MMMMMMMMMMMMMMNyrrrRrWMMmzOrzdNyrrrZNvrwQWWfb....(r~~_J>_.....~.~~-dpfpffpfpppWHHMNdMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMNrtrStdMMMNxzrzMNmrrrdNWfVfffP._-.(~_J!............JpfpffpfpfffpppWNppppHMMMMMMMMMMMM // MMMMMMMMMMMMMMMMNOtXtdMMMMMNxzZMMNmgHyVVVVVW%..?/(.,(x-..........(HfffpffpffpffWHHffpffppfVyyWMMMMMM // include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef vector<int> VI; typedef vector<bool> VB; typedef vector<char> VC; typedef vector<double> VD; typedef vector<string> VS; typedef vector<LL> VLL; typedef vector<VI> VVI; typedef vector<VB> VVB; typedef vector<VS> VVS; typedef vector<VLL> VVLL; typedef vector<VVI> VVVI; typedef vector<VVLL> VVVLL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<int, string> PIS; typedef pair<string, int> PSI; typedef pair<string, string> PSS; typedef vector<PII> VPII; typedef vector<PLL> VPLL; typedef vector<VPII> VVPII; typedef vector<VPLL> VVPLL; typedef vector<VS> VVS; typedef map<int, int> MII; typedef map<LL, LL> MLL; typedef map<string, int> MSI; typedef map<int, string> MIS; //数値・文字列 //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline LL toLongLong(string s) { LL v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline VC toVC(string s) { VC data(s.begin(), s.end()); return data; } template <typename List> void SPRIT(const std::string &s, const std::string &delim, List &result) { result.clear(); string::size_type pos = 0; while (pos != string::npos) { string::size_type p = s.find(delim, pos); if (p == string::npos) { result.push_back(s.substr(pos)); break; } else { result.push_back(s.substr(pos, p - pos)); } pos = p + delim.size(); } } vector<string> SPRIT(const std::string &s, const std::string &delim) { vector<string> result; string::size_type pos = 0; while (pos != string::npos) { string::size_type p = s.find(delim, pos); if (p == string::npos) { result.push_back(s.substr(pos)); break; } else { result.push_back(s.substr(pos, p - pos)); } pos = p + delim.size(); } return result; } string TRIM(const string &str, const char *trimCharacterList = " \t\v\r\n") { string result; string::size_type left = str.find_first_not_of(trimCharacterList); if (left != string::npos) { string::size_type right = str.find_last_not_of(trimCharacterList); result = str.substr(left, right - left + 1); } return result; } string REPLACE_STRING(const string source, const string find, const string alt) { string result = source; string::size_type pos = 0; while (pos = result.find(find, pos), pos != string::npos) { result.replace(pos, find.length(), alt); pos += alt.length(); } return result; } template <typename T> bool VECTOR_EXISTS(vector<T> vec, T data) { auto itr = std::find(vec.begin(), vec.end(), data); size_t index = distance(vec.begin(), itr); if (index != vec.size()) return true; else return false; } template <typename T> vector<T> VECTOR_UNIQUE_ERASE(vector<T> vec) { sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } template <typename T> void VECTOR_REMOVE_VALUE_ALL(vector<T> &vec, T data) { vec.erase(remove(vec.begin(), vec.end(), data), vec.end()); } template <typename T> vector<T> VECTOR_REMOVE_VALUE_ALL_FAST(vector<T> vec, T data) { vector<T> vec2; for (auto &x : vec) if (x != data) vec2.push_back(x); return vec2; } bool REG_MATCH(string const &text, regex const &re) { bool result = regex_match(text, re); return result; } bool REG_MATCH(string const &text, smatch &match, regex const &re) { bool result = regex_match(text, match, re); return result; } smatch REG_SEARCH(string const &text, regex const &re) { smatch m; regex_search(text, m, re); return m; } vector<smatch> REG_ALL_SEARCH(string const &text, regex const &re) { vector<smatch> matchs; sregex_iterator iter(text.cbegin(), text.cend(), re); sregex_iterator end; for (; iter != end; iter++) matchs.push_back(*iter); return matchs; } string REG_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace, regex_constants::format_first_only); return result; } string REG_ALL_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace); return result; } template <typename T, typename U, typename V, typename W> auto operator+(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first + r.first), decltype(l.second + r.second)> { return {l.first + r.first, l.second + r.second}; } template <typename T, typename U, typename V, typename W> auto operator-(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first - r.first), decltype(l.second - r.second)> { return {l.first - r.first, l.second - r.second}; } #define UPPER(s) transform((s).begin(), (s).end(), (s).begin(), ::toupper) #define LOWER(s) transform((s).begin(), (s).end(), (s).begin(), ::tolower) //四捨五入 nLen=小数点第n位にする //------------------------------------------ //切り上げ double ceil_n(double dIn, int nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.9); return dOut * pow(10.0, -nLen); } //切り捨て double floor_n(double dIn, int nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut); return dOut * pow(10.0, -nLen); } //四捨五入 double round_n(double dIn, int nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.5); return dOut * pow(10.0, -nLen); } // n桁目の数の取得 int take_a_n(LL num, int n) { string str = toString(num); return str[str.length() - n] - '0'; } //整数を2進数表記したときの1の個数を返す LL bitcount64(LL bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff); } // comparison //------------------------------------------ #define C_MAX(a, b) ((a) > (b) ? (a) : (b)) #define C_MIN(a, b) ((a) < (b) ? (a) : (b)) #define C_ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b)) template <typename T1, typename T2> inline void S_MAX(T1 &a, T2 b) { a = C_MAX(a, b); }; template <typename T1, typename T2> inline void S_MIN(T1 &a, T2 b) { a = C_MIN(a, b); }; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) int((a).size()) #define EACH(i, arr) \ for (typeof((arr).begin()) i = (arr).begin(); i != (arr).end(); ++i) #define EXIST(str, e) ((str).find(e) != (str).end()) #define COUNT(arr, v) count((arr).begin(), (arr).end(), v) #define SEARCH(v, w) search((v).begin(), (v).end(), (w).begin(), (w).end()) #define B_SEARCH(arr, v) binary_search((arr).begin(), (arr).end(), v) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define ROTATE_LEFT(arr, c) \ rotate((arr).begin(), (arr).begin() + (c), (arr).end()) #define ROTATE_RIGHT(arr, c) \ rotate((arr).rbegin(), (arr).rbegin() + (c), (arr).rend()) #define SUMI(arr) accumulate((arr).begin(), (arr).end(), 0) #define SUMD(arr) accumulate((arr).begin(), (arr).end(), 0.) #define SUMLL(arr) accumulate((arr).begin(), (arr).end(), 0LL) #define SUMS(arr) accumulate((arr).begin(), (arr).end(), string()) #define MULD(arr) \ accumulate((arr).begin(), (arr).end(), 1., multiplies<double>()) #define MULLL(arr) \ accumulate((arr).begin(), (arr).end(), 1LL, multiplies<long long>()) #define UB(arr, n) upper_bound((arr).begin(), (arr).end(), n) #define LB(arr, n) lower_bound((arr).begin(), (arr).end(), n) #define OF_ALL(arr, func) all_of((arr).begin(), (arr).end(), (func)) #define OF_NONE(arr, func) none_of((arr).begin(), (arr).end(), (func)) #define OF_ANY(arr, func) any_of((arr).begin(), (arr).end(), (func)) #define PB push_back #define MP make_pair #define ft first #define sd second // input output //------------------------------------------ #define GL(s) getline(cin, (s)) #define INIT() \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define OUT(d) std::cout << (d) #define OUT_L(d) std::cout << (d) << endl #define FOUT(n, data) std::cout << std::fixed << std::setprecision(n) << (data) #define FOUT_L(n, data) \ std::cout << std::fixed << std::setprecision(n) << (data) << "\n" #define EL() printf("\n") #define SHOW_VECTOR(v) \ { \ std::cerr << #v << "\t:"; \ for (const auto &xxx : v) { \ std::cerr << xxx << " "; \ } \ std::cerr << "\n"; \ } #define SHOW_MAP(v) \ { \ std::cerr << #v << endl; \ for (const auto &xxx : v) { \ std::cerr << xxx.first << " " << xxx.second << "\n"; \ } \ } #define Yes() printf("Yes\n") #define No() printf("No\n") #define YES() printf("YES\n") #define NO() printf("NO\n") template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &p) { in >> p.first >> p.second; return in; } template <typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &x : v) in >> x; return in; } // repetition //------------------------------------------ #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(i, 0, n) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define FORLL(i, a, b) for (LL i = LL(a); i < LL(b); ++i) #define RFORLL(i, a, b) for (LL i = LL(b) - 1; i >= LL(a); --i) #define REPLL(i, n) for (LL i = 0; i < LL(n); ++i) #define RREPLL(i, n) for (LL i = LL(n) - 1; i >= 0; --i) #define FOREACH(x, arr) for (auto &(x) : (arr)) #define FORITER(x, arr) for (auto(x) = (arr).begin(); (x) != (arr).end(); ++(x)) // constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; // math //-------------------------------------------- // min <= aim <= max template <typename T> inline bool BETWEEN(const T aim, const T min, const T max) { if (min <= aim && aim <= max) { return true; } else { return false; } } template <typename T1, typename T2> inline bool IS_OUT(const T1 toY, const T1 toX, const T2 H, const T2 W) { return (toY < 0 || toY >= H || toX < 0 || toX >= W); } template <class T> inline T SQR(const T x) { return x * x; } template <class T1, class T2> inline T1 POW(const T1 x, const T2 y) { if (!y) return 1; else if ((y & 1) == 0) { return SQR(POW(x, y >> 1)); } else return POW(x, y ^ 1) * x; } template <typename T> constexpr T ABS(T x) { return x < 0 ? -x : x; } // partial_permutation nPr 順列 // first・・最初の数 // middle・・r(取り出す数) // last・・n(全体数) template <class Iter> bool next_partial_permutation(Iter first, Iter middle, Iter last) { reverse(middle, last); return next_permutation(first, last); } // combination nCr 組み合わせ // first1・・最初の数 // last1==first2・・r(取り出す数) // last2・・n(全体数) template <class Iter> bool next_combination(Iter first1, Iter last1, Iter first2, Iter last2) { if ((first1 == last1) || (first2 == last2)) { return false; } Iter m1 = last1; Iter m2 = last2; --m2; while (--m1 != first1 && !(*m1 < *m2)) { } bool result = (m1 == first1) && !(*first1 < *m2); if (!result) { while (first2 != m2 && !(*m1 < *first2)) { ++first2; } first1 = m1; std::iter_swap(first1, first2); ++first1; ++first2; } if ((first1 != last1) && (first2 != last2)) { m1 = last1; m2 = first2; while ((m1 != first1) && (m2 != last2)) { std::iter_swap(--m1, m2); ++m2; } std::reverse(first1, m1); std::reverse(first1, last1); std::reverse(m2, last2); std::reverse(first2, last2); } return !result; } // numeric_law //-------------------------------------------- template <typename T> constexpr bool ODD(T x) { return x % 2 != 0; } template <typename T> constexpr bool EVEN(T x) { return x % 2 == 0; } //最大公約数 template <class T> inline T GCD(const T x, const T y) { if (x < 0) return GCD(-x, y); if (y < 0) return GCD(x, -y); return (!y) ? x : GCD(y, x % y); } //最小公倍数 template <class T> inline T LCM(const T x, const T y) { if (x < 0) return LCM(-x, y); if (y < 0) return LCM(x, -y); return x * (y / GCD(x, y)); } // ax + by = 1 // x,yが変数に格納される template <class T> inline T EXTGCD(const T a, const T b, T &x, T &y) { if (a < 0) { T d = EXTGCD(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = EXTGCD(a, -b, x, y); y = -y; return d; } if (!b) { x = 1; y = 0; return a; } else { T d = EXTGCD(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } //素数 template <class T> inline bool ISPRIME(const T x) { if (x <= 1) return false; for (T i = 2; i * i <= x; i++) if (x % i == 0) return false; return true; } //素数をtrueとして返す template <class T> VB ERATOSTHENES(const T n) { VB arr(n + 1, true); arr[0] = arr[1] = false; for (LL i = 2; i * i <= n; i++) { if (arr[i]) { for (LL j = i * 2LL; j <= n; j += i) { arr[j] = false; } } } return arr; } // a <= x < b の素数を返す template <typename T> VB ERATOSTHENES(const T a, const T b) { VB small = ERATOSTHENES(b); VB prime(b - a, true); for (LL i = 2; i * i <= b; i++) { if (small[i]) { for (LL j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) { prime[j - a] = false; } } } return prime; } // nの約数 template <typename T> vector<T> DIVISOR(T n) { vector<T> v; for (LL i = 1; i * i <= n; ++i) { if (n % i == 0) { v.push_back(i); if (i != n / i) { v.push_back(n / i); } } } sort(v.begin(), v.end()); return v; } // nまでのすべての約数 template <typename T> vector<vector<T>> DIVISOR_ALL(T n) { vector<vector<T>> res(n + 1); for (LL i = 1; i <= n; i++) { for (LL j = i; j <= n; j += i) { res[j].push_back(i); } } return res; } //素因数分解 template <typename T> vector<pair<T, LL>> FACTORIZATION(T x) { vector<pair<T, LL>> ans; for (LL i = 2; i * i <= x; i++) { if (x % i == 0) { LL count = 0; while (x % i == 0) { count++; x /= i; } ans.push_back(MP(i, count)); } } if (x != 1) ans.push_back(MP(x, 1)); return ans; } // N^P (mod M) LL POW_MOD(LL N, LL P, LL M) { if (P == 0) return 1LL; if (P % 2 == 0) { LL ret = POW_MOD(N, P / 2, M); return ret * ret % M; } return N * POW_MOD(N, P - 1, M) % M; } //組み合わせ個数 template <typename T> inline T NCR(T n, T r) { if (r > n - r) r = n - r; T ans = 1; REPLL(i, r) { ans = ans * (n - i) / (i + 1); } return ans; } //組み合わせ個数 (mod M) LL NCR_MOD(LL n, LL r, LL M) { if (r > n - r) return NCR_MOD(n, n - r, M); LL numerator = 1LL; //分子 LL denominator = 1LL; //分母 for (LL i = 0; i < r; i++) { numerator *= (n - i); numerator %= M; denominator *= (i + 1); denominator %= M; } return numerator * POW_MOD(denominator, M - 2, M) % M; } // confirmation //-------------------------------------------- // clear memory #define CLR(arr, d) memset((arr), (d), sizeof(arr)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << endl; //~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~ int main() { int A, B; cin >> A >> B; int K; cin >> K; vector<int> arr; for (int i = 1; i <= min(A, B); i++) { if (A % i == 0 && B % i == 0) { arr.push_back(i); } } SORT(arr); cout << arr[K - 1]; return 0; }
// Codeforces: ganariya // AtCoder: ganariya2525 // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMHBYYYWMMMM#BYYTTTYWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMB9O1==?????zzCC111>>;;;;;;;;;;;<?TMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM9Olll=l======??????????>>>>>>;;;;;;;;;:;?TMMMMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMMMM9ttlllllllll=l=======?????????>>>>>>;;;;;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMMMBOttOtttttltlllllllll=======??????????>>>>>>>;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMMMBttwOtttttttttttttlllllllll========?????????>>>>>>;;;;;<TMMMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMMBrwZrttttttttttttttttttlllllllllll======???????????>>>>>>;;?HMMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMMSw0trtrrtrtrttrtttttttttttttlllOllllll========????<<zz??>>>>>>ZMMMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMMMX0ttrtrOOttrttrttOOttttttttttttltwllllllllll========??wy?????>>>vZMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMMM0ttrI+wV1rtttttttwZtttttttltttOwylOXOllllllllllll=l====1dkz???????vZdMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMSrrwrtwZCjttttttttwSttOlllltllllwtXOlZkOlllllllllllllll==z+dk===?????X2JMMMMMMMMMMMMM // MMMMMMMMMMMMMBrtwwtrw0<jttttttttOXllOttltllttllOZwHOtXkyltlllllllllllllll<+XZ======?dk?JMMMMMMMMMMMM // MMMMMMMMMMMMStwdZtwXC<+ttttttOOOd6ltZlltllllttllStWWOOHWytttttltltOllltllz:zHllll===zX=?dMMMMMMMMMMM // MMMMMMMMMMBrwdKOtwW3;;zrttttwZwXRlldOllltltlltttwlXvktdXWytltttttttOttlttl<<dklllllllZ===dMMMMMMMMMM // MMMMMMMMM8tQM#ttwW3;;;1trttwSwfUOlORltllltlllllldtX>dktDOWOtlttltttOOttltO<;+WOllllllXlllzMMMMMMMMMM // MMMMMMMM9OdM#Ottd$;;;;;<?1z0OKjRltd0llltOllllllldZX>?WOw_WWOtttttttttOttI<;;<dkttttllllllldMMMMMMMMM // MMMMMMM9wMMMSttwS<;;;;>;;;J<j>(I<?U111zltllllllld0X>~dkwl(WkttlttlOOwWk<;;:;;zHttttttwOllllMMMMMMMMM // MMMMMMBdMMM8tttdI+zttttttdSXt~dlzXwlllzzOzzzzzlldkW<~?kOk~?sx++++jdHmH6+++<;;jdZtttttdkOtlldMMMMMMMM // MMMMM#dMMM#tttw0+tttttttdKdf((RsdfRllllldZllltlldWK~~_W0w_~OWOlOdgg9ZtOWOtttz+wktttttdpktttwMMMMMMMM // MMMMMWMMMMSlttdIttttttOdWHH>~(IzWDRll=llzRlllzlldk$>++dkd<~_XkdgH9tttttdktttt+OkrttrtdfpkttOMMMMMMMM // MMMMNWMMM#Zttlk=tttttOXWWd$_.(IdW1R=llll=SlllzOldK<_._(kd6+-(MM9lltttttrWktttztWZttrwXppWttrMMMMMMMM // MMMMNMMMM#lltwDzttllOXyW0X:..(OXk<Rl=ll=lwOlllOld3<``.(Rd>~?CdklllltttttXdXttzOWktrwwWpfpkrtMMMMMMMM // MMMMMMMMM@ltldIzlttOXyW$w$```(OyD(Rl==llldZ=llIlw;~```-Xd:~~~~UkylltttAyHdgSrzObRtOXwpfppWrrMMMMMMMM // MMMMMMMMM@llldtlllldVyW+d>```.wZ$ wl==lI=wRl=ll=w<```` // dd_..~~(RZXOQdggHH9ZwrzwHWrdXXppfppkrMMMMMMMM // MMMMMMMMM#llldlltlwyyyD(S-...,Wk] zI=l=llzWzl=l=P~```` // jZ``...~zQkH@MBUtrZtrtldHRdSdpfpffpkwMMMMMMMM // MMMMNMMMMNZllXtllldVyW3(Mf=<ONMHP~(k===l=zdk=lld3```...(C````..(M96lttttrrtrrtdHWHXpfpppfpRwMMMMMMMM // MMMMMMMMMMNzzWZllzyyyy(W@` =~MWK6 jz=lzlzvRz=lZ`.I+JgkWm&-. // `..(ZltlttttrtttrWWHppfppfpppSdMMMMMMMM MMMMMMMMMMMkAWRllzVyyS_(b // .MNHU-(Uz=lI={XkzO>.dVT7<TMHMNHHx-.(kwZyltttrtrrdHHpfppfpffpp0dMMMMMMMM // MMMMMMMMMMMMKyWzOzyyyk.`<! hdWMH]``(S==t=l(kX2 ?_` // WMMHH#HH+.XwkwOttttrwrZ~(HfpfpppfpWwXMMMMMMMM MMMMMMMMMMMMMHWROOyyyW;` `. // (WVM#b```(0=zzz wX!``` a.dM#NM@N(4WhXkXkWtttttwd3O_(HpffpfpfWwSMMMMMMMM // MMMMMMMMMMMMNZvWzXXyyXP```-_ ?o+?!````.4=Z=`(:```` HpbNNMHHH // (C=XXyWZWttrdwf:(>.dfppffppSXSMMMMMMMM // MMMMMMMMMMMMMRzuHzXyZXH.``````````````` ?zz ``````` ZKvTHHbWt `` // XZyyHZWOdSZ<::~`(fpfpfffXp0WMMMMMMM // MMMMMMMMMMMMMKzyyHvyZZW____.`````````````.I_```````` // ?nJzX7^````.WXWyyHyWKZ<:::_`Jffpfpfpfp0WMMMMMMM // MMMMMMMMMMMMM@zZyZWwWyXo-_~(~ ```````````` `````````````` // _`````.WXkyyVWmWc::<~ .HffppfffffkXMMMMMMM // MMMMMMMMMMMMMKzZZZZXkUXr~....```````....```````````` ... // ````..JXWWyyW83vXx~..WfffVfWVffffkdMMMMMMM // MMMMMMMMMMMMMRzZZZZZZZZb````````````<````````````./<~._<_.____`(WfdyW3<:~~(XWkVVVVVVVHVVVVV0dMMMMMMM // MMMMMMMMMMMMMSzZZZZZZZWX-```````````````````````````.......~~._j9jX=_~~_(XZyVHHkyyyyWHyyykykOMMMMMMM // MMMMMMMMMMMMMSzuuuuuZXWZW,```````````````````````````````.``..(3<! // ...JWyyXWyyyWHkyyWHyyyHyklMMMMMMM MMMMMMMMMMMMNXzuuuXXuXSuuXh,```````` .... // ```````````````````_~ .JWyyyyZyy0HyyZyyZyZXWZZZWHZIdMMMMMM // MMMMMMMMMMMMNwtuuuXkuXXuuuuXh,``````(:::~<?71(,``````````````.(UMNUkZZZZZZZHZZ0ZZZZZWWZZZWNXIdMMMMMM // MMMMMMMMMMMMNKOzuzXkuXuuuuuXuXW, ```` // _~~~:~~(}```````````.(YC;::<kCfZZZZXO#ZZVZZZZZMZZuuMMNXzMMMMMM // MMMMMMMMMMMMHKOzzuXkzdzzzzuXXzuuU&.``````````````````` // .JY>::::;;J=:dZuZuZd#uuruuuud#uuuXMMMNXdMMMMM // MMMMMMMMMMMMMNOvzzXkvMRzzzzXKzuzzzXh, // `````````````..JC<;:;;:;;+7<:~(HHuXIdNuuzuuuXMSuuuWMMMMROMMMMM // MMMMMMMMMMMMMNvvvrdkvM#vzzzzHzzzzzuzzUG. ``` // ...JdY<:;:;:::;;+v<~~~:(HpHmzMNXZzuzzd#zzzdMMMMMMRdMMMM // MMMMMMMMMMMMMNwrrvdRrMNwvvvvdRvvvzwkzzzzXWWHY=~~O+::::::::<+<~~~~~~~dppppWMMkZzzzwM#zzdMMMMMMMMNMMMM // MMMMMMMMMMMMMM#rrrwRrMMbOrrOZNkrvvvXwvvvvvwX;.~._W_:::::(?!~~~~~~~~(HpppppppHWdvwM#XwdMMMMMMMMMMNMMM // MMMMMMMMMMMMMMNyrrrRrWMMmzOrzdNyrrrZNvrwQWWfb....(r~~_J>_.....~.~~-dpfpffpfpppWHHMNdMMMMMMMMMMMMMMMM // MMMMMMMMMMMMMMMNrtrStdMMMNxzrzMNmrrrdNWfVfffP._-.(~_J!............JpfpffpfpfffpppWNppppHMMMMMMMMMMMM // MMMMMMMMMMMMMMMMNOtXtdMMMMMNxzZMMNmgHyVVVVVW%..?/(.,(x-..........(HfffpffpffpffWHHffpffppfVyyWMMMMMM // include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <regex> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef vector<int> VI; typedef vector<bool> VB; typedef vector<char> VC; typedef vector<double> VD; typedef vector<string> VS; typedef vector<LL> VLL; typedef vector<VI> VVI; typedef vector<VB> VVB; typedef vector<VS> VVS; typedef vector<VLL> VVLL; typedef vector<VVI> VVVI; typedef vector<VVLL> VVVLL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<int, string> PIS; typedef pair<string, int> PSI; typedef pair<string, string> PSS; typedef vector<PII> VPII; typedef vector<PLL> VPLL; typedef vector<VPII> VVPII; typedef vector<VPLL> VVPLL; typedef vector<VS> VVS; typedef map<int, int> MII; typedef map<LL, LL> MLL; typedef map<string, int> MSI; typedef map<int, string> MIS; //数値・文字列 //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline LL toLongLong(string s) { LL v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline VC toVC(string s) { VC data(s.begin(), s.end()); return data; } template <typename List> void SPRIT(const std::string &s, const std::string &delim, List &result) { result.clear(); string::size_type pos = 0; while (pos != string::npos) { string::size_type p = s.find(delim, pos); if (p == string::npos) { result.push_back(s.substr(pos)); break; } else { result.push_back(s.substr(pos, p - pos)); } pos = p + delim.size(); } } vector<string> SPRIT(const std::string &s, const std::string &delim) { vector<string> result; string::size_type pos = 0; while (pos != string::npos) { string::size_type p = s.find(delim, pos); if (p == string::npos) { result.push_back(s.substr(pos)); break; } else { result.push_back(s.substr(pos, p - pos)); } pos = p + delim.size(); } return result; } string TRIM(const string &str, const char *trimCharacterList = " \t\v\r\n") { string result; string::size_type left = str.find_first_not_of(trimCharacterList); if (left != string::npos) { string::size_type right = str.find_last_not_of(trimCharacterList); result = str.substr(left, right - left + 1); } return result; } string REPLACE_STRING(const string source, const string find, const string alt) { string result = source; string::size_type pos = 0; while (pos = result.find(find, pos), pos != string::npos) { result.replace(pos, find.length(), alt); pos += alt.length(); } return result; } template <typename T> bool VECTOR_EXISTS(vector<T> vec, T data) { auto itr = std::find(vec.begin(), vec.end(), data); size_t index = distance(vec.begin(), itr); if (index != vec.size()) return true; else return false; } template <typename T> vector<T> VECTOR_UNIQUE_ERASE(vector<T> vec) { sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } template <typename T> void VECTOR_REMOVE_VALUE_ALL(vector<T> &vec, T data) { vec.erase(remove(vec.begin(), vec.end(), data), vec.end()); } template <typename T> vector<T> VECTOR_REMOVE_VALUE_ALL_FAST(vector<T> vec, T data) { vector<T> vec2; for (auto &x : vec) if (x != data) vec2.push_back(x); return vec2; } bool REG_MATCH(string const &text, regex const &re) { bool result = regex_match(text, re); return result; } bool REG_MATCH(string const &text, smatch &match, regex const &re) { bool result = regex_match(text, match, re); return result; } smatch REG_SEARCH(string const &text, regex const &re) { smatch m; regex_search(text, m, re); return m; } vector<smatch> REG_ALL_SEARCH(string const &text, regex const &re) { vector<smatch> matchs; sregex_iterator iter(text.cbegin(), text.cend(), re); sregex_iterator end; for (; iter != end; iter++) matchs.push_back(*iter); return matchs; } string REG_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace, regex_constants::format_first_only); return result; } string REG_ALL_REPLACE(string const &text, regex const &re, string const &replace) { string result = regex_replace(text, re, replace); return result; } template <typename T, typename U, typename V, typename W> auto operator+(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first + r.first), decltype(l.second + r.second)> { return {l.first + r.first, l.second + r.second}; } template <typename T, typename U, typename V, typename W> auto operator-(const std::pair<T, U> &l, const std::pair<V, W> &r) -> std::pair<decltype(l.first - r.first), decltype(l.second - r.second)> { return {l.first - r.first, l.second - r.second}; } #define UPPER(s) transform((s).begin(), (s).end(), (s).begin(), ::toupper) #define LOWER(s) transform((s).begin(), (s).end(), (s).begin(), ::tolower) //四捨五入 nLen=小数点第n位にする //------------------------------------------ //切り上げ double ceil_n(double dIn, int nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.9); return dOut * pow(10.0, -nLen); } //切り捨て double floor_n(double dIn, int nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut); return dOut * pow(10.0, -nLen); } //四捨五入 double round_n(double dIn, int nLen) { double dOut; dOut = dIn * pow(10.0, nLen); dOut = (double)(long long)(dOut + 0.5); return dOut * pow(10.0, -nLen); } // n桁目の数の取得 int take_a_n(LL num, int n) { string str = toString(num); return str[str.length() - n] - '0'; } //整数を2進数表記したときの1の個数を返す LL bitcount64(LL bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff); } // comparison //------------------------------------------ #define C_MAX(a, b) ((a) > (b) ? (a) : (b)) #define C_MIN(a, b) ((a) < (b) ? (a) : (b)) #define C_ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b)) template <typename T1, typename T2> inline void S_MAX(T1 &a, T2 b) { a = C_MAX(a, b); }; template <typename T1, typename T2> inline void S_MIN(T1 &a, T2 b) { a = C_MIN(a, b); }; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) int((a).size()) #define EACH(i, arr) \ for (typeof((arr).begin()) i = (arr).begin(); i != (arr).end(); ++i) #define EXIST(str, e) ((str).find(e) != (str).end()) #define COUNT(arr, v) count((arr).begin(), (arr).end(), v) #define SEARCH(v, w) search((v).begin(), (v).end(), (w).begin(), (w).end()) #define B_SEARCH(arr, v) binary_search((arr).begin(), (arr).end(), v) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define ROTATE_LEFT(arr, c) \ rotate((arr).begin(), (arr).begin() + (c), (arr).end()) #define ROTATE_RIGHT(arr, c) \ rotate((arr).rbegin(), (arr).rbegin() + (c), (arr).rend()) #define SUMI(arr) accumulate((arr).begin(), (arr).end(), 0) #define SUMD(arr) accumulate((arr).begin(), (arr).end(), 0.) #define SUMLL(arr) accumulate((arr).begin(), (arr).end(), 0LL) #define SUMS(arr) accumulate((arr).begin(), (arr).end(), string()) #define MULD(arr) \ accumulate((arr).begin(), (arr).end(), 1., multiplies<double>()) #define MULLL(arr) \ accumulate((arr).begin(), (arr).end(), 1LL, multiplies<long long>()) #define UB(arr, n) upper_bound((arr).begin(), (arr).end(), n) #define LB(arr, n) lower_bound((arr).begin(), (arr).end(), n) #define OF_ALL(arr, func) all_of((arr).begin(), (arr).end(), (func)) #define OF_NONE(arr, func) none_of((arr).begin(), (arr).end(), (func)) #define OF_ANY(arr, func) any_of((arr).begin(), (arr).end(), (func)) #define PB push_back #define MP make_pair #define ft first #define sd second // input output //------------------------------------------ #define GL(s) getline(cin, (s)) #define INIT() \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define OUT(d) std::cout << (d) #define OUT_L(d) std::cout << (d) << endl #define FOUT(n, data) std::cout << std::fixed << std::setprecision(n) << (data) #define FOUT_L(n, data) \ std::cout << std::fixed << std::setprecision(n) << (data) << "\n" #define EL() printf("\n") #define SHOW_VECTOR(v) \ { \ std::cerr << #v << "\t:"; \ for (const auto &xxx : v) { \ std::cerr << xxx << " "; \ } \ std::cerr << "\n"; \ } #define SHOW_MAP(v) \ { \ std::cerr << #v << endl; \ for (const auto &xxx : v) { \ std::cerr << xxx.first << " " << xxx.second << "\n"; \ } \ } #define Yes() printf("Yes\n") #define No() printf("No\n") #define YES() printf("YES\n") #define NO() printf("NO\n") template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &p) { in >> p.first >> p.second; return in; } template <typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &x : v) in >> x; return in; } // repetition //------------------------------------------ #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(i, 0, n) #define RREP(i, n) for (int i = n - 1; i >= 0; i--) #define FORLL(i, a, b) for (LL i = LL(a); i < LL(b); ++i) #define RFORLL(i, a, b) for (LL i = LL(b) - 1; i >= LL(a); --i) #define REPLL(i, n) for (LL i = 0; i < LL(n); ++i) #define RREPLL(i, n) for (LL i = LL(n) - 1; i >= 0; --i) #define FOREACH(x, arr) for (auto &(x) : (arr)) #define FORITER(x, arr) for (auto(x) = (arr).begin(); (x) != (arr).end(); ++(x)) // constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; // math //-------------------------------------------- // min <= aim <= max template <typename T> inline bool BETWEEN(const T aim, const T min, const T max) { if (min <= aim && aim <= max) { return true; } else { return false; } } template <typename T1, typename T2> inline bool IS_OUT(const T1 toY, const T1 toX, const T2 H, const T2 W) { return (toY < 0 || toY >= H || toX < 0 || toX >= W); } template <class T> inline T SQR(const T x) { return x * x; } template <class T1, class T2> inline T1 POW(const T1 x, const T2 y) { if (!y) return 1; else if ((y & 1) == 0) { return SQR(POW(x, y >> 1)); } else return POW(x, y ^ 1) * x; } template <typename T> constexpr T ABS(T x) { return x < 0 ? -x : x; } // partial_permutation nPr 順列 // first・・最初の数 // middle・・r(取り出す数) // last・・n(全体数) template <class Iter> bool next_partial_permutation(Iter first, Iter middle, Iter last) { reverse(middle, last); return next_permutation(first, last); } // combination nCr 組み合わせ // first1・・最初の数 // last1==first2・・r(取り出す数) // last2・・n(全体数) template <class Iter> bool next_combination(Iter first1, Iter last1, Iter first2, Iter last2) { if ((first1 == last1) || (first2 == last2)) { return false; } Iter m1 = last1; Iter m2 = last2; --m2; while (--m1 != first1 && !(*m1 < *m2)) { } bool result = (m1 == first1) && !(*first1 < *m2); if (!result) { while (first2 != m2 && !(*m1 < *first2)) { ++first2; } first1 = m1; std::iter_swap(first1, first2); ++first1; ++first2; } if ((first1 != last1) && (first2 != last2)) { m1 = last1; m2 = first2; while ((m1 != first1) && (m2 != last2)) { std::iter_swap(--m1, m2); ++m2; } std::reverse(first1, m1); std::reverse(first1, last1); std::reverse(m2, last2); std::reverse(first2, last2); } return !result; } // numeric_law //-------------------------------------------- template <typename T> constexpr bool ODD(T x) { return x % 2 != 0; } template <typename T> constexpr bool EVEN(T x) { return x % 2 == 0; } //最大公約数 template <class T> inline T GCD(const T x, const T y) { if (x < 0) return GCD(-x, y); if (y < 0) return GCD(x, -y); return (!y) ? x : GCD(y, x % y); } //最小公倍数 template <class T> inline T LCM(const T x, const T y) { if (x < 0) return LCM(-x, y); if (y < 0) return LCM(x, -y); return x * (y / GCD(x, y)); } // ax + by = 1 // x,yが変数に格納される template <class T> inline T EXTGCD(const T a, const T b, T &x, T &y) { if (a < 0) { T d = EXTGCD(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = EXTGCD(a, -b, x, y); y = -y; return d; } if (!b) { x = 1; y = 0; return a; } else { T d = EXTGCD(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } //素数 template <class T> inline bool ISPRIME(const T x) { if (x <= 1) return false; for (T i = 2; i * i <= x; i++) if (x % i == 0) return false; return true; } //素数をtrueとして返す template <class T> VB ERATOSTHENES(const T n) { VB arr(n + 1, true); arr[0] = arr[1] = false; for (LL i = 2; i * i <= n; i++) { if (arr[i]) { for (LL j = i * 2LL; j <= n; j += i) { arr[j] = false; } } } return arr; } // a <= x < b の素数を返す template <typename T> VB ERATOSTHENES(const T a, const T b) { VB small = ERATOSTHENES(b); VB prime(b - a, true); for (LL i = 2; i * i <= b; i++) { if (small[i]) { for (LL j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) { prime[j - a] = false; } } } return prime; } // nの約数 template <typename T> vector<T> DIVISOR(T n) { vector<T> v; for (LL i = 1; i * i <= n; ++i) { if (n % i == 0) { v.push_back(i); if (i != n / i) { v.push_back(n / i); } } } sort(v.begin(), v.end()); return v; } // nまでのすべての約数 template <typename T> vector<vector<T>> DIVISOR_ALL(T n) { vector<vector<T>> res(n + 1); for (LL i = 1; i <= n; i++) { for (LL j = i; j <= n; j += i) { res[j].push_back(i); } } return res; } //素因数分解 template <typename T> vector<pair<T, LL>> FACTORIZATION(T x) { vector<pair<T, LL>> ans; for (LL i = 2; i * i <= x; i++) { if (x % i == 0) { LL count = 0; while (x % i == 0) { count++; x /= i; } ans.push_back(MP(i, count)); } } if (x != 1) ans.push_back(MP(x, 1)); return ans; } // N^P (mod M) LL POW_MOD(LL N, LL P, LL M) { if (P == 0) return 1LL; if (P % 2 == 0) { LL ret = POW_MOD(N, P / 2, M); return ret * ret % M; } return N * POW_MOD(N, P - 1, M) % M; } //組み合わせ個数 template <typename T> inline T NCR(T n, T r) { if (r > n - r) r = n - r; T ans = 1; REPLL(i, r) { ans = ans * (n - i) / (i + 1); } return ans; } //組み合わせ個数 (mod M) LL NCR_MOD(LL n, LL r, LL M) { if (r > n - r) return NCR_MOD(n, n - r, M); LL numerator = 1LL; //分子 LL denominator = 1LL; //分母 for (LL i = 0; i < r; i++) { numerator *= (n - i); numerator %= M; denominator *= (i + 1); denominator %= M; } return numerator * POW_MOD(denominator, M - 2, M) % M; } // confirmation //-------------------------------------------- // clear memory #define CLR(arr, d) memset((arr), (d), sizeof(arr)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << endl; //~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~ int main() { int A, B; cin >> A >> B; int K; cin >> K; vector<int> arr; for (int i = 1; i <= min(A, B); i++) { if (A % i == 0 && B % i == 0) { arr.push_back(i); } } RSORT(arr); // SHOW_VECTOR(arr); cout << arr[K - 1]; return 0; }
[ "identifier.change", "call.function.change" ]
917,971
917,972
u259053514
cpp
p03106
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; #define rep(i, a, n) for (ll i = a; i < n; i++) #define rrep(i, a, n) for (ll i = n; i >= a; i--) typedef long long ll; typedef pair<ll, ll> P; const ll INF = 1e+17; const ll MODcdf = 998244353; int main() { ll n1, n2; cin >> n1 >> n2; ll num; cin >> num; ll cnt = 0; ll ans; rep(i, 1, max(n1, n2)) { if (n1 % i == 0 && n2 % i == 0) { cnt++; if (cnt == num) { ans = i; break; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; #define rep(i, a, n) for (ll i = a; i < n; i++) #define rrep(i, a, n) for (ll i = n; i >= a; i--) typedef long long ll; typedef pair<ll, ll> P; const ll INF = 1e+17; const ll MODcdf = 998244353; int main() { ll n1, n2; cin >> n1 >> n2; ll num; cin >> num; ll cnt = 0; ll ans; rrep(i, 1, min(n1, n2)) { if (n1 % i == 0 && n2 % i == 0) { cnt++; if (cnt == num) { ans = i; break; } } } cout << ans << endl; return 0; }
[ "identifier.change", "call.function.change", "misc.opposites", "call.arguments.change" ]
917,977
917,978
u119345557
cpp
p03106
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int main(void) { int a, b, k, sei[1000], num = 0; cin >> a >> b >> k; for (int l = 1; l <= min(a, b); l++) { if (a >= l && b >= l && a % l == 0 && b % l == 0) { sei[num] = l; // printf("l=%d\nsei[%d]=%d\n", l, num, l); num++; } } cout << sei[k - 1] << "\n"; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; int main(void) { int a, b, k, sei[1000], num = 0; cin >> a >> b >> k; for (int l = 1; l <= min(a, b); l++) { if (a >= l && b >= l && a % l == 0 && b % l == 0) { sei[num] = l; // printf("l=%d\nsei[%d]=%d\n", l, num, l); num++; } } cout << sei[num - k] << "\n"; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "io.output.change", "identifier.replace.add", "literal.replace.remove" ]
917,981
917,982
u217596176
cpp
p03106
#include <iostream> using namespace std; int main(void) { int A, B, K; cin >> A >> B >> K; int i = max(A, B); while (K > 0) { i--; if (A % i == 0 && B % i == 0) K--; } cout << i << endl; return 0; }
#include <iostream> using namespace std; int main(void) { int A, B, K; cin >> A >> B >> K; int i = max(A, B) + 1; while (K > 0) { i--; if (A % i == 0 && B % i == 0) K--; } cout << i << endl; return 0; }
[ "assignment.change" ]
917,985
917,986
u330913290
cpp
p03106
#include <stdio.h> int main(void) { int a, b, k, yaku[1000], su; scanf("%d", &a); scanf("%d", &b); scanf("%d", &k); int i, co = 0; for (i = 1; i <= 100; i++) { if (a % i == 0) { if (b % i == 0) { yaku[co] = i; co++; } } } su = yaku[k - 1]; printf("%d\n", su); return 0; }
#include <stdio.h> int main(void) { int a, b, k, yaku[1000], su; scanf("%d", &a); scanf("%d", &b); scanf("%d", &k); int i, co = 0; for (i = 1; i <= 100; i++) { if (a % i == 0) { if (b % i == 0) { yaku[co] = i; co++; } } } su = yaku[co - k]; printf("%d\n", su); return 0; }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change", "identifier.replace.add", "literal.replace.remove" ]
917,987
917,988
u180133008
cpp
p03106
#include <algorithm> #include <bitset> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair<int, int> P; #define stop \ char nyaa; \ cin >> nyaa; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef long double ld; typedef complex<ld> Point; const ld eps = 1e-2; const ld pi = acos(-1.0); typedef pair<ll, ll> LP; int main() { int a, b, k; cin >> a >> b >> k; int cnt = 0; rep1(i, max(a, b)) { if (a % i == 0 && b % i == 0) { cnt++; if (cnt == k) { cout << i << endl; break; } } } // stop return 0; }
#include <algorithm> #include <bitset> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair<int, int> P; #define stop \ char nyaa; \ cin >> nyaa; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef long double ld; typedef complex<ld> Point; const ld eps = 1e-2; const ld pi = acos(-1.0); typedef pair<ll, ll> LP; int main() { int a, b, k; cin >> a >> b >> k; int cnt = 0; per1(i, max(a, b)) { if ((a % i) == 0 && (b % i) == 0) { cnt++; if (cnt == k) { cout << i << endl; break; } } } // stop return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
917,993
917,994
u294531924
cpp
p03106
#include <iostream> using namespace std; int a, b, c, sum = 0; int main() { scanf("%d %d %d", &a, &b, &c); for (int i = min(a, b); i >= 1; i--) { if (a % i == 0 && b % i == 0) sum++; if (sum == c) printf("%d\n", i); return 0; } }
#include <iostream> using namespace std; int a, b, c, sum = 0; int main() { scanf("%d %d %d", &a, &b, &c); for (int i = min(a, b); i >= 1; i--) { if (a % i == 0 && b % i == 0) sum++; if (sum == c) { printf("%d\n", i); return 0; } } }
[]
918,000
918,001
u601344838
cpp
p03106
#include <iostream> using namespace std; int main() { int a, b, k; cin >> a >> b >> k; for (int i = 1;; i++) { if (a % i == 0 && b % i == 0) { k--; if (k == 0) { cout << i << endl; break; } } } return 0; }
#include <iostream> using namespace std; int main() { int a, b, k; cin >> a >> b >> k; for (int i = a;; i--) { if (a % i == 0 && b % i == 0) { k--; if (k == 0) { cout << i << endl; break; } } } return 0; }
[ "variable_declaration.value.change", "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change" ]
918,012
918,013
u587665681
cpp
p03106
#include <iostream> using namespace std; int main() { int A, B, K; cin >> A; cin >> B; cin >> K; int ans[100]; int c = 0; for (int i = 1; i < 100; i++) { if (A % i == 0 & B % i == 0) { ans[c] = i; c++; } } cout << ans[c - (K - 1)]; return 0; }
#include <iostream> using namespace std; int main() { int A, B, K; cin >> A; cin >> B; cin >> K; int ans[1000]; int c = 0; for (int i = 1; i < 1000; i++) { if (A % i == 0 & B % i == 0) { ans[c] = i; c++; } } cout << ans[c - (K)]; return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
918,032
918,031
u184572586
cpp