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
p03145
#include <iostream> #include <string> using namespace std; int main() { int a, b, value; cin >> a >> b; value = (a + b) / 2; cout << value << endl; return 0; }
#include <iostream> #include <string> using namespace std; int main() { int a, b, value; cin >> a >> b; value = a * b / 2; cout << value << endl; return 0; }
[ "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
943,253
943,254
u415865011
cpp
p03145
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; cout << A * B << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; cout << A * B / 2 << endl; }
[ "expression.operation.binary.add" ]
943,257
943,258
u348914050
cpp
p03145
#include <stdio.h> int main(int atgc, char *argv[]) { int c, a, b; scanf("%d%d%d", &c, &a, &b); printf("%d", c * a); return 0; }
#include <stdio.h> int main(int atgc, char *argv[]) { int c, a, b; scanf("%d%d%d", &c, &a, &b); printf("%d", c * a / 2); return 0; }
[ "expression.operation.binary.add" ]
943,276
943,277
u801102476
cpp
p03145
#include <stdio.h> int main() { int c, a, b; scanf("%d%d%d", &c, &a, &b); printf("%d", c * a); return 0; }
#include <stdio.h> int main() { int c, a, b; scanf("%d%d%d", &c, &a, &b); printf("%d", c * a / 2); return 0; }
[ "expression.operation.binary.add" ]
943,279
943,280
u801102476
cpp
p03145
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; typedef long long unsigned int ll; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; cout << cbrt(a * b * c) / 2 << endl; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; typedef long long unsigned int ll; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; cout << (a * b) / 2 << endl; return 0; }
[ "expression.operation.binary.remove" ]
943,289
943,290
u032337012
cpp
p03145
#include <bits/stdc++.h> using namespace std; typedef long long ll; /* // 配列の最大値を取得 int max = *max_element(vec.begin(), vec.end()); // 配列の最大値のイテレータを取得 vector<int>::iterator maxIt = max_element(vec.begin(), vec.end()); // 配列の最大値までの距離を取得 int maxIndex = distance(vec.begin(), maxIt); // 隣り合う重複要素を削除し、末尾のゴミを削除 // (uniqueは、重複を取り除いた範囲の末尾の次を指すイテレータを返す) vec.erase(unique(vec.begin(), vec.end()), vec.end()); */ int main() { int a, b, c; cin >> a >> b >> c; cout << sqrt(a * b / 2) << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; /* // 配列の最大値を取得 int max = *max_element(vec.begin(), vec.end()); // 配列の最大値のイテレータを取得 vector<int>::iterator maxIt = max_element(vec.begin(), vec.end()); // 配列の最大値までの距離を取得 int maxIndex = distance(vec.begin(), maxIt); // 隣り合う重複要素を削除し、末尾のゴミを削除 // (uniqueは、重複を取り除いた範囲の末尾の次を指すイテレータを返す) vec.erase(unique(vec.begin(), vec.end()), vec.end()); */ int main() { int a, b, c; cin >> a >> b >> c; cout << a * b / 2 << endl; }
[ "call.remove", "call.arguments.change" ]
943,305
943,306
u319234342
cpp
p03145
#include <algorithm> #include <iostream> #include <math.h> #include <set> #include <string.h> #include <vector> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a * b / c << endl; }
#include <algorithm> #include <iostream> #include <math.h> #include <set> #include <string.h> #include <vector> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a * b / 2 << endl; }
[ "identifier.replace.remove", "literal.replace.add", "io.output.change" ]
943,307
943,308
u394033362
cpp
p03145
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int a, b; cin >> a >> b; return (a * b / 2); }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int a, b; cin >> a >> b; cout << (a * b / 2); return 0; }
[ "io.output.change", "control_flow.return.add", "control_flow.return.0.add" ]
943,335
943,336
u051493691
cpp
p03145
#include <bits/stdc++.h> using namespace std; int main(void) { int a, b, c; cin >> a >> b >> c; cout << (a + b) / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int a, b, c; cin >> a >> b >> c; cout << (a * b) / 2 << endl; return 0; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
943,355
943,356
u787972656
cpp
p03145
#include <stdio.h> int main(void) { int a, b, c; scanf("%d %d %d", &a, &b, &c); printf("%d", a * b); return 0; }
#include <stdio.h> int main(void) { int a, b, c; scanf("%d %d %d", &a, &b, &c); printf("%d", a * b / 2); return 0; }
[ "expression.operation.binary.add" ]
943,365
943,366
u644100188
cpp
p03145
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a * b << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a * b / 2 << endl; return 0; }
[ "expression.operation.binary.add" ]
943,377
943,378
u902428263
cpp
p03145
#include <iostream> int main() { int ab, bc, ca; std::cin >> ab >> bc >> ca; std::cout << ab * bc << '\n'; return 0; }
#include <iostream> int main() { int ab, bc, ca; std::cin >> ab >> bc >> ca; std::cout << ab * bc / 2 << '\n'; return 0; }
[ "expression.operation.binary.add" ]
943,384
943,385
u901295506
cpp
p03145
#include <bits/stdc++.h> using namespace std; int main() { int AB, BC, AC, i; cin >> AB >> BC >> AC; i = AB * AC / 2; cout << i; }
#include <bits/stdc++.h> using namespace std; int main() { int AB, BC, AC, i; cin >> AB >> BC >> AC; i = AB * BC / 2; cout << i; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
943,478
943,479
u810066979
cpp
p03145
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; int answer = a * b % 2; cout << answer << endl; }
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; int answer = a * b / 2; cout << answer << endl; }
[ "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
943,535
943,536
u068896454
cpp
p03145
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; int answer = a * b; cout << answer << endl; }
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a; cin >> b; cin >> c; int answer = a * b / 2; cout << answer << endl; }
[ "assignment.change" ]
943,537
943,536
u068896454
cpp
p03145
#include <iostream> using namespace std; int main() { int AB, BC, CA; cin >> AB >> BC >> CA; cout << AB * BC << endl; }
#include <iostream> using namespace std; int main() { int AB, BC, CA; cin >> AB >> BC >> CA; cout << AB * BC / 2 << endl; }
[ "expression.operation.binary.add" ]
943,542
943,543
u448367673
cpp
p03145
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; cout << (ab + bc) / 2 << endl; }
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; cout << ab * bc / 2 << endl; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
943,554
943,555
u170650966
cpp
p03145
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v, n) reverse(v, v + n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define INF 9999999999 #define m0(x) memset(x, 0, sizeof(x)) #define fill(x, y) memset(x, y, sizeof(x)) #define print(x) cout << x << endl; #define pe(x) cout << x << " "; #define lb(v, n) lower_bound(v.begin(), v.end(), n); #define int long long using namespace std; int dy[4] = {0, 0, 1, -1}; int dx[4] = {1, -1, 0, 0}; int dxx[9] = {0, 0, 0, 1, 1, 1, -1, -1, -1}; int dyy[9] = {0, 1, -1, 0, 1, -1, 0, 1, -1}; ll gcd(ll x, ll y) { ll m = max(x, y), n = min(x, y); if (m % n == 0) return n; else return gcd(m % n, n); } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } ll myPow(ll x, ll n, ll m) { if (n == 0) return 1; if (n % 2 == 0) return myPow(x * x % m, n / 2, m); else return x * myPow(x, n - 1, m) % m; } ll pow2(ll a, ll n) { // aのn乗を計算します。 ll x = 1; while (n > 0) { //全てのbitが捨てられるまで。 if (n & 1) { // 1番右のbitが1のとき。 x = x * a; } a = a * a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる。 } return x; } long long nCr(int n, int r) { if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r) long long ans = 1; int i; for (i = 1; i <= r; i++) { ans *= n - r + i; ans /= i; } return ans; } const int MAX = 510000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } bool arr[100000100]; vector<ll> sosuu; void Eratosthenes() { ll N = 10000010; int c = 0; for (int i = 0; i < N; i++) { arr[i] = 1; } for (ll i = 2; i < sqrt(N); i++) { if (arr[i]) { for (ll j = 0; i * (j + 2) < N; j++) { arr[i * (j + 2)] = 0; } } } for (ll i = 2; i < N; i++) { if (arr[i]) { sosuu.pb(i); // cout << sosuu[c] << " "; c++; } } // cout << endl; // cout << c << endl; } ll stoL(string s) { ll n = s.length(); ll ans = 0; for (int i = 0; i < n; i++) { ans += pow2(10, n - i - 1) * (ll)(s[i] - '0'); } return ans; } int imos[2020][2020]; map<int, int> compX, compY; string A[1010]; signed main() { int A, B, C; cin >> A >> B >> C; print(A * B); }
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v, n) reverse(v, v + n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define INF 9999999999 #define m0(x) memset(x, 0, sizeof(x)) #define fill(x, y) memset(x, y, sizeof(x)) #define print(x) cout << x << endl; #define pe(x) cout << x << " "; #define lb(v, n) lower_bound(v.begin(), v.end(), n); #define int long long using namespace std; int dy[4] = {0, 0, 1, -1}; int dx[4] = {1, -1, 0, 0}; int dxx[9] = {0, 0, 0, 1, 1, 1, -1, -1, -1}; int dyy[9] = {0, 1, -1, 0, 1, -1, 0, 1, -1}; ll gcd(ll x, ll y) { ll m = max(x, y), n = min(x, y); if (m % n == 0) return n; else return gcd(m % n, n); } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } ll myPow(ll x, ll n, ll m) { if (n == 0) return 1; if (n % 2 == 0) return myPow(x * x % m, n / 2, m); else return x * myPow(x, n - 1, m) % m; } ll pow2(ll a, ll n) { // aのn乗を計算します。 ll x = 1; while (n > 0) { //全てのbitが捨てられるまで。 if (n & 1) { // 1番右のbitが1のとき。 x = x * a; } a = a * a; n >>= 1; // bit全体を右に1つシフトして一番右を捨てる。 } return x; } long long nCr(int n, int r) { if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r) long long ans = 1; int i; for (i = 1; i <= r; i++) { ans *= n - r + i; ans /= i; } return ans; } const int MAX = 510000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } bool arr[100000100]; vector<ll> sosuu; void Eratosthenes() { ll N = 10000010; int c = 0; for (int i = 0; i < N; i++) { arr[i] = 1; } for (ll i = 2; i < sqrt(N); i++) { if (arr[i]) { for (ll j = 0; i * (j + 2) < N; j++) { arr[i * (j + 2)] = 0; } } } for (ll i = 2; i < N; i++) { if (arr[i]) { sosuu.pb(i); // cout << sosuu[c] << " "; c++; } } // cout << endl; // cout << c << endl; } ll stoL(string s) { ll n = s.length(); ll ans = 0; for (int i = 0; i < n; i++) { ans += pow2(10, n - i - 1) * (ll)(s[i] - '0'); } return ans; } int imos[2020][2020]; map<int, int> compX, compY; string A[1010]; signed main() { int A, B, C; cin >> A >> B >> C; print(A * B / 2); }
[ "expression.operation.binary.add" ]
943,567
943,568
u859396346
cpp
p03145
#include <iostream> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; cout << ab * ca / 2; return 0; }
#include <iostream> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; cout << ab * bc / 2; return 0; }
[ "identifier.change", "io.output.change" ]
943,578
943,579
u896807328
cpp
p03145
#include <bits/stdc++.h> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; int S = ab * bc; cout << S << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; int S = (ab * bc) / 2; cout << S << endl; }
[ "assignment.change" ]
943,612
943,613
u916256067
cpp
p03145
#include <iostream> #include <stdio.h> using namespace std; int main(void) { int ab; int bc; int ca; int ans; cin >> ab; cin >> bc; cin >> ca; ans = ab * bc; cout << ans; return 0; }
#include <iostream> #include <stdio.h> using namespace std; int main(void) { int ab; int bc; int ca; int ans; cin >> ab; cin >> bc; cin >> ca; ans = ab * bc / 2; cout << ans; return 0; }
[ "assignment.change" ]
943,616
943,617
u231282396
cpp
p03145
#include <iostream> using namespace std; int main() { // 整数の入力 int a, b, c; cin >> a >> b >> c; // スペース区切りの整数の入力 // 文字列の入力 cout << (a + b) / 2 << endl; return 0; }
#include <iostream> using namespace std; int main() { // 整数の入力 int a, b, c; cin >> a >> b >> c; // スペース区切りの整数の入力 // 文字列の入力 cout << (a * b) / 2 << endl; return 0; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
943,620
943,621
u989274743
cpp
p03145
#include <cstdio> int main() { int c, a, b; scanf("%d %d %d", &c, &a, &b); printf("%d\n", c * b / 2); return 0; }
#include <cstdio> int main() { int c, a, b; scanf("%d %d %d", &c, &a, &b); printf("%d\n", c * a / 2); return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
943,643
943,644
u289709148
cpp
p03145
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a << endl; }
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << a * b / 2 << endl; }
[ "expression.operation.binary.add" ]
943,655
943,656
u791146764
cpp
p03145
#include <bits/stdc++.h> /* g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc116/a.cpp */ using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define SZ(x) ((int)(x).size()) #define INF (1e16) typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); //おまじないでcin, cout早くする int x, y, z; cin >> x >> y >> z; cout << x * z / 2 << "\n"; return 0; }
#include <bits/stdc++.h> /* g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc116/a.cpp */ using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define SZ(x) ((int)(x).size()) #define INF (1e16) typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); //おまじないでcin, cout早くする int x, y, z; cin >> x >> y >> z; cout << x * y / 2 << "\n"; return 0; }
[ "identifier.change", "io.output.change" ]
943,663
943,664
u811561461
cpp
p03145
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned ll; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using P = pair<int, int>; using PL = pair<ll, ll>; const int INF = 1 << 30, MOD = 1000000007; const ll LINF = 1ll << 60; #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) _repi(i, 0, n) #define _repi(i, a, b) for (int i = a, i##_l = (b); i < i##_l; ++i) #define REP(...) _overload3(__VA_ARGS__, _repi, _rep, )(__VA_ARGS__) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define REPARR(i, v) for (int i = 0; i < v.size(); ++i) #define all(v) (v).begin(), (v).end() #define uniq(v) \ sort(all(v)); \ v.erase(unique(all(v)), v.end()) #define bit(n) (1ll << (n)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define yes(n) cout << ((n) ? "yes" : "no") << endl #define poss(n) cout << ((n) ? "" : "im") << "possible" << endl #define Poss(n) cout << ((n) ? "P" : "Imp") << "ossible" << endl template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { for (T i : v) o << i << ' '; return o; } template <typename T> istream &operator>>(istream &i, vector<T> &v) { for (T &j : v) i >> j; return i; } template <typename T> ostream &operator<<(ostream &o, const set<T> &v) { for (T i : v) o << i << ' '; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << v.first << ' ' << v.second; return o; } int main() { int a, b, c; cin >> a >> b >> c; cout << a * c / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned ll; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using P = pair<int, int>; using PL = pair<ll, ll>; const int INF = 1 << 30, MOD = 1000000007; const ll LINF = 1ll << 60; #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) _repi(i, 0, n) #define _repi(i, a, b) for (int i = a, i##_l = (b); i < i##_l; ++i) #define REP(...) _overload3(__VA_ARGS__, _repi, _rep, )(__VA_ARGS__) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define REPARR(i, v) for (int i = 0; i < v.size(); ++i) #define all(v) (v).begin(), (v).end() #define uniq(v) \ sort(all(v)); \ v.erase(unique(all(v)), v.end()) #define bit(n) (1ll << (n)) template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define yes(n) cout << ((n) ? "yes" : "no") << endl #define poss(n) cout << ((n) ? "" : "im") << "possible" << endl #define Poss(n) cout << ((n) ? "P" : "Imp") << "ossible" << endl template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { for (T i : v) o << i << ' '; return o; } template <typename T> istream &operator>>(istream &i, vector<T> &v) { for (T &j : v) i >> j; return i; } template <typename T> ostream &operator<<(ostream &o, const set<T> &v) { for (T i : v) o << i << ' '; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << v.first << ' ' << v.second; return o; } int main() { int a, b, c; cin >> a >> b >> c; cout << a * b / 2 << endl; return 0; }
[ "identifier.change", "io.output.change" ]
943,731
943,732
u502709453
cpp
p03145
#include <iostream> int main() { int a, b, c; std::cin >> a >> b >> c; std::cout << (a + b) / 2 << std::endl; return 0; }
#include <iostream> int main() { int a, b, c; std::cin >> a >> b >> c; std::cout << (a * b) / 2 << std::endl; return 0; }
[ "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
943,749
943,750
u108171020
cpp
p03145
#include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a * b << endl; }
#include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a * b / 2 << endl; }
[ "expression.operation.binary.add" ]
943,780
943,781
u739259290
cpp
p03145
#include <iostream> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; int S = ab * bc; cout << S << endl; }
#include <iostream> using namespace std; int main() { int ab, bc, ca; cin >> ab >> bc >> ca; int S = ab * bc / 2; cout << S << endl; }
[ "assignment.change" ]
943,801
943,802
u000623733
cpp
p03145
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a, b, c; cout << (a * b / 2); return 0; }
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << (a * b / 2); return 0; }
[]
943,836
943,837
u190462847
cpp
p03145
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a, b, c; cout << a * b / 2; return 0; }
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << (a * b / 2); return 0; }
[]
943,838
943,837
u190462847
cpp
p03145
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << ((a + b) / 2) << endl; }
#include <iostream> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << ((a * b) / 2) << endl; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
943,892
943,893
u708117547
cpp
p03145
#include <iostream> using namespace std; int main() { int c, a, b; cin >> c >> a >> b; cout << c * a << endl; }
#include <iostream> using namespace std; int main() { int c, a, b; cin >> c >> a >> b; cout << c * a / 2 << endl; }
[ "expression.operation.binary.add" ]
943,900
943,901
u468811760
cpp
p03145
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int ans = 0; ans = 1 / 2 * a * b; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int ans = 0; ans = a * b / 2; cout << ans << endl; return 0; }
[ "expression.operation.binary.remove", "assignment.change" ]
943,913
943,914
u018434698
cpp
p03145
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << (a * b) % 2 << endl; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << (a * b) / 2 << endl; }
[ "expression.operator.arithmetic.change", "io.output.change" ]
943,964
943,965
u133142920
cpp
p03145
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll, ll> #define FOR(I, A, B) for (int I = int(A); I < int(B); ++I) #define FORR(I, A, B) for (int I = int((B)-1); I >= int(A); --I) #define TO(x, t, f) ((x) ? (t) : (f)) #define SORT(x) (sort(x.begin(), x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x, v) \ (lower_bound(x.begin(), x.end(), v) - x.begin()) // ai>=v x is sorted #define POSU(x, v) \ (upper_bound(x.begin(), x.end(), v) - x.begin()) // ai>v x is sorted #define NUM(x, v) (POSU(x, v) - POSL(x, v)) // x is sorted #define REV(x) (reverse(x.begin(), x.end())) // reverse ll gcd(ll a, ll b) { if (a < b) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } ll lcm(ll a, ll b) { ll c = gcd(a, b); return ((a / c) * (b / c) * c); } // saisyo kobaisu #define NEXTP(x) next_permutation(x.begin(), x.end()) const ll INF = 1e18 + 7; const ll MOD = 1e9 + 7; #define pri(a) cout << (a) << endl int main() { ios::sync_with_stdio(false); cin.tie(0); ll A, B, C; cin >> A >> B >> C; cout << A * C / 2 << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll, ll> #define FOR(I, A, B) for (int I = int(A); I < int(B); ++I) #define FORR(I, A, B) for (int I = int((B)-1); I >= int(A); --I) #define TO(x, t, f) ((x) ? (t) : (f)) #define SORT(x) (sort(x.begin(), x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x, v) \ (lower_bound(x.begin(), x.end(), v) - x.begin()) // ai>=v x is sorted #define POSU(x, v) \ (upper_bound(x.begin(), x.end(), v) - x.begin()) // ai>v x is sorted #define NUM(x, v) (POSU(x, v) - POSL(x, v)) // x is sorted #define REV(x) (reverse(x.begin(), x.end())) // reverse ll gcd(ll a, ll b) { if (a < b) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } ll lcm(ll a, ll b) { ll c = gcd(a, b); return ((a / c) * (b / c) * c); } // saisyo kobaisu #define NEXTP(x) next_permutation(x.begin(), x.end()) const ll INF = 1e18 + 7; const ll MOD = 1e9 + 7; #define pri(a) cout << (a) << endl int main() { ios::sync_with_stdio(false); cin.tie(0); ll A, B, C; cin >> A >> B >> C; cout << A * B / 2 << endl; }
[ "identifier.change", "io.output.change" ]
943,976
943,977
u780122303
cpp
p03146
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; if (N == 1 || N == 2 || N == 4) { cout << 4 << endl; } int i = 1; while (true) { if (N % 2 == 1) { N = 3 * N + 1; } else { N /= 2; } i++; if (N == 4) { cout << i + 3 << endl; break; } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int N; cin >> N; if (N == 1 || N == 2 || N == 4) { cout << 4 << endl; } else { int i = 1; while (true) { if (N % 2 == 1) { N = 3 * N + 1; } else { N /= 2; } i++; if (N == 4) { cout << i + 3 << endl; break; } } } }
[ "control_flow.branch.else.add" ]
943,982
943,983
u298972557
cpp
p03146
/* abc168 double dots int main() { int n,m; cin >> n >> m; Graph G(n); rep(i,m){ int a,b; cin >> a >> b; --a;--b; G[a].push_back(b); G[b].push_back(a); } //BFSのためのデータ構造 vector<int>dist(n,-1); queue<int>q; vector<int>prev(n,-1); //初期条件(頂点0を初期ノードとする dist[0] = 0; q.push(0); //BFS開始 while(!q.empty()){ int v = q.front(); q.pop(); //vから辿れる頂点を全て調べる for(int nv : G[v]){ if(dist[nv] != -1)continue; dist[nv] = dist[v] + 1; prev[nv] = v; q.push(nv); } } cout << "Yes"<<endl; rep(i,n){ if(i==0)continue; cout << prev[i] + 1 << endl; } } */ /* // ABC141 D - Powerful Discount Tickets // 優先度キュー プライオリティーキュー int main() { ll n,m; cin >> n >> m; // プライオリティーキューに突っ込む priority_queue<ll> q; rep(i,n){ ll k; cin >> k; q.push(k); } // 値段の高いものから割引券を適応して戻す rep(i,m){ ll now = q.top(); q.pop(); now /= 2; q.push(now); } // 結果的に合計いくらになったか計算する ll ans = 0; while (!q.empty()) { ans += q.top(); q.pop(); } cout << ans << endl; } */ /* ABC026 高橋君の給料 DFS int dfs(int n,vector<vector<int>> G){ int mi = 1000000000; int ma = 0; int w,v; for(int i=0;i<G[n].size();i++){ v = G[n][i]; if(G[v].size() == 0)w = 1; else w = dfs(v,G); mi = min(mi,w); ma = max(ma,w); } return mi + ma + 1; } int main() { int n; cin >> n; Graph G(n+1); for(int i=2;i<=n;i++){ int a; cin >> a; G[a].push_back(i); } int ans = dfs(1,G); cout << ans << endl; } */ //素因数分解 // ABC169-D - Div Game /* int main() { ll n; cin >> n; vector<pair<ll,ll> > res; for(ll i = 2;i*i <= n;i++){ if(n % i !=0) continue; ll ex = 0;// 指数 //割れる限り割り続ける while(n % i ==0){ ex++; n /=i; } //その結果をpush res.push_back({i,ex}); } //最後に残った数について if(n !=1) res.push_back({n,1}); // cout << n << ":"; // for (auto p : res) { // for (int i = 0; i < p.second; ++i) cout << " " << p.first; // } // cout << endl; ll times = 0; for (auto p : res) { int count = 1; int cnt = 0; while(p.second > cnt){ // cout << p.second << endl; p.second -=count; count++; cnt ++; } times += cnt; } cout << times << endl; } */ // ABC146 //二分探索 /*int main() { ll a,b,x; cin >> a >> b >> x; ll left = 0; ll right = 1000000001; while(right - left > 1){ ll mid = (left + right ) /2; if(a * mid + b * ketasuu(mid) > x) right = mid; else left = mid; // cout << left << " " << right << endl; } cout << left << endl; } */ // ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(), a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second +1 << endl; } } */ // ABC_058_Cのように // s.at(j) == a のとき // cout << s.at(j)-'0' - 49 << endl; //とすると、「0」を出力してくれる。 →もっといいほかの方法はないの? //全bit探索を入れよう!! /*ABC_167_C skill up などを参考に… //https://qiita.com/hareku/items/3d08511eab56a481c7db int main() { int n = 3; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 0; bit < (1<<n); ++bit) { vector<int> S; for (int i = 0; i < n; ++i) { if (bit & (1<<i)) { // 列挙に i が含まれるか S.push_back(i); } } cout << bit << ": {"; for (int i = 0; i < (int)S.size(); ++i) { cout << S[i] << " "; } cout << "}" << endl; } } */ // next_permutation(順列列挙) /*https://note.com/memenekokaburi/n/nf0201d6002cd //https://scrapbox.io/ganariya/AtCoderGrandContest022_A%E5%95%8F%E9%A1%8C300%E7%82%B9%E3%80%8CDiverse_Word%E3%80%8D_(copy) //https://atcoder.jp/contests/agc022/tasks/agc022_a ABC_150_Cなど。 int main() { int n; cin >> n ; vector<int>array = {}; for(int i=0;i<n;i++){ array.push_back(i); } do{ for(int i=0; i<n; i++){ cout << array.at(i); if(i!=n-1)cout<<" "; } cout<<endl; }while(next_permutation(array.begin(),array.end())); return 0; } */ // ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble // kan_halfのようにかく /* //ABC_041_C// pair型 int main() { int n; cin >> n; vector<pair<int,int>>a(n); for(int i=0;i<n;i++){ int num; cin >> num; a.at(i).first = num; a.at(i).second = i; } sort(a.begin(), a.end()); reverse(a.begin(),a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second + 1<< endl; } } */ /*ABC_068_C //boolの配列を使って bool s[200050] = {}; bool t[200050] = {}; int main() { ll n, m; cin >> n >> m; for (int i = 0; i < m; i++){ ll a, b; cin >> a >> b; if (a == 1) { t[b] = true; } if (b == n) { s[a] = true; } } for (int i = 0; i < 200050; i++){ if (s[i] && t[i]) { cout << "POSSIBLE" << endl; return 0; } } cout << "IMPOSSIBLE" << endl; return 0; } */ // int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = // 2*10^9 再帰関数 ABC_029_C /* void f(int rest , string s){ if(rest == 0){ cout << s << endl; } else{ for(char moji = 'a' ;moji <='c' ; moji++){ f(rest-1,s+moji); } } } int main() { int n; cin >> n; f(n, ""); } */ //連想配列 ARC_081_Cの解答 //ABC073でも復習できます。 /* int main() { ll n; cin >> n; vector<ll>a(n); rep(i,n) cin>>a.at(i); map<ll,ll>mp; rep(i,n){ mp[a.at(i)]++; } ll one = 0; ll two = 0; for(auto p:mp){ // cout << p.first << " " << p.second << endl; if(p.second >= 2){ if(one <= p.first){ two = one; one = p.first; } } if(p.second >= 4){ if(one <= p.first){ two = p.first; one = p.first; } } } // cout << one << endl; // cout << two << endl; // cout << endl; cout << one * two << endl; } */ //関数 /* ll gcd(ll a, ll b){ if (a%b == 0){ return(b); } else{ return(gcd(b, a%b)); } } ll lcm(ll a, ll b){ // return a * b / gcd(a, b); return a / gcd(a, b)* b; } int kan_hyaku(int n){ int kurai = 0; for(int i=0;i<3;i++){ kurai = n%10; n /=10; } return kurai; } int kan_ju(int n){ int kurai = 0; for(int i=0;i<2;i++){ kurai = n%10; n /=10; } return kurai; } int kan_ichi(int n){ int kurai = 0; for(int i=0;i<1;i++){ kurai = n%10; n /=10; } return kurai; } ll keta(ll n){ ll wa = 1; while(n>0){ wa *=10; n--; } return wa; } double kan_half(int n){ double wa = 1; while(n>0){ // cout << "TEST"<<endl; wa *= 0.5; // cout << wa << endl; n--; } return wa; } ll facctorialMethod(ll k){ ll sum = 1; for (ll i = 1; i <= k; ++i) { sum = sum%1000000007 * i%1000000007; } return sum; } int zorocheck(string s){ int count = 0; rep(i,s.size()){ if(s.at(i) == s.at(0)) count++; } if(count ==s.size()){ return 1; } else{ return 0; } } int sannobekijou(int n){ int wa = 1; while(n>0){ n--; wa *=3; } return wa; } ll ketasuu(ll k){ ll wa = 0; while(k > 0){ k /=10; wa++; } return wa; } ll beki(ll f,ll num){ ll wa = 1; while(num > 0){ wa *= f; num--; // cout << wa << endl; } return wa; } ll fibona(ll num){ vector<ll>c(3); c.at(0) = 1; c.at(1) = 2; c.at(2) = 3; if(num == 1){ return c.at(0); } else if(num == 2){ return c.at(1); } else if(num == 3){ return c.at(2); } else{ for(ll i = 3; i < num;i++){ // cout << " tes " << endl; ll tmp; tmp = c.at(1) + c.at(2); tmp %= 1000000007; c.at(0) = c.at(1); c.at(1) = c.at(2); c.at(2) = tmp; } return c.at(2); } } */ //桁数を指定して出力する方法 //#include <iomanip>//これをincludeしておかないといけない // cout << fixed << setprecision(20)<< ans << endl; // s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま // s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま // getline(cin, s); //空白文字を含むものをまとめて入力できる。 // s配列に格納した単語を、辞書順にソートする // sort(s.begin(), s.end()); // string t = "keyence";//で文字列を格納できる // s.empty() //emptyなら1を出力 入っていれば0を出力 /*//ABC018-B 部分的にreverseをかける解法 int main() { string s; cin >> s; int n; cin >> n; vector<int>a(n); vector<int>b(n); rep(i,n) cin>>a.at(i)>>b.at(i); rep(i,n)a.at(i)--; rep(i,n)b.at(i)--; string t; rep(i,n){ t = s; for(int k=0;k<=b.at(i)-a.at(i);k++){ t.at(a.at(i)+k) = s.at(b.at(i)-k); } s = t; } cout << s << endl; } *///ABC018-B // cout << char(i+48) << // endl;//なぜかaは47と得る時がある。+48で出力もaにできる。 cout << char(97) << // endl;//アスキーコードでaを出力 // sort(b.begin(), b.end());//bという配列を小さい方からソート // reverse(b.begin(), b.end());//bという配列をリターン /*01 02 03 12 13 23 と6回見ていくパターン for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ } } */ // vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言 // 10のi乗pow(10, i);//ただしdouble型のため注意 /*string s; stringでの文字列を数字型に変える方法 cin >> s; rep(i,s.size()-2) { int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0'; */ /* int n; cin >> n; vector<int>a(n); rep(i,n) cin >> a.at(i); */ // cout << fixed << setprecision(10)<< ans << endl; //数字から文字列に変換 a.at(0) = std::to_string(111); #include <bits/stdc++.h> #include <iomanip> //これをincludeしておかないといけない #include <iostream> #include <queue> #include <vector> using namespace std; using Graph = vector<vector<int>>; typedef long long ll; typedef long double lld; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265359 #define MOD 1000000007 int main() { int n; cin >> n; if (n == 1 || n == 4) { cout << 4 << endl; return 0; } if (n == 2) { cout << 3 << endl; return 0; } int i = 1; while (n != 4) { if (n % 2 == 0) { n /= 2; } else { n = 3 * n + 1; } i++; } cout << i + 3 << endl; }
/* abc168 double dots int main() { int n,m; cin >> n >> m; Graph G(n); rep(i,m){ int a,b; cin >> a >> b; --a;--b; G[a].push_back(b); G[b].push_back(a); } //BFSのためのデータ構造 vector<int>dist(n,-1); queue<int>q; vector<int>prev(n,-1); //初期条件(頂点0を初期ノードとする dist[0] = 0; q.push(0); //BFS開始 while(!q.empty()){ int v = q.front(); q.pop(); //vから辿れる頂点を全て調べる for(int nv : G[v]){ if(dist[nv] != -1)continue; dist[nv] = dist[v] + 1; prev[nv] = v; q.push(nv); } } cout << "Yes"<<endl; rep(i,n){ if(i==0)continue; cout << prev[i] + 1 << endl; } } */ /* // ABC141 D - Powerful Discount Tickets // 優先度キュー プライオリティーキュー int main() { ll n,m; cin >> n >> m; // プライオリティーキューに突っ込む priority_queue<ll> q; rep(i,n){ ll k; cin >> k; q.push(k); } // 値段の高いものから割引券を適応して戻す rep(i,m){ ll now = q.top(); q.pop(); now /= 2; q.push(now); } // 結果的に合計いくらになったか計算する ll ans = 0; while (!q.empty()) { ans += q.top(); q.pop(); } cout << ans << endl; } */ /* ABC026 高橋君の給料 DFS int dfs(int n,vector<vector<int>> G){ int mi = 1000000000; int ma = 0; int w,v; for(int i=0;i<G[n].size();i++){ v = G[n][i]; if(G[v].size() == 0)w = 1; else w = dfs(v,G); mi = min(mi,w); ma = max(ma,w); } return mi + ma + 1; } int main() { int n; cin >> n; Graph G(n+1); for(int i=2;i<=n;i++){ int a; cin >> a; G[a].push_back(i); } int ans = dfs(1,G); cout << ans << endl; } */ //素因数分解 // ABC169-D - Div Game /* int main() { ll n; cin >> n; vector<pair<ll,ll> > res; for(ll i = 2;i*i <= n;i++){ if(n % i !=0) continue; ll ex = 0;// 指数 //割れる限り割り続ける while(n % i ==0){ ex++; n /=i; } //その結果をpush res.push_back({i,ex}); } //最後に残った数について if(n !=1) res.push_back({n,1}); // cout << n << ":"; // for (auto p : res) { // for (int i = 0; i < p.second; ++i) cout << " " << p.first; // } // cout << endl; ll times = 0; for (auto p : res) { int count = 1; int cnt = 0; while(p.second > cnt){ // cout << p.second << endl; p.second -=count; count++; cnt ++; } times += cnt; } cout << times << endl; } */ // ABC146 //二分探索 /*int main() { ll a,b,x; cin >> a >> b >> x; ll left = 0; ll right = 1000000001; while(right - left > 1){ ll mid = (left + right ) /2; if(a * mid + b * ketasuu(mid) > x) right = mid; else left = mid; // cout << left << " " << right << endl; } cout << left << endl; } */ // ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(), a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second +1 << endl; } } */ // ABC_058_Cのように // s.at(j) == a のとき // cout << s.at(j)-'0' - 49 << endl; //とすると、「0」を出力してくれる。 →もっといいほかの方法はないの? //全bit探索を入れよう!! /*ABC_167_C skill up などを参考に… //https://qiita.com/hareku/items/3d08511eab56a481c7db int main() { int n = 3; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 0; bit < (1<<n); ++bit) { vector<int> S; for (int i = 0; i < n; ++i) { if (bit & (1<<i)) { // 列挙に i が含まれるか S.push_back(i); } } cout << bit << ": {"; for (int i = 0; i < (int)S.size(); ++i) { cout << S[i] << " "; } cout << "}" << endl; } } */ // next_permutation(順列列挙) /*https://note.com/memenekokaburi/n/nf0201d6002cd //https://scrapbox.io/ganariya/AtCoderGrandContest022_A%E5%95%8F%E9%A1%8C300%E7%82%B9%E3%80%8CDiverse_Word%E3%80%8D_(copy) //https://atcoder.jp/contests/agc022/tasks/agc022_a ABC_150_Cなど。 int main() { int n; cin >> n ; vector<int>array = {}; for(int i=0;i<n;i++){ array.push_back(i); } do{ for(int i=0; i<n; i++){ cout << array.at(i); if(i!=n-1)cout<<" "; } cout<<endl; }while(next_permutation(array.begin(),array.end())); return 0; } */ // ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble // kan_halfのようにかく /* //ABC_041_C// pair型 int main() { int n; cin >> n; vector<pair<int,int>>a(n); for(int i=0;i<n;i++){ int num; cin >> num; a.at(i).first = num; a.at(i).second = i; } sort(a.begin(), a.end()); reverse(a.begin(),a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second + 1<< endl; } } */ /*ABC_068_C //boolの配列を使って bool s[200050] = {}; bool t[200050] = {}; int main() { ll n, m; cin >> n >> m; for (int i = 0; i < m; i++){ ll a, b; cin >> a >> b; if (a == 1) { t[b] = true; } if (b == n) { s[a] = true; } } for (int i = 0; i < 200050; i++){ if (s[i] && t[i]) { cout << "POSSIBLE" << endl; return 0; } } cout << "IMPOSSIBLE" << endl; return 0; } */ // int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = // 2*10^9 再帰関数 ABC_029_C /* void f(int rest , string s){ if(rest == 0){ cout << s << endl; } else{ for(char moji = 'a' ;moji <='c' ; moji++){ f(rest-1,s+moji); } } } int main() { int n; cin >> n; f(n, ""); } */ //連想配列 ARC_081_Cの解答 //ABC073でも復習できます。 /* int main() { ll n; cin >> n; vector<ll>a(n); rep(i,n) cin>>a.at(i); map<ll,ll>mp; rep(i,n){ mp[a.at(i)]++; } ll one = 0; ll two = 0; for(auto p:mp){ // cout << p.first << " " << p.second << endl; if(p.second >= 2){ if(one <= p.first){ two = one; one = p.first; } } if(p.second >= 4){ if(one <= p.first){ two = p.first; one = p.first; } } } // cout << one << endl; // cout << two << endl; // cout << endl; cout << one * two << endl; } */ //関数 /* ll gcd(ll a, ll b){ if (a%b == 0){ return(b); } else{ return(gcd(b, a%b)); } } ll lcm(ll a, ll b){ // return a * b / gcd(a, b); return a / gcd(a, b)* b; } int kan_hyaku(int n){ int kurai = 0; for(int i=0;i<3;i++){ kurai = n%10; n /=10; } return kurai; } int kan_ju(int n){ int kurai = 0; for(int i=0;i<2;i++){ kurai = n%10; n /=10; } return kurai; } int kan_ichi(int n){ int kurai = 0; for(int i=0;i<1;i++){ kurai = n%10; n /=10; } return kurai; } ll keta(ll n){ ll wa = 1; while(n>0){ wa *=10; n--; } return wa; } double kan_half(int n){ double wa = 1; while(n>0){ // cout << "TEST"<<endl; wa *= 0.5; // cout << wa << endl; n--; } return wa; } ll facctorialMethod(ll k){ ll sum = 1; for (ll i = 1; i <= k; ++i) { sum = sum%1000000007 * i%1000000007; } return sum; } int zorocheck(string s){ int count = 0; rep(i,s.size()){ if(s.at(i) == s.at(0)) count++; } if(count ==s.size()){ return 1; } else{ return 0; } } int sannobekijou(int n){ int wa = 1; while(n>0){ n--; wa *=3; } return wa; } ll ketasuu(ll k){ ll wa = 0; while(k > 0){ k /=10; wa++; } return wa; } ll beki(ll f,ll num){ ll wa = 1; while(num > 0){ wa *= f; num--; // cout << wa << endl; } return wa; } ll fibona(ll num){ vector<ll>c(3); c.at(0) = 1; c.at(1) = 2; c.at(2) = 3; if(num == 1){ return c.at(0); } else if(num == 2){ return c.at(1); } else if(num == 3){ return c.at(2); } else{ for(ll i = 3; i < num;i++){ // cout << " tes " << endl; ll tmp; tmp = c.at(1) + c.at(2); tmp %= 1000000007; c.at(0) = c.at(1); c.at(1) = c.at(2); c.at(2) = tmp; } return c.at(2); } } */ //桁数を指定して出力する方法 //#include <iomanip>//これをincludeしておかないといけない // cout << fixed << setprecision(20)<< ans << endl; // s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま // s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま // getline(cin, s); //空白文字を含むものをまとめて入力できる。 // s配列に格納した単語を、辞書順にソートする // sort(s.begin(), s.end()); // string t = "keyence";//で文字列を格納できる // s.empty() //emptyなら1を出力 入っていれば0を出力 /*//ABC018-B 部分的にreverseをかける解法 int main() { string s; cin >> s; int n; cin >> n; vector<int>a(n); vector<int>b(n); rep(i,n) cin>>a.at(i)>>b.at(i); rep(i,n)a.at(i)--; rep(i,n)b.at(i)--; string t; rep(i,n){ t = s; for(int k=0;k<=b.at(i)-a.at(i);k++){ t.at(a.at(i)+k) = s.at(b.at(i)-k); } s = t; } cout << s << endl; } *///ABC018-B // cout << char(i+48) << // endl;//なぜかaは47と得る時がある。+48で出力もaにできる。 cout << char(97) << // endl;//アスキーコードでaを出力 // sort(b.begin(), b.end());//bという配列を小さい方からソート // reverse(b.begin(), b.end());//bという配列をリターン /*01 02 03 12 13 23 と6回見ていくパターン for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ } } */ // vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言 // 10のi乗pow(10, i);//ただしdouble型のため注意 /*string s; stringでの文字列を数字型に変える方法 cin >> s; rep(i,s.size()-2) { int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0'; */ /* int n; cin >> n; vector<int>a(n); rep(i,n) cin >> a.at(i); */ // cout << fixed << setprecision(10)<< ans << endl; //数字から文字列に変換 a.at(0) = std::to_string(111); #include <bits/stdc++.h> #include <iomanip> //これをincludeしておかないといけない #include <iostream> #include <queue> #include <vector> using namespace std; using Graph = vector<vector<int>>; typedef long long ll; typedef long double lld; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265359 #define MOD 1000000007 int main() { int n; cin >> n; if (n == 1 || n == 4) { cout << 4 << endl; return 0; } if (n == 2) { cout << 4 << endl; return 0; } int i = 1; while (n != 4) { if (n % 2 == 0) { n /= 2; } else { n = 3 * n + 1; } i++; } cout << i + 3 << endl; }
[ "literal.number.change", "io.output.change" ]
943,994
943,995
u037563046
cpp
p03146
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> typedef long long ll; const int INF = 1e9 + 1; const int MOD = 2e9 + 9; const ll LINF = 1e18; using namespace std; int main() { int s; int cnt = 0; cin >> s; vector<int> a(1000001); a.at(0) = s; while (1) { if (s % 2 == 0) { s = s / 2; cnt++; if (a.at(s) == 1) { cout << cnt + 1 << endl; return 0; } else { a.at(s) = 1; } } else { cnt++; s = 3 * s + 1; if (a.at(s) == 1) { cout << cnt + 1 << endl; return 0; } else { a.at(s) = 1; } } } return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> typedef long long ll; const int INF = 1e9 + 1; const int MOD = 2e9 + 9; const ll LINF = 1e18; using namespace std; int main() { int s; int cnt = 0; cin >> s; vector<int> a(1000001); a.at(s) = 1; while (1) { if (s % 2 == 0) { s = s / 2; cnt++; if (a.at(s) == 1) { cout << cnt + 1 << endl; return 0; } else { a.at(s) = 1; } } else { cnt++; s = 3 * s + 1; if (a.at(s) == 1) { cout << cnt + 1 << endl; return 0; } else { a.at(s) = 1; } } } return 0; }
[ "assignment.variable.change", "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "assignment.value.change", "identifier.replace.remove", "literal.replace.add" ]
944,026
944,027
u912678856
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { bool chk = false; int A; cin >> A; vector<int> B(1000000); B.at(0) = A; int count = 0; for (int i = 1; i < 10000001; i++) { if (A % 2 == 0) { A = A / 2; B.at(i) = A; count++; } else { A = 3 * A + 1; B.at(i) = A; count++; } for (int j = 0; j < i; ++j) { if (B.at(j) == B.at(i)) { chk = true; } } if (chk) { break; } } cout << chk + 1 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { bool chk = false; int A; cin >> A; vector<int> B(1000000); B.at(0) = A; int count = 0; for (int i = 1; i < 10000001; i++) { if (A % 2 == 0) { A = A / 2; B.at(i) = A; count++; } else { A = 3 * A + 1; B.at(i) = A; count++; } for (int j = 0; j < i; ++j) { if (B.at(i) == B.at(j)) { chk = true; } } if (chk) { break; } } cout << count + 1 << endl; }
[ "identifier.change", "control_flow.branch.if.condition.change", "io.output.change" ]
944,028
944,029
u977547071
cpp
p03146
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int, int> #define _FastIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define MAXX 1005 int s, t; bool used[MAXX]; int main() { _FastIO; cin >> s; int ans = 0; used[s] = true; t = 1; while (true) { t++; if (s % 2 == 0) s /= 2; else s = s * 3 + 1; if (used[s]) { ans = t; break; } used[s] = true; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int, int> #define _FastIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define MAXX 100005 int s, t; bool used[MAXX]; int main() { _FastIO; cin >> s; int ans = 0; used[s] = true; t = 1; while (true) { t++; if (s % 2 == 0) s /= 2; else s = s * 3 + 1; if (used[s]) { ans = t; break; } used[s] = true; } cout << ans << endl; return 0; }
[ "preprocessor.define.value.change", "literal.integer.change" ]
944,030
944,031
u958323734
cpp
p03146
#define _USE_MATH_DEFINES #include <algorithm> #include <climits> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <set> #include <string> #include <utility> #include <vector> #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() #define pb push_back template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define INF INT_MAX / 2; #define PI 3.14159265358979323846264338327950L; const int INF2 = 1001001001; typedef long long ll; using namespace std; using vi = vector<int>; using vll = vector<ll>; ll mod = 1e9 + 7; // ll llmax = 10000000000000000000ll; const ll LINF = 1e18; using namespace std; using Graph = vector<vector<int>>; int cnt_digit(ll N) { int digit = 0; while (N > 0) { N /= 10; digit++; } return digit; } // 最大公約数計算 ll gcd(ll a, ll b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } // 最小公倍数の計算 ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; } struct union_find { vector<int> par, r; union_find(int n) { par.resize(n); r.resize(n); init(n); } void init(int n) { for (int i = 0; i < n; i++) par[i] = i; for (int i = 0; i < n; i++) r[i] = 0; } int find(int x) { if (par[x] == x) return x; else return find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (r[x] < r[y]) { par[x] = y; } else { par[y] = x; if (r[x] == r[y]) { r[x]++; } } } }; const int MAX_N = 110000; int memo[MAX_N]; int rec(int n) { if (n == 0) return 0; if (memo[n] != -1) return memo[n]; int res = n; for (int pow6 = 1; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1); for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1); return memo[n] = res; } int calc(int x) { int ret = 0; while (x % 2 == 0) { x /= 2; ret++; } return ret; } int a[12][12]; int D; ll G; vector<ll> P, C; // aのp乗を求めるアルゴリズム long modpow(long a, int p) { if (p == 0) return 1; if (p % 2 == 0) { // pが偶数のとき int halfP = p / 2; long half = modpow(a, halfP); return half * half % mod; } else { // pが奇数の時は、 // pを偶数にするために1減らす return a * modpow(a, p - 1) % mod; } } //(10*9*8)/(3*2*1); // 10*9*8 -> ansMul // 3*2*1 -> ansDiv; long calcComb(int a, int b) { if (b > a - b) return calcComb(a, a - b); long ansMul = 1; long ansDiv = 1; rep(i, 0, b) { ansMul *= (a - i); ansDiv *= (i + 1); ansMul %= mod; ansDiv %= mod; } // ansMul /ansDivをやりたい // ansDivの逆元を使って求めよう。 long ans = ansMul * modpow(ansDiv, mod - 2) % mod; return ans; } bool is_war(const vector<int> &x, const vector<int> &y) { for (int Z = -100; Z <= 100; Z++) { bool is_ok = true; rep(i, 0, x.size()) { if (x[i] >= Z) { is_ok = false; } rep(i, 0, y.size()) { if (y[i] < Z) { is_ok = false; } } } if (is_ok) return false; } return true; } //約数列挙 vector<long long> calc_divisor(ll n); vector<ll> calc_divisor(ll n) { vector<ll> res; for (ll i = 1ll; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); ll j = n / i; if (j != i) { res.push_back(j); } } } sort(res.begin(), res.end()); return res; } int N; int ans = 0; void dfs(ll cur, bool flag3, bool flag5, bool flag7) { if (cur > N) return; if (flag3 && flag5 && flag7) ans++; dfs(cur * 10 + 3, true, flag5, flag7); dfs(cur * 10 + 5, flag3, true, flag7); dfs(cur * 10 + 7, flag3, flag5, true); } int main() { cin.tie(0); ios::sync_with_stdio(false); //入力 int s; cin >> s; set<int> done; done.insert(s); int cur = s; rep(i, 2, 1010101) { int nxt; if (cur % 2 == 0) nxt = cur / 2; else 3 * cur + 1; if (done.count(nxt)) { cout << i << endl; return 0; } done.insert(nxt); cur = nxt; } }
#define _USE_MATH_DEFINES #include <algorithm> #include <climits> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <numeric> #include <set> #include <string> #include <utility> #include <vector> #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() #define pb push_back template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define INF INT_MAX / 2; #define PI 3.14159265358979323846264338327950L; const int INF2 = 1001001001; typedef long long ll; using namespace std; using vi = vector<int>; using vll = vector<ll>; ll mod = 1e9 + 7; // ll llmax = 10000000000000000000ll; const ll LINF = 1e18; using namespace std; using Graph = vector<vector<int>>; int cnt_digit(ll N) { int digit = 0; while (N > 0) { N /= 10; digit++; } return digit; } // 最大公約数計算 ll gcd(ll a, ll b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } // 最小公倍数の計算 ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; } struct union_find { vector<int> par, r; union_find(int n) { par.resize(n); r.resize(n); init(n); } void init(int n) { for (int i = 0; i < n; i++) par[i] = i; for (int i = 0; i < n; i++) r[i] = 0; } int find(int x) { if (par[x] == x) return x; else return find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (r[x] < r[y]) { par[x] = y; } else { par[y] = x; if (r[x] == r[y]) { r[x]++; } } } }; const int MAX_N = 110000; int memo[MAX_N]; int rec(int n) { if (n == 0) return 0; if (memo[n] != -1) return memo[n]; int res = n; for (int pow6 = 1; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1); for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1); return memo[n] = res; } int calc(int x) { int ret = 0; while (x % 2 == 0) { x /= 2; ret++; } return ret; } int a[12][12]; int D; ll G; vector<ll> P, C; // aのp乗を求めるアルゴリズム long modpow(long a, int p) { if (p == 0) return 1; if (p % 2 == 0) { // pが偶数のとき int halfP = p / 2; long half = modpow(a, halfP); return half * half % mod; } else { // pが奇数の時は、 // pを偶数にするために1減らす return a * modpow(a, p - 1) % mod; } } //(10*9*8)/(3*2*1); // 10*9*8 -> ansMul // 3*2*1 -> ansDiv; long calcComb(int a, int b) { if (b > a - b) return calcComb(a, a - b); long ansMul = 1; long ansDiv = 1; rep(i, 0, b) { ansMul *= (a - i); ansDiv *= (i + 1); ansMul %= mod; ansDiv %= mod; } // ansMul /ansDivをやりたい // ansDivの逆元を使って求めよう。 long ans = ansMul * modpow(ansDiv, mod - 2) % mod; return ans; } bool is_war(const vector<int> &x, const vector<int> &y) { for (int Z = -100; Z <= 100; Z++) { bool is_ok = true; rep(i, 0, x.size()) { if (x[i] >= Z) { is_ok = false; } rep(i, 0, y.size()) { if (y[i] < Z) { is_ok = false; } } } if (is_ok) return false; } return true; } //約数列挙 vector<long long> calc_divisor(ll n); vector<ll> calc_divisor(ll n) { vector<ll> res; for (ll i = 1ll; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); ll j = n / i; if (j != i) { res.push_back(j); } } } sort(res.begin(), res.end()); return res; } int N; int ans = 0; void dfs(ll cur, bool flag3, bool flag5, bool flag7) { if (cur > N) return; if (flag3 && flag5 && flag7) ans++; dfs(cur * 10 + 3, true, flag5, flag7); dfs(cur * 10 + 5, flag3, true, flag7); dfs(cur * 10 + 7, flag3, flag5, true); } int main() { cin.tie(0); ios::sync_with_stdio(false); //入力 int s; cin >> s; set<int> done; done.insert(s); int cur = s; rep(i, 2, 1010101) { int nxt; if (cur % 2 == 0) nxt = cur / 2; else nxt = 3 * cur + 1; if (done.count(nxt)) { cout << i << endl; return 0; } done.insert(nxt); cur = nxt; } }
[ "assignment.change" ]
944,040
944,041
u983547593
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { set<int> s; int now = n, cnt = 0; while (!s.count(now)) { cnt++; s.insert(now); if (now % 2) now = 3 * now + 1; else now /= 2; } printf("%d\n", cnt); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { set<int> s; int now = n, cnt = 0; while (!s.count(now)) { cnt++; s.insert(now); if (now % 2) now = 3 * now + 1; else now /= 2; } printf("%d\n", cnt + 1); } return 0; }
[ "expression.operation.binary.add" ]
944,044
944,045
u516708338
cpp
p03146
#include <bits/stdc++.h> using namespace std; #define REP(i, a, b) for (int i = a; i < b; i++) #define rep(i, n) REP(i, 0, n) typedef long long ll; int main() { int MAX_M = 1000003; int s; cin >> s; int a[MAX_M]; rep(i, MAX_M) a[i] = 0; a[s] = 1; int ans; rep(i, MAX_M) { if (s % 2 == 1) s = 3 * s + 1; else s /= 2; ++a[s]; if (a[s] == 2) { ans = i + 1; break; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, a, b) for (int i = a; i < b; i++) #define rep(i, n) REP(i, 0, n) typedef long long ll; int main() { int MAX_M = 1000003; int s; cin >> s; int a[MAX_M]; rep(i, MAX_M) a[i] = 0; a[s] = 1; int ans; rep(i, MAX_M) { if (s % 2 == 1) s = 3 * s + 1; else s /= 2; ++a[s]; if (a[s] == 2) { ans = i + 2; break; } } cout << ans << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change" ]
944,049
944,050
u933962236
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i + 1)) { cout << i + 1 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i + 1)) { cout << i + 1 << endl; return 0; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
944,053
944,054
u187417007
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < X; j++) { if (A.at(j) == A.at(i + 1)) { cout << i + 1 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < X; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } } }
[ "identifier.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
944,055
944,054
u187417007
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < X; j++) { if (A.at(j) == A.at(i)) { cout << i + 2 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < X; j++) { if (A.at(j) == A.at(i)) { cout << i + 2 << endl; return 0; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } } }
[ "identifier.change", "control_flow.branch.if.condition.change", "literal.number.change", "io.output.change" ]
944,056
944,054
u187417007
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < X; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < X; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int X; vector<int> A; X = s; A.push_back(s); for (int i = 0; i < 100000000; i++) { if (X % 2 == 0) { X = X / 2; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } if (X % 2 == 1) { X = X * 3 + 1; A.push_back(X); for (int j = 0; j < i; j++) { if (A.at(j) == A.at(i)) { cout << i + 1 << endl; return 0; } } } } }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
944,057
944,054
u187417007
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; if (s == 2 || s == 1) { cout << 4 << endl; return 0; } int i = 1; while (s != 4) { if (s % 2 == 0) s /= 2; else s = s * 3 + 1; i++; } cout << i << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; if (s == 2 || s == 1) { cout << 4 << endl; return 0; } int i = 4; while (s != 4) { if (s % 2 == 0) s /= 2; else s = s * 3 + 1; i++; } cout << i << endl; }
[ "literal.number.change", "variable_declaration.value.change" ]
944,058
944,059
u306482197
cpp
p03146
#include <bits/stdc++.h> using namespace std; int a[1000005]; int b[1000005]; int main() { cin >> a[0]; int ans; for (int i = 1; i < 1e6 + 1; i++) { if (a[i - 1] % 2 == 0) a[i] = a[i - 1] / 2; else a[i] = 3 * a[i - 1] + 1; if (b[a[i]] > 0 || a[i] == a[0]) { ans = i; break; } b[a[i]] = i; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int a[1000005]; int b[1000005]; int main() { cin >> a[0]; int ans; for (int i = 1; i < 1e6 + 1; i++) { if (a[i - 1] % 2 == 0) a[i] = a[i - 1] / 2; else a[i] = 3 * a[i - 1] + 1; if (b[a[i]] > 0 || a[i] == a[0]) { ans = i; break; } b[a[i]] = i; } cout << ans + 1 << endl; }
[ "expression.operation.binary.add" ]
944,067
944,068
u983681697
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; map<int, int> Map; for (int i = 0; i < 1000000; i++) { if (Map[s] > 0) { cout << i + 1 << endl; return 0; } Map[s]++; if (s % 2 == 0) { s /= 2; } else { s += s * 3 + 1; } } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; map<int, int> Map; for (int i = 0; i < 1000000; i++) { if (Map[s] > 0) { cout << i + 1 << endl; return 0; } Map[s]++; if (s % 2 == 0) { s /= 2; } else { s += s * 2 + 1; } } cout << s << endl; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change" ]
944,075
944,076
u237390401
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long i = 1; if (n == 1 || n == 2) cout << 4; while (1) { if (n == 4) { cout << i + 3; return 0; } if (n % 2 == 0) n /= 2; else n = n * 3 + 1; i++; } }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long i = 1; if (n == 1 || n == 2) { cout << 4; return 0 ; } while (1) { if (n == 4) { cout << i + 3; return 0; } if (n % 2 == 0) n /= 2; else n = n * 3 + 1; i++; } }
[ "control_flow.return.add", "function.return_value.change" ]
944,093
944,094
u222643545
cpp
p03146
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; int main() { int s; cin >> s; set<int> a; a.insert(s); int n = s; for (int i = 2; i < 1000001; i++) { if (n % 2 == 0) n /= 2; else n = 3 * n + 1; if (a.count(n)) { cout << n << endl; return 0; } a.insert(n); } return 0; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; int main() { int s; cin >> s; set<int> a; a.insert(s); int n = s; for (int i = 2; i < 1000001; i++) { if (n % 2 == 0) n /= 2; else n = 3 * n + 1; if (a.count(n)) { cout << i << endl; return 0; } a.insert(n); } return 0; }
[ "identifier.change", "io.output.change" ]
944,095
944,096
u109191542
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; vector<int> a(1000000); a.at(0) = s; int i = 1; while (1) { if (s % 2 == 0) { s = s / 2; auto result = find(a.begin() + 1, a.end(), s); if (result != a.end()) { cout << i + 1 << endl; return 0; } a.at(i) = s; i += 1; } else { s = 3 * s + 1; auto result = find(a.begin() + 1, a.end(), s); if (result != a.end()) { cout << i + 1 << endl; return 0; } a.at(i) = s; i += 1; } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; vector<int> a(1000000); a.at(0) = s; int i = 1; while (1) { if (s % 2 == 0) { s = s / 2; auto result = find(a.begin(), a.end(), s); if (result != a.end()) { cout << i + 1 << endl; return 0; } a.at(i) = s; i += 1; } else { s = 3 * s + 1; auto result = find(a.begin(), a.end(), s); if (result != a.end()) { cout << i + 1 << endl; return 0; } a.at(i) = s; i += 1; } } }
[ "expression.operation.binary.remove" ]
944,109
944,110
u552331659
cpp
p03146
#include <bits/stdc++.h> using namespace std; #define inf 1072114514 #define llinf 4154118101919364364 #define mod 1000000007 #define pi 3.1415926535897932384 int round(int a, int b) { if ((a % b) * 2 >= b) { return (a / b) + 1; } return a / b; } int gcd(int a, int b) { int c; while (b != 0) { c = a % b; a = b; b = c; } return a; } //最大公約数 int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a * b; } //最小公倍数 int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; } return r; } //コンビネーション int nHr(int a, int b) { return nCr(a + b - 1, b); } // 重複組み合わせ int fact(int a) { int i, r = 1; for (i = 1; i <= a; i++) { r *= i; } return r; } //階乗 int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; } return r; } // a~bまでの階乗 int dsum(int x) { int r = 0; while (x) { r += (x % 10); x /= 10; } return r; } //数字の各位の和 int dsumb(int x, int b) { int r = 0; while (x) { r += (x % b); x /= b; } return r; } // b進数の各位の和? int sankaku(int x) { return ((1 + x) * x) / 2; } //三角数 xまでの和 //以下long long ver long long llmax(long long a, long long b) { if (a > b) { return a; } return b; } long long llmin(long long a, long long b) { if (a < b) { return a; } return b; } long long llzt(long long a, long long b) { return llmax(a, b) - llmin(a, b); } long long llround(long long a, long long b) { if ((a % b) * 2 >= b) { return (a / b) + 1; } return a / b; } long long llceil(long long a, long long b) { if (a % b == 0) { return a / b; } return (a / b) + 1; } long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a % b; a = b; b = c; } return a; } long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a * b; } long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; } return r; } long long llnHr(long long a, long long b) { return llnCr(a + b - 1, b); } long long llfact(long long a) { long long i, r = 1; for (i = 1; i <= a; i++) { r *= i; } return r; } long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; } return r; } long long lldsum(long long x) { long long r = 0; while (x) { r += (x % 10); x /= 10; } return r; } long long lldsumb(long long x, long long b) { long long r = 0; while (x) { r += (x % b); x /= b; } return r; } long long llsankaku(long long x) { return ((1 + x) * x) / 2; } // double double dbmax(double a, double b) { if (a > b) { return a; } return b; } double dbmin(double a, double b) { if (a < b) { return a; } return b; } double dbzt(double a, double b) { return dbmax(a, b) - dbmin(a, b); } typedef pair<int, int> ii; typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; #define forr(i, a, b) \ ; \ for (int i = (a); i < (b); i++) #define clean(arr, val) memset(arr, val, sizeof(arr)) #define forn(i, n) forr(i, 0, n) #define PB push_back typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vpll; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; /*CODE START HERE*/ int main() { int s; cin >> s; int a_n = s; int n = 1; forn(i, 1000000) { if (a_n != 1 || a_n != 2 || a_n != 4) { break; } if (a_n % 2 == 1) { a_n = 3 * a_n + 1; } else if (a_n % 2 == 0) { a_n /= 2; } n++; } cout << n + 3 << endl; }
#include <bits/stdc++.h> using namespace std; #define inf 1072114514 #define llinf 4154118101919364364 #define mod 1000000007 #define pi 3.1415926535897932384 int round(int a, int b) { if ((a % b) * 2 >= b) { return (a / b) + 1; } return a / b; } int gcd(int a, int b) { int c; while (b != 0) { c = a % b; a = b; b = c; } return a; } //最大公約数 int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a * b; } //最小公倍数 int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; } return r; } //コンビネーション int nHr(int a, int b) { return nCr(a + b - 1, b); } // 重複組み合わせ int fact(int a) { int i, r = 1; for (i = 1; i <= a; i++) { r *= i; } return r; } //階乗 int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; } return r; } // a~bまでの階乗 int dsum(int x) { int r = 0; while (x) { r += (x % 10); x /= 10; } return r; } //数字の各位の和 int dsumb(int x, int b) { int r = 0; while (x) { r += (x % b); x /= b; } return r; } // b進数の各位の和? int sankaku(int x) { return ((1 + x) * x) / 2; } //三角数 xまでの和 //以下long long ver long long llmax(long long a, long long b) { if (a > b) { return a; } return b; } long long llmin(long long a, long long b) { if (a < b) { return a; } return b; } long long llzt(long long a, long long b) { return llmax(a, b) - llmin(a, b); } long long llround(long long a, long long b) { if ((a % b) * 2 >= b) { return (a / b) + 1; } return a / b; } long long llceil(long long a, long long b) { if (a % b == 0) { return a / b; } return (a / b) + 1; } long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a % b; a = b; b = c; } return a; } long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a * b; } long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; } return r; } long long llnHr(long long a, long long b) { return llnCr(a + b - 1, b); } long long llfact(long long a) { long long i, r = 1; for (i = 1; i <= a; i++) { r *= i; } return r; } long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; } return r; } long long lldsum(long long x) { long long r = 0; while (x) { r += (x % 10); x /= 10; } return r; } long long lldsumb(long long x, long long b) { long long r = 0; while (x) { r += (x % b); x /= b; } return r; } long long llsankaku(long long x) { return ((1 + x) * x) / 2; } // double double dbmax(double a, double b) { if (a > b) { return a; } return b; } double dbmin(double a, double b) { if (a < b) { return a; } return b; } double dbzt(double a, double b) { return dbmax(a, b) - dbmin(a, b); } typedef pair<int, int> ii; typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> pll; #define forr(i, a, b) \ ; \ for (int i = (a); i < (b); i++) #define clean(arr, val) memset(arr, val, sizeof(arr)) #define forn(i, n) forr(i, 0, n) #define PB push_back typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vpll; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; /*CODE START HERE*/ int main() { int s; cin >> s; int a_n = s; int n = 1; forn(i, 1000000) { if (a_n == 1 || a_n == 2 || a_n == 4) { break; } if (a_n % 2 == 1) { a_n = 3 * a_n + 1; } else if (a_n % 2 == 0) { a_n /= 2; } n++; } cout << n + 3 << endl; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
944,121
944,122
u946082956
cpp
p03146
#include <bits/stdc++.h> #include <iostream> typedef long long ll; #define rep(i, a, b) for (ll i = a; i <= b; i++) #define per(i, a, b) for (ll i = a; i >= b; i--) using namespace std; typedef vector<ll> vi; typedef vector<vector<ll>> vvi; int main() { // ifstream cin("input.txt"); ll n; cin >> n; int c = 1; while (n > 4) { c++; if (n % 2 == 0) n = n / 2; else n = 3 * n + 1; } cout << c + 3; }
#include <bits/stdc++.h> #include <iostream> typedef long long ll; #define rep(i, a, b) for (ll i = a; i <= b; i++) #define per(i, a, b) for (ll i = a; i >= b; i--) using namespace std; typedef vector<ll> vi; typedef vector<vector<ll>> vvi; int main() { // ifstream cin("input.txt"); ll n; cin >> n; int c = 1; while (n > 4 || n == 3) { c++; if (n % 2 == 0) n = n / 2; else n = 3 * n + 1; } cout << c + 3; }
[ "control_flow.loop.condition.change" ]
944,135
944,136
u847929893
cpp
p03146
#include <iostream> #include <stdio.h> #include <vector> using namespace std; int main(void) { int s; scanf("%d", &s); vector<int> a = {s}; int m = 2; while (1) { if (s % 2 == 0) { s /= 2; } else { s = 3 * s + 1; } for (int i = a.size(); i > 0; i--) { if (a[i] == s) { printf("%d\n", m); return 0; } } a.push_back(s); m++; } return 0; }
#include <iostream> #include <stdio.h> #include <vector> using namespace std; int main(void) { int s; scanf("%d", &s); vector<int> a = {s}; int m = 2; while (1) { if (s % 2 == 0) { s /= 2; } else { s = 3 * s + 1; } // cout << m << " " << s << endl; for (int i = a.size(); i > 0; i--) { if (a[i - 1] == s) { printf("%d\n", m); return 0; } } a.push_back(s); m++; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
944,142
944,143
u684448032
cpp
p03146
//#pragma GCC optimize "trapv" //-D_GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define int long long int #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define ii pair<int, int> #define Max 100000 + 5 #define IO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define f first #define s second #define pb push_back int mod = 1000000007; int mod1 = 998244353; vector<int> g[Max]; bool vis[Max]; int d, x, y; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } void ex(int A, int B) { if (B == 0) { d = A; x = 1; y = 0; } else { ex(B, A % B); int temp = x; x = y; y = temp - (A / B) * y; } } void dfs(int u) { vis[u] = 1; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; if (vis[v] != 1) dfs(v); } } int power(int a, int b) { if (b == 1) return a; if (a > mod) a %= mod; int r = 1; while (b) { if (b & 1) r = r % mod * a % mod; a = a % mod * a % mod; b /= 2; } return r; } class uf { vector<int> v; vector<int> sz; public: uf(int n) { v.resize(n + 1); iota(v.begin() + 1, v.end(), 1); sz.resize(n + 1, 1); // 1 to sz } int root(int b) { while (v[b] != b) { b = v[b]; } return b; } void u(int a, int b) { // combine a and b int ra = root(a); int rb = root(b); if (ra == rb) return; if (sz[ra] < sz[rb]) { v[ra] = v[rb]; sz[rb] += sz[ra]; } else { v[rb] = v[ra]; sz[ra] += sz[rb]; } } bool f(int a, int b) { // same set return (root(a) == root(b)); } }; vector<int> matmul(vector<int> a, vector<int> b) { vector<int> c(4, 0); c[0] = (a[0] % mod * b[0] % mod + a[1] % mod * b[2] % mod) % mod; c[1] = (a[0] % mod * b[1] % mod + a[1] % mod * b[3] % mod) % mod; c[2] = (a[2] % mod * b[0] % mod + a[3] % mod * b[2] % mod) % mod; c[3] = (a[2] % mod * b[1] % mod + a[3] % mod * b[3] % mod) % mod; return c; } vector<int> id = {1, 0, 0, 1}; int32_t main() { IO // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int n; cin >> n; map<int, int> m; m[n] = 1; int i = 2; int prev = n; while (1) { int next = prev % 2 ? prev * 2 + 1 : prev / 2; if (m[next]) { cout << i; break; } else m[next] = 1; i++; prev = next; } }
//#pragma GCC optimize "trapv" //-D_GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define int long long int #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define ii pair<int, int> #define Max 100000 + 5 #define IO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define f first #define s second #define pb push_back int mod = 1000000007; int mod1 = 998244353; vector<int> g[Max]; bool vis[Max]; int d, x, y; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } void ex(int A, int B) { if (B == 0) { d = A; x = 1; y = 0; } else { ex(B, A % B); int temp = x; x = y; y = temp - (A / B) * y; } } void dfs(int u) { vis[u] = 1; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; if (vis[v] != 1) dfs(v); } } int power(int a, int b) { if (b == 1) return a; if (a > mod) a %= mod; int r = 1; while (b) { if (b & 1) r = r % mod * a % mod; a = a % mod * a % mod; b /= 2; } return r; } class uf { vector<int> v; vector<int> sz; public: uf(int n) { v.resize(n + 1); iota(v.begin() + 1, v.end(), 1); sz.resize(n + 1, 1); // 1 to sz } int root(int b) { while (v[b] != b) { b = v[b]; } return b; } void u(int a, int b) { // combine a and b int ra = root(a); int rb = root(b); if (ra == rb) return; if (sz[ra] < sz[rb]) { v[ra] = v[rb]; sz[rb] += sz[ra]; } else { v[rb] = v[ra]; sz[ra] += sz[rb]; } } bool f(int a, int b) { // same set return (root(a) == root(b)); } }; vector<int> matmul(vector<int> a, vector<int> b) { vector<int> c(4, 0); c[0] = (a[0] % mod * b[0] % mod + a[1] % mod * b[2] % mod) % mod; c[1] = (a[0] % mod * b[1] % mod + a[1] % mod * b[3] % mod) % mod; c[2] = (a[2] % mod * b[0] % mod + a[3] % mod * b[2] % mod) % mod; c[3] = (a[2] % mod * b[1] % mod + a[3] % mod * b[3] % mod) % mod; return c; } vector<int> id = {1, 0, 0, 1}; int32_t main() { IO // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int n; cin >> n; map<int, int> m; m[n] = 1; int i = 2; int prev = n; while (1) { int next = prev % 2 ? prev * 3 + 1 : prev / 2; if (m[next]) { cout << i; break; } else m[next] = 1; i++; prev = next; } }
[ "literal.number.change", "expression.operation.binary.change" ]
944,163
944,164
u532535081
cpp
p03146
#include <algorithm> #include <cmath> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; int prev = n; int cnt = 2; if (n == 1 or n == 2 or n == 4) { cout << 3 << '\n'; return 0; } while (true) { int value; if (prev % 2 == 0) value = prev / 2; else value = 3 * prev + 1; if (value == 4 or value == 2 or value == 1) { cout << cnt + 3 << '\n'; break; } prev = value; cnt++; } return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; int prev = n; int cnt = 2; if (n == 1 or n == 2 or n == 4) { cout << 4 << '\n'; return 0; } while (true) { int value; if (prev % 2 == 0) value = prev / 2; else value = 3 * prev + 1; if (value == 4 or value == 2 or value == 1) { cout << cnt + 3 << '\n'; break; } prev = value; cnt++; } return 0; }
[ "literal.number.change", "io.output.change" ]
944,169
944,170
u963667945
cpp
p03146
#include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <vector> typedef long long ll; using namespace std; void saiki(ll &c, int tmp, map<ll, ll> m) { if (tmp % 2 == 0) { tmp = tmp / 2; } else { tmp = 3 * tmp + 1; } if (m.count(tmp)) return; m[tmp] = 1; c = c + 1; saiki(c, tmp, m); } int main(void) { ll s; cin >> s; map<ll, ll> m; ll counter = 2; m[2] = 1; saiki(counter, s, m); cout << counter << endl; }
#include <iostream> #include <map> #include <math.h> #include <stdio.h> #include <vector> typedef long long ll; using namespace std; void saiki(ll &c, int tmp, map<ll, ll> m) { if (tmp % 2 == 0) { tmp = tmp / 2; } else { tmp = 3 * tmp + 1; } if (m.count(tmp)) return; m[tmp] = 1; c = c + 1; saiki(c, tmp, m); } int main(void) { ll s; cin >> s; map<ll, ll> m; ll counter = 2; m[s] = 1; saiki(counter, s, m); cout << counter << endl; }
[ "assignment.variable.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change" ]
944,171
944,172
u456303471
cpp
p03146
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define dbg(x) cerr << #x << " = " << x << '\n' #define sz(x) (int)x.size() #define ff first #define ss second #define pii pair<int, int> using namespace std; inline void solve() { map<int, int> mp; int n, cnt = 1; cin >> n; mp[n]++; while (true) { cnt++; if (n & 1) n = 3 * n + 1; else n /= 2; mp[n]++; if (mp[n] == 2 and (n & (n - 1) == 0)) break; } cout << cnt << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define dbg(x) cerr << #x << " = " << x << '\n' #define sz(x) (int)x.size() #define ff first #define ss second #define pii pair<int, int> using namespace std; inline void solve() { map<int, int> mp; int n, cnt = 1; cin >> n; mp[n]++; while (true) { cnt++; if (n & 1) n = 3 * n + 1; else n /= 2; mp[n]++; if (mp[n] == 2 and !(n & (n - 1))) break; } cout << cnt << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
[ "expression.operation.unary.add", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
944,177
944,178
u931901821
cpp
p03146
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define dbg(x) cerr << #x << " = " << x << '\n' #define sz(x) (int)x.size() #define ff first #define ss second #define pii pair<int, int> using namespace std; inline void solve() { map<int, int> mp; int n, cnt = 1; cin >> n; mp[n]++; while (true) { cnt++; if (n & 1) n = 3 * n + 1; else n /= 2; mp[n]++; if (mp[n] == 2 and (n & (n - 1) == 0)) break; } cout << cnt << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define dbg(x) cerr << #x << " = " << x << '\n' #define sz(x) (int)x.size() #define ff first #define ss second #define pii pair<int, int> using namespace std; inline void solve() { map<int, int> mp; int n, cnt = 1; cin >> n; mp[n]++; while (true) { cnt++; if (n & 1) n = 3 * n + 1; else n /= 2; mp[n]++; if (mp[n] >= 2 and !(n & (n - 1))) break; } cout << cnt << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operation.unary.add", "expression.operation.binary.remove" ]
944,177
944,179
u931901821
cpp
p03146
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define dbg(x) cerr << #x << " = " << x << '\n' #define sz(x) (int)x.size() #define ff first #define ss second #define pii pair<int, int> using namespace std; inline void solve() { map<int, int> mp; int n, cnt = 1; cin >> n; mp[n]++; while (true) { cnt++; if (n & 1) n = 3 * n + 1; else n /= 2; mp[n]++; if (mp[4] == 2) break; } cout << cnt << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
/*------------------------------------ ........Bismillahir Rahmanir Rahim.... ..........created by Abdul Aziz....... ------------------------------------*/ #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <unordered_map> #include <vector> #define mod 998244353 #define int long long #define ld long double #define pb push_back #define vi vector<int> #define dbg(x) cerr << #x << " = " << x << '\n' #define sz(x) (int)x.size() #define ff first #define ss second #define pii pair<int, int> using namespace std; inline void solve() { map<int, int> mp; int n, cnt = 1; cin >> n; mp[n]++; while (true) { cnt++; if (n & 1) n = 3 * n + 1; else n /= 2; mp[n]++; if (mp[n] == 2) break; } cout << cnt << endl; } signed main() { int n = 1; // cin>>n; while (n--) solve(); return 0; }
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
944,180
944,181
u931901821
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; long long m = 1000000; vector<int> a(m); a[0] = s; for (int i = 1; i < m; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } if (a[i - 1] % 2 == 1) { a[i] = 3 * a[i - 1] + 1; } for (int j = 0; j < i; j++) { if (a[i] == a[j]) { cout << i << endl; return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; long long m = 1000001; vector<int> a(m); a[0] = s; for (int i = 1; i < m; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } if (a[i - 1] % 2 == 1) { a[i] = 3 * a[i - 1] + 1; } for (int j = 0; j < i; j++) { if (a[i] == a[j]) { cout << i + 1 << endl; return 0; } } } }
[ "literal.number.change", "variable_declaration.value.change" ]
944,192
944,193
u759465878
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; long long m = 1000000; vector<int> a(m); a[0] = s; for (int i = 1; i < m; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } if (a[i - 1] % 2 == 1) { a[i] = 3 * a[i - 1] + 1; } for (int j = 0; j < m; j++) { if (a[i] == a[j]) { cout << i << endl; return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; long long m = 1000001; vector<int> a(m); a[0] = s; for (int i = 1; i < m; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } if (a[i - 1] % 2 == 1) { a[i] = 3 * a[i - 1] + 1; } for (int j = 0; j < i; j++) { if (a[i] == a[j]) { cout << i + 1 << endl; return 0; } } } }
[ "literal.number.change", "variable_declaration.value.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
944,194
944,193
u759465878
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; long long m = 1000000; vector<int> a(m); a[0] = s; for (int i = 1; i < m; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } if (a[i - 1] % 2 == 1) { a[i] = 2 * a[i - 1] + 1; } for (int j = 0; j < m; j++) { if (a[i] == a[j]) { cout << i << endl; return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; long long m = 1000001; vector<int> a(m); a[0] = s; for (int i = 1; i < m; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } if (a[i - 1] % 2 == 1) { a[i] = 3 * a[i - 1] + 1; } for (int j = 0; j < i; j++) { if (a[i] == a[j]) { cout << i + 1 << endl; return 0; } } } }
[ "literal.number.change", "variable_declaration.value.change", "assignment.value.change", "expression.operation.binary.change", "identifier.change", "control_flow.loop.for.condition.change" ]
944,195
944,193
u759465878
cpp
p03143
#include "bits/stdc++.h" #define YES "YES" #define NO "NO" #define YESNO OUT(three(solve(), YES, NO)) #define ECHO OUT(solve()) #define three(A, B, C) ((A) ? (B) : (C)) #define FOR(i, a, b) for (LL i = (a); i < (LL)(b); i++) #define EFOR(i, a, b) for (LL i = (a); i <= (LL)(b); i++) #define RFOR(i, a, b) for (LL i = (b); i >= (LL)(a); i--) #define REP(i, b) FOR(i, zero, b) #define rep REP #define EREP(i, b) EFOR(i, zero, b) #define RREP(i, b) RFOR(i, b, zero) #define ALL(c) c.begin(), c.end() #define UNIQUE(c) \ sort(ALL(c)); \ c.erase(unique(ALL(c)), c.end()) #define MAX(c) (*max_element(ALL(c))) #define MIN(c) (*min_element(ALL(c))) #define MP make_pair #define FI first #define SE second #define SI(x) (LL(x.size())) #define PB push_back #define DEBUG(a) OUT(a) #define DEBUG2(a, b) OUT2(a, b) #define cat cout << __LINE__ << endl #define OUT(a) cout << (a) << endl #define OUT2(a, b) cout << (a) << " " << (b) << endl #define zero 0LL #define all ALL #define pb emplace_back #define eb pb #define int long long using namespace std; template <typename T> inline void maximize(T &a, T b) { a = max(a, b); } template <typename T> inline void minimize(T &a, T b) { a = min(a, b); } template <typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; } template <class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; } template <class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; } typedef int LL; typedef double ld; typedef int ut; typedef vector<ut> VI; typedef vector<VI> VII; typedef pair<ut, ut> pr; typedef pair<ut, pr> ppr; typedef vector<pr> Vpr; typedef vector<ppr> Vppr; typedef tuple<int, int, int, int> tapu; typedef vector<tapu> Vtapu; typedef priority_queue<ppr, Vppr, greater<ppr>> PQ; inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; } OUT(""); } const int SIZE1 = 3e5 + 1000; const int SIZE2 = 2010; const int SIZE3 = 430; const int SIZE = SIZE1; const int MAPSIZE = 40; const LL p = 7 + 1e9; const LL INF = 1LL << 60; const long double EPS = 1e-7; typedef pair<ld, ut> pld; VI evals[SIZE]; LL maxim[SIZE]; LL anses = 0; LL X[SIZE]; class UnionFind { vector<int> unions, talls, sents, dists, sizes; int size; public: UnionFind() {} UnionFind(int size) : size(size) { init(); } void init() { unions = vector<int>(size); talls = vector<int>(size); sents = vector<int>(size); dists = vector<int>(size); sizes = vector<int>(size); FOR(i, 0, size) { unions[i] = i; sents[i] = 0; sizes[i] = 0; // ns[i].PB(pr(0,1)); talls[i] = 1; } } int find(int x, int t = 0) { if (unions[x] == x || sents[x] > t) return x; return find(unions[x], t); } int minisize(int x) { if (x == unions[x]) return sizes[x]; return minisize(find(x)); } bool isFriend(int a, int b, int t = 0) { return find(a, t) == find(b, t); } void unite(int a, int b, LL y, int t = 0) { a = find(a, t); b = find(b, t); if (talls[a] < talls[b]) unite(b, a, t); if (isFriend(a, b, t)) { sizes[a] += 1; MX(maxim[a], y); assert(maxim[a] <= y); if (maxim[a] <= X[a]) { assert(sizes[a] == 1); anses += sizes[a]; sizes[a] = 0; } return; } else { MX(maxim[a], maxim[b]); // cout << maxim[a] << " " << y << endl; assert(maxim[a] <= y); MX(maxim[a], y); sizes[a] += sizes[b] + 1; sizes[b] = 0; X[a] += X[b]; X[b] = 0; if (maxim[a] <= X[a]) { anses += sizes[a]; sizes[a] = 0; } sents[b] = t; talls[a] = max(talls[a], talls[b] + 1); unions[b] = a; dists[b] = 1; // ns[a].PB(pr(t,ns[b].back().second+ns[a].back().second)); } } }; //#define endl "\n" //インタラクティブでは消す // ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U; ut N, M, K, L, Q, D, H, W, R; VI edges[SIZE]; LL vals[SIZE], answer = zero; LL maps[SIZE2][SIZE2]; LL solve() { cin >> N >> M; EFOR(i, 1, N) cin >> X[i]; Vppr v; REP(i, M) { LL a, b, y; cin >> a >> b >> y; v.pb(y, pr(a, b)); } sort(ALL(v)); UnionFind uf = UnionFind(N + 1); REP(i, v.size()) { LL a = v[i].second.first, b = v[i].second.second, y = v[i].first; uf.unite(a, b, y); // cout << a << " " << b << " " << anses << endl; } assert(0 <= anses and anses <= M); cout << M - anses << endl; return 0; } //!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!! signed main() { ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); string s; solve(); // cin >> N; return 0; }
#include "bits/stdc++.h" #define YES "YES" #define NO "NO" #define YESNO OUT(three(solve(), YES, NO)) #define ECHO OUT(solve()) #define three(A, B, C) ((A) ? (B) : (C)) #define FOR(i, a, b) for (LL i = (a); i < (LL)(b); i++) #define EFOR(i, a, b) for (LL i = (a); i <= (LL)(b); i++) #define RFOR(i, a, b) for (LL i = (b); i >= (LL)(a); i--) #define REP(i, b) FOR(i, zero, b) #define rep REP #define EREP(i, b) EFOR(i, zero, b) #define RREP(i, b) RFOR(i, b, zero) #define ALL(c) c.begin(), c.end() #define UNIQUE(c) \ sort(ALL(c)); \ c.erase(unique(ALL(c)), c.end()) #define MAX(c) (*max_element(ALL(c))) #define MIN(c) (*min_element(ALL(c))) #define MP make_pair #define FI first #define SE second #define SI(x) (LL(x.size())) #define PB push_back #define DEBUG(a) OUT(a) #define DEBUG2(a, b) OUT2(a, b) #define cat cout << __LINE__ << endl #define OUT(a) cout << (a) << endl #define OUT2(a, b) cout << (a) << " " << (b) << endl #define zero 0LL #define all ALL #define pb emplace_back #define eb pb #define int long long using namespace std; template <typename T> inline void maximize(T &a, T b) { a = max(a, b); } template <typename T> inline void minimize(T &a, T b) { a = min(a, b); } template <typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; } template <class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; } template <class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; } typedef int LL; typedef double ld; typedef int ut; typedef vector<ut> VI; typedef vector<VI> VII; typedef pair<ut, ut> pr; typedef pair<ut, pr> ppr; typedef vector<pr> Vpr; typedef vector<ppr> Vppr; typedef tuple<int, int, int, int> tapu; typedef vector<tapu> Vtapu; typedef priority_queue<ppr, Vppr, greater<ppr>> PQ; inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; } OUT(""); } const int SIZE1 = 3e5 + 1000; const int SIZE2 = 2010; const int SIZE3 = 430; const int SIZE = SIZE1; const int MAPSIZE = 40; const LL p = 7 + 1e9; const LL INF = 1LL << 60; const long double EPS = 1e-7; typedef pair<ld, ut> pld; VI evals[SIZE]; LL maxim[SIZE]; LL anses = 0; LL X[SIZE]; class UnionFind { vector<int> unions, talls, sents, dists, sizes; int size; public: UnionFind() {} UnionFind(int size) : size(size) { init(); } void init() { unions = vector<int>(size); talls = vector<int>(size); sents = vector<int>(size); dists = vector<int>(size); sizes = vector<int>(size); FOR(i, 0, size) { unions[i] = i; sents[i] = 0; sizes[i] = 0; // ns[i].PB(pr(0,1)); talls[i] = 1; } } int find(int x, int t = 0) { if (unions[x] == x || sents[x] > t) return x; return find(unions[x], t); } int minisize(int x) { if (x == unions[x]) return sizes[x]; return minisize(find(x)); } bool isFriend(int a, int b, int t = 0) { return find(a, t) == find(b, t); } void unite(int a, int b, LL y, int t = 0) { a = find(a, t); b = find(b, t); if (talls[a] < talls[b]) unite(b, a, y, t); if (isFriend(a, b, t)) { sizes[a] += 1; MX(maxim[a], y); assert(maxim[a] <= y); if (maxim[a] <= X[a]) { assert(sizes[a] == 1); anses += sizes[a]; sizes[a] = 0; } return; } else { MX(maxim[a], maxim[b]); // cout << maxim[a] << " " << y << endl; assert(maxim[a] <= y); MX(maxim[a], y); sizes[a] += sizes[b] + 1; sizes[b] = 0; X[a] += X[b]; X[b] = 0; if (maxim[a] <= X[a]) { anses += sizes[a]; sizes[a] = 0; } sents[b] = t; talls[a] = max(talls[a], talls[b] + 1); unions[b] = a; dists[b] = 1; // ns[a].PB(pr(t,ns[b].back().second+ns[a].back().second)); } } }; //#define endl "\n" //インタラクティブでは消す // ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U; ut N, M, K, L, Q, D, H, W, R; VI edges[SIZE]; LL vals[SIZE], answer = zero; LL maps[SIZE2][SIZE2]; LL solve() { cin >> N >> M; EFOR(i, 1, N) cin >> X[i]; Vppr v; REP(i, M) { LL a, b, y; cin >> a >> b >> y; v.pb(y, pr(a, b)); } sort(ALL(v)); UnionFind uf = UnionFind(N + 1); REP(i, v.size()) { LL a = v[i].second.first, b = v[i].second.second, y = v[i].first; uf.unite(a, b, y); // cout << a << " " << b << " " << anses << endl; } assert(0 <= anses and anses <= M); cout << M - anses << endl; return 0; } //!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!! signed main() { ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); string s; solve(); // cin >> N; return 0; }
[ "call.arguments.add" ]
944,200
944,201
u295617748
cpp
p03143
#include <algorithm> #include <functional> #include <set> #include <stdio.h> #include <utility> #include <vector> typedef long long ll; using namespace std; int main(void) { ll i, j, k, n, m, h, w, a, b, sum = 0, ans = 0; scanf("%lld%lld", &n, &m); ll x[n]; pair<ll, pair<ll, ll>> e[m]; for (i = 0; i < n; ++i) scanf("%lld", &x[i]), sum += x[i]; for (i = 0; i < m; ++i) { scanf("%lld%lld%lld", &e[i].second.first, &e[i].second.second, &e[i].first); e[i].second.first--, e[i].second.second--; if (e[i].first > sum) ++ans; } sort(e, e + m); if (!ans) { printf("0"); return 0; } ans = 0; ll uf[n], now[n]; ll num[n]; for (i = 0; i < n; ++i) uf[i] = i, now[i] = x[i], num[i] = 0; for (i = 0; e[i].first <= sum; ++i) { ll ra = 0, rb = 0, na = e[i].second.first, nb = e[i].second.second, tmpa, tmpb; while (uf[na] != na) ra++, na = uf[na]; while (uf[nb] != nb) rb++, nb = uf[nb]; if (na != nb) { if (ra < rb) { uf[na] = nb, now[nb] += now[na], now[na] = 0; tmpa = now[nb], tmpb = nb; num[nb] += num[na], num[na] = 0; } else { uf[nb] = na, now[na] += now[nb], now[nb] = 0; tmpa = now[na], tmpb = na; num[na] += num[nb], num[nb] = 0; } } else tmpa = now[na], tmpb = na; if (tmpa > e[i].first) ans += num[tmpb] + 1, num[tmpb] = 0; else num[tmpb]++; } printf("%lld", m - ans); return 0; }
#include <algorithm> #include <functional> #include <set> #include <stdio.h> #include <utility> #include <vector> typedef long long ll; using namespace std; int main(void) { ll i, j, k, n, m, h, w, a, b, sum = 0, ans = 0; scanf("%lld%lld", &n, &m); ll x[n]; pair<ll, pair<ll, ll>> e[m]; for (i = 0; i < n; ++i) scanf("%lld", &x[i]), sum += x[i]; for (i = 0; i < m; ++i) { scanf("%lld%lld%lld", &e[i].second.first, &e[i].second.second, &e[i].first); e[i].second.first--, e[i].second.second--; if (e[i].first > sum) ++ans; } sort(e, e + m); if (!ans) { printf("0"); return 0; } ans = 0; ll uf[n], now[n]; ll num[n]; for (i = 0; i < n; ++i) uf[i] = i, now[i] = x[i], num[i] = 0; for (i = 0; e[i].first <= sum; ++i) { ll ra = 0, rb = 0, na = e[i].second.first, nb = e[i].second.second, tmpa, tmpb; while (uf[na] != na) ra++, na = uf[na]; while (uf[nb] != nb) rb++, nb = uf[nb]; if (na != nb) { if (ra < rb) { uf[na] = nb, now[nb] += now[na], now[na] = 0; tmpa = now[nb], tmpb = nb; num[nb] += num[na], num[na] = 0; } else { uf[nb] = na, now[na] += now[nb], now[nb] = 0; tmpa = now[na], tmpb = na; num[na] += num[nb], num[nb] = 0; } } else tmpa = now[na], tmpb = na; if (tmpa >= e[i].first) ans += num[tmpb] + 1, num[tmpb] = 0; else num[tmpb]++; } printf("%lld", m - ans); return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
944,202
944,203
u440920318
cpp
p03143
#include <bits/stdc++.h> #define ll long long #define fornum(A, B, C) for (A = B; A < C; A++) #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// ll N, M; vector<pair<ll, pll>> jv; ll ct[101010]; ll i, j, ans; ll mk[101010]; ll gc[101010], ghn[101010], ghnd[101010]; ll gnxt[101010]; ll ggt(ll a) { ll aa = a; while (gnxt[aa] != aa) { aa = gnxt[aa]; } return gnxt[a] = aa; } int main() { scanf("%lld%lld", &N, &M); fornum(i, 0, N) { ll x; scanf("%lld", &x); gnxt[i + 1] = i + 1; gc[i + 1] = x; } fornum(i, 0, M) { ll a, b, c; scanf("%lld%lld%lld", &a, &b, &c); jv.push_back(mp(c, mp(a, b))); } sort(jv.begin(), jv.end()); fornum(i, 0, M) { auto ja = jv[i]; auto jp = ja.second; ll a = ggt(jp.first); ll b = ggt(jp.second); if (a != b) { gc[a] += gc[b]; ghn[a] += ghn[b]; ghnd[a] += ghnd[b]; gnxt[b] = a; } ghnd[a]++; if (jv[i].first < gc[a]) { ghn[a] = ghnd[a]; } } fornum(i, 0, N) { ll a = ggt(i + 1); if (mk[a] == 0) { mk[a] = 1; ans += ghnd[a] - ghn[a]; } } printf("%lld", ans); return 0; }
#include <bits/stdc++.h> #define ll long long #define fornum(A, B, C) for (A = B; A < C; A++) #define mp make_pair #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; ///////////////////////////////////////////////////// ll N, M; vector<pair<ll, pll>> jv; ll ct[101010]; ll i, j, ans; ll mk[101010]; ll gc[101010], ghn[101010], ghnd[101010]; ll gnxt[101010]; ll ggt(ll a) { ll aa = a; while (gnxt[aa] != aa) { aa = gnxt[aa]; } return gnxt[a] = aa; } int main() { scanf("%lld%lld", &N, &M); fornum(i, 0, N) { ll x; scanf("%lld", &x); gnxt[i + 1] = i + 1; gc[i + 1] = x; } fornum(i, 0, M) { ll a, b, c; scanf("%lld%lld%lld", &a, &b, &c); jv.push_back(mp(c, mp(a, b))); } sort(jv.begin(), jv.end()); fornum(i, 0, M) { auto ja = jv[i]; auto jp = ja.second; ll a = ggt(jp.first); ll b = ggt(jp.second); if (a != b) { gc[a] += gc[b]; ghn[a] += ghn[b]; ghnd[a] += ghnd[b]; gnxt[b] = a; } ghnd[a]++; if (jv[i].first <= gc[a]) { ghn[a] = ghnd[a]; } } fornum(i, 0, N) { ll a = ggt(i + 1); if (mk[a] == 0) { mk[a] = 1; ans += ghnd[a] - ghn[a]; } } printf("%lld", ans); return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
944,209
944,210
u259396003
cpp
p03144
// #pragma GCC target("avx") // CPU 処理並列化 // #pragma GCC optimize("O3") // CPU 処理並列化 // #pragma GCC optimize("unroll-loops") // 条件処理の呼び出しを減らす // #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = // malloc(size);void * stack_extend_origin_memory_;char * // stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long // long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm // volatile("mov %%rsp, %%rbx\nmov %%rax, // %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024)); // #define END_STACK_EXTEND asm volatile("mov %%rax, // %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_); #include <algorithm> #include <bitset> #include <cassert> #include <complex> #include <deque> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; const long long mod = 1000000007; const long long inf = mod * mod; const long long d2 = (mod + 1) / 2; const double EPS = 1e-11; const double INF = 1e+10; const double PI = acos(-1.0); const int C_SIZE = 3100000; const int UF_SIZE = 3100000; namespace { long long fact[C_SIZE]; long long finv[C_SIZE]; long long inv[C_SIZE]; inline long long Comb(int a, int b) { if (a < b || b < 0) return 0; return fact[a] * finv[b] % mod * finv[a - b] % mod; } void init_C(int n) { fact[0] = finv[0] = inv[1] = 1; for (int i = 2; i < n; i++) { inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; } for (int i = 1; i < n; i++) { fact[i] = fact[i - 1] * i % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long pw(long long a, long long b) { if (a < 0LL) return 0; if (b < 0LL) return 0; long long ret = 1; while (b) { if (b % 2) ret = ret * a % mod; a = a * a % mod; b /= 2; } return ret; } long long pw_mod(long long a, long long b, long long M) { if (a < 0LL) return 0; if (b < 0LL) return 0; long long ret = 1; while (b) { if (b % 2) ret = ret * a % M; a = a * a % M; b /= 2; } return ret; } int pw_mod_int(int a, int b, int M) { if (a < 0) return 0; if (b < 0) return 0; int ret = 1; while (b) { if (b % 2) ret = (long long)ret * a % M; a = (long long)a * a % M; b /= 2; } return ret; } int ABS(int a) { return max(a, -a); } long long ABS(long long a) { return max(a, -a); } double ABS(double a) { return max(a, -a); } int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; } int UF[UF_SIZE]; void init_UF(int n) { for (int i = 0; i < n; i++) UF[i] = -1; } int FIND(int a) { if (UF[a] < 0) return a; return UF[a] = FIND(UF[a]); } void UNION(int a, int b) { a = FIND(a); b = FIND(b); if (a == b) return; if (UF[a] > UF[b]) swap(a, b); UF[a] += UF[b]; UF[b] = a; } } // namespace // ここから編集しろ int p[210000]; long long q[210000]; pair<long long, int> t[210000]; vector<long long> v[210000]; long long ans[210000]; int cnt[210000]; int main() { int a, b; scanf("%d%d", &a, &b); for (int i = 0; i < a; i++) { scanf("%d%lld", p + i, q + i); p[i]--; v[p[i]].push_back(q[i]); } int sz = 0; for (int i = 0; i < b; i++) { std::sort(v[i].begin(), v[i].end()); reverse(v[i].begin(), v[i].end()); for (int j = 2; j < v[i].size(); j++) { t[sz++] = make_pair(v[i][j] * 2, i); } t[sz++] = make_pair(v[i][0] + v[i][1], i); t[sz++] = make_pair(v[i][0] + v[i][1], i); } std::sort(t, t + sz); reverse(t, t + sz); set<pair<long long, pair<int, int>>> A; set<pair<long long, pair<int, int>>> B; set<pair<long long, int>> C; set<pair<long long, int>> D; set<pair<long long, int>> E; for (int i = 0; i < b; i++) { D.insert(make_pair(v[i][0] + v[i][1], i)); if (v[i].size() > 2) { E.insert(make_pair(v[i][0] + v[i][1] + v[i][2], i)); } } long long tmp = 0; for (int i = 0; i < a; i++) { cnt[t[i].second]++; if (cnt[t[i].second] == 1) { long long val = -2; if (!B.empty()) { long long v1 = tmp + 2 * (B.rbegin()->first); val = max(val, v1); } if (!A.empty() && !D.empty()) { long long v1 = tmp - 2 * (A.begin()->first) + 2 * (D.rbegin()->first); val = max(val, v1); } if (!C.empty() && !E.empty()) { long long v1 = tmp - (C.begin()->first) + 2 * (E.rbegin()->first); val = max(val, v1); } ans[i] = val; } else { if (cnt[t[i].second] == 2) { tmp += t[i].first * 2; for (int j = 2; j < v[t[i].second].size(); j++) { B.insert(make_pair(v[t[i].second][j], make_pair(t[i].second, j))); } C.insert(make_pair(t[i].first * 2, t[i].second)); D.erase(make_pair(t[i].first, t[i].second)); if (v[t[i].second].size() > 2) { int I = t[i].second; E.erase(make_pair(v[I][0] + v[I][1] + v[I][2], I)); } } else { tmp += t[i].first; A.insert(make_pair(t[i].first, make_pair(t[i].second, cnt[t[i].second] - 1))); B.erase(make_pair(t[i].first, make_pair(t[i].second, cnt[t[i].second] - 1))); } ans[i] = tmp; } } for (int i = 0; i < a; i++) { printf("%lld\n", ans[i] / 2); } }
// #pragma GCC target("avx") // CPU 処理並列化 // #pragma GCC optimize("O3") // CPU 処理並列化 // #pragma GCC optimize("unroll-loops") // 条件処理の呼び出しを減らす // #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = // malloc(size);void * stack_extend_origin_memory_;char * // stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long // long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm // volatile("mov %%rsp, %%rbx\nmov %%rax, // %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024)); // #define END_STACK_EXTEND asm volatile("mov %%rax, // %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_); #include <algorithm> #include <bitset> #include <cassert> #include <complex> #include <deque> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; const long long mod = 1000000007; const long long inf = mod * mod; const long long d2 = (mod + 1) / 2; const double EPS = 1e-11; const double INF = 1e+10; const double PI = acos(-1.0); const int C_SIZE = 3100000; const int UF_SIZE = 3100000; namespace { long long fact[C_SIZE]; long long finv[C_SIZE]; long long inv[C_SIZE]; inline long long Comb(int a, int b) { if (a < b || b < 0) return 0; return fact[a] * finv[b] % mod * finv[a - b] % mod; } void init_C(int n) { fact[0] = finv[0] = inv[1] = 1; for (int i = 2; i < n; i++) { inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; } for (int i = 1; i < n; i++) { fact[i] = fact[i - 1] * i % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long pw(long long a, long long b) { if (a < 0LL) return 0; if (b < 0LL) return 0; long long ret = 1; while (b) { if (b % 2) ret = ret * a % mod; a = a * a % mod; b /= 2; } return ret; } long long pw_mod(long long a, long long b, long long M) { if (a < 0LL) return 0; if (b < 0LL) return 0; long long ret = 1; while (b) { if (b % 2) ret = ret * a % M; a = a * a % M; b /= 2; } return ret; } int pw_mod_int(int a, int b, int M) { if (a < 0) return 0; if (b < 0) return 0; int ret = 1; while (b) { if (b % 2) ret = (long long)ret * a % M; a = (long long)a * a % M; b /= 2; } return ret; } int ABS(int a) { return max(a, -a); } long long ABS(long long a) { return max(a, -a); } double ABS(double a) { return max(a, -a); } int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; } int UF[UF_SIZE]; void init_UF(int n) { for (int i = 0; i < n; i++) UF[i] = -1; } int FIND(int a) { if (UF[a] < 0) return a; return UF[a] = FIND(UF[a]); } void UNION(int a, int b) { a = FIND(a); b = FIND(b); if (a == b) return; if (UF[a] > UF[b]) swap(a, b); UF[a] += UF[b]; UF[b] = a; } } // namespace // ここから編集しろ int p[210000]; long long q[210000]; pair<long long, int> t[210000]; vector<long long> v[210000]; long long ans[210000]; int cnt[210000]; int main() { int a, b; scanf("%d%d", &a, &b); for (int i = 0; i < a; i++) { scanf("%d%lld", p + i, q + i); p[i]--; v[p[i]].push_back(q[i]); } int sz = 0; for (int i = 0; i < b; i++) { std::sort(v[i].begin(), v[i].end()); reverse(v[i].begin(), v[i].end()); for (int j = 2; j < v[i].size(); j++) { t[sz++] = make_pair(v[i][j] * 2, i); } t[sz++] = make_pair(v[i][0] + v[i][1], i); t[sz++] = make_pair(v[i][0] + v[i][1], i); } std::sort(t, t + sz); reverse(t, t + sz); set<pair<long long, pair<int, int>>> A; set<pair<long long, pair<int, int>>> B; set<pair<long long, int>> C; set<pair<long long, int>> D; set<pair<long long, int>> E; for (int i = 0; i < b; i++) { D.insert(make_pair(v[i][0] + v[i][1], i)); if (v[i].size() > 2) { E.insert(make_pair(v[i][0] + v[i][1] + v[i][2], i)); } } long long tmp = 0; for (int i = 0; i < a; i++) { cnt[t[i].second]++; if (cnt[t[i].second] == 1) { long long val = -2; if (!B.empty()) { long long v1 = tmp + 2 * (B.rbegin()->first); val = max(val, v1); } if (!A.empty() && !D.empty()) { long long v1 = tmp - 2 * (A.begin()->first) + 2 * (D.rbegin()->first); val = max(val, v1); } if (!C.empty() && !E.empty()) { long long v1 = tmp - (C.begin()->first) + 2 * (E.rbegin()->first); val = max(val, v1); } ans[i] = val; } else { if (cnt[t[i].second] == 2) { tmp += t[i].first * 2; for (int j = 2; j < v[t[i].second].size(); j++) { B.insert(make_pair(v[t[i].second][j], make_pair(t[i].second, j))); } C.insert(make_pair(t[i].first * 2, t[i].second)); D.erase(make_pair(t[i].first, t[i].second)); if (v[t[i].second].size() > 2) { int I = t[i].second; E.erase(make_pair(v[I][0] + v[I][1] + v[I][2], I)); } } else { tmp += t[i].first; A.insert(make_pair(t[i].first / 2, make_pair(t[i].second, cnt[t[i].second] - 1))); B.erase(make_pair(t[i].first / 2, make_pair(t[i].second, cnt[t[i].second] - 1))); } ans[i] = tmp; } } for (int i = 0; i < a; i++) { printf("%lld\n", ans[i] / 2); } }
[ "expression.operation.binary.add" ]
944,230
944,231
u648138491
cpp
p03144
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define poly vector<ll> #define sqr(x) ((x) * (x)) #define mp make_pair inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } #define gc getchar inline ll read() { ll x = 0; char ch = gc(); bool positive = 1; for (; !isdigit(ch); ch = gc()) if (ch == '-') positive = 0; for (; isdigit(ch); ch = gc()) x = x * 10 + ch - '0'; return positive ? x : -x; } inline void write(ll a) { if (a < 0) { a = -a; putchar('-'); } if (a >= 10) write(a / 10); putchar('0' + a % 10); } inline void wri(ll a) { write(a); putchar(' '); } inline void writeln(ll a) { write(a); puts(""); } const int N = 200005; const ll inf = 1e18; vector<int> v[N]; poly me(poly a, poly b) { int n = a.size(), m = b.size(), i = 0, j = 0; poly c(n + m - 1); while (i < n && j < m) { c[i + j] = a[i] + b[j]; if ((i + 1 < n && (j + 1 == m || a[i + 1] + b[j] > a[i] + b[j + 1]))) i++; else j++; } return c; } poly operator+(poly a, poly b) { poly A[2], B[2]; for (int i = 0; i < 2; i++) { for (unsigned j = i; j < a.size(); j += 2) A[i].push_back(a[j]); for (unsigned j = i; j < b.size(); j += 2) B[i].push_back(b[j]); } poly ans(a.size() + b.size() - 1); for (auto &i : ans) i = -inf; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { poly c = me(A[i], B[j]); for (unsigned k = 0; k < c.size(); k++) { ans[k * 2 + i + j] = max(ans[k * 2 + i + j], c[k]); } } } return ans; } poly solve(int l, int r) { if (l == r) { sort(v[l].begin(), v[l].end()); int m = v[l].size(); poly ans(m + 1); for (int i = 1; i <= m; i++) ans[i] = ans[i - 1] + v[l][m - i]; ans[1] = -inf; // cout<<l<<" fjzzq "<<ans.size()<<endl; return ans; } int mid = (l + r) >> 1; return solve(l, mid) + solve(mid + 1, r); } signed main() { int n = read(), k = read(); for (int i = 1; i <= n; i++) { int c = read(), w = read(); v[c].push_back(w); } poly ans(n + 1); for (auto &i : ans) i = -inf; for (int i = 1; i <= 3; i++) { for (int i = 1; i <= k; i++) swap(v[i], v[(rand() << 15 ^ rand()) % i + 1]); poly zs = solve(1, k); for (int i = 1; i <= n; i++) ans[i] = max(ans[i], zs[i]); } for (int i = 1; i <= n; i++) { if (ans[i] < 0) puts("-1"); else writeln(ans[i]); } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define poly vector<ll> #define sqr(x) ((x) * (x)) #define mp make_pair inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } #define gc getchar inline ll read() { ll x = 0; char ch = gc(); bool positive = 1; for (; !isdigit(ch); ch = gc()) if (ch == '-') positive = 0; for (; isdigit(ch); ch = gc()) x = x * 10 + ch - '0'; return positive ? x : -x; } inline void write(ll a) { if (a < 0) { a = -a; putchar('-'); } if (a >= 10) write(a / 10); putchar('0' + a % 10); } inline void wri(ll a) { write(a); putchar(' '); } inline void writeln(ll a) { write(a); puts(""); } const int N = 200005; const ll inf = 1e18; vector<int> v[N]; poly me(poly a, poly b) { int n = a.size(), m = b.size(), i = 0, j = 0; poly c(n + m - 1); while (i < n && j < m) { c[i + j] = a[i] + b[j]; if ((i + 1 < n && (j + 1 == m || a[i + 1] + b[j] > a[i] + b[j + 1]))) i++; else j++; } return c; } poly operator+(poly a, poly b) { poly A[2], B[2]; for (int i = 0; i < 2; i++) { for (unsigned j = i; j < a.size(); j += 2) A[i].push_back(a[j]); for (unsigned j = i; j < b.size(); j += 2) B[i].push_back(b[j]); } poly ans(a.size() + b.size() - 1); for (auto &i : ans) i = -inf; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { poly c = me(A[i], B[j]); for (unsigned k = 0; k < c.size(); k++) { ans[k * 2 + i + j] = max(ans[k * 2 + i + j], c[k]); } } } return ans; } poly solve(int l, int r) { if (l == r) { sort(v[l].begin(), v[l].end()); int m = v[l].size(); poly ans(m + 1); for (int i = 1; i <= m; i++) ans[i] = ans[i - 1] + v[l][m - i]; ans[1] = -inf; // cout<<l<<" fjzzq "<<ans.size()<<endl; return ans; } int mid = (l + r) >> 1; return solve(l, mid) + solve(mid + 1, r); } signed main() { int n = read(), k = read(); for (int i = 1; i <= n; i++) { int c = read(), w = read(); v[c].push_back(w); } poly ans(n + 1); for (auto &i : ans) i = -inf; for (int i = 1; i <= 2; i++) { for (int i = 1; i <= k; i++) swap(v[i], v[((ll)rand() << 15 ^ rand()) % i + 1]); poly zs = solve(1, k); for (int i = 1; i <= n; i++) ans[i] = max(ans[i], zs[i]); } for (int i = 1; i <= n; i++) { if (ans[i] < 0) puts("-1"); else writeln(ans[i]); } }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
944,241
944,242
u910444501
cpp
p03144
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define poly vector<ll> #define sqr(x) ((x) * (x)) #define mp make_pair inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } #define gc getchar inline ll read() { ll x = 0; char ch = gc(); bool positive = 1; for (; !isdigit(ch); ch = gc()) if (ch == '-') positive = 0; for (; isdigit(ch); ch = gc()) x = x * 10 + ch - '0'; return positive ? x : -x; } inline void write(ll a) { if (a < 0) { a = -a; putchar('-'); } if (a >= 10) write(a / 10); putchar('0' + a % 10); } inline void wri(ll a) { write(a); putchar(' '); } inline void writeln(ll a) { write(a); puts(""); } const int N = 200005; const ll inf = 1e18; vector<int> v[N]; poly me(poly a, poly b) { int n = a.size(), m = b.size(), i = 0, j = 0; poly c(n + m - 1); while (i < n && j < m) { c[i + j] = a[i] + b[j]; if ((i + 1 < n && (j + 1 == m || a[i + 1] + b[j] > a[i] + b[j + 1]))) i++; else j++; } return c; } poly operator+(poly a, poly b) { poly A[2], B[2]; for (int i = 0; i < 2; i++) { for (unsigned j = i; j < a.size(); j += 2) A[i].push_back(a[j]); for (unsigned j = i; j < b.size(); j += 2) B[i].push_back(b[j]); } poly ans(a.size() + b.size() - 1); for (auto &i : ans) i = -inf; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { poly c = me(A[i], B[j]); for (unsigned k = 0; k < c.size(); k++) { ans[k * 2 + i + j] = max(ans[k * 2 + i + j], c[k]); } } } return ans; } poly solve(int l, int r) { if (l == r) { sort(v[l].begin(), v[l].end()); int m = v[l].size(); poly ans(m + 1); for (int i = 1; i <= m; i++) ans[i] = ans[i - 1] + v[l][m - i]; ans[1] = -inf; // cout<<l<<" fjzzq "<<ans.size()<<endl; return ans; } int mid = (l + r) >> 1; return solve(l, mid) + solve(mid + 1, r); } signed main() { int n = read(), k = read(); for (int i = 1; i <= n; i++) { int c = read(), w = read(); v[c].push_back(w); } poly ans(n + 1); for (auto &i : ans) i = -inf; for (int i = 1; i <= 3; i++) { for (int i = 1; i <= k; i++) swap(v[i], v[(rand() << 15 ^ rand()) % i + 1]); poly zs = solve(1, k); for (int i = 1; i <= n; i++) ans[i] = max(ans[i], zs[i]); } for (int i = 1; i <= n; i++) { if (ans[i] < 0) puts("-1"); else writeln(ans[i]); } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define poly vector<ll> #define sqr(x) ((x) * (x)) #define mp make_pair inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } #define gc getchar inline ll read() { ll x = 0; char ch = gc(); bool positive = 1; for (; !isdigit(ch); ch = gc()) if (ch == '-') positive = 0; for (; isdigit(ch); ch = gc()) x = x * 10 + ch - '0'; return positive ? x : -x; } inline void write(ll a) { if (a < 0) { a = -a; putchar('-'); } if (a >= 10) write(a / 10); putchar('0' + a % 10); } inline void wri(ll a) { write(a); putchar(' '); } inline void writeln(ll a) { write(a); puts(""); } const int N = 200005; const ll inf = 1e18; vector<int> v[N]; poly me(poly a, poly b) { int n = a.size(), m = b.size(), i = 0, j = 0; poly c(n + m - 1); while (i < n && j < m) { c[i + j] = a[i] + b[j]; if ((i + 1 < n && (j + 1 == m || a[i + 1] + b[j] > a[i] + b[j + 1]))) i++; else j++; } return c; } poly operator+(poly a, poly b) { poly A[2], B[2]; for (int i = 0; i < 2; i++) { for (unsigned j = i; j < a.size(); j += 2) A[i].push_back(a[j]); for (unsigned j = i; j < b.size(); j += 2) B[i].push_back(b[j]); } poly ans(a.size() + b.size() - 1); for (auto &i : ans) i = -inf; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { poly c = me(A[i], B[j]); for (unsigned k = 0; k < c.size(); k++) { ans[k * 2 + i + j] = max(ans[k * 2 + i + j], c[k]); } } } return ans; } poly solve(int l, int r) { if (l == r) { sort(v[l].begin(), v[l].end()); int m = v[l].size(); poly ans(m + 1); for (int i = 1; i <= m; i++) ans[i] = ans[i - 1] + v[l][m - i]; ans[1] = -inf; // cout<<l<<" fjzzq "<<ans.size()<<endl; return ans; } int mid = (l + r) >> 1; return solve(l, mid) + solve(mid + 1, r); } signed main() { int n = read(), k = read(); for (int i = 1; i <= n; i++) { int c = read(), w = read(); v[c].push_back(w); } poly ans(n + 1); for (auto &i : ans) i = -inf; for (int i = 1; i <= 3; i++) { for (int i = 1; i <= k; i++) swap(v[i], v[((ll)rand() << 15 ^ rand()) % i + 1]); poly zs = solve(1, k); for (int i = 1; i <= n; i++) ans[i] = max(ans[i], zs[i]); } for (int i = 1; i <= n; i++) { if (ans[i] < 0) puts("-1"); else writeln(ans[i]); } }
[ "type_conversion.add" ]
944,241
944,243
u910444501
cpp
p03144
#ifndef BZ #pragma GCC optimize "-O3" #endif #include <bits/stdc++.h> #define FASTIO #define ALL(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i = (l); i < (r); ++i) #ifdef FASTIO #define scanf abacaba #define printf abacaba #endif typedef long long ll; typedef long double ld; typedef unsigned long long ull; using namespace std; /* ll pw(ll a, ll b) { ll ans = 1; while (b) { while (!(b & 1)) b >>= 1, a = (a * a) % MOD; ans = (ans * a) % MOD, --b; } return ans; } */ const int MAXN = 220000; int n, k; vector<int> go[MAXN]; vector<pair<ll, int>> vv; ll ans[MAXN]; ll dp[MAXN]; int main() { #ifdef FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); #endif cin >> n >> k; for (int i = 0; i < n; ++i) { int c; ll v; cin >> c >> v; v *= 2; go[c].push_back(v); } for (int i = 0; i < MAXN; ++i) { if (go[i].empty()) continue; sort(ALL(go[i])); ll sum = go[i].back(); go[i].pop_back(); sum += go[i].back(); go[i].pop_back(); sum /= 2; vv.emplace_back(sum, i); } sort(ALL(vv)); reverse(ALL(vv)); multiset<int> ss; for (int i = 0; i <= n; ++i) ans[i] = -2; int cur = 0; ll now = 0; dp[vv.size() - 1] = -1; for (int i = (int)vv.size() - 2; i >= 0; --i) { int k = vv[i + 1].second; dp[i] = dp[i + 1]; if (!go[k].empty()) dp[i] = max(dp[i], go[k].back() + vv[i + 1].first * 2); } multiset<ll> tak; if (dp[0] != -1) ans[3] = max(ans[cur], dp[0]); for (int i = 0; i < vv.size(); ++i) { cur += 2; now += 2 * vv[i].first; for (ll j : go[vv[i].second]) ss.insert(j); if (!tak.empty()) { ll x = *tak.begin(); ans[cur - 1] = max(ans[cur - 1], now - x); if (dp[i] != -1) ans[cur - 1 + 2] = max(ans[cur - 1 + 2], now - x + dp[i]); } while (true) { ans[cur] = max(ans[cur], now); if (dp[i] != -1) ans[cur + 3] = max(ans[cur + 3], now + dp[i]); if (!ss.empty()) { ll x = *ss.rbegin(); ans[cur + 1] = max(ans[cur + 1], now + x); if (dp[i] != -1) ans[cur + 4] = max(ans[cur + 4], now + x + dp[i]); } if (!ss.empty() && (i + 1 == vv.size() || *ss.rbegin() > vv[i + 1].first)) { ll x = *ss.rbegin(); ss.erase(ss.find(x)); tak.insert(x); now += x; cur += 1; } else { break; } } } for (int i = 1; i <= n; ++i) cout << ans[i] / 2 << "\n"; return 0; }
#ifndef BZ #pragma GCC optimize "-O3" #endif #include <bits/stdc++.h> #define FASTIO #define ALL(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i = (l); i < (r); ++i) #ifdef FASTIO #define scanf abacaba #define printf abacaba #endif typedef long long ll; typedef long double ld; typedef unsigned long long ull; using namespace std; /* ll pw(ll a, ll b) { ll ans = 1; while (b) { while (!(b & 1)) b >>= 1, a = (a * a) % MOD; ans = (ans * a) % MOD, --b; } return ans; } */ const int MAXN = 220000; int n, k; vector<int> go[MAXN]; vector<pair<ll, int>> vv; ll ans[MAXN]; ll dp[MAXN]; int main() { #ifdef FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); #endif cin >> n >> k; for (int i = 0; i < n; ++i) { int c; ll v; cin >> c >> v; v *= 2; go[c].push_back(v); } for (int i = 0; i < MAXN; ++i) { if (go[i].empty()) continue; sort(ALL(go[i])); ll sum = go[i].back(); go[i].pop_back(); sum += go[i].back(); go[i].pop_back(); sum /= 2; vv.emplace_back(sum, i); } sort(ALL(vv)); reverse(ALL(vv)); multiset<int> ss; for (int i = 0; i <= n; ++i) ans[i] = -2; int cur = 0; ll now = 0; dp[vv.size() - 1] = -1; for (int i = (int)vv.size() - 2; i >= 0; --i) { int k = vv[i + 1].second; dp[i] = dp[i + 1]; if (!go[k].empty()) dp[i] = max(dp[i], go[k].back() + vv[i + 1].first * 2); } multiset<ll> tak; if (dp[0] != -1) ans[3] = max(ans[cur], dp[0]); for (int i = 0; i < vv.size(); ++i) { cur += 2; now += 2 * vv[i].first; for (ll j : go[vv[i].second]) ss.insert(j); if (!tak.empty()) { ll x = *tak.begin(); ans[cur - 1] = max(ans[cur - 1], now - x); if (dp[i] != -1) ans[cur - 1 + 3] = max(ans[cur - 1 + 3], now - x + dp[i]); } while (true) { ans[cur] = max(ans[cur], now); if (dp[i] != -1) ans[cur + 3] = max(ans[cur + 3], now + dp[i]); if (!ss.empty()) { ll x = *ss.rbegin(); ans[cur + 1] = max(ans[cur + 1], now + x); if (dp[i] != -1) ans[cur + 4] = max(ans[cur + 4], now + x + dp[i]); } if (!ss.empty() && (i + 1 == vv.size() || *ss.rbegin() > vv[i + 1].first)) { ll x = *ss.rbegin(); ss.erase(ss.find(x)); tak.insert(x); now += x; cur += 1; } else { break; } } } for (int i = 1; i <= n; ++i) cout << ans[i] / 2 << "\n"; return 0; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "expression.operation.binary.change", "assignment.value.change", "call.arguments.change" ]
944,246
944,247
u953484888
cpp
p03144
// includes {{{ #include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <tuple> #include <vector> // #include<deque> // #include<multiset> // #include<bitset> // #include<cstring> // #include<bits/stdc++.h> // }}} using namespace std; using ll = long long; int n, k; const int N = 2e5 + 10; int c[N], a[N]; vector<int> v[N]; // smin, smax {{{ // clang-format off template < class T, class U > inline void smin(T &a, const U &b) { a = a < (T) b ? a : b; } template < class T, class U > inline void smax(T &a, const U &b) { a = a < (T) b ? b : a; } // clang-format on // }}} int main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> c[i] >> a[i]; v[c[i]].emplace_back(a[i]); } using P = tuple<ll, int, int, int, int>; vector<P> w; using Q = tuple<ll, int>; set<Q> bestAdd1; set<Q> bestAdd3; set<Q> bestDel1; set<Q> bestDel2; for (int i = 1; i <= k; i++) if (v[i].size()) { sort(rbegin(v[i]), rend(v[i])); w.emplace_back(v[i][0] + v[i][1], 2, i, 0, 2); for (int j = 2; j < (int)v[i].size(); j++) { w.emplace_back(v[i][j] * 2, 1, i, -j, j + 1); } // !!!!!!!!! 同じ値同じインデックスのタイがうまくとれていない // !!!!!!!!!!!!!!! 教訓 : タイはタプルとかに予めしておいて必ずとろう if (v[i].size() >= 3) bestAdd3.insert(Q((ll)v[i][0] + v[i][1] + v[i][2], i)); /// overflowwwwww!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } sort(begin(w), end(w)); int now = 0; ll x = 0; // dump(w); for (int i = 1; i <= n; i++) { ll val; ll res = -1; int weight, index, next; assert(w.size()); tie(val, weight, index, ignore, next) = w.back(); val = val * weight / 2; if (now + weight > i) { assert(weight == 2); if (bestAdd1.size()) { smax(res, x + get<0>(*--bestAdd1.end())); } if (bestAdd3.size() && bestDel2.size()) { smax(res, x + get<0>(*--bestAdd3.end()) - get<0>(*bestDel2.begin())); } if (bestDel1.size()) { smax(res, x + val - get<0>(*bestDel1.begin())); } } else { // 同時に起こり得るものはinsertを後に now += weight; x += val; if (next - 1 >= 3) { size_t sz = bestAdd1.size(); bestAdd1.erase(Q(v[index][next - 1], index)); assert(sz != bestAdd1.size()); } if (next - 1 == 1) { bestDel2.insert(Q(v[index][0] + v[index][1], index)); if (v[index].size() >= 3) bestAdd3.erase(Q((ll)v[index][0] + v[index][1] + v[index][2], index)); // here too } if (next - 1 == 2) { bestDel2.erase(Q(v[index][0] + v[index][1], index)); } if (next - 1 >= 3) { bestDel1.erase(Q(v[index][next - 2], index)); } if (next - 1 >= 2) { bestDel1.insert(Q(v[index][next - 1], index)); } if (next < (int)v[index].size()) bestAdd1.insert(Q(v[index][next], index)); w.pop_back(); res = x; } cout << res << "\n"; } assert(bestAdd1.size() == 0); return 0; }
// includes {{{ #include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <tuple> #include <vector> // #include<deque> // #include<multiset> // #include<bitset> // #include<cstring> // #include<bits/stdc++.h> // }}} using namespace std; using ll = long long; int n, k; const int N = 2e5 + 10; int c[N], a[N]; vector<int> v[N]; // smin, smax {{{ // clang-format off template < class T, class U > inline void smin(T &a, const U &b) { a = a < (T) b ? a : b; } template < class T, class U > inline void smax(T &a, const U &b) { a = a < (T) b ? b : a; } // clang-format on // }}} int main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> c[i] >> a[i]; v[c[i]].emplace_back(a[i]); } using P = tuple<ll, int, int, int, int>; vector<P> w; using Q = tuple<ll, int>; set<Q> bestAdd1; set<Q> bestAdd3; set<Q> bestDel1; set<Q> bestDel2; for (int i = 1; i <= k; i++) if (v[i].size()) { sort(rbegin(v[i]), rend(v[i])); w.emplace_back(v[i][0] + v[i][1], 2, i, 0, 2); for (int j = 2; j < (int)v[i].size(); j++) { w.emplace_back(v[i][j] * 2, 1, i, -j, j + 1); } // !!!!!!!!! 同じ値同じインデックスのタイがうまくとれていない // !!!!!!!!!!!!!!! 教訓 : タイはタプルとかに予めしておいて必ずとろう if (v[i].size() >= 3) bestAdd3.insert(Q((ll)v[i][0] + v[i][1] + v[i][2], i)); /// overflowwwwww!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } sort(begin(w), end(w)); int now = 0; ll x = 0; for (int i = 1; i <= n; i++) { ll val; ll res = -1; int weight, index, next; assert(w.size()); tie(val, weight, index, ignore, next) = w.back(); val = val * weight / 2; if (now + weight > i) { assert(weight == 2); if (bestAdd1.size()) { smax(res, x + get<0>(*--bestAdd1.end())); } if (bestAdd3.size() && bestDel2.size()) { smax(res, x + get<0>(*--bestAdd3.end()) - get<0>(*bestDel2.begin())); } if (bestDel1.size()) { smax(res, x + val - get<0>(*bestDel1.begin())); } } else { // 同時に起こり得るものはinsertを後に now += weight; x += val; if (next - 1 >= 2) { size_t sz = bestAdd1.size(); bestAdd1.erase(Q(v[index][next - 1], index)); assert(sz != bestAdd1.size()); } if (next - 1 == 1) { bestDel2.insert(Q(v[index][0] + v[index][1], index)); if (v[index].size() >= 3) bestAdd3.erase(Q((ll)v[index][0] + v[index][1] + v[index][2], index)); // here too } if (next - 1 == 2) { bestDel2.erase(Q(v[index][0] + v[index][1], index)); } if (next - 1 >= 3) { bestDel1.erase(Q(v[index][next - 2], index)); } if (next - 1 >= 2) { bestDel1.insert(Q(v[index][next - 1], index)); } if (next < (int)v[index].size()) bestAdd1.insert(Q(v[index][next], index)); w.pop_back(); res = x; } cout << res << "\n"; } assert(bestAdd1.size() == 0); return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
944,248
944,249
u884379688
cpp
p03145
#include <stdio.h> int main() { int A; int B; int C; scanf("%d %d %d", &A, &B, &C); printf("%d", B * C / 2); return 0; }
#include <stdio.h> int main() { int A; int B; int C; scanf("%d %d %d", &A, &B, &C); printf("%d", A * B / 2); return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
944,279
944,280
u089230684
cpp
p03145
#include <stdio.h> int main() { int a; int b; int c; scanf("%d %d %d", &a, &b, &c); int l = a * b; printf("%d", l); return 0; }
#include <stdio.h> int main() { int a; int b; int c; scanf("%d %d %d", &a, &b, &c); int l = (a * b) / 2; printf("%d", l); return 0; }
[ "assignment.change" ]
944,281
944,282
u816631826
cpp
p03145
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(), (x).end() using ll = long long; using vl = vector<ll>; using vvl = vector<vector<ll>>; const ll MOD = 1000000007; const ll MOD9 = 998244353; const int inf = 1e9 + 10; const ll INF = 4e18; const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1}; using Graph = vector<vector<int>>; double nCk(ll n, ll k) { double res = 1.0; for (ll i = 0; i < n; i++) { res *= 0.5; } for (ll i = 0; i < k; i++) { res *= (double)(n - i); res /= (double)(k - i); } return res; } struct edge { ll to, cost; }; typedef pair<ll, ll> P; struct graph { ll V; vector<vector<edge>> G; vector<ll> d; graph(ll n) { init(n); } void init(ll n) { V = n; G.resize(V); d.resize(V); rep(i, V) { d[i] = INF; } } void add_edge(ll s, ll t, ll cost) { edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void dijkstra(ll s) { rep(i, V) { d[i] = INF; } d[s] = 0; priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); ll v = p.second; if (d[v] < p.first) continue; for (auto e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } }; class UnionFind { public: ll par[100005]; ll depth[100005]; ll nGroup[100005]; UnionFind(ll n) { init(n); } void init(ll n) { for (ll i = 0; i < n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } ll root(ll x) { if (par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(ll x, ll y) { return root(x) == root(y); } void unite(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if (depth[x] == depth[y]) depth[x]++; } } }; const ll MAX = 500010; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } vector<ll> depth; vector<ll> f; vector<ll> g; void dfs(const Graph &G, ll v, ll p, ll d) { depth[v] = d; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d + 1); } // 帰りがけ時に、部分木サイズを求める f[v] = 1; g[v] = 1; // 自分自身 for (auto c : G[v]) { if (c == p) continue; f[v] *= g[c]; f[v] %= MOD; g[v] *= f[c]; g[v] %= MOD; } f[v] += g[v]; f[v] %= MOD; } template <ll MOD> struct Fp { ll val; constexpr Fp(ll v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr ll getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { ll a = r.val, b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<MOD>; mint calc(ll N, ll K) { mint res = 1; for (ll n = 0; n < K; ++n) { res *= (N - n); res /= (n + 1); } return res; } mint COM(ll n, ll k) { if (k == 0) return 1; if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n, m, k; cin >> n >> m >> k; cout << n * k / 2 << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(), (x).end() using ll = long long; using vl = vector<ll>; using vvl = vector<vector<ll>>; const ll MOD = 1000000007; const ll MOD9 = 998244353; const int inf = 1e9 + 10; const ll INF = 4e18; const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1}; using Graph = vector<vector<int>>; double nCk(ll n, ll k) { double res = 1.0; for (ll i = 0; i < n; i++) { res *= 0.5; } for (ll i = 0; i < k; i++) { res *= (double)(n - i); res /= (double)(k - i); } return res; } struct edge { ll to, cost; }; typedef pair<ll, ll> P; struct graph { ll V; vector<vector<edge>> G; vector<ll> d; graph(ll n) { init(n); } void init(ll n) { V = n; G.resize(V); d.resize(V); rep(i, V) { d[i] = INF; } } void add_edge(ll s, ll t, ll cost) { edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void dijkstra(ll s) { rep(i, V) { d[i] = INF; } d[s] = 0; priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); ll v = p.second; if (d[v] < p.first) continue; for (auto e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } }; class UnionFind { public: ll par[100005]; ll depth[100005]; ll nGroup[100005]; UnionFind(ll n) { init(n); } void init(ll n) { for (ll i = 0; i < n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } ll root(ll x) { if (par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(ll x, ll y) { return root(x) == root(y); } void unite(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if (depth[x] == depth[y]) depth[x]++; } } }; const ll MAX = 500010; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } vector<ll> depth; vector<ll> f; vector<ll> g; void dfs(const Graph &G, ll v, ll p, ll d) { depth[v] = d; for (auto nv : G[v]) { if (nv == p) continue; // nv が親 p だったらダメ dfs(G, nv, v, d + 1); } // 帰りがけ時に、部分木サイズを求める f[v] = 1; g[v] = 1; // 自分自身 for (auto c : G[v]) { if (c == p) continue; f[v] *= g[c]; f[v] %= MOD; g[v] *= f[c]; g[v] %= MOD; } f[v] += g[v]; f[v] %= MOD; } template <ll MOD> struct Fp { ll val; constexpr Fp(ll v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr ll getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { ll a = r.val, b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<MOD>; mint calc(ll N, ll K) { mint res = 1; for (ll n = 0; n < K; ++n) { res *= (N - n); res /= (n + 1); } return res; } mint COM(ll n, ll k) { if (k == 0) return 1; if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n, m, k; cin >> n >> m >> k; cout << n * m / 2 << endl; }
[ "identifier.change", "io.output.change" ]
944,294
944,295
u722640678
cpp
p03146
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; int main() { int s; cin >> s; if (s == 1 or s == 2 or s == 4) { cout << 3 << endl; return 0; } for (int i = 0;; i++) { if (s % 2 == 0) s /= 2; else s = 3 * s + 1; if (s == 4) { cout << i + 5 << endl; break; } } return 0; }
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; int main() { int s; cin >> s; if (s == 1 or s == 2 or s == 4) { cout << 4 << endl; return 0; } for (int i = 0;; i++) { if (s % 2 == 0) s /= 2; else s = 3 * s + 1; if (s == 4) { cout << i + 5 << endl; break; } } return 0; }
[ "literal.number.change", "io.output.change" ]
944,314
944,315
u201553784
cpp
p03146
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; int main() { int s; cin >> s; if (s == 1 or s == 2 or s == 4) { cout << 4 << endl; return 0; } for (int i = 0;; i++) { if (s % 2 == 0) s /= 2; else s = 3 * s + 1; if (s == 4) { cout << i + 3 << endl; break; } } return 0; }
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; int main() { int s; cin >> s; if (s == 1 or s == 2 or s == 4) { cout << 4 << endl; return 0; } for (int i = 0;; i++) { if (s % 2 == 0) s /= 2; else s = 3 * s + 1; if (s == 4) { cout << i + 5 << endl; break; } } return 0; }
[ "literal.number.change", "io.output.change" ]
944,316
944,315
u201553784
cpp
p03146
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; int main() { int s; cin >> s; if (s == 1 or s == 2 or s == 4) { cout << 4 << endl; return 0; } for (int i = 0;; i++) { if (s % 2 == 0) s /= 2; else s = 3 * s + 1; if (s == 4) { cout << i + 4 << endl; break; } } return 0; }
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> llP; int main() { int s; cin >> s; if (s == 1 or s == 2 or s == 4) { cout << 4 << endl; return 0; } for (int i = 0;; i++) { if (s % 2 == 0) s /= 2; else s = 3 * s + 1; if (s == 4) { cout << i + 5 << endl; break; } } return 0; }
[ "literal.number.change", "io.output.change" ]
944,317
944,315
u201553784
cpp
p03146
#include <iostream> using namespace std; int main() { int s; cin >> s; int a[1000] = {}; a[0] = s; for (int i = 1; i < 1000; i++) { if (a[i] % 2 == 0) { a[i] = a[i - 1] / 2; } else { a[i] = a[i - 1] * 3 + 1; } for (int j = 0; j <= i; j++) { if (a[i] == a[j] && i != j) { cout << i + 1 << endl; return 0; } } } return 0; }
#include <iostream> using namespace std; int main() { int s; cin >> s; int a[1000] = {}; a[0] = s; for (int i = 1; i < 1000; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } else { a[i] = a[i - 1] * 3 + 1; } for (int j = 0; j <= i; j++) { if (a[i] == a[j] && i != j) { cout << i + 1 << endl; return 0; } } } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
944,321
944,322
u056912761
cpp
p03146
#include <iostream> using namespace std; int main() { int s; cin >> s; int a[10000] = {}; a[0] = s; for (int i = 1; i < 1000; i++) { if (a[i] % 2 == 0) { a[i] = a[i - 1] / 2; } else { a[i] = a[i - 1] * 3 + 1; } for (int j = 0; j <= i; j++) { if (a[i] == a[j] && i != j) { cout << i + 1 << endl; return 0; } } } return 0; }
#include <iostream> using namespace std; int main() { int s; cin >> s; int a[1000] = {}; a[0] = s; for (int i = 1; i < 1000; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } else { a[i] = a[i - 1] * 3 + 1; } for (int j = 0; j <= i; j++) { if (a[i] == a[j] && i != j) { cout << i + 1 << endl; return 0; } } } return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
944,323
944,322
u056912761
cpp
p03146
#include <iostream> using namespace std; int main() { int s; cin >> s; long long int a[1000000000] = {}; a[0] = s; for (int i = 1; i < 1000; i++) { if (a[i] % 2 == 0) { a[i] = a[i - 1] / 2; } else { a[i] = a[i - 1] * 3 + 1; } for (int j = 0; j <= i; j++) { if (a[i] == a[j] && i != j) { cout << i + 1 << endl; return 0; } } } return 0; }
#include <iostream> using namespace std; int main() { int s; cin >> s; int a[1000] = {}; a[0] = s; for (int i = 1; i < 1000; i++) { if (a[i - 1] % 2 == 0) { a[i] = a[i - 1] / 2; } else { a[i] = a[i - 1] * 3 + 1; } for (int j = 0; j <= i; j++) { if (a[i] == a[j] && i != j) { cout << i + 1 << endl; return 0; } } } return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
944,324
944,322
u056912761
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s, k = 0; cin >> s; vector<int> t(10000000); t.at(0) = s; for (int i = 1; i < 10000000; i++) { if (t.at(i - 1) % 2 == 0) t.at(i) = t.at(i - 1) / 2; else t.at(i) = 3 * t.at(i - 1) + 1; for (int j = 0; j < i; j++) { if (t.at(j) == t.at(i)) { k = -1; break; } } if (k == -1) { cout << i << endl; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int s, k = 0; cin >> s; vector<int> t(10000000); t.at(0) = s; for (int i = 1; i < 10000000; i++) { if (t.at(i - 1) % 2 == 0) t.at(i) = t.at(i - 1) / 2; else t.at(i) = 3 * t.at(i - 1) + 1; for (int j = 0; j < i; j++) { if (t.at(j) == t.at(i)) { k = -1; break; } } if (k == -1) { cout << i + 1 << endl; break; } } return 0; }
[ "expression.operation.binary.add" ]
944,325
944,326
u646051775
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int count = 0; while (true) { count++; if (s == 1 || s == 2 || s == 4) { cout << count + 4 << endl; break; } else { if (s % 2 == 0) { s = s / 2; } else { s = 3 * s + 1; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int count = 0; while (true) { count++; if (s == 1 || s == 2 || s == 4) { cout << count + 3 << endl; break; } else { if (s % 2 == 0) { s = s / 2; } else { s = 3 * s + 1; } } } }
[ "literal.number.change", "io.output.change" ]
944,327
944,328
u646051775
cpp
p03146
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; i++) #define ll long long using namespace std; signed main() { ll n, i = 1; cin >> n; map<ll, ll> mp; while (true) { mp[n]++; if (mp[n] == 2) { cout << i + 1 << "\n"; return 0; } if (n % 2 == 0) { n /= 2; } else { n = 3 * n + 1; } i++; } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; i++) #define ll long long using namespace std; signed main() { ll n, i = 1; cin >> n; map<ll, ll> mp; while (true) { mp[n]++; if (mp[n] == 2) { cout << i << "\n"; return 0; } if (n % 2 == 0) { n /= 2; } else { n = 3 * n + 1; } i++; } return 0; }
[ "expression.operation.binary.remove" ]
944,329
944,330
u652908807
cpp
p03146
#include <iostream> #include <set> using namespace std; int f(int); int main() { int s; set<int> a_s; a_s.insert(s); int prev_size = a_s.size(); int curr_size; int a = s; int count = 1; while (1) { a = f(a); a_s.insert(a); count++; curr_size = a_s.size(); if (prev_size == curr_size) break; prev_size = curr_size; } cout << count << endl; return 0; } int f(int n) { if (n % 2 == 0) return n / 2; else return 3 * n + 1; }
#include <iostream> #include <set> using namespace std; int f(int); int main() { int s; cin >> s; set<int> a_s; a_s.insert(s); int prev_size = a_s.size(); int curr_size; int a = s; int count = 1; while (1) { a = f(a); a_s.insert(a); count++; curr_size = a_s.size(); if (prev_size == curr_size) break; prev_size = curr_size; } cout << count << endl; return 0; } int f(int n) { if (n % 2 == 0) return n / 2; else return 3 * n + 1; }
[]
944,333
944,334
u236540805
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; if (s == 2) { cout << "5" << endl; return 0; } vector<int> A(1000001); A.at(0) = s; for (int i = 0; i < 1000000; i++) { if (A.at(i) % 2 == 0) { A.at(i + 1) = A.at(i) / 2; } else { A.at(i + 1) = 3 * A.at(i) + 1; } } int b = 0; for (int i = 0; i < 1000001; i++) { for (int j = 0; j < i; j++) { if (A.at(i) == A.at(j)) { cout << i + 1 << endl; return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; if (s == 2) { cout << "4" << endl; return 0; } vector<int> A(1000001); A.at(0) = s; for (int i = 0; i < 1000000; i++) { if (A.at(i) % 2 == 0) { A.at(i + 1) = A.at(i) / 2; } else { A.at(i + 1) = 3 * A.at(i) + 1; } } int b = 0; for (int i = 0; i < 1000001; i++) { for (int j = 0; j < i; j++) { if (A.at(i) == A.at(j)) { cout << i + 1 << endl; return 0; } } } }
[ "literal.string.change", "io.output.change" ]
944,335
944,336
u776280752
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int a = s, b = 2; while (a > 1) { if (a % 2 == 0) { a /= 2; } else { a = 3 * a + 1; } b++; } if (s == 1 && s == 2 && s == 4) { cout << "4" << endl; } else { cout << b << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int a = s, b = 2; while (a > 1) { if (a % 2 == 0) { a /= 2; } else { a = 3 * a + 1; } b++; } if (s == 1 || s == 2 || s == 4) { cout << "4" << endl; } else { cout << b << endl; } }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
944,341
944,342
u158290747
cpp
p03146
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; map<int, int> m; m[s]++; int count = 0; while (m[s] < 2) { if (s % 2 == 0) { s = s / 2; } else { s = 3 * s + 1; } count++; m[s]++; } cout << count; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; map<int, int> m; m[s]++; int count = 1; while (m[s] < 2) { if (s % 2 == 0) { s = s / 2; } else { s = 3 * s + 1; } count++; m[s]++; } cout << count; return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
944,356
944,357
u203979694
cpp
p03146
#include <iostream> #include <map> using namespace std; int f(int n) { if (n % 2 == 0) return n / 2; else 3 * n + 1; } int main() { map<int, bool> used; int s; cin >> s; used[s] = true; int n = 1; while (!used[f(s)]) { s = f(s); used[s] = true; n++; } cout << ++n << endl; }
#include <iostream> #include <map> using namespace std; int f(int n) { if (n % 2 == 0) return n / 2; else return 3 * n + 1; } int main() { map<int, bool> used; int s; cin >> s; used[s] = true; int n = 1; while (!used[f(s)]) { s = f(s); used[s] = true; n++; } cout << ++n << endl; }
[ "control_flow.return.add" ]
944,365
944,366
u858670323
cpp
p03146
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int s; cin >> s; int ans = 0; while (s != 1 && s != 2 && s != 4) { ans++; if (s % 2 == 0) { s = s / 2; } else { s = 3 * s + 1; } } cout << ans + 2 << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int s; cin >> s; int ans = 0; while (s != 1 && s != 2 && s != 4) { ans++; if (s % 2 == 0) { s = s / 2; } else { s = 3 * s + 1; } } cout << ans + 4 << endl; }
[ "literal.number.change", "io.output.change" ]
944,369
944,370
u093973314
cpp
p03146
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define sort(s) sort(s.begin(), s.end()) #define reverse(s) reverse(s.begin(), s.end()) #define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++) const ll mod = 1e9 + 7; //最大公約数 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最小公倍数 ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } //素数判定 bool isPrime(ll x) { ll i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } //桁和 int digsum(ll n) { int res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } //桁数 int dignum(ll n) { int res = 0; while (n > 0) { res++; n /= 10; } return res; } //文字列中の特定の文字カウント ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } //階乗 ll ka(ll i) { ll res = 1; while (i > 0) { res = res * i; i--; } return res; } // ncr ll ncr(ll x, ll y) { ll a = x; ll b = 1; if (y > (x / 2)) { y = x - y; } for (ll i = 1; i < y; i++) { a *= x - i; b *= i + 1; } return a / b; } //フィボナッチ数列 -92 ll f(ll x) { ll dp[x + 1]; dp[1] = 1; dp[2] = 1; for (ll i = 3; i <= x; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[x]; } int main() { int s; cin >> s; map<int, int> mp; mp[s]++; int i = 1; while (mp.size() == i) { if (s % 2 == 0) { s /= 2; } else { s = 3 * s + 1; } i++; mp[s]++; } cout << i + 1 << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define sort(s) sort(s.begin(), s.end()) #define reverse(s) reverse(s.begin(), s.end()) #define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++) const ll mod = 1e9 + 7; //最大公約数 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最小公倍数 ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } //素数判定 bool isPrime(ll x) { ll i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } //桁和 int digsum(ll n) { int res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } //桁数 int dignum(ll n) { int res = 0; while (n > 0) { res++; n /= 10; } return res; } //文字列中の特定の文字カウント ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } //階乗 ll ka(ll i) { ll res = 1; while (i > 0) { res = res * i; i--; } return res; } // ncr ll ncr(ll x, ll y) { ll a = x; ll b = 1; if (y > (x / 2)) { y = x - y; } for (ll i = 1; i < y; i++) { a *= x - i; b *= i + 1; } return a / b; } //フィボナッチ数列 -92 ll f(ll x) { ll dp[x + 1]; dp[1] = 1; dp[2] = 1; for (ll i = 3; i <= x; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[x]; } int main() { int s; cin >> s; map<int, int> mp; mp[s]++; int i = 1; while (mp.size() == i) { if (s % 2 == 0) { s /= 2; } else { s = 3 * s + 1; } i++; mp[s]++; } cout << i << endl; }
[ "expression.operation.binary.remove" ]
944,379
944,380
u584787460
cpp
p03146
#include <bits/stdc++.h> #define pb push_back typedef long long ll; typedef long double la; using namespace std; int main() { int s; cin >> s; vector<int> b; if (s == 1) { cout << '4' << endl; return 0; } b.pb(s); while (1) { if (s % 2 == 0) { b.pb(s / 2); s = s / 2; } else { b.pb(3 * s + 1); s = 3 * s + 1; } if (s == 1) { break; } } cout << b.size() + 1 << endl; }
#include <bits/stdc++.h> #define pb push_back typedef long long ll; typedef long double la; using namespace std; int main() { int s; cin >> s; vector<int> b; if (s == 1 || s == 2) { cout << '4' << endl; return 0; } b.pb(s); while (1) { if (s % 2 == 0) { b.pb(s / 2); s = s / 2; } else { b.pb(3 * s + 1); s = 3 * s + 1; } if (s == 1) { break; } } cout << b.size() + 1 << endl; }
[ "control_flow.branch.if.condition.change" ]
944,387
944,388
u663075270
cpp
p03138
#include <bits/stdc++.h> #define re return #define ll long long #define ull unsigned ll #define ld long double #define f first #define s second #define pi acos(-1) #define oo (ll)1e9 #define OO 1e18 #define EPS 1e-6 #define Endl '\n' #define FX(n) fixed << setprecision(n) #define mm(o, k) memset(o, k, sizeof o) #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; const int maxn = 100005; int main() { IO; ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; ll ans = accumulate(a.begin(), a.end(), 0ll); vector<ll> arkam; vector<int> num, asle; for (int idx = 0; idx <= 41; ++idx) { ll fade = 0; ll mlyan = 0; for (auto i : a) { if (i & (1ll << idx)) ++fade; else ++mlyan; } if (mlyan > fade) num.push_back(1); else num.push_back(0); if (k & (1ll << idx)) asle.push_back(1); else asle.push_back(0); mlyan -= fade; arkam.push_back(mlyan * (1ll << idx)); } bool ok = false; for (int i = 41; i; --i) { if (ok) { if (num[i]) ans += arkam[i]; continue; } if (num[i] == 1 && asle[i] == 1) ans += arkam[i]; if (num[i] == 0 && asle[i] == 1) ok = true; } cout << ans << endl; re 0; }
#include <bits/stdc++.h> #define re return #define ll long long #define ull unsigned ll #define ld long double #define f first #define s second #define pi acos(-1) #define oo (ll)1e9 #define OO 1e18 #define EPS 1e-6 #define Endl '\n' #define FX(n) fixed << setprecision(n) #define mm(o, k) memset(o, k, sizeof o) #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; const int maxn = 100005; int main() { IO; ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; ll ans = accumulate(a.begin(), a.end(), 0ll); vector<ll> arkam; vector<int> num, asle; for (int idx = 0; idx <= 40; ++idx) { ll fade = 0; ll mlyan = 0; for (auto i : a) { if (i & (1ll << idx)) ++fade; else ++mlyan; } if (mlyan > fade) num.push_back(1); else num.push_back(0); if (k & (1ll << idx)) asle.push_back(1); else asle.push_back(0); mlyan -= fade; arkam.push_back(mlyan * (1ll << idx)); } bool ok = false; for (int i = 40; i + 1; --i) { if (ok) { if (num[i]) ans += arkam[i]; continue; } if (num[i] == 1 && asle[i] == 1) ans += arkam[i]; if (num[i] == 0 && asle[i] == 1) ok = true; } cout << ans << endl; re 0; }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "misc.off_by_one" ]
944,401
944,402
u775315680
cpp
p03138
#include <bits/stdc++.h> #define re return #define ll long long #define ull unsigned ll #define ld long double #define f first #define s second #define pi acos(-1) #define oo (ll)1e9 #define OO 1e18 #define EPS 1e-6 #define Endl '\n' #define FX(n) fixed << setprecision(n) #define mm(o, k) memset(o, k, sizeof o) #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; const int maxn = 100005; int main() { IO; ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; ll ans = accumulate(a.begin(), a.end(), 0ll); vector<ll> arkam; vector<int> num, asle; for (int idx = 0; idx <= 40; ++idx) { ll fade = 0; ll mlyan = 0; for (auto i : a) { if (i & (1ll << idx)) ++fade; else ++mlyan; } if (mlyan > fade) num.push_back(1); else num.push_back(0); if (k & (1ll << idx)) asle.push_back(1); else asle.push_back(0); mlyan -= fade; arkam.push_back(mlyan * (1ll << idx)); } bool ok = false; for (int i = 40; i; --i) { if (ok) { if (num[i]) ans += arkam[i]; continue; } if (num[i] == 1 && asle[i] == 1) ans += arkam[i]; if (num[i] == 0 && asle[i] == 1) ok = true; } cout << ans << endl; re 0; }
#include <bits/stdc++.h> #define re return #define ll long long #define ull unsigned ll #define ld long double #define f first #define s second #define pi acos(-1) #define oo (ll)1e9 #define OO 1e18 #define EPS 1e-6 #define Endl '\n' #define FX(n) fixed << setprecision(n) #define mm(o, k) memset(o, k, sizeof o) #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; const int maxn = 100005; int main() { IO; ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; ll ans = accumulate(a.begin(), a.end(), 0ll); vector<ll> arkam; vector<int> num, asle; for (int idx = 0; idx <= 40; ++idx) { ll fade = 0; ll mlyan = 0; for (auto i : a) { if (i & (1ll << idx)) ++fade; else ++mlyan; } if (mlyan > fade) num.push_back(1); else num.push_back(0); if (k & (1ll << idx)) asle.push_back(1); else asle.push_back(0); mlyan -= fade; arkam.push_back(mlyan * (1ll << idx)); } bool ok = false; for (int i = 40; i + 1; --i) { if (ok) { if (num[i]) ans += arkam[i]; continue; } if (num[i] == 1 && asle[i] == 1) ans += arkam[i]; if (num[i] == 0 && asle[i] == 1) ok = true; } cout << ans << endl; re 0; }
[ "control_flow.loop.for.condition.change", "misc.off_by_one" ]
944,403
944,402
u775315680
cpp
p03138
#include <bits/stdc++.h> #define re return #define ll long long #define ull unsigned ll #define ld long double #define f first #define s second #define pi acos(-1) #define oo (ll)1e9 #define OO 1e18 #define EPS 1e-6 #define Endl '\n' #define FX(n) fixed << setprecision(n) #define mm(o, k) memset(o, k, sizeof o) #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; const int maxn = 100005; int main() { IO; ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; ll ans = accumulate(a.begin(), a.end(), 0); vector<ll> arkam; vector<int> num, asle; for (int idx = 0; idx <= 40; ++idx) { ll fade = 0; ll mlyan = 0; for (auto i : a) { if (i & (1ll << idx)) ++fade; else ++mlyan; } if (mlyan > fade) num.push_back(1); else num.push_back(0); if (k & (1ll << idx)) asle.push_back(1); else asle.push_back(0); mlyan -= fade; arkam.push_back(mlyan * (1ll << idx)); } bool ok = false; for (int i = 40; i; --i) { if (ok) { if (num[i]) ans += arkam[i]; continue; } if (num[i] == 1 && asle[i] == 1) ans += arkam[i]; if (num[i] == 0 && asle[i] == 1) ok = true; } cout << ans << endl; re 0; }
#include <bits/stdc++.h> #define re return #define ll long long #define ull unsigned ll #define ld long double #define f first #define s second #define pi acos(-1) #define oo (ll)1e9 #define OO 1e18 #define EPS 1e-6 #define Endl '\n' #define FX(n) fixed << setprecision(n) #define mm(o, k) memset(o, k, sizeof o) #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; const int maxn = 100005; int main() { IO; ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; ll ans = accumulate(a.begin(), a.end(), 0ll); vector<ll> arkam; vector<int> num, asle; for (int idx = 0; idx <= 40; ++idx) { ll fade = 0; ll mlyan = 0; for (auto i : a) { if (i & (1ll << idx)) ++fade; else ++mlyan; } if (mlyan > fade) num.push_back(1); else num.push_back(0); if (k & (1ll << idx)) asle.push_back(1); else asle.push_back(0); mlyan -= fade; arkam.push_back(mlyan * (1ll << idx)); } bool ok = false; for (int i = 40; i + 1; --i) { if (ok) { if (num[i]) ans += arkam[i]; continue; } if (num[i] == 1 && asle[i] == 1) ans += arkam[i]; if (num[i] == 0 && asle[i] == 1) ok = true; } cout << ans << endl; re 0; }
[ "call.arguments.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
944,404
944,402
u775315680
cpp
p03138
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> using namespace std; typedef long long ll; ll n, k, a[100008], x, x_modify, ans; int main() { cin >> n >> k; for (ll i = 1; i <= n; i++) { cin >> a[i]; } x = 0; ll digit = 0; for (ll j = 0; j <= 40; j++) { if (k & (1LL << j)) { digit = j; } } // cout << digit << k << endl; for (ll j = 0; j <= 40; j++) { ll vote = 0; for (ll i = 1; i <= n; i++) { if (!(a[i] & (1LL << j))) { vote++; } } if (vote >= n - vote) { x |= (1LL << j); } } // modify ll ans = 0; for (ll j = digit + 1; j >= -1; j--) { x_modify = 0; ll ansbuf = 0; if (j == digit + 1 || j == -1 || k & (1LL << j)) { for (ll jj = 49; jj >= j + 1; jj--) { if (k & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll jj = j - 1; jj >= 0; jj--) { if (x & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll i = 1; i <= n; i++) { ansbuf += x_modify ^ a[i]; } ans = max(ansbuf, ans); } } // cout << x_modify << endl; if (k == 0) { ans = a[1]; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> using namespace std; typedef long long ll; ll n, k, a[100008], x, x_modify, ans; int main() { cin >> n >> k; for (ll i = 1; i <= n; i++) { cin >> a[i]; } x = 0; ll digit = 0; for (ll j = 0; j <= 40; j++) { if (k & (1LL << j)) { digit = j; } } // cout << digit << k << endl; for (ll j = 0; j <= 40; j++) { ll vote = 0; for (ll i = 1; i <= n; i++) { if (!(a[i] & (1LL << j))) { vote++; } } if (vote >= n - vote) { x |= (1LL << j); } } // modify ll ans = 0; for (ll j = digit; j >= -1; j--) { x_modify = 0; ll ansbuf = 0; if (j == digit + 1 || j == -1 || k & (1LL << j)) { for (ll jj = digit; jj >= j + 1; jj--) { if (k & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll jj = j - 1; jj >= 0; jj--) { if (x & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll i = 1; i <= n; i++) { ansbuf += x_modify ^ a[i]; } ans = max(ansbuf, ans); } } // cout << x_modify << endl; if (k == 0) { ans = a[1]; } cout << ans << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "variable_declaration.value.change", "identifier.replace.add", "literal.replace.remove" ]
944,412
944,413
u388697579
cpp
p03138
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> using namespace std; typedef long long ll; ll n, k, a[100008], x, x_modify, ans; int main() { cin >> n >> k; for (ll i = 1; i <= n; i++) { cin >> a[i]; } x = 0; ll digit = 0; for (ll j = 0; j <= 40; j++) { if (k & (1LL << j)) { digit = j; } } // cout << digit << k << endl; for (ll j = 0; j < 40; j++) { ll vote = 0; for (ll i = 1; i <= n; i++) { if (!(a[i] & (1LL << j))) { vote++; } } if (vote >= n - vote) { x |= (1LL << j); } } // modify ll ans = 0; for (ll j = digit + 1; j >= -1; j--) { x_modify = 0; ll ansbuf = 0; if (j == digit + 1 || j == -1 || k & (1 << j)) { for (ll jj = 49; jj >= j + 1; jj--) { if (k & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll jj = j - 1; jj >= 0; jj--) { if (x & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll i = 1; i <= n; i++) { ansbuf += x_modify ^ a[i]; } ans = max(ansbuf, ans); } } // cout << x_modify << endl; if (k == 0) { ans = a[1]; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> using namespace std; typedef long long ll; ll n, k, a[100008], x, x_modify, ans; int main() { cin >> n >> k; for (ll i = 1; i <= n; i++) { cin >> a[i]; } x = 0; ll digit = 0; for (ll j = 0; j <= 40; j++) { if (k & (1LL << j)) { digit = j; } } // cout << digit << k << endl; for (ll j = 0; j <= 40; j++) { ll vote = 0; for (ll i = 1; i <= n; i++) { if (!(a[i] & (1LL << j))) { vote++; } } if (vote >= n - vote) { x |= (1LL << j); } } // modify ll ans = 0; for (ll j = digit; j >= -1; j--) { x_modify = 0; ll ansbuf = 0; if (j == digit + 1 || j == -1 || k & (1LL << j)) { for (ll jj = digit; jj >= j + 1; jj--) { if (k & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll jj = j - 1; jj >= 0; jj--) { if (x & (1LL << jj)) { x_modify |= (1LL << jj); } } for (ll i = 1; i <= n; i++) { ansbuf += x_modify ^ a[i]; } ans = max(ansbuf, ans); } } // cout << x_modify << endl; if (k == 0) { ans = a[1]; } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "control_flow.branch.if.condition.change", "variable_declaration.value.change...
944,414
944,413
u388697579
cpp
p03138
///////////////////////////////////////////////////////// // // c/temp.cpp file // Last Updated: 2018-10-23 ...Maybe // // I hope you adding this code to the setting file // alias g++='g++ -std=c++1y -DDEBUG_LOCAL' // ///////////////////////////////////////////////////////// #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back //#define int long long #define _overload3(_1, _2, _3, name, ...) name #define _REP(i, n) REAP(i, 0, n) #define REAP(i, a, b) for (int i = int(a); i < int(b); ++i) #define REP(...) _overload3(__VA_ARGS__, REAP, _REP, )(__VA_ARGS__) #define _REPR(i, n) REAPR(i, n, 0) #define REAPR(i, a, b) for (int i = int(a - 1); i >= int(b); --i) #define REPR(...) _overload3(__VA_ARGS__, REAPR, _REPR, )(__VA_ARGS__) #define ALL(a) a.begin(), a.end() #define rALL(a) a.rbegin(), a.rend() #define coutALL(a) \ { \ int loop_coutALL = 0; \ for (auto e : a) \ cout << (loop_coutALL++ ? " " : "") << e; \ cout << endl; \ } #define coutYN(a) cout << ((a) ? "YES" : "NO") << endl; #define coutYn(a) cout << ((a) ? "Yes" : "No") << endl; #define coutyn(a) cout << ((a) ? "yes" : "no") << endl; #define pcnt __builtin_popcount #define buli(x) __builtin_popcountll(x) const int INF = 1145141919; // const long long INF=114514191911451419; const int MOD = (int)1e9 + 7; const double EPS = 1e-12; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; // const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1}; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; typedef pair<int, int> pii; typedef pair<int, string> pis; typedef pair<string, int> psi; typedef pair<string, string> pss; typedef long long ll; template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; } template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { int i = 0; for (T &x : v) os << (i++ ? " " : "") << x; return os; } ll rev(ll n) { ll x = 0; for (; n > 0;) { x = x * 10 + n % 10; n /= 10; } return x; } ll upper(ll n, ll m) { return (n + m - 1) / m; }; ll rounding(ll n) { return (long double)n + 0.5; }; bool inG(ll x, ll n) { return 0 <= x && x < n; } bool outG(ll x, ll n) { return x < 0 || n <= x; } inline int qp(int a, ll b) { if (!b) return 1; int ans = 1; do { if (b & 1) ans = 1ll * ans * a; a = 1ll * a * a; } while (b >>= 1); return ans; } inline int qp(int a, ll b, int mo) { if (!b) return 1; int ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; } inline ll fac(ll k, ll n) { ll a = 1; for (int i = 0; i < n; i++) a *= k--; return a; } inline ll fac(ll k, ll n, int mo) { ll a = 1; for (int i = 0; i < n; i++) a *= k--, a %= mo; return a; } inline int dsum(ll n) { int a = 0; for (; n; n /= 10) a += n % 10; return a; } struct Arithmetic { Arithmetic() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); } }; //#define DEBUG_LOCAL #ifdef DEBUG_LOCAL template <typename T> void deb(T a) { cerr << "deb: " << a << "です" << endl; } #define debl \ { cerr << "debug: " << __LINE__ << "行目だ" << endl; } void what_cr() { cout << __GCC_ATOMIC_CHAR16_T_LOCK_FREE << " ←?" << endl; } // ori_func S // ori_func E #else template <typename T> void deb(T a) {} #define debl void what_cr() {} void t_t() {} #endif using ull = unsigned long long; signed main() { Arithmetic Exception; int n; ull k; cin >> n >> k; vi li1(40, 0); vi li0(40, 0); REP(i, n) { ull a; cin >> a; REP(j, 40) { if ((1uLL << j) & a) li1[j]++; else li0[j]++; } } ull now = 0; vector<ull> li2(40, 0); REP(i, 40) { int x = li0[i] - li1[i]; if (x <= 0) x = 0; li2[i] = (1ull << i) * (ull)x; now += (1ull << i) * li1[i]; } ull ans = now; REP(i, 1, 40) li2[i] += li2[i - 1]; for (int i = 39; i != -1; i--) { if ((1ull << i) & k) { if (!i) { now += li2[i]; ans = max(ans, now); break; } if (li1[i] < li0[i]) { ans = max(ans, now + li2[i - 1]); now += (1ull << i) * (li0[i] - li1[i]); } else { ans = max(ans, now + li2[i]); break; } } } cout << ans << endl; return 0; }
///////////////////////////////////////////////////////// // // c/temp.cpp file // Last Updated: 2018-10-23 ...Maybe // // I hope you adding this code to the setting file // alias g++='g++ -std=c++1y -DDEBUG_LOCAL' // ///////////////////////////////////////////////////////// #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back //#define int long long #define _overload3(_1, _2, _3, name, ...) name #define _REP(i, n) REAP(i, 0, n) #define REAP(i, a, b) for (int i = int(a); i < int(b); ++i) #define REP(...) _overload3(__VA_ARGS__, REAP, _REP, )(__VA_ARGS__) #define _REPR(i, n) REAPR(i, n, 0) #define REAPR(i, a, b) for (int i = int(a - 1); i >= int(b); --i) #define REPR(...) _overload3(__VA_ARGS__, REAPR, _REPR, )(__VA_ARGS__) #define ALL(a) a.begin(), a.end() #define rALL(a) a.rbegin(), a.rend() #define coutALL(a) \ { \ int loop_coutALL = 0; \ for (auto e : a) \ cout << (loop_coutALL++ ? " " : "") << e; \ cout << endl; \ } #define coutYN(a) cout << ((a) ? "YES" : "NO") << endl; #define coutYn(a) cout << ((a) ? "Yes" : "No") << endl; #define coutyn(a) cout << ((a) ? "yes" : "no") << endl; #define pcnt __builtin_popcount #define buli(x) __builtin_popcountll(x) const int INF = 1145141919; // const long long INF=114514191911451419; const int MOD = (int)1e9 + 7; const double EPS = 1e-12; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; // const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1}; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; typedef pair<int, int> pii; typedef pair<int, string> pis; typedef pair<string, int> psi; typedef pair<string, string> pss; typedef long long ll; template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; } template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { int i = 0; for (T &x : v) os << (i++ ? " " : "") << x; return os; } ll rev(ll n) { ll x = 0; for (; n > 0;) { x = x * 10 + n % 10; n /= 10; } return x; } ll upper(ll n, ll m) { return (n + m - 1) / m; }; ll rounding(ll n) { return (long double)n + 0.5; }; bool inG(ll x, ll n) { return 0 <= x && x < n; } bool outG(ll x, ll n) { return x < 0 || n <= x; } inline int qp(int a, ll b) { if (!b) return 1; int ans = 1; do { if (b & 1) ans = 1ll * ans * a; a = 1ll * a * a; } while (b >>= 1); return ans; } inline int qp(int a, ll b, int mo) { if (!b) return 1; int ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; } inline ll fac(ll k, ll n) { ll a = 1; for (int i = 0; i < n; i++) a *= k--; return a; } inline ll fac(ll k, ll n, int mo) { ll a = 1; for (int i = 0; i < n; i++) a *= k--, a %= mo; return a; } inline int dsum(ll n) { int a = 0; for (; n; n /= 10) a += n % 10; return a; } struct Arithmetic { Arithmetic() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); } }; //#define DEBUG_LOCAL #ifdef DEBUG_LOCAL template <typename T> void deb(T a) { cerr << "deb: " << a << "です" << endl; } #define debl \ { cerr << "debug: " << __LINE__ << "行目だ" << endl; } void what_cr() { cout << __GCC_ATOMIC_CHAR16_T_LOCK_FREE << " ←?" << endl; } // ori_func S // ori_func E #else template <typename T> void deb(T a) {} #define debl void what_cr() {} void t_t() {} #endif using ull = unsigned long long; signed main() { Arithmetic Exception; int n; ull k; cin >> n >> k; vi li1(40, 0); vi li0(40, 0); REP(i, n) { ull a; cin >> a; REP(j, 40) { if ((1uLL << j) & a) li1[j]++; else li0[j]++; } } ull now = 0; vector<ull> li2(40, 0); REP(i, 40) { int x = li0[i] - li1[i]; if (x <= 0) x = 0; li2[i] = (1ull << i) * (ull)x; now += (1ull << i) * li1[i]; } ull ans = now; REP(i, 1, 40) li2[i] += li2[i - 1]; for (int i = 39; i != -1; i--) { if ((1ull << i) & k) { if (!i) { now += li2[i]; ans = max(ans, now); break; } if (li1[i] < li0[i]) { ans = max(ans, now + li2[i - 1]); now += (1ull << i) * (li0[i] - li1[i]); } else { ans = max(ans, now + li2[i]); break; } } } cout << max(ans, now) << endl; return 0; }
[ "call.add", "call.arguments.add" ]
944,424
944,425
u657913472
cpp