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
p02955
#include "bits/stdc++.h" typedef long long ll; #define int ll #define fi first #define se second #define SORT(a) sort(a.begin(), a.end()) #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define MP(a, b) make_pair(a, b) #define pb(a) push_back(a) #define INF LLONG_MAX / 2 #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << ": " << x << endl #define debug_vec(v) \ cerr << #v << ":"; \ rep(i, v.size()) cerr << " " << v[i]; \ cerr << endl using namespace std; int MOD = 1000000007; signed main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; int s = 0; rep(i, n) s += a[i]; set<int> y; for (int i = 1; i < sqrt(s) + 1; i++) { if (s % i == 0) { y.insert(i); y.insert(s / i); } } int ans = 1; for (auto x : y) { // cerr << x << " "; int ss = 0; vector<int> b(n); rep(i, n) { ss += a[i] % x; b[i] = a[i] % x; } SORT(b); //判定 // if(ss <= k*2)ans = max(ans,x); int er = ss / x; int h = 0; for (int i = 0; i < n - er; i++) { h += b[i]; } if (h < k) ans = x; } // cerr << endl; cout << ans << endl; return 0; } // g++ -std=c++14 code1.cpp // rm -r -f test;oj dl // https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a rm -r -f // test;oj dl http://abc136.contest.atcoder.jp/tasks/abc136_b
#include "bits/stdc++.h" typedef long long ll; #define int ll #define fi first #define se second #define SORT(a) sort(a.begin(), a.end()) #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, n) for (int i = 0; i < (n); i++) #define MP(a, b) make_pair(a, b) #define pb(a) push_back(a) #define INF LLONG_MAX / 2 #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << ": " << x << endl #define debug_vec(v) \ cerr << #v << ":"; \ rep(i, v.size()) cerr << " " << v[i]; \ cerr << endl using namespace std; int MOD = 1000000007; signed main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; int s = 0; rep(i, n) s += a[i]; set<int> y; for (int i = 1; i < sqrt(s) + 1; i++) { if (s % i == 0) { y.insert(i); y.insert(s / i); } } int ans = 1; for (auto x : y) { // cerr << x << " "; int ss = 0; vector<int> b(n); rep(i, n) { ss += a[i] % x; b[i] = a[i] % x; } SORT(b); //判定 // if(ss <= k*2)ans = max(ans,x); int er = ss / x; int h = 0; for (int i = 0; i < n - er; i++) { h += b[i]; } if (h <= k) ans = x; } // cerr << endl; cout << ans << endl; return 0; } // g++ -std=c++14 code1.cpp // rm -r -f test;oj dl // https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a rm -r -f // test;oj dl http://abc136.contest.atcoder.jp/tasks/abc136_b
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
759,218
759,219
u548768105
cpp
p02955
#include <bits/stdc++.h> #define M 505 using namespace std; int A[M], n, sum, m, W[M], tail; int main() { int ans = 1; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &A[i]), sum += A[i]; for (int i = 1; i <= sqrt(sum); i++) { if (sum % i != 0) continue; for (int j = 1; j <= n; j++) W[j] = A[j] % i; sort(W + 1, W + n + 1); int R = n; long long tot = 0; for (int j = 1; j <= n; j++) { while (R >= j && i - W[R] < W[j]) tot += i - W[R], W[j] -= (i - W[R]), W[R] = 0, R--; if (R > j) W[R] -= W[j], tot += W[j], W[j] = 0; } if (tot <= m) ans = max(ans, i); int now = sum / i; for (int j = 1; j <= n; j++) W[j] = A[j] % now; sort(W + 1, W + n + 1); R = n; tot = 0; for (int j = 1; j <= n; j++) { while (R >= j && now - W[R] < W[j]) tot += now - W[R], W[j] -= (now - W[R]), W[R] = 0, R--; if (R > j) W[R] -= W[j], tot += W[j], W[j] = 0; } if (tot <= m) ans = max(ans, now); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> #define M 505 using namespace std; int A[M], n, sum, m, W[M], tail; int main() { int ans = 1; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &A[i]), sum += A[i]; for (int i = 1; i <= sqrt(sum); i++) { if (sum % i != 0) continue; for (int j = 1; j <= n; j++) W[j] = A[j] % i; sort(W + 1, W + n + 1); int R = n; long long tot = 0; for (int j = 1; j <= n; j++) { while (R >= j && i - W[R] < W[j]) tot += i - W[R], W[j] -= (i - W[R]), W[R] = 0, R--; if (R > j) W[R] += W[j], tot += W[j], W[j] = 0; } if (tot <= m) ans = max(ans, i); int now = sum / i; for (int j = 1; j <= n; j++) W[j] = A[j] % now; sort(W + 1, W + n + 1); R = n; tot = 0; for (int j = 1; j <= n; j++) { while (R >= j && now - W[R] < W[j]) tot += now - W[R], W[j] -= (now - W[R]), W[R] = 0, R--; if (R > j) W[R] += W[j], tot += W[j], W[j] = 0; } if (tot <= m) ans = max(ans, now); } printf("%d\n", ans); return 0; }
[ "expression.operator.change" ]
759,225
759,226
u765391939
cpp
p02955
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, k, a[500], sum = 0; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } vector<int> div; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { div.push_back(i); if (i * i != sum) div.push_back(sum / i); } } sort(div.begin(), div.end(), greater<>()); for (int i = 0; i < div.size(); i++) { int na[500]; sum = 0; for (int j = 0; j < n; j++) { na[j] = a[j] % div[i]; sum += na[j]; } sort(na, na + n, greater<>()); int tmp = 0; for (int j = 0; j < sum / div[i]; j++) tmp += div[i] - a[j]; if (tmp <= k) { cout << div[i] << endl; return 0; } } }
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, k, a[500], sum = 0; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } vector<int> div; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { div.push_back(i); if (i * i != sum) div.push_back(sum / i); } } sort(div.begin(), div.end(), greater<>()); for (int i = 0; i < div.size(); i++) { int na[500]; sum = 0; for (int j = 0; j < n; j++) { na[j] = a[j] % div[i]; sum += na[j]; } sort(na, na + n, greater<>()); int tmp = 0; for (int j = 0; j < sum / div[i]; j++) tmp += div[i] - na[j]; if (tmp <= k) { cout << div[i] << endl; return 0; } } }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
759,233
759,234
u598050616
cpp
p02955
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int a[N], b[N], n, k, c[N]; int check(int anv) { for (int i = 1; i <= n; i++) c[i] = a[i] % anv; sort(c + 1, c + n + 1); int ans = 0, sum = 0, l = 0, r = n + 1; while (l < r - 1) { if (sum <= 0) l++, ans += c[l], sum += c[l]; else r--, sum -= (anv - c[l]); } return ans; } int main() { scanf("%d%d", &n, &k); int sum = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } int num = 0; for (int i = 1; i <= sqrt(sum); i++) if (sum % i == 0) { b[++num] = i; b[++num] = sum / i; } sort(b + 1, b + num + 1); for (int i = num; i >= 1; i--) if (check(b[i]) <= k) { printf("%d\n", b[i]); break; } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int a[N], b[N], n, k, c[N]; int check(int anv) { for (int i = 1; i <= n; i++) c[i] = a[i] % anv; sort(c + 1, c + n + 1); int ans = 0, sum = 0, l = 0, r = n + 1; while (l < r - 1) { if (sum <= 0) l++, ans += c[l], sum += c[l]; else r--, sum -= (anv - c[r]); } return ans; } int main() { scanf("%d%d", &n, &k); int sum = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } int num = 0; for (int i = 1; i <= sqrt(sum); i++) if (sum % i == 0) { b[++num] = i; b[++num] = sum / i; } sort(b + 1, b + num + 1); for (int i = num; i >= 1; i--) if (check(b[i]) <= k) { printf("%d\n", b[i]); break; } return 0; }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
759,235
759,236
u374819456
cpp
p02955
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <stack> #include <vector> using namespace std; const int maxn = 1e5 + 10; int read() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = (x << 3) + (x << 1) + c - 48; c = getchar(); } return x * f; } int n, m; int a[maxn], b[maxn]; bool check(int x) { for (register int i = 1; i <= n; i++) { b[i] = a[i] % x; // cout<<i<<" "<<b[i]<<endl; } sort(b + 1, b + n + 1); int num = 0, l = 1, r = n; while (l < r) { // cout<<l<<" "<<r<<" "<<b[l]<<" "<<b[r]<<endl; int minn = min(b[l], x - b[r]); b[l] -= minn; (b[r] += minn) %= x; num += minn; if (num > m) return false; if (!b[l]) l++; if (!b[r]) r--; } // cout<<x<<" "<<num<<" "<<m<<endl; if (l == r && b[l]) return false; return true; } int main() { int k, num = 0, ans; n = read(); m = read(); for (register int i = 1; i <= n; i++) { a[i] = read(); num += a[i]; } for (register int i = 1; i * i <= num; i++) { if (num % i == 0) { if (check(i)) ans = max(ans, i); if (check(num / i)) ans = max(ans, num / i); } } printf("%d\n", ans); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <stack> #include <vector> using namespace std; const int maxn = 500 + 10; int read() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = (x << 3) + (x << 1) + c - 48; c = getchar(); } return x * f; } int n, m; int a[maxn], b[maxn]; bool check(int x) { for (register int i = 1; i <= n; i++) { b[i] = a[i] % x; // cout<<i<<" "<<b[i]<<endl; } sort(b + 1, b + n + 1); int num = 0, l = 1, r = n; while (l < r) { // cout<<l<<" "<<r<<" "<<b[l]<<" "<<b[r]<<endl; int minn = min(b[l], x - b[r]); b[l] -= minn; (b[r] += minn) %= x; num += minn; if (num > m) return false; if (!b[l]) l++; if (!b[r]) r--; } // cout<<x<<" "<<num<<" "<<m<<endl; if (l == r && b[l]) return false; return true; } int main() { int k, num = 0, ans = 0; n = read(); m = read(); for (register int i = 1; i <= n; i++) { a[i] = read(); num += a[i]; } for (register int i = 1; i * i <= num; i++) { if (num % i == 0) { if (check(i)) ans = max(ans, i); if (check(num / i)) ans = max(ans, num / i); } } printf("%d\n", ans); return 0; }
[ "literal.number.change", "expression.operation.binary.change", "variable_declaration.value.change" ]
759,237
759,238
u998694062
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define int long long int MAX = 1000000007; vector<int> divisor(int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } signed main() { int n, k; cin >> n >> k; int a[n], ala = 0; for (int i = 0; i < n; i++) { cin >> a[i]; ala += a[i]; } int ama[n], q = 0, p, ans = MAX; vector<int> da = divisor(ala); for (int i0 = da.size() - 1; i0 > 0; i0--) { int i = da[i0]; p = 0; q = 0; for (int j = 0; j < n; j++) { ama[j] = a[j] % i; q += i - ama[j]; } sort(ama, ama + n); for (int j = 0; (j < (q / i)) && (j < n); j++) p += ama[j]; if (p <= k) { cout << i; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long int MAX = 1000000007; vector<int> divisor(int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } signed main() { int n, k; cin >> n >> k; int a[n], ala = 0; for (int i = 0; i < n; i++) { cin >> a[i]; ala += a[i]; } int ama[n], q = 0, p, ans = MAX; vector<int> da = divisor(ala); for (int i0 = da.size() - 1; i0 >= 0; i0--) { int i = da[i0]; p = 0; q = 0; for (int j = 0; j < n; j++) { ama[j] = a[j] % i; q += i - ama[j]; } sort(ama, ama + n); for (int j = 0; (j < (q / i)) && (j < n); j++) p += ama[j]; if (p <= k) { cout << i; break; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
759,241
759,242
u651317892
cpp
p02955
/*#pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast")*/ //#pragma GCC optimize("fast-math") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma //GCC optimize("unroll-loops") #define _CRT_SECURE_NO_WARNINGS #pragma GCC //optimize("unroll-loops") #pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma //GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma //GCC optimize("Ofast,no-stack-protector") #include <algorithm> #include <bitset> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef long double ld; #define all(a) a.begin(), a.end() #define lb(a, x) lower_bound(a.begin(), a.end(), x) #define pb(x) push_back(x) #define fr(i, n) for (int i = 0; i < n; ++i) // typedef cc_hash_table<int, int, hash<int>> hst2; // typedef cc_hash_table<int, hst2, hash<int>> hst; typedef pii ord_set_t; #ifdef ABCD typedef set<ord_set_t> ordered_set; int __builtin_popcount(int x) { int cnt = 0; for (; x > 0; x >>= 1) cnt += x & 1; return cnt; } #else #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> mt19937 rnd(239); using namespace __gnu_pbds; typedef tree<ord_set_t, null_type, less<ord_set_t>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #endif const int N = 501; ll a[N]; ll k; bool check(ll p, ll n) { ll sum = 0; fr(i, n) sum += a[i] % p; ll mas[N]; fr(i, n) mas[i] = a[i] % p; sort(mas, mas + n); ll d = sum / p; fr(i, d) { sum -= mas[n - i - 1]; sum += p - mas[n - i - 1]; } return sum <= k; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef ABCD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else #endif ll n; cin >> n >> k; fr(i, n) cin >> a[i]; ll sum = 0; fr(i, n) sum += a[i]; ll ans = 0; for (ll i = 1, sz = sqrt(sum) + 1; i < sz; ++i) { if (sum % i == 0) { if (check(i, n)) ans = max(ans, i); if (check(sum / i, n)) ans = max(ans, sum / i); } } cout << ans; }
/*#pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast")*/ //#pragma GCC optimize("fast-math") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma //GCC optimize("unroll-loops") #define _CRT_SECURE_NO_WARNINGS #pragma GCC //optimize("unroll-loops") #pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma //GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") //#pragma GCC optimize("unroll-loops") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma //GCC optimize("Ofast,no-stack-protector") #include <algorithm> #include <bitset> #include <deque> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef long double ld; #define all(a) a.begin(), a.end() #define lb(a, x) lower_bound(a.begin(), a.end(), x) #define pb(x) push_back(x) #define fr(i, n) for (int i = 0; i < n; ++i) // typedef cc_hash_table<int, int, hash<int>> hst2; // typedef cc_hash_table<int, hst2, hash<int>> hst; typedef pii ord_set_t; #ifdef ABCD typedef set<ord_set_t> ordered_set; int __builtin_popcount(int x) { int cnt = 0; for (; x > 0; x >>= 1) cnt += x & 1; return cnt; } #else #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> mt19937 rnd(239); using namespace __gnu_pbds; typedef tree<ord_set_t, null_type, less<ord_set_t>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #endif const int N = 501; ll a[N]; ll k; bool check(ll p, ll n) { ll sum = 0; fr(i, n) sum += a[i] % p; ll mas[N]; fr(i, n) mas[i] = a[i] % p; sort(mas, mas + n); ll d = sum / p; fr(i, d) { sum -= mas[n - i - 1]; sum += p - mas[n - i - 1]; } return sum <= 2ll * k; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef ABCD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else #endif ll n; cin >> n >> k; fr(i, n) cin >> a[i]; ll sum = 0; fr(i, n) sum += a[i]; ll ans = 0; for (ll i = 1, sz = sqrt(sum) + 1; i < sz; ++i) { if (sum % i == 0) { if (check(i, n)) ans = max(ans, i); if (check(sum / i, n)) ans = max(ans, sum / i); } } cout << ans; }
[ "expression.operation.binary.add" ]
759,249
759,250
u841694668
cpp
p02955
#include "bits/stdc++.h" using namespace std; using ll = int64_t; int main() { ll N, K; cin >> N >> K; vector<ll> A(N); for (ll i = 0; i < N; i++) { cin >> A[i]; } sort(A.rbegin(), A.rend()); auto minOp = [&](ll x) { // Aを全てxで割り切れるようにするときにかかる最小回数 vector<ll> mod(N); for (ll i = 0; i < N; i++) { mod[i] = A[i] % x; } sort(mod.begin(), mod.end()); ll back = N - 1; ll num = 0; for (ll i = 0; i < N; i++) { // mod[i]は減らす,mod[back]は増やす if (mod[i] == x - mod[back]) { ll curr_op_num = mod[i]; num += curr_op_num; mod[i] -= curr_op_num; mod[back] += curr_op_num; back--; } else if (mod[i] > x - mod[back]) { ll curr_op_num = x - mod[back]; num += curr_op_num; mod[i] -= curr_op_num; mod[back] += curr_op_num; back--; i--; } else { ll curr_op_num = mod[i]; num += curr_op_num; mod[i] -= curr_op_num; mod[back] += curr_op_num; } } for (ll i = 0; i < N; i++) { assert(mod[i] % x == 0); } return num; }; ll sum = accumulate(A.begin(), A.end(), (ll)0); ll ans = 0; for (ll i = 1; i * i <= sum; i++) { if (sum % i != 0) { continue; } if (minOp(sum / i) <= K) { ans = max(ans, sum / i); continue; } if (minOp(i) <= K) { ans = max(ans, i); } } cout << ans << endl; }
#include "bits/stdc++.h" using namespace std; using ll = int64_t; int main() { ll N, K; cin >> N >> K; vector<ll> A(N); for (ll i = 0; i < N; i++) { cin >> A[i]; } sort(A.rbegin(), A.rend()); auto minOp = [&](ll x) { // Aを全てxで割り切れるようにするときにかかる最小回数 vector<ll> mod(N); for (ll i = 0; i < N; i++) { mod[i] = A[i] % x; } sort(mod.begin(), mod.end()); ll back = N - 1; ll num = 0; for (ll i = 0; i < back; i++) { // mod[i]は減らす,mod[back]は増やす if (mod[i] == x - mod[back]) { ll curr_op_num = mod[i]; num += curr_op_num; mod[i] -= curr_op_num; mod[back] += curr_op_num; back--; } else if (mod[i] > x - mod[back]) { ll curr_op_num = x - mod[back]; num += curr_op_num; mod[i] -= curr_op_num; mod[back] += curr_op_num; back--; i--; } else { ll curr_op_num = mod[i]; num += curr_op_num; mod[i] -= curr_op_num; mod[back] += curr_op_num; } } for (ll i = 0; i < N; i++) { assert(mod[i] % x == 0); } return num; }; ll sum = accumulate(A.begin(), A.end(), (ll)0); ll ans = 0; for (ll i = 1; i * i <= sum; i++) { if (sum % i != 0) { continue; } if (minOp(sum / i) <= K) { ans = max(ans, sum / i); continue; } if (minOp(i) <= K) { ans = max(ans, i); } } cout << ans << endl; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
759,251
759,252
u456065785
cpp
p02955
#include <bits/stdc++.h> #define f first #define s second #define MOD 1000000007 #define PMOD 998244353 #define pb(x) push_back(x) using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef pair<ll, ll> plii; typedef pair<int, pii> piii; const int INF = 1e9 + 10; const ll LINF = 1LL * INF * INF; const int MAXN = 2e5 + 10; const int MAXM = 5e3 + 10; priority_queue<int> pq; vector<vector<int>> graph; queue<int> que; int A[MAXN]; char S[MAXN]; vector<int> fac; ll myabs(ll p) { if (p >= 0) return p; return -p; } int main() { int n, m, k, a, b, x, y; ll sum = 0; int cnt = 0; int mx = 0; ll mn = INF; int cur = 0, idx = -1; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> A[i]; for (int i = 1; i <= n; i++) sum += A[i]; for (int i = 1; i * i <= sum; i++) { if (!(sum % i)) { fac.push_back(i); if (i * i != A[i]) { fac.push_back(sum / i); } } } sort(fac.begin(), fac.end()); ll pl = 0, mi = 0; ll psum = 0; int nw; int res = 0; for (int runs = 0; runs < fac.size(); runs++) { cur = fac[runs]; vector<int> re; pl = 0; for (int i = 1; i <= n; i++) { re.push_back(A[i] % cur), pl += (ll)(A[i] % cur); } sort(re.begin(), re.end()); mn = n * (ll)cur - pl; psum = 0; for (int i = 0; i < n; i++) { psum += re[i]; mn = min(mn, max(psum, (n - i - 1) * (ll)cur - (pl - psum))); } if (mn <= k) res = cur; } cout << res << "\n"; return 0; }
#include <bits/stdc++.h> #define f first #define s second #define MOD 1000000007 #define PMOD 998244353 #define pb(x) push_back(x) using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef pair<ll, ll> plii; typedef pair<int, pii> piii; const int INF = 1e9 + 10; const ll LINF = 1LL * INF * INF; const int MAXN = 2e5 + 10; const int MAXM = 5e3 + 10; priority_queue<int> pq; vector<vector<int>> graph; queue<int> que; int A[MAXN]; char S[MAXN]; vector<int> fac; ll myabs(ll p) { if (p >= 0) return p; return -p; } int main() { int n, m, k, a, b, x, y; ll sum = 0; int cnt = 0; int mx = 0; ll mn = INF; int cur = 0, idx = -1; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> A[i]; for (int i = 1; i <= n; i++) sum += A[i]; for (int i = 1; i * i <= sum; i++) { if (!(sum % i)) { fac.push_back(i); if (i * i != sum) { fac.push_back(sum / i); } } } sort(fac.begin(), fac.end()); ll pl = 0, mi = 0; ll psum = 0; int nw; int res = 0; for (int runs = 0; runs < fac.size(); runs++) { cur = fac[runs]; vector<int> re; pl = 0; for (int i = 1; i <= n; i++) { re.push_back(A[i] % cur), pl += (ll)(A[i] % cur); } sort(re.begin(), re.end()); mn = n * (ll)cur - pl; psum = 0; for (int i = 0; i < n; i++) { psum += re[i]; mn = min(mn, max(psum, (n - i - 1) * (ll)cur - (pl - psum))); } // cout<<mn<<" "<<cur<<"\n"; if (mn <= k) res = cur; } cout << res << "\n"; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
759,255
759,256
u114415753
cpp
p02955
#define _CRT_SECURE_NO_WARNINGS #pragma comment(linker, "/stack:256000000") #include <algorithm> #include <bitset> #include <cassert> #include <ccomplex> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // 4Head #define all(x) x.begin(), x.end() #define mp make_pair #define X first #define Y second using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; mt19937_64 gen(time(NULL)); // belik's shit ll const mod = 1e9 + 7; namespace { ll mult(ll a, ll b) { ll val = a * b - (ll)((ld)a * b / mod) * mod; if (val < 0) { val += mod; } if (val >= mod) { val -= mod; } return val; } ll poww(ll a, ll b) { ll val = 1; a %= mod; while (b > 0) { if (b % 2) val = mult(a, val); a = mult(a, a); b >>= 1; } return val % mod; } ll inv(ll a) { return poww(a, mod - 2); } } // namespace ll const maxn = 2e5 + 5; ll ans[maxn]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<ll> a(n); ll k; cin >> k; for (ll i = 0; i < n; i++) cin >> a[i]; sort(all(a)); ll ans = LLONG_MIN; ll sm = 0; for (ll i = 0; i < n - 1; i++) sm += a[i]; if (sm <= k) { cout << a[n - 1] + sm; return 0; } else { sm += a[n - 1]; for (ll d = 2; d * d <= sm; d++) { if (sm % d) continue; bool f1 = 0, f2 = 0; vector<ll> xd; for (ll i = 0; i < n; i++) { xd.push_back(a[i] % d); } sort(all(xd)); ll kek = -1; vector<ll> pref(n), suf(n); for (ll i = 0; i < n; i++) pref[i] = xd[i] + (i ? pref[i - 1] : 0); for (ll i = n - 1; i >= 0; i--) suf[i] = xd[i] + (n - 1 - i ? suf[i + 1] : 0); if (pref[n - 1] == 0) { f1 = true; } else { for (ll i = 0; i < n - 1; i++) { if (pref[i] == d * (n - i - 1) - suf[i + 1]) { kek = pref[i]; break; } } if (kek != -1) { if (kek <= k) { f1 = true; } } } ll dd = sm / d; xd.clear(); for (ll i = 0; i < n; i++) { xd.push_back(a[i] % dd); } sort(all(xd)); kek = -1; pref.clear(), suf.clear(); pref.resize(n), suf.resize(n); for (ll i = 0; i < n; i++) pref[i] = xd[i] + (i ? pref[i - 1] : 0); for (ll i = n - 1; i >= 0; i--) suf[i] = xd[i] + (n - 1 - i ? suf[i + 1] : 0); if (pref[n - 1] == 0) { f2 = true; } else { for (ll i = 0; i < n - 1; i++) { if (pref[i] == dd * (n - i - 1) - suf[i + 1]) { kek = pref[i]; break; } } if (kek != -1) { if (kek <= k) { f2 = true; } } } if (f1) { ans = max(ans, d); } if (f2) { ans = max(ans, dd); } } } cout << ans; return 0; } /* */
#define _CRT_SECURE_NO_WARNINGS #pragma comment(linker, "/stack:256000000") #include <algorithm> #include <bitset> #include <cassert> #include <ccomplex> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // 4Head #define all(x) x.begin(), x.end() #define mp make_pair #define X first #define Y second using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; mt19937_64 gen(time(NULL)); // belik's shit ll const mod = 1e9 + 7; namespace { ll mult(ll a, ll b) { ll val = a * b - (ll)((ld)a * b / mod) * mod; if (val < 0) { val += mod; } if (val >= mod) { val -= mod; } return val; } ll poww(ll a, ll b) { ll val = 1; a %= mod; while (b > 0) { if (b % 2) val = mult(a, val); a = mult(a, a); b >>= 1; } return val % mod; } ll inv(ll a) { return poww(a, mod - 2); } } // namespace ll const maxn = 2e5 + 5; ll ans[maxn]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<ll> a(n); ll k; cin >> k; for (ll i = 0; i < n; i++) cin >> a[i]; sort(all(a)); ll ans = 1; ll sm = 0; for (ll i = 0; i < n - 1; i++) sm += a[i]; if (sm <= k) { cout << a[n - 1] + sm; return 0; } else { sm += a[n - 1]; for (ll d = 2; d * d <= sm; d++) { if (sm % d) continue; bool f1 = 0, f2 = 0; vector<ll> xd; for (ll i = 0; i < n; i++) { xd.push_back(a[i] % d); } sort(all(xd)); ll kek = -1; vector<ll> pref(n), suf(n); for (ll i = 0; i < n; i++) pref[i] = xd[i] + (i ? pref[i - 1] : 0); for (ll i = n - 1; i >= 0; i--) suf[i] = xd[i] + (n - 1 - i ? suf[i + 1] : 0); if (pref[n - 1] == 0) { f1 = true; } else { for (ll i = 0; i < n - 1; i++) { if (pref[i] == d * (n - i - 1) - suf[i + 1]) { kek = pref[i]; break; } } if (kek != -1) { if (kek <= k) { f1 = true; } } } ll dd = sm / d; xd.clear(); for (ll i = 0; i < n; i++) { xd.push_back(a[i] % dd); } sort(all(xd)); kek = -1; pref.clear(), suf.clear(); pref.resize(n), suf.resize(n); for (ll i = 0; i < n; i++) pref[i] = xd[i] + (i ? pref[i - 1] : 0); for (ll i = n - 1; i >= 0; i--) suf[i] = xd[i] + (n - 1 - i ? suf[i + 1] : 0); if (pref[n - 1] == 0) { f2 = true; } else { for (ll i = 0; i < n - 1; i++) { if (pref[i] == dd * (n - i - 1) - suf[i + 1]) { kek = pref[i]; break; } } if (kek != -1) { if (kek <= k) { f2 = true; } } } if (f1) { ans = max(ans, d); } if (f2) { ans = max(ans, dd); } } } cout << ans; return 0; } /* */
[ "variable_declaration.value.change", "identifier.replace.remove", "literal.replace.add" ]
759,257
759,258
u258032299
cpp
p02955
#include <bits/stdc++.h> using namespace std; long INF = 1000000000000000; int main() { long N, K; cin >> N >> K; vector<long> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); long sum = 0; for (int i = 0; i < N; i++) sum += A.at(i); vector<long> divi(0); long n = 1; while (n * n <= sum) { if (sum % n == 0) { divi.push_back(n); divi.push_back(sum / n); } n++; } long ans = 0; vector<long> rem(N); for (int i = 0; i < divi.size(); i++) { long d = divi.at(i); // cout<<d<<endl; for (int i = 0; i < N; i++) rem.at(i) = (A.at(i) % d); sort(rem.begin(), rem.end()); long cost = 0; long L = 0, R = N - 1; while (L < R) { long mess = rem.at(L); cost += mess; while (mess > 0) { if ((d - rem.at(R)) >= mess) { rem.at(R) += mess; mess = 0; } else { mess -= (d - rem.at(R)); rem.at(R) = d; } if (rem.at(R) == d) R--; } L++; } // cout<<d<<" "<<cost<<endl; if (cost < K) ans = max(ans, d); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; long INF = 1000000000000000; int main() { long N, K; cin >> N >> K; vector<long> A(N); for (int i = 0; i < N; i++) cin >> A.at(i); long sum = 0; for (int i = 0; i < N; i++) sum += A.at(i); vector<long> divi(0); long n = 1; while (n * n <= sum) { if (sum % n == 0) { divi.push_back(n); divi.push_back(sum / n); } n++; } long ans = 0; vector<long> rem(N); for (int i = 0; i < divi.size(); i++) { long d = divi.at(i); // cout<<d<<endl; for (int i = 0; i < N; i++) rem.at(i) = (A.at(i) % d); sort(rem.begin(), rem.end()); long cost = 0; long L = 0, R = N - 1; while (L < R) { long mess = rem.at(L); cost += mess; while (mess > 0) { if ((d - rem.at(R)) >= mess) { rem.at(R) += mess; mess = 0; } else { mess -= (d - rem.at(R)); rem.at(R) = d; } if (rem.at(R) == d) R--; } L++; } // cout<<d<<" "<<cost<<endl; if (cost <= K) ans = max(ans, d); } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
759,263
759,264
u968365254
cpp
p02955
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } typedef long long int64; typedef pair<int, int> ii; const int INF = 1 << 29; const int MOD = 1e9 + 7; int main() { int n, m; scanf("%d%d", &n, &m); vector<int> a(n), b(n); int all = 0; for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); // a[i] = rand() % 1000000 + 1; all += a[i]; } vector<int> can; for (int k = 2; k * k <= all; ++k) { if (all % k == 0) { can.push_back(k); if (all / k != k) can.push_back(all / k); } } int ret = 1; for (auto &k : can) { for (int i = 0; i < n; ++i) { b[i] = a[i] % k; } sort(b.begin(), b.end()); int r = 0; for (; r < n && b[r] == 0; ++r) ; int64 R = 0; for (int i = r; i < n; ++i) { R += k - b[i]; } int64 L = 0; for (int i = r; i < n && L < R; ++i) { L += b[i]; R -= k - b[i]; } if (L <= m) ret = max(ret, k); } printf("%d\n", ret); return 0; }
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << ": " << arg1 << " |"; __f(comma + 1, args...); } typedef long long int64; typedef pair<int, int> ii; const int INF = 1 << 29; const int MOD = 1e9 + 7; int main() { int n, m; scanf("%d%d", &n, &m); vector<int> a(n), b(n); int all = 0; for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); // a[i] = rand() % 1000000 + 1; all += a[i]; } vector<int> can; for (int k = 1; k * k <= all; ++k) { if (all % k == 0) { can.push_back(k); if (all / k != k) can.push_back(all / k); } } int ret = 1; for (auto &k : can) { for (int i = 0; i < n; ++i) { b[i] = a[i] % k; } sort(b.begin(), b.end()); int r = 0; for (; r < n && b[r] == 0; ++r) ; int64 R = 0; for (int i = r; i < n; ++i) { R += k - b[i]; } int64 L = 0; for (int i = r; i < n && L < R; ++i) { L += b[i]; R -= k - b[i]; } if (L <= m) ret = max(ret, k); } printf("%d\n", ret); return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
759,265
759,266
u112723190
cpp
p02955
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> as(n); int sum = 0; for (int i = 0; i < n; i++) { cin >> as[i]; sum += as[i]; } vector<int> ds; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { ds.push_back(i); if (sum / i != i) { ds.push_back(sum / i); } } } sort(ds.rbegin(), ds.rend()); for (int d : ds) { int tot = 0; vector<pair<int, int>> hoge; for (int i = 0; i < n; i++) { int a = as[i]; if (a % d == 0) continue; int iran = a % d; int iru = d - iran; hoge.emplace_back(iran, iru); tot += iru; } sort(hoge.begin(), hoge.end()); int cur = 0; for (int i = 0;; i++) { if (i >= hoge.size()) break; cur += hoge[i].first; tot -= hoge[i].second; if (cur > k) break; if (cur == tot) { cout << d << endl; return 0; } } } cout << 0 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> as(n); int sum = 0; for (int i = 0; i < n; i++) { cin >> as[i]; sum += as[i]; } vector<int> ds; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { ds.push_back(i); if (sum / i != i) { ds.push_back(sum / i); } } } sort(ds.rbegin(), ds.rend()); for (int d : ds) { int tot = 0; vector<pair<int, int>> hoge; for (int i = 0; i < n; i++) { int a = as[i]; if (a % d == 0) continue; int iran = a % d; int iru = d - iran; hoge.emplace_back(iran, iru); tot += iru; } sort(hoge.begin(), hoge.end()); int cur = 0; for (int i = 0;; i++) { if (i >= hoge.size()) break; cur += hoge[i].first; tot -= hoge[i].second; if (cur > k) break; if (cur == tot) { cout << d << endl; return 0; } } } cout << 1 << endl; }
[ "literal.number.change", "io.output.change" ]
759,277
759,278
u210718367
cpp
p02955
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <numeric> #include <queue> #include <stack> #include <vector> template <class T> std::vector<T> getDivisors(T N) { std::queue<T> D_lower; std::stack<T> D_upper; for (T i = static_cast<T>(1); i * i <= N; ++i) { if (N % i == 0) { D_lower.emplace(i); if (i * i != N) { D_upper.emplace(N / i); } } } std::vector<T> D; while (!D_lower.empty()) { D.emplace_back(D_lower.front()); D_lower.pop(); } while (!D_upper.empty()) { D.emplace_back(D_upper.top()); D_upper.pop(); } return D; } int main(int argc, char *argv[]) { long long N, K; std::cin >> N >> K; std::vector<long long> A(N); for (auto &a : A) { std::cin >> a; } long long S = std::accumulate(A.begin(), A.end(), 0); auto D = getDivisors(S); std::sort(D.begin(), D.end(), std::greater<long long>()); long long g, gTilde; std::vector<long long> R(N); long long i; long long sumQuot, sumDiff; long long quot, quotSup; for (const auto d : D) { g = d; gTilde = 0; for (i = 0; i < N; ++i) { R[i] = A[i] % g; gTilde += R[i]; } gTilde /= g; sumQuot = 0; sumDiff = 0; std::sort(R.begin(), R.end(), std::greater<long long>()); for (i = 0; i < N; ++i) { quot = std::min((K + R[i] - sumDiff) / g, gTilde - sumQuot); if (quot <= 0) { break; } sumQuot += quot; sumDiff += quot * g - R[i]; } if (sumQuot == gTilde) { break; } } std::cout << g << std::endl; return 0; }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <numeric> #include <queue> #include <stack> #include <vector> template <class T> std::vector<T> getDivisors(T N) { std::queue<T> D_lower; std::stack<T> D_upper; for (T i = static_cast<T>(1); i * i <= N; ++i) { if (N % i == 0) { D_lower.emplace(i); if (i * i != N) { D_upper.emplace(N / i); } } } std::vector<T> D; while (!D_lower.empty()) { D.emplace_back(D_lower.front()); D_lower.pop(); } while (!D_upper.empty()) { D.emplace_back(D_upper.top()); D_upper.pop(); } return D; } int main(int argc, char *argv[]) { long long N, K; std::cin >> N >> K; std::vector<long long> A(N); for (auto &a : A) { std::cin >> a; } long long S = std::accumulate(A.begin(), A.end(), 0); auto D = getDivisors(S); std::sort(D.begin(), D.end(), std::greater<long long>()); long long g, gTilde; std::vector<long long> R(N); long long i; long long sumQuot, sumDiff; long long quot, quotSup; for (const auto d : D) { g = d; gTilde = 0; for (i = 0; i < N; ++i) { R[i] = A[i] % g; gTilde += R[i]; } gTilde /= g; sumQuot = 0; sumDiff = 0; std::sort(R.begin(), R.end(), std::greater<long long>()); for (i = 0; i < N; ++i) { quot = std::min((K + R[i] - sumDiff) / g, gTilde - sumQuot); if (quot <= 0) { break; } quot = 1; sumQuot += quot; sumDiff += quot * g - R[i]; } if (sumQuot == gTilde) { break; } } std::cout << g << std::endl; return 0; }
[ "assignment.add" ]
759,282
759,283
u436832975
cpp
p02955
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll sum = 0LL; ll N, K; cin >> N >> K; vector<ll> A(N); for (ll i = 0LL; i < N; i++) { cin >> A[i]; sum += A[i]; } set<ll> s; for (ll i = 1LL; i * i <= sum; i++) { if (sum % i == 0LL) { s.insert(i); s.insert(sum % i); } } ll ans = 1LL; for (auto ne : s) { vector<ll> rem(N); for (ll i = 0LL; i < N; i++) { rem[i] = A[i] % ne; } sort(rem.begin(), rem.end()); ll lsum = 0LL; ll rsum = 0LL; for (ll i = 0; i < N; i++) { rsum += ne - rem[i]; } ll cnt = 1LL << 60; for (ll i = 0LL; i < N; i++) { lsum += rem[i]; rsum -= ne - rem[i]; if (lsum != rsum) { continue; } cnt = min(cnt, lsum); } if (cnt <= K) { ans = max(ans, ne); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll sum = 0LL; ll N, K; cin >> N >> K; vector<ll> A(N); for (ll i = 0LL; i < N; i++) { cin >> A[i]; sum += A[i]; } set<ll> s; for (ll i = 1LL; i * i <= sum; i++) { if (sum % i == 0LL) { s.insert(i); s.insert(sum / i); } } ll ans = 1LL; for (auto ne : s) { vector<ll> rem(N); for (ll i = 0LL; i < N; i++) { rem[i] = A[i] % ne; } sort(rem.begin(), rem.end()); ll lsum = 0LL; ll rsum = 0LL; for (ll i = 0; i < N; i++) { rsum += ne - rem[i]; } ll cnt = 1LL << 60; for (ll i = 0LL; i < N; i++) { lsum += rem[i]; rsum -= ne - rem[i]; if (lsum != rsum) { continue; } cnt = min(cnt, lsum); } if (cnt <= K) { ans = max(ans, ne); } } cout << ans << endl; return 0; }
[ "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
759,299
759,300
u904123392
cpp
p02955
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N, K; cin >> N >> K; ll sum = 0; vector<ll> A(N); for (ll i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } //考えられるのは、sumの約数しかありえない set<ll> s; ll ans = 1LL; // ans は 答えとなりうるsの要素に過ぎない for (ll i = 1; i * i <= sum; i++) { if (sum % i == 0) { s.insert(i); s.insert(sum / i); } } // sにsum の約数列挙 for (auto ne : s) { ll cnt = 1LL << 60; // caliculate cnt in this part vector<ll> r(N); for (ll i = 0; i < N; i++) { r[i] = A[i] % ne; } sort(r.begin(), r.end()); ll rsum = 0; for (ll i = 0; i < N; i++) { rsum += ne - r[i]; } ll lsum = 0; for (ll j = 0; j < N; j++) { lsum += r[j]; rsum -= ne - r[j]; cnt = min(lsum + rsum, cnt); } if (cnt <= K) { ans = max(ans, ne); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N, K; cin >> N >> K; ll sum = 0; vector<ll> A(N); for (ll i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } //考えられるのは、sumの約数しかありえない set<ll> s; ll ans = 1LL; // ans は 答えとなりうるsの要素に過ぎない for (ll i = 1; i * i <= sum; i++) { if (sum % i == 0) { s.insert(i); s.insert(sum / i); } } // sにsum の約数列挙 for (auto ne : s) { ll cnt = 1LL << 60; // caliculate cnt in this part vector<ll> r(N); for (ll i = 0; i < N; i++) { r[i] = A[i] % ne; } sort(r.begin(), r.end()); ll rsum = 0; for (ll i = 0; i < N; i++) { rsum += ne - r[i]; } ll lsum = 0; for (ll j = 0; j < N; j++) { lsum += r[j]; rsum -= ne - r[j]; cnt = min(max(lsum, rsum), cnt); } if (cnt <= K) { ans = max(ans, ne); } } cout << ans << endl; return 0; }
[ "call.add", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
759,301
759,302
u904123392
cpp
p02955
#include <algorithm> #include <iostream> #include <set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; ll sum = 0; rep(i, n) sum += a[i]; set<ll> candidates; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { candidates.insert(i); candidates.insert(i / sum); } } ll ans = 1; for (ll x : candidates) { ll need; { vector<ll> r(n); rep(i, n) r[i] = a[i] % x; sort(r.begin(), r.end()); ll B = 0; rep(i, n) B += x - r[i]; ll A = 0; need = 1e18; rep(i, n) { A += r[i]; B -= x - r[i]; need = min(need, max(A, B)); } } if (need <= k) ans = max(ans, x); } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <set> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i, n) cin >> a[i]; ll sum = 0; rep(i, n) sum += a[i]; set<ll> candidates; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { candidates.insert(i); candidates.insert(sum / i); } } ll ans = 1; for (ll x : candidates) { ll need; { vector<ll> r(n); rep(i, n) r[i] = a[i] % x; sort(r.begin(), r.end()); ll B = 0; rep(i, n) B += x - r[i]; ll A = 0; need = 1e18; rep(i, n) { A += r[i]; B -= x - r[i]; need = min(need, max(A, B)); } } if (need <= k) ans = max(ans, x); } cout << ans << endl; return 0; }
[ "expression.operation.binary.remove" ]
759,312
759,313
u235231201
cpp
p02955
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> VI; 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 _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(x) (x).begin(), (x).end() int main() { int n, k; cin >> n >> k; int sum = 0; int a[n]; rep(i, n) { cin >> a[i]; sum += a[i]; } vector<int> p; for (int i = 1; i * i <= sum; ++i) { if (sum % i == 0) { p.push_back(i); if (i * i != sum) p.push_back(sum / i); } } sort(all(p)); reverse(all(p)); rep(i, p.size()) { int b[n]; rep(j, n) b[j] = a[j] % p[i]; sort(b, b + n); ll sum[n + 1]; sum[0] = 0; rep(j, n) sum[j + 1] = sum[j] + b[j]; rep(j, n) { if (max(sum[j + 1] - sum[0], (n - j - i) * p[i] - (sum[n] - sum[j + 1])) <= k) { cout << p[i] << endl; exit(0); } } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> VI; 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 _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(x) (x).begin(), (x).end() int main() { int n, k; cin >> n >> k; int sum = 0; int a[n]; rep(i, n) { cin >> a[i]; sum += a[i]; } vector<int> p; for (int i = 1; i * i <= sum; ++i) { if (sum % i == 0) { p.push_back(i); if (i * i != sum) p.push_back(sum / i); } } sort(all(p)); reverse(all(p)); rep(i, p.size()) { int b[n]; rep(j, n) b[j] = a[j] % p[i]; sort(b, b + n); ll sum[n + 1]; sum[0] = 0; rep(j, n) sum[j + 1] = sum[j] + b[j]; rep(j, n) { if (max(sum[j + 1] - sum[0], 1ll * (n - j - 1) * p[i] - (sum[n] - sum[j + 1])) <= k) { cout << p[i] << endl; exit(0); } } } }
[ "control_flow.branch.if.condition.change" ]
759,316
759,315
u071692456
cpp
p02955
// Charan Sriramula #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long int ll; const ll lg = 22; const ll N = 1e6 + 5; const ll M = 5e8; const ll INF = 1e18; const ll mod = 1e9 + 7; const double PI = 3.14159265358979323846; #define is(n) scanf("%d", &n) #define io(n) printf("%d\n", n) #define ls(n) scanf("%lld", &n) #define lo(n) printf("%lld\n", n) #define f first #define s second #define pb(x) push_back(x) #define pf(x) push_front(x) #define mp(x, y) make_pair(x, y) #define GCD(a, b) __gcd((a), (b)) #define all(v) v.begin(), v.end() #define bits(x) __builtin_popcount(x) #define LCM(a, b) ((a) * (b)) / GCD((a), (b)) #define fast \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); template <typename T> T power(T x, T y, ll m) { T ans = 1; while (y > 0) { if (y & 1LL) ans = (ans * x) % m; y >>= 1LL; x = (x * x) % m; } return ans % m; } inline ll mul(ll a, ll b, ll p) { return (a * 1ll * b) % p; } inline ll sub(ll a, ll b, ll p) { ll c = a - b; if (c < 0) c += p; return c; } inline ll add(ll a, ll b, ll p) { ll c = a + b; if (c > p) c -= p; return c; } #define trace1(x) cerr << #x << ": " << x << endl #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl #define trace3(x, y, z) \ cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \ << z << endl #define trace4(a, b, c, d) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << endl #define trace5(a, b, c, d, e) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl #define trace6(a, b, c, d, e, f) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " \ << #f << ": " << f << endl ll n, k, a[N]; bool F(ll cur) { ll cnt = 0; vector<ll> v; for (ll i = 0; i < n; i++) { ll div = a[i] % cur; if (div == 0 || div == cur) { continue; } v.pb(div); } sort(all(v)); ll low = 0, high = v.size() - 1; while (low < high) { ll lowsteps = v[low]; ll highsteps = cur - v[high]; if (lowsteps == highsteps) { v[low] = 0; v[high] = cur; low++; high--; cnt += lowsteps; } else if (lowsteps < highsteps) { v[low] = 0; v[high] += lowsteps; low++; cnt += lowsteps; } else { v[high] = 0; v[low] -= highsteps; high--; cnt += highsteps; } if (cnt > k) { return false; } } for (ll i = 0; i < v.size(); i++) { if (v[i] == 0 || v[i] == cur) { continue; } return false; } return true; } int main() { cin >> n >> k; ll maxi, sum = 0; for (ll i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } for (ll i = 1; i <= sqrt(sum); i++) { if (sum % i) { continue; } ll pos = F(i); ll qpos = F(sum / i); if (pos) { maxi = max(maxi, i); } if (qpos) { maxi = max(maxi, sum / i); } } cout << maxi << endl; }
// Charan Sriramula #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long int ll; const ll lg = 22; const ll N = 1e6 + 5; const ll M = 5e8; const ll INF = 1e18; const ll mod = 1e9 + 7; const double PI = 3.14159265358979323846; #define is(n) scanf("%d", &n) #define io(n) printf("%d\n", n) #define ls(n) scanf("%lld", &n) #define lo(n) printf("%lld\n", n) #define f first #define s second #define pb(x) push_back(x) #define pf(x) push_front(x) #define mp(x, y) make_pair(x, y) #define GCD(a, b) __gcd((a), (b)) #define all(v) v.begin(), v.end() #define bits(x) __builtin_popcount(x) #define LCM(a, b) ((a) * (b)) / GCD((a), (b)) #define fast \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); template <typename T> T power(T x, T y, ll m) { T ans = 1; while (y > 0) { if (y & 1LL) ans = (ans * x) % m; y >>= 1LL; x = (x * x) % m; } return ans % m; } inline ll mul(ll a, ll b, ll p) { return (a * 1ll * b) % p; } inline ll sub(ll a, ll b, ll p) { ll c = a - b; if (c < 0) c += p; return c; } inline ll add(ll a, ll b, ll p) { ll c = a + b; if (c > p) c -= p; return c; } #define trace1(x) cerr << #x << ": " << x << endl #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl #define trace3(x, y, z) \ cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " \ << z << endl #define trace4(a, b, c, d) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << endl #define trace5(a, b, c, d, e) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl #define trace6(a, b, c, d, e, f) \ cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " \ << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " \ << #f << ": " << f << endl ll n, k, a[N]; bool F(ll cur) { ll cnt = 0; vector<ll> v; for (ll i = 0; i < n; i++) { ll div = a[i] % cur; if (div == 0 || div == cur) { continue; } v.pb(div); } sort(all(v)); ll low = 0, high = v.size() - 1; while (low < high) { ll lowsteps = v[low]; ll highsteps = cur - v[high]; if (lowsteps == highsteps) { v[low] = 0; v[high] = cur; low++; high--; cnt += lowsteps; } else if (lowsteps < highsteps) { v[low] = 0; v[high] += lowsteps; low++; cnt += lowsteps; } else { v[high] = 0; v[low] -= highsteps; high--; cnt += highsteps; } if (cnt > k) { return false; } } for (ll i = 0; i < v.size(); i++) { if (v[i] == 0 || v[i] == cur) { continue; } return false; } return true; } int main() { cin >> n >> k; ll maxi = 0, sum = 0; for (ll i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } for (ll i = 1; i <= sqrt(sum); i++) { if (sum % i) { continue; } ll pos = F(i); ll qpos = F(sum / i); if (pos) { maxi = max(maxi, i); } if (qpos) { maxi = max(maxi, sum / i); } } cout << maxi << endl; }
[ "variable_declaration.value.change" ]
759,319
759,320
u416273217
cpp
p02955
/// usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 510; int n, a[N], k, sum; int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d", &n, &k); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); sum += a[i]; } vector<int> v; for (int i = 2; i * i <= sum; ++i) if (sum % i == 0) { v.push_back(i); if (i * i != sum) { v.push_back(sum / i); } } int ans = 1; for (int d : v) { vector<int> x; ll s1 = 0, s2 = 0; for (int i = 0; i < n; ++i) { x.push_back(a[i] % d); s2 += d - a[i] % d; } sort(x.begin(), x.end()); for (int i = 0; i < n; ++i) { s1 += x[i]; s2 -= d - x[i]; if (s1 == s2) { if (s1 <= k) ans = max(ans, d); else break; } } } printf("%d\n", ans); }
/// usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 510; int n, a[N], k, sum; int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d", &n, &k); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); sum += a[i]; } vector<int> v; for (int i = 1; i * i <= sum; ++i) if (sum % i == 0) { v.push_back(i); if (i * i != sum) { v.push_back(sum / i); } } int ans = 1; for (int d : v) { vector<int> x; ll s1 = 0, s2 = 0; for (int i = 0; i < n; ++i) { x.push_back(a[i] % d); s2 += d - a[i] % d; } sort(x.begin(), x.end()); for (int i = 0; i < n; ++i) { s1 += x[i]; s2 -= d - x[i]; if (s1 == s2) { if (s1 <= k) ans = max(ans, d); else break; } } } printf("%d\n", ans); }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
759,323
759,324
u548415105
cpp
p02955
#include <bits/stdc++.h> using namespace std; const int N = 510; int n, k; int a[N], sum; int ans; int b[N]; bool check(int x) { for (int i = 1; i <= n; ++i) { b[i] = a[i] % x; } sort(b + 1, b + n + 1); int cnt = 0, sum = 0, r = n; for (int i = 1; i <= r; ++i) { if (!b[i]) continue; cnt += b[i]; sum += b[i]; while (sum + a[r] >= x) sum -= x - a[r], --r; } return cnt <= k; } int main() { // freopen("1.in","r",stdin); cin >> n >> k; for (int i = 1; i <= n; ++i) scanf("%d", a + i), sum += a[i]; for (int i = 1; i * i <= sum; ++i) { if (sum % i != 0) continue; if (i > ans && check(i)) ans = max(ans, i); if (sum / i > ans && check(sum / i)) ans = max(ans, sum / i); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 510; int n, k; int a[N], sum; int ans; int b[N]; bool check(int x) { for (int i = 1; i <= n; ++i) { b[i] = a[i] % x; } sort(b + 1, b + n + 1); int cnt = 0, sum = 0, r = n; for (int i = 1; i <= r; ++i) { if (!b[i]) continue; cnt += b[i]; sum += b[i]; while (sum + b[r] >= x) sum -= x - b[r], --r; } return cnt <= k; } int main() { // freopen("1.in","r",stdin); cin >> n >> k; for (int i = 1; i <= n; ++i) scanf("%d", a + i), sum += a[i]; for (int i = 1; i * i <= sum; ++i) { if (sum % i != 0) continue; if (i > ans && check(i)) ans = max(ans, i); if (sum / i > ans && check(sum / i)) ans = max(ans, sum / i); } cout << ans << endl; }
[ "identifier.change", "control_flow.loop.condition.change", "assignment.value.change", "expression.operation.binary.change" ]
759,339
759,340
u821187988
cpp
p02955
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { // freopen("in.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int A[n]; vector<int> factors; int sum = 0; for (int i = 0; i < n; ++i) { cin >> A[i]; sum += A[i]; } for (int i = 2; i * i <= sum; ++i) { if (sum % i == 0) { factors.push_back(i); factors.push_back(sum / i); } } multiset<int> s; int ans = 0; for (int j = 0; j < (int)factors.size(); ++j) { int d = factors[j]; // cout<<"d : " <<d<<endl; int totalCost = 0; s.clear(); for (int i = 0; i < n; ++i) { int mod = A[i] % d; s.insert(mod); totalCost += (d - mod); } int cnt = 0; for (auto e : s) { // cout<<e<<" "; cnt += e; totalCost -= d; if (totalCost == 0 && cnt <= k) { ans = max(ans, d); } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { // freopen("in.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int A[n]; vector<int> factors; int sum = 0; for (int i = 0; i < n; ++i) { cin >> A[i]; sum += A[i]; } for (int i = 1; i * i <= sum; ++i) { if (sum % i == 0) { factors.push_back(i); factors.push_back(sum / i); } } multiset<int> s; int ans = 0; for (int j = 0; j < (int)factors.size(); ++j) { int d = factors[j]; // cout<<"d : " <<d<<endl; int totalCost = 0; s.clear(); for (int i = 0; i < n; ++i) { int mod = A[i] % d; s.insert(mod); totalCost += (d - mod); } int cnt = 0; for (auto e : s) { // cout<<e<<" "; cnt += e; totalCost -= d; if (totalCost == 0 && cnt <= k) { ans = max(ans, d); } } } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
759,343
759,344
u781659997
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define repr(i, a, b) for (int i = a, i##_len = (b); i < i##_len; ++i) #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define irepr(i, a, b) for (int i = a, i##_len = (b); i >= i##_len; --i) #define irep(i, n) for (int i = n; i >= 0; --i) #define printline(str) cout << str << "\n" #define lint long long template <class T, std::size_t N> void printArray(T (&arr)[N], string del = {','}) { cout << arr[0]; repr(i, 1, N) { cout << del << arr[i]; } cout << "\n"; } int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } std::vector<int> divisor(int n) // nの約数を列挙 { std::vector<int> ret; ret.reserve(n / 2 + 1); for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } sort(ret.begin(), ret.end(), greater<int>()); return ret; } int main() { // cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N; cin >> K; vector<int> A(N); int sumA = 0; rep(i, N) { cin >> A[i]; sumA += A[i]; } std::sort(A.begin(), A.end(), greater<int>()); auto div = divisor(sumA); if (sumA - A[0] <= K) { printline(sumA); return 0; } for (const auto d : div) { if (sumA % d == 0) { lint inc = 0; lint dec = 0; vector<int> M(N); rep(i, N) { M[i] = A[i] % d; } sort(M.begin(), M.end(), greater<lint>()); inc += d - M[0]; repr(i, 1, N) { dec += M[i]; } if (inc == dec) { if (dec <= K) { printline(d); return 0; } } repr(i, 1, N) { inc += d - M[i]; dec -= M[i]; if (inc == dec) { if (inc <= K) { printline(d); return 0; } } } } } }
#include <bits/stdc++.h> using namespace std; #define repr(i, a, b) for (int i = a, i##_len = (b); i < i##_len; ++i) #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define irepr(i, a, b) for (int i = a, i##_len = (b); i >= i##_len; --i) #define irep(i, n) for (int i = n; i >= 0; --i) #define printline(str) cout << str << "\n" #define lint long long template <class T, std::size_t N> void printArray(T (&arr)[N], string del = {','}) { cout << arr[0]; repr(i, 1, N) { cout << del << arr[i]; } cout << "\n"; } int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } std::vector<int> divisor(int n) // nの約数を列挙 { std::vector<int> ret; ret.reserve(n / 2 + 1); for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } sort(ret.begin(), ret.end(), greater<int>()); return ret; } int main() { // cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N; cin >> K; vector<int> A(N); int sumA = 0; rep(i, N) { cin >> A[i]; sumA += A[i]; } std::sort(A.begin(), A.end(), greater<int>()); auto div = divisor(sumA); if (sumA - A[0] <= K) { printline(sumA); return 0; } for (const auto d : div) { if (sumA % d == 0) { lint inc = 0; lint dec = 0; vector<int> M(N); rep(i, N) { M[i] = A[i] % d; } sort(M.begin(), M.end(), greater<lint>()); inc += d - M[0]; repr(i, 1, N) { dec += M[i]; } if (inc == dec) { if (dec <= K) { printline(d); return 0; } } repr(i, 1, N) { inc += d - M[i]; dec -= M[i]; if (inc == dec) { if (inc <= K) { printline(d); return 0; } } } } } printline(1); }
[ "call.add" ]
759,349
759,350
u258457185
cpp
p02955
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <sstream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N, 0); for (int i = 0; i < N; ++i) { cin >> A[i]; } int total = 0; for (int i = 0; i < N; ++i) { total += A[i]; } for (int div = 1; div <= total; ++div) { if (total % div != 0) { continue; } vector<int> mod(N, 0); int num = total / div; for (int i = 0; i < N; ++i) { mod[i] = A[i] % num; } sort(mod.begin(), mod.end()); int count = 0; while (count < K) { if (mod.size() == 0) { cout << num << endl; return 0; } else if (mod[0] == 0) { mod.erase(mod.begin()); continue; } int step = min(mod[0], num - mod[mod.size() - 1]); count += step; mod[0] -= step; if (mod[0] == 0) { mod.erase(mod.begin()); } mod[mod.size() - 1] += step; if (mod[mod.size() - 1] == num) { mod.erase(mod.end() - 1); } } } cout << "1" << endl; return 0; }
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <sstream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N, 0); for (int i = 0; i < N; ++i) { cin >> A[i]; } int total = 0; for (int i = 0; i < N; ++i) { total += A[i]; } for (int div = 1; div <= total / 2; ++div) { if (total % div != 0) { continue; } vector<int> mod(N, 0); int num = total / div; for (int i = 0; i < N; ++i) { mod[i] = A[i] % num; } sort(mod.begin(), mod.end()); int count = 0; while (count <= K) { if (mod.size() == 0) { cout << num << endl; return 0; } else if (mod[0] == 0) { mod.erase(mod.begin()); continue; } int step = min(mod[0], num - mod[mod.size() - 1]); count += step; mod[0] -= step; if (mod[0] == 0) { mod.erase(mod.begin()); } mod[mod.size() - 1] += step; if (mod[mod.size() - 1] == num) { mod.erase(mod.end() - 1); } } } cout << "1" << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operator.compare.change", "control_flow.loop.condition.change" ]
759,355
759,356
u086244479
cpp
p02955
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <sstream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N, 0); for (int i = 0; i < N; ++i) { cin >> A[i]; } int total = 0; for (int i = 0; i < N; ++i) { total += A[i]; } for (int div = 1; div <= total / 2; ++div) { if (total % div != 0) { continue; } vector<int> mod(N, 0); int num = total / div; for (int i = 0; i < N; ++i) { mod[i] = A[i] % num; } sort(mod.begin(), mod.end()); int count = 0; while (count < K) { if (mod.size() == 0) { cout << num << endl; return 0; } else if (mod[0] == 0) { mod.erase(mod.begin()); continue; } int step = min(mod[0], num - mod[mod.size() - 1]); count += step; mod[0] -= step; if (mod[0] == 0) { mod.erase(mod.begin()); } mod[mod.size() - 1] += step; if (mod[mod.size() - 1] == num) { mod.erase(mod.end() - 1); } } } cout << "1" << endl; return 0; }
#include <algorithm> #include <iostream> #include <iterator> #include <map> #include <sstream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N, 0); for (int i = 0; i < N; ++i) { cin >> A[i]; } int total = 0; for (int i = 0; i < N; ++i) { total += A[i]; } for (int div = 1; div <= total / 2; ++div) { if (total % div != 0) { continue; } vector<int> mod(N, 0); int num = total / div; for (int i = 0; i < N; ++i) { mod[i] = A[i] % num; } sort(mod.begin(), mod.end()); int count = 0; while (count <= K) { if (mod.size() == 0) { cout << num << endl; return 0; } else if (mod[0] == 0) { mod.erase(mod.begin()); continue; } int step = min(mod[0], num - mod[mod.size() - 1]); count += step; mod[0] -= step; if (mod[0] == 0) { mod.erase(mod.begin()); } mod[mod.size() - 1] += step; if (mod[mod.size() - 1] == num) { mod.erase(mod.end() - 1); } } } cout << "1" << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
759,357
759,356
u086244479
cpp
p02955
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; const int MAXN = 1001000; int n; int K; int a[MAXN]; bool go(int p) { vector<int> v; int cost = 0; for (int i = 0; i < n; ++i) { int k = a[i] % p; if (k < 0) k += p; if (k == 0) continue; v.push_back(k); cost += p - k; } int cost2 = 0; if (cost2 <= K && cost < K) { return true; } sort(v.begin(), v.end()); for (int i = 0; i < v.size(); ++i) { int k = v[i]; cost -= p - k; cost2 += k; if (cost2 <= K && cost < K) { return true; } } return false; } int main() { cin >> n >> K; int sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; } int ans = 1; for (int p = 1; p <= 5E8; ++p) { if (sum % p == 0) { if (go(p)) { ans = p; } } } cout << ans << "\n"; }
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; const int MAXN = 1001000; int n; int K; int a[MAXN]; bool go(int p) { vector<int> v; long long cost = 0; for (int i = 0; i < n; ++i) { int k = a[i] % p; if (k < 0) k += p; if (k == 0) continue; v.push_back(k); cost += p - k; } long long cost2 = 0; if (cost2 <= K && cost <= K) { return true; } sort(v.begin(), v.end()); for (int i = 0; i < v.size(); ++i) { int k = v[i]; cost -= p - k; cost2 += k; if (cost2 <= K && cost <= K) { return true; } } return false; } int main() { cin >> n >> K; int sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; } int ans = 1; for (int p = 1; p <= 5E8; ++p) { if (sum % p == 0) { if (go(p)) { ans = p; } } } cout << ans << "\n"; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
759,365
759,364
u382759311
cpp
p02955
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) using ll = long long; using namespace std; ll n, k, s = 0, a[550], b[550], ans = 0; ll f(ll p) { ll s2 = 0, s3 = 0; rep(i, 0, n) { b[i] = a[i] % p; s2 += b[i]; } sort(b, b + n); rep(i, 0, n - s2 / p) s3 += b[i]; return s3 <= k ? p : 0; } int main() { cin >> n >> k; rep(i, 0, n) { cin >> a[i]; s += a[i]; } for (ll p = 1; (p * p) <= s; p++) if (s % p == 0) { ans = max(ans, f(p)); ans = max(ans, f(s / p)); cout << ans; } }
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) using ll = long long; using namespace std; ll n, k, s = 0, a[550], b[550], ans = 0; ll f(ll p) { ll s2 = 0, s3 = 0; rep(i, 0, n) { b[i] = a[i] % p; s2 += b[i]; } sort(b, b + n); rep(i, 0, n - s2 / p) s3 += b[i]; return s3 <= k ? p : 0; } int main() { cin >> n >> k; rep(i, 0, n) { cin >> a[i]; s += a[i]; } for (ll p = 1; (p * p) <= s; p++) if (s % p == 0) { ans = max(ans, f(p)); ans = max(ans, f(s / p)); } cout << ans; }
[]
759,366
759,367
u499009346
cpp
p02955
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) using ll = long long; using namespace std; ll n, k, s = 0, a[550], b[550], ans = 0; ll f(ll p) { ll s2 = 0, s3 = 0; rep(i, 0, n) { b[i] = a[i] % p; s2 += b[i]; } // s2...16行目で探索する約数pでa[i]を割ったものの和 sort(b, b + n); rep(i, 0, n - s2 / p) s3 += b [i]; // s3は操作する回数:s2/pは作る約数の数、つまりそれ以前の数まで(n-s2/p)についてb[i]を操作する if (s3 <= k) return p; // k回越えなければ返す } int main() { cin >> n >> k; rep(i, 0, n) { cin >> a[i]; s += a[i]; } // s...a[i]の和を取り、sのすべての約数について試す for (ll p = 1; (p * p) <= s; p++) if (s % p == 0) { //中央の約数は√s1よりp*p<=s前後から約数を探索 ans = max(ans, f(p)); //約数pについてk回以下で処理できるかf関数で確認 if (s % p == 0) ans = max( ans, f(s / p)); //上は√pまで、ここでは√pからsまで後ろから探索(s%pが約数となる条件) } cout << ans; }
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) using ll = long long; using namespace std; ll n, k, s = 0, a[550], b[550], ans = 0; ll f(ll p) { ll s2 = 0, s3 = 0; rep(i, 0, n) { b[i] = a[i] % p; s2 += b[i]; } // s2...16行目で探索する約数pでa[i]を割ったものの和 sort(b, b + n); rep(i, 0, n - s2 / p) s3 += b [i]; // s3は操作する回数:s2/pは作る約数の数、つまりそれ以前の数まで(n-s2/p)についてb[i]を操作する if (s3 <= k) return p; // k回越えなければ返す else return 0; } int main() { cin >> n >> k; rep(i, 0, n) { cin >> a[i]; s += a[i]; } // s...a[i]の和を取り、sのすべての約数について試す for (ll p = 1; (p * p) <= s; p++) if (s % p == 0) { //中央の約数は√s1よりp*p<=s前後から約数を探索 ans = max(ans, f(p)); //約数pについてk回以下で処理できるかf関数で確認 if (s % p == 0) ans = max( ans, f(s / p)); //上は√pまで、ここでは√pからsまで後ろから探索(s%pが約数となる条件) } cout << ans; }
[ "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "control_flow.return.add", "control_flow.return.0.add" ]
759,368
759,369
u499009346
cpp
p02955
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, K; int A[500]; cin >> N >> K; int sum = 0; for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } vector<int> factor(0); for (int p = 1; p * p <= sum; p++) { if (sum % p == 0) { factor.push_back(p); factor.push_back(sum / p); } } sort(factor.begin(), factor.end()); for (int i = factor.size() - 1; i >= 0; i--) { int k = factor[i]; vector<int> rem(0); int remsum = 0; for (int j = 0; j < N; j++) { rem.push_back(A[j] % k); remsum += A[j] % k; } sort(rem.begin(), rem.end()); int remsum_pos = 0; for (int j = 0; j < N - remsum / k; j++) remsum_pos += rem[j]; if (remsum_pos < K) { cout << k << endl; return 0; } } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, K; int A[500]; cin >> N >> K; int sum = 0; for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } vector<int> factor(0); for (int p = 1; p * p <= sum; p++) { if (sum % p == 0) { factor.push_back(p); factor.push_back(sum / p); } } sort(factor.begin(), factor.end()); for (int i = factor.size() - 1; i >= 0; i--) { int k = factor[i]; vector<int> rem(0); int remsum = 0; for (int j = 0; j < N; j++) { rem.push_back(A[j] % k); remsum += A[j] % k; } sort(rem.begin(), rem.end()); int remsum_pos = 0; for (int j = 0; j < N - remsum / k; j++) remsum_pos += rem[j]; if (remsum_pos <= K) { cout << k << endl; return 0; } } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
759,373
759,374
u798909123
cpp
p02955
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, K; int A[500]; cin >> N >> K; int sum = 0; for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } vector<int> factor(0); for (int p = 1; p * p < sum; p++) { if (sum % p == 0) { factor.push_back(p); factor.push_back(sum / p); } } sort(factor.begin(), factor.end()); for (int i = factor.size() - 1; i >= 0; i--) { int k = factor[i]; vector<int> rem(0); int remsum = 0; for (int j = 0; j < N; j++) { rem.push_back(A[j] % k); remsum += A[j] % k; } sort(rem.begin(), rem.end()); int remsum_pos = 0; for (int j = 0; j < N - remsum / k; j++) remsum_pos += rem[j]; if (remsum_pos < K) { cout << k << endl; return 0; } } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int N, K; int A[500]; cin >> N >> K; int sum = 0; for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; } vector<int> factor(0); for (int p = 1; p * p <= sum; p++) { if (sum % p == 0) { factor.push_back(p); factor.push_back(sum / p); } } sort(factor.begin(), factor.end()); for (int i = factor.size() - 1; i >= 0; i--) { int k = factor[i]; vector<int> rem(0); int remsum = 0; for (int j = 0; j < N; j++) { rem.push_back(A[j] % k); remsum += A[j] % k; } sort(rem.begin(), rem.end()); int remsum_pos = 0; for (int j = 0; j < N - remsum / k; j++) remsum_pos += rem[j]; if (remsum_pos <= K) { cout << k << endl; return 0; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
759,375
759,374
u798909123
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define maxn 100005 int a[maxn], n, k, b[maxn]; bool check(int x) { for (int i = 0; i < n; i++) { b[i] = a[i] % x; } sort(b, b + n); int w = 0, i; for (i = 0; i < n; i++) { w += x - b[i]; if (w > k) break; } for (w = 0; i < n; i++) { w += b[i]; if (w > k) return 0; } return 1; } int main() { int sum = 0, x; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", a + i), sum += a[i]; x = sqrt(sum); for (int i = 1; i <= x; i++) { if (sum % i == 0) { if (check(sum / i)) { printf("%d\n", sum / i); return 0; } } } for (int i = sqrt(sum); i >= 1; i--) { if (sum % i == 0) { if (check(i)) { printf("%d\n", i); return 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; #define maxn 100005 int a[maxn], n, k, b[maxn]; bool check(int x) { for (int i = 0; i < n; i++) { b[i] = a[i] % x; } sort(b, b + n); int w = 0, i; for (i = 0; i < n; i++) { w += b[i]; if (w > k) break; } for (w = 0; i < n; i++) { w += x - b[i]; if (w > k) return 0; } return 1; } int main() { int sum = 0, x; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", a + i), sum += a[i]; x = sqrt(sum); for (int i = 1; i <= x; i++) { if (sum % i == 0) { if (check(sum / i)) { printf("%d\n", sum / i); return 0; } } } for (int i = sqrt(sum); i >= 1; i--) { if (sum % i == 0) { if (check(i)) { printf("%d\n", i); return 0; } } } return 0; }
[ "expression.operation.binary.remove", "assignment.change" ]
759,378
759,379
u518028964
cpp
p02955
#include <bits/stdc++.h> #define REP(i, x, n) for (int i = x; i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)(x.size()) #define popcount(x) __builtin_popcount(x) #define popcountll(x) __builtin_popcountll(x) #define uniq(x) x.erase(unique(x.begin(), x.end()), x.end()) #define F first #define S second #define mp make_pair #define eb emplace_back #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; typedef long long ll; /* --- INFの値が適切か確認する --- */ // const int INF = 1 << 30; // const ll INF = 1LL << 60; // const int MOD = 1000000007; int main() { ll N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; int sum = 0; rep(i, N) sum += A[i]; vector<int> d; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { d.eb(i); if (sum / i != i) { d.eb(sum / i); } } } sort(rall(d)); rep(i, sz(d)) { int mod = d[i]; vector<int> a = A; rep(j, sz(a)) a[i] %= mod; sort(all(a)); ll m = 0, p = 0; rep(j, sz(a)) p += (mod - a[j]); rep(j, sz(a)) { m += a[j]; p -= (mod - a[j]); if (m == p && m <= K) { cout << mod << endl; return 0; } } } cout << "-1" << endl; }
#include <bits/stdc++.h> #define REP(i, x, n) for (int i = x; i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)(x.size()) #define popcount(x) __builtin_popcount(x) #define popcountll(x) __builtin_popcountll(x) #define uniq(x) x.erase(unique(x.begin(), x.end()), x.end()) #define F first #define S second #define mp make_pair #define eb emplace_back #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; typedef long long ll; /* --- INFの値が適切か確認する --- */ // const int INF = 1 << 30; // const ll INF = 1LL << 60; // const int MOD = 1000000007; int main() { ll N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; int sum = 0; rep(i, N) sum += A[i]; vector<int> d; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { d.eb(i); if (sum / i != i) { d.eb(sum / i); } } } sort(rall(d)); rep(i, sz(d)) { int mod = d[i]; vector<int> a = A; rep(j, sz(a)) a[j] %= mod; sort(all(a)); ll m = 0, p = 0; rep(j, sz(a)) p += (mod - a[j]); rep(j, sz(a)) { m += a[j]; p -= (mod - a[j]); if (m == p && m <= K) { cout << mod << endl; return 0; } } } cout << "-1" << endl; }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
759,380
759,381
u267022560
cpp
p02955
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using LL = long long; int N; LL K; LL A[1234]; LL R[1234]; bool ok(LL x) { for (int i = 0; i < N; ++i) { R[i] = A[i] % x; } LL wrap = 0; for (int i = 0; i < N; ++i) { wrap += R[i]; } wrap /= x; sort(R, R + N); for (int i = N - 1; i >= 0; --i) { while (wrap > 0) { wrap--; R[i] -= x; } } LL can = 0; for (int i = 0; i < N; ++i) { can += max(0LL, R[i]); } return can <= K; } int main() { cin >> N >> K; LL total = 0; for (int i = 0; i < N; i++) { cin >> A[i]; total += A[i]; } set<LL> yak; for (LL i = 1; i * i <= total; ++i) { if (total % i == 0) { yak.insert(i); yak.insert(total / i); } } LL ans = 1; for (LL y : yak) { if (ok(y)) { ans = max(ans, y); } } cout << ans << endl; return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using LL = long long; int N; LL K; LL A[1234]; LL R[1234]; bool ok(LL x) { for (int i = 0; i < N; ++i) { R[i] = A[i] % x; } LL wrap = 0; for (int i = 0; i < N; ++i) { wrap += R[i]; } wrap /= x; sort(R, R + N); for (int i = N - 1; i >= 0; --i) { if (wrap > 0) { wrap--; R[i] -= x; } } LL can = 0; for (int i = 0; i < N; ++i) { can += max(0LL, R[i]); } return can <= K; } int main() { cin >> N >> K; LL total = 0; for (int i = 0; i < N; i++) { cin >> A[i]; total += A[i]; } set<LL> yak; for (LL i = 1; i * i <= total; ++i) { if (total % i == 0) { yak.insert(i); yak.insert(total / i); } } LL ans = 1; for (LL y : yak) { if (ok(y)) { ans = max(ans, y); } } cout << ans << endl; return 0; }
[ "control_flow.branch.while.replace.add", "control_flow.loop.if.replace.remove" ]
759,384
759,385
u558671021
cpp
p02941
#include <bits/stdc++.h> using namespace std; typedef long long ll; void DC() { cout << -1 << endl; } int main() { int N; cin >> N; ll cnt = 0; vector<ll> A(N); vector<ll> B(N); priority_queue<pair<ll, int>> Q; for (int i = 0; i < N; i++) { cin >> B[i]; } for (int j = 0; j < N; j++) { cin >> A[j]; Q.push(make_pair(A[j], j)); } while (!Q.empty()) { ll p = Q.top().first; int b = Q.top().second; Q.pop(); if (p == B[b]) { continue; } if (p < B[b]) { DC(); return 0; } int a, c; if (b == 0) { a = N - 1; } else { a = b - 1; } if (b == N - 1) { c = 0; } else { c = b + 1; } if (A[b] < A[a] + A[c]) { DC(); return 0; } if (A[b] % (A[a] + A[c]) >= B[b]) { cnt += A[b] / (A[a] + A[c]); Q.push(make_pair(A[b] / (A[a] + A[c]), b)); A[b] = A[b] % (A[a] + A[c]); } else { ll res = A[b] - ((A[b] - B[b]) / (A[a] + A[c])) * (A[a] + A[c]); if (res == A[b]) { DC(); return 0; } cnt += (A[b] - B[b]) / (A[a] + A[c]); Q.push(make_pair(res, b)); A[b] = res; } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; void DC() { cout << -1 << endl; } int main() { int N; cin >> N; ll cnt = 0; vector<ll> A(N); vector<ll> B(N); priority_queue<pair<ll, int>> Q; for (int i = 0; i < N; i++) { cin >> B[i]; } for (int j = 0; j < N; j++) { cin >> A[j]; Q.push(make_pair(A[j], j)); } while (!Q.empty()) { ll p = Q.top().first; int b = Q.top().second; Q.pop(); if (p == B[b]) { continue; } if (p < B[b]) { DC(); return 0; } int a, c; if (b == 0) { a = N - 1; } else { a = b - 1; } if (b == N - 1) { c = 0; } else { c = b + 1; } if (A[b] < A[a] + A[c]) { DC(); return 0; } if (A[b] % (A[a] + A[c]) >= B[b]) { cnt += A[b] / (A[a] + A[c]); Q.push(make_pair(A[b] % (A[a] + A[c]), b)); A[b] = A[b] % (A[a] + A[c]); } else { ll res = A[b] - ((A[b] - B[b]) / (A[a] + A[c])) * (A[a] + A[c]); if (res == A[b]) { DC(); return 0; } cnt += (A[b] - B[b]) / (A[a] + A[c]); Q.push(make_pair(res, b)); A[b] = res; } } cout << cnt << endl; return 0; }
[ "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
759,477
759,478
u904123392
cpp
p02941
#include <bits/stdc++.h> using namespace std; typedef long long ll; void DC() { cout << -1 << endl; } int main() { int N; cin >> N; ll cnt = 0; vector<ll> A(N); vector<ll> B(N); priority_queue<pair<ll, int>> Q; for (int i = 0; i < N; i++) { cin >> B[i]; } for (int j = 0; j < N; j++) { cin >> A[j]; Q.push(make_pair(A[j], j)); } while (!Q.empty()) { ll p = Q.top().first; int b = Q.top().second; Q.pop(); if (p == B[b]) { continue; } if (p < B[b]) { DC(); return 0; } int a, c; if (b == 0) { a = N - 1; } else { a = b - 1; } if (b == N - 1) { c = 0; } else { c == b + 1; } if (A[b] < A[a] + A[c]) { DC(); return 0; } if (A[b] % (A[a] + A[c]) >= B[b]) { cnt += A[b] / (A[a] + A[c]); Q.push(make_pair(A[b] / (A[a] + A[c]), b)); A[b] = A[b] % (A[a] + A[c]); } else { ll res = A[b] - (A[b] - B[b]) / (A[a] + A[c]) * (A[a] + A[c]); if (res == A[b]) { DC(); return 0; } cnt += (A[b] - B[b]) / (A[a] + A[c]); Q.push(make_pair(res, b)); A[b] = res; } } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; void DC() { cout << -1 << endl; } int main() { int N; cin >> N; ll cnt = 0; vector<ll> A(N); vector<ll> B(N); priority_queue<pair<ll, int>> Q; for (int i = 0; i < N; i++) { cin >> B[i]; } for (int j = 0; j < N; j++) { cin >> A[j]; Q.push(make_pair(A[j], j)); } while (!Q.empty()) { ll p = Q.top().first; int b = Q.top().second; Q.pop(); if (p == B[b]) { continue; } if (p < B[b]) { DC(); return 0; } int a, c; if (b == 0) { a = N - 1; } else { a = b - 1; } if (b == N - 1) { c = 0; } else { c = b + 1; } if (A[b] < A[a] + A[c]) { DC(); return 0; } if (A[b] % (A[a] + A[c]) >= B[b]) { cnt += A[b] / (A[a] + A[c]); Q.push(make_pair(A[b] % (A[a] + A[c]), b)); A[b] = A[b] % (A[a] + A[c]); } else { ll res = A[b] - ((A[b] - B[b]) / (A[a] + A[c])) * (A[a] + A[c]); if (res == A[b]) { DC(); return 0; } cnt += (A[b] - B[b]) / (A[a] + A[c]); Q.push(make_pair(res, b)); A[b] = res; } } cout << cnt << endl; return 0; }
[ "expression.operation.compare.replace.remove", "assignment.replace.add", "misc.typo", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
759,479
759,478
u904123392
cpp
p02941
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fs first #define fst first #define sc second #define snd second #define sz(X) (int)(X).size() #define forn(i, n) for (int i = 0; i < int(n); i++) #define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--) #define forab(i, a, b) for (int i = int(a); i < int(b); i++) #define all(X) X.begin(), X.end() typedef long long ll; typedef pair<int, int> pii; typedef unsigned int uint; typedef unsigned long long ull; typedef double dbl; typedef long double ld; typedef vector<int> vi; const int N = 1e6; const int LOG = 21; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LLMOD = 998244353; const ll LLINF = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vi a(n), b(n); forn(i, n) cin >> a[i]; forn(i, n) cin >> b[i]; set<pii> q; forn(i, n) q.insert({b[i], i}); ll ans = 0; while (!q.empty()) { int i = q.rbegin()->second; q.erase(*q.rbegin()); int neighbors = b[(i + n - 1) % n] + b[(i + 1) % n]; int d = b[i] - a[i]; if (d % neighbors == 0) { ans += d / neighbors; b[i] = a[i]; } else { if (neighbors >= b[i]) { cout << "a-1\n"; return 0; } ans += b[i] / neighbors; b[i] %= neighbors; if (b[i] < a[i]) { cout << "b-1\n"; return 0; } q.insert({b[i], i}); } } cout << ans << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fs first #define fst first #define sc second #define snd second #define sz(X) (int)(X).size() #define forn(i, n) for (int i = 0; i < int(n); i++) #define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--) #define forab(i, a, b) for (int i = int(a); i < int(b); i++) #define all(X) X.begin(), X.end() typedef long long ll; typedef pair<int, int> pii; typedef unsigned int uint; typedef unsigned long long ull; typedef double dbl; typedef long double ld; typedef vector<int> vi; const int N = 1e6; const int LOG = 21; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LLMOD = 998244353; const ll LLINF = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vi a(n), b(n); forn(i, n) cin >> a[i]; forn(i, n) cin >> b[i]; set<pii> q; forn(i, n) q.insert({b[i], i}); ll ans = 0; while (!q.empty()) { int i = q.rbegin()->second; q.erase(*q.rbegin()); int neighbors = b[(i + n - 1) % n] + b[(i + 1) % n]; int d = b[i] - a[i]; if (d % neighbors == 0) { ans += d / neighbors; b[i] = a[i]; } else { if (neighbors >= b[i]) { cout << "-1\n"; return 0; } ans += b[i] / neighbors; b[i] %= neighbors; if (b[i] < a[i]) { cout << "-1\n"; return 0; } q.insert({b[i], i}); } } cout << ans << "\n"; return 0; }
[ "literal.string.change", "io.output.change" ]
759,480
759,481
u711540245
cpp
p02941
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; int a[maxn], b[maxn], n; priority_queue<pair<int, int>> s; long long ans = 0; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { scanf("%d", &b[i]); s.push({b[i], i}); } int l, r; while (!s.empty()) { auto it = s.top(); if (it.first == a[it.second]) { s.pop(); continue; } int l = ((it.second) - 1); if (l < 0) l = n - 1; int r = (l + 2); if (r >= n) l -= n; int sum = (b[l] + b[r]); if (b[it.second] < sum || b[it.second] - sum < a[it.second]) { return !printf("-1"); } if (a[it.second] > sum) { if ((b[it.second] - a[it.second]) % sum) return !printf("-1"); ans += (b[it.second] - a[it.second]) / sum; b[it.second] = a[it.second]; s.pop(); continue; } /// find the first number that is in form of /// b-sum*k<=sum sum*(k+1)>=b int cur = b[it.second] / sum - (b[it.second] % sum == 0 ? 1 : 0); b[it.second] -= sum * cur; ans += cur; s.pop(); s.push({b[it.second], it.second}); } printf("%lld\n", ans); } /* Good Luck -Lucina */
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; int a[maxn], b[maxn], n; priority_queue<pair<int, int>> s; long long ans; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { scanf("%d", &b[i]); s.push({b[i], i}); } int l, r; while (!s.empty()) { auto it = s.top(); if (it.first == a[it.second]) { s.pop(); continue; } int l = ((it.second) - 1); if (l < 0) l = n - 1; int r = (l + 2); if (r >= n) r -= n; int sum = (b[l] + b[r]); if (b[it.second] < sum || b[it.second] - sum < a[it.second]) { return !printf("-1"); } if (a[it.second] > sum) { if ((b[it.second] - a[it.second]) % sum) return !printf("-1"); ans += (b[it.second] - a[it.second]) / sum; b[it.second] = a[it.second]; s.pop(); continue; } /// find the first number that is in form of /// b-sum*k<=sum sum*(k+1)>=b int cur = b[it.second] / sum - (b[it.second] % sum == 0 ? 1 : 0); b[it.second] -= sum * cur; ans += cur; s.pop(); s.push({b[it.second], it.second}); } printf("%lld\n", ans); } /* Good Luck -Lucina */
[ "assignment.variable.change", "identifier.change" ]
759,551
759,552
u047398677
cpp
p02941
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> #define int long long #define inf 1000000007 #define pa pair<int, int> #define ll long long #define pal pair<double, double> #define ppap pair<pa, int> #define PI 3.14159265358979323846 #define paa pair<int, char> #define mp make_pair #define pb push_back #define EPS (1e-8) int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dy[8] = {1, 0, -1, 0, -1, 1, 1, -1}; using namespace std; class pa3 { public: int x; int y, z; pa3(int x = 0, int y = 0, int z = 0) : x(x), y(y), z(z) {} bool operator<(const pa3 &p) const { if (x != p.x) return x < p.x; if (y != p.y) return y < p.y; return z < p.z; // return x != p.x ? x<p.x: y<p.y; } bool operator>(const pa3 &p) const { if (x != p.x) return x > p.x; if (y != p.y) return y > p.y; return z > p.z; // return x != p.x ? x<p.x: y<p.y; } bool operator==(const pa3 &p) const { return x == p.x && y == p.y && z == p.z; } bool operator!=(const pa3 &p) const { return !(x == p.x && y == p.y && z == p.z); } }; class pa4 { public: int x; int y, z, w; pa4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), y(y), z(z), w(w) {} bool operator<(const pa4 &p) const { if (x != p.x) return x < p.x; if (y != p.y) return y < p.y; if (z != p.z) return z < p.z; return w < p.w; // return x != p.x ? x<p.x: y<p.y; } bool operator>(const pa4 &p) const { if (x != p.x) return x > p.x; if (y != p.y) return y > p.y; if (z != p.z) return z > p.z; return w > p.w; // return x != p.x ? x<p.x: y<p.y; } bool operator==(const pa4 &p) const { return x == p.x && y == p.y && z == p.z && w == p.w; } }; class pa2 { public: int x, y; pa2(int x = 0, int y = 0) : x(x), y(y) {} pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); } pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); } bool operator<(const pa2 &p) const { return y != p.y ? y < p.y : x < p.x; } bool operator>(const pa2 &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const pa2 &p) const { return abs(x - p.x) == 0 && abs(y - p.y) == 0; } bool operator!=(const pa2 &p) const { return !(abs(x - p.x) == 0 && abs(y - p.y) == 0); } }; string itos(int i) { ostringstream s; s << i; return s.str(); } int gcd(int v, int b) { if (v > b) return gcd(b, v); if (v == b) return b; if (b % v == 0) return v; return gcd(v, b % v); } int mod; int extgcd(int a, int b, int &x, int &y) { if (b == 0) { x = 1; y = 0; return a; } int d = extgcd(b, a % b, y, x); y -= a / b * x; return d; } pa operator+(const pa &l, const pa &r) { return {l.first + r.first, l.second + r.second}; } pa operator-(const pa &l, const pa &r) { return {l.first - r.first, l.second - r.second}; } int pr[1000010]; int inv[1000010]; int beki(int wa, int rr, int warukazu) { if (rr == 0) return 1 % warukazu; if (rr == 1) return wa % warukazu; wa %= warukazu; if (rr % 2 == 1) return ((ll)beki(wa, rr - 1, warukazu) * (ll)wa) % warukazu; ll zx = beki(wa, rr / 2, warukazu); return (zx * zx) % warukazu; } int comb(int nn, int rr) { if (rr < 0 || rr > nn || nn < 0) return 0; int r = pr[nn] * inv[rr]; r %= mod; r *= inv[nn - rr]; r %= mod; return r; } void gya(int ert) { pr[0] = 1; for (int i = 1; i <= ert; i++) { pr[i] = (pr[i - 1] * i) % mod; } inv[ert] = beki(pr[ert], mod - 2, mod); for (int i = ert - 1; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % mod; } } // cin.tie(0); // ios::sync_with_stdio(false); // priority_queue<pa3,vector<pa3>,greater<pa3>> pq; // sort(ve.begin(),ve.end(),greater<int>()); // mt19937(clock_per_sec); // mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ; //----------------kokomade tenpure------------ priority_queue<pa> pq; bool sumi[200020] = {}; signed main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n), b(b); vector<int> ve(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { cin >> b[i]; pq.push(mp(b[i], i)); } int ans = 0; while (pq.size()) { pa z = pq.top(); pq.pop(); int id = z.second; int val = z.first; if (b[id] == a[id]) { sumi[id] = 1; continue; } if (b[id] < a[id]) { cout << -1 << endl; return 0; continue; } int mae = id - 1; int ato = id + 1; if (mae == -1) mae = n - 1; if (ato == n) ato = 0; if (b[mae] + b[ato] >= b[id]) { cout << -1 << endl; return 0; } int moku = max(a[id], b[id] % (b[mae] + b[ato])); int sa = b[id] - moku; int g = sa / (b[mae] + b[ato]); if (g == 0) { cout << -1 << endl; return 0; } b[id] -= g * (b[mae] + b[ato]); ans += g; pq.push(mp(b[id], id)); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> #define int long long #define inf 1000000007 #define pa pair<int, int> #define ll long long #define pal pair<double, double> #define ppap pair<pa, int> #define PI 3.14159265358979323846 #define paa pair<int, char> #define mp make_pair #define pb push_back #define EPS (1e-8) int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dy[8] = {1, 0, -1, 0, -1, 1, 1, -1}; using namespace std; class pa3 { public: int x; int y, z; pa3(int x = 0, int y = 0, int z = 0) : x(x), y(y), z(z) {} bool operator<(const pa3 &p) const { if (x != p.x) return x < p.x; if (y != p.y) return y < p.y; return z < p.z; // return x != p.x ? x<p.x: y<p.y; } bool operator>(const pa3 &p) const { if (x != p.x) return x > p.x; if (y != p.y) return y > p.y; return z > p.z; // return x != p.x ? x<p.x: y<p.y; } bool operator==(const pa3 &p) const { return x == p.x && y == p.y && z == p.z; } bool operator!=(const pa3 &p) const { return !(x == p.x && y == p.y && z == p.z); } }; class pa4 { public: int x; int y, z, w; pa4(int x = 0, int y = 0, int z = 0, int w = 0) : x(x), y(y), z(z), w(w) {} bool operator<(const pa4 &p) const { if (x != p.x) return x < p.x; if (y != p.y) return y < p.y; if (z != p.z) return z < p.z; return w < p.w; // return x != p.x ? x<p.x: y<p.y; } bool operator>(const pa4 &p) const { if (x != p.x) return x > p.x; if (y != p.y) return y > p.y; if (z != p.z) return z > p.z; return w > p.w; // return x != p.x ? x<p.x: y<p.y; } bool operator==(const pa4 &p) const { return x == p.x && y == p.y && z == p.z && w == p.w; } }; class pa2 { public: int x, y; pa2(int x = 0, int y = 0) : x(x), y(y) {} pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); } pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); } bool operator<(const pa2 &p) const { return y != p.y ? y < p.y : x < p.x; } bool operator>(const pa2 &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const pa2 &p) const { return abs(x - p.x) == 0 && abs(y - p.y) == 0; } bool operator!=(const pa2 &p) const { return !(abs(x - p.x) == 0 && abs(y - p.y) == 0); } }; string itos(int i) { ostringstream s; s << i; return s.str(); } int gcd(int v, int b) { if (v > b) return gcd(b, v); if (v == b) return b; if (b % v == 0) return v; return gcd(v, b % v); } int mod; int extgcd(int a, int b, int &x, int &y) { if (b == 0) { x = 1; y = 0; return a; } int d = extgcd(b, a % b, y, x); y -= a / b * x; return d; } pa operator+(const pa &l, const pa &r) { return {l.first + r.first, l.second + r.second}; } pa operator-(const pa &l, const pa &r) { return {l.first - r.first, l.second - r.second}; } int pr[1000010]; int inv[1000010]; int beki(int wa, int rr, int warukazu) { if (rr == 0) return 1 % warukazu; if (rr == 1) return wa % warukazu; wa %= warukazu; if (rr % 2 == 1) return ((ll)beki(wa, rr - 1, warukazu) * (ll)wa) % warukazu; ll zx = beki(wa, rr / 2, warukazu); return (zx * zx) % warukazu; } int comb(int nn, int rr) { if (rr < 0 || rr > nn || nn < 0) return 0; int r = pr[nn] * inv[rr]; r %= mod; r *= inv[nn - rr]; r %= mod; return r; } void gya(int ert) { pr[0] = 1; for (int i = 1; i <= ert; i++) { pr[i] = (pr[i - 1] * i) % mod; } inv[ert] = beki(pr[ert], mod - 2, mod); for (int i = ert - 1; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1) % mod; } } // cin.tie(0); // ios::sync_with_stdio(false); // priority_queue<pa3,vector<pa3>,greater<pa3>> pq; // sort(ve.begin(),ve.end(),greater<int>()); // mt19937(clock_per_sec); // mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()) ; //----------------kokomade tenpure------------ priority_queue<pa> pq; bool sumi[200020] = {}; signed main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n), b(n); vector<int> ve(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { cin >> b[i]; pq.push(mp(b[i], i)); } int ans = 0; while (pq.size()) { pa z = pq.top(); pq.pop(); int id = z.second; int val = z.first; if (b[id] == a[id]) { sumi[id] = 1; continue; } if (b[id] < a[id]) { cout << -1 << endl; return 0; continue; } int mae = id - 1; int ato = id + 1; if (mae == -1) mae = n - 1; if (ato == n) ato = 0; if (b[mae] + b[ato] >= b[id]) { cout << -1 << endl; return 0; } int moku = max(a[id], b[id] % (b[mae] + b[ato])); int sa = b[id] - moku; int g = sa / (b[mae] + b[ato]); // cout<<g<<endl; if (g == 0) { cout << -1 << endl; return 0; } b[id] -= g * (b[mae] + b[ato]); ans += g; pq.push(mp(b[id], id)); } cout << ans << endl; return 0; }
[]
759,585
759,586
u834777932
cpp
p02955
#include <bits/stdc++.h> #define ls(x) (x) << 1 #define rs(x) (x) << 1 | 1 #define lson l, m, rt << 1 #define rson m + 1, r, rt << 1 | 1 #define ll rt << 1 #define rr rt << 1 | 1 #define PI acos(-1) //#define MM int m=(l+r)>>1; #define fu(i, r, t) for (int i = r; i <= t; i++) #define fd(i, r, t) for (int i = r; i >= t; i--) #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define endl '\n' #define lcm(a, b) (a * b) / __gcd(a, b) #define Case(i, ans) cout << "Case " << i << ": " << ans << endl; #define cp(i, ans) printf("%.if", ans); #define cpp(i, ans) cout << setprecision(i) << fixed << ans << endl; #define ppb pop_back #define ppf pop_front #define pb push_back #define pf push_front #define pq priority_queue #define lowbit(x) (x) & (-x) #define all(V) V.begin(), V.end() #define ms multiset #define mod(x) (x + mo_num) % mo_num #define vc vector #define vct vector<int> #define fa(i, V) for (auto i : V) #define out(i) cout << (i) << endl; #define fi first #define se second #define fun(i) fu(i, 1, n) #define fut(i) fu(i, 1, t) #define fum(i) fu(i, 1, m) #define ld long double //#define P pair<int,int> using namespace std; const int INF = LLONG_MAX; const int maxn = 1e5 + 5; const int mo_num = 1e9 + 7; int n, m, a[maxn], b[maxn]; int c[maxn]; bool check(int ans) { int plus = 0; int M = m; fu(i, 1, n) c[i] = a[i] % ans; sort(c + 1, c + 1 + n); int l = 1, r = n; while (l < r) { plus += c[l]; M -= c[l]; l++; if (M < 0) return 0; while (plus + c[r] >= ans) { r--; plus -= (ans - c[r]); } } return 1; } int32_t main() { IOS cin >> n >> m; int sum = 0; fun(i) { cin >> a[i]; sum += a[i]; } int ans = 0; int t = sqrt(sum); for (int i = 1; i * i <= sum; i++) { if (sum % i) continue; if (check(sum / i)) { return cout << sum / i, 0; } else if (check(i)) ans = max(ans, sum / i); } cout << ans; return 0; }
#include <bits/stdc++.h> #define ls(x) (x) << 1 #define rs(x) (x) << 1 | 1 #define lson l, m, rt << 1 #define rson m + 1, r, rt << 1 | 1 #define ll rt << 1 #define rr rt << 1 | 1 #define PI acos(-1) //#define MM int m=(l+r)>>1; #define fu(i, r, t) for (int i = r; i <= t; i++) #define fd(i, r, t) for (int i = r; i >= t; i--) #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define endl '\n' #define lcm(a, b) (a * b) / __gcd(a, b) #define Case(i, ans) cout << "Case " << i << ": " << ans << endl; #define cp(i, ans) printf("%.if", ans); #define cpp(i, ans) cout << setprecision(i) << fixed << ans << endl; #define ppb pop_back #define ppf pop_front #define pb push_back #define pf push_front #define pq priority_queue #define lowbit(x) (x) & (-x) #define all(V) V.begin(), V.end() #define ms multiset #define mod(x) (x + mo_num) % mo_num #define vc vector #define vct vector<int> #define fa(i, V) for (auto i : V) #define out(i) cout << (i) << endl; #define fi first #define se second #define fun(i) fu(i, 1, n) #define fut(i) fu(i, 1, t) #define fum(i) fu(i, 1, m) #define ld long double //#define P pair<int,int> using namespace std; const int INF = LLONG_MAX; const int maxn = 1e5 + 5; const int mo_num = 1e9 + 7; int n, m, a[maxn], b[maxn]; int c[maxn]; bool check(int ans) { int plus = 0; int M = m; fu(i, 1, n) c[i] = a[i] % ans; sort(c + 1, c + 1 + n); int l = 1, r = n; while (l < r) { plus += c[l]; M -= c[l]; l++; if (M < 0) return 0; while (plus + c[r] >= ans) { r--; plus -= (ans - c[r]); } } return 1; } int32_t main() { IOS cin >> n >> m; int sum = 0; fun(i) { cin >> a[i]; sum += a[i]; } int ans = 0; int t = sqrt(sum); for (int i = 1; i * i <= sum; i++) { if (sum % i) continue; if (check(sum / i)) { return cout << sum / i, 0; } else if (check(i)) ans = max(ans, i); } cout << ans; return 0; }
[ "expression.operation.binary.remove" ]
759,595
759,596
u020160935
cpp
p02955
#include <bits/stdc++.h> using namespace std; int n, k, a[510], tmp[510], r[510], l[510], sum, av, ans = 0; bool check(int num) { for (int i = 1; i <= n; ++i) tmp[i] = a[i] % num; sort(tmp + 1, tmp + n + 1); for (int i = 1; i <= n; ++i) l[i] = l[i - 1] + tmp[i]; for (int i = n; i >= 1; --i) r[i] = r[i + 1] + (num - tmp[i]); for (int i = 1; i < n; ++i) if (l[i] == r[i + 1] && l[i] <= k) return true; return false; } int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); sum += a[i]; } for (int i = 1; i * i <= sum; ++i) if (sum % i == 0) { if (check(i)) ans = max(ans, i); if (check(sum / i)) ans = max(ans, sum / i); } printf("%d", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, k, a[510], tmp[510], r[510], l[510], sum, ans = 1; bool check(int num) { for (int i = 1; i <= n; ++i) tmp[i] = a[i] % num; sort(tmp + 1, tmp + n + 1); for (int i = 1; i <= n; ++i) l[i] = l[i - 1] + tmp[i]; for (int i = n; i >= 1; --i) r[i] = r[i + 1] + (num - tmp[i]); for (int i = 1; i < n; ++i) if (l[i] == r[i + 1] && l[i] <= k) return true; return false; } int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); sum += a[i]; } for (int i = 1; i * i <= sum; ++i) if (sum % i == 0) { if (check(i)) ans = max(ans, i); if (check(sum / i)) ans = max(ans, sum / i); } printf("%d", ans); return 0; }
[ "variable_declaration.remove", "literal.number.change", "variable_declaration.value.change" ]
759,599
759,600
u573810484
cpp
p02955
#include <bits/stdc++.h> using namespace std; int n, k, s, a[1000], t[1000]; int ok(int x) { int tmp = 0; for (int i = 0; i < n; i++) { t[i] = a[i] % x; tmp += t[i]; } sort(t, t + n); int xxx = 0; for (int i = 0; i < n - 1 - tmp / x; i++) { xxx += t[i]; } return xxx <= k ? x : 0; } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } int ans = 1; for (int i = 1; i * i <= s; i++) { if (s % i == 0) { ans = max(ans, ok(i)); ans = max(ans, ok(s / i)); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, k, s, a[1000], t[1000]; int ok(int x) { int tmp = 0; for (int i = 0; i < n; i++) { t[i] = a[i] % x; tmp += t[i]; } sort(t, t + n); int xxx = 0; for (int i = 0; i < n - tmp / x; i++) { xxx += t[i]; } return xxx <= k ? x : 0; } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } int ans = 1; for (int i = 1; i * i <= s; i++) { if (s % i == 0) { ans = max(ans, ok(i)); ans = max(ans, ok(s / i)); } } cout << ans << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
759,603
759,604
u832527250
cpp
p02955
#include <algorithm> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; typedef long long ll; const int INF = 1 << 30; const ll MOD = 1e9 + 7; const double EPS = 1e-9; int main(int argc, const char *argv[]) { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; vector<int> divs; int Asum = accumulate(A.begin(), A.end(), 0); for (int i = 1; i * i <= Asum; i++) { if (Asum % i == 0) { divs.push_back(i); if (i * i != Asum) divs.push_back(Asum / i); } } int Rsum, ans, minKforD, r; vector<int> R; for (auto d : divs) { for (auto a : A) R.push_back(a % d); sort(R.begin(), R.end(), greater<int>()); Rsum = accumulate(R.begin(), R.end(), 0); r = Rsum / d; minKforD = 0; for (int i = 0; i < r; i++) { // R[i] != 0 の個数はr以上あるので考えなくていい minKforD += d - R[i]; } if (minKforD <= K) ans = max(ans, d); R.clear(); } cout << ans << endl; return 0; }
#include <algorithm> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; typedef long long ll; const int INF = 1 << 30; const ll MOD = 1e9 + 7; const double EPS = 1e-9; int main(int argc, const char *argv[]) { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; vector<int> divs; int Asum = accumulate(A.begin(), A.end(), 0); for (int i = 1; i * i <= Asum; i++) { if (Asum % i == 0) { divs.push_back(i); if (i * i != Asum) divs.push_back(Asum / i); } } int Rsum, ans, minKforD, r; ans = 1; vector<int> R; for (auto d : divs) { for (auto a : A) R.push_back(a % d); sort(R.begin(), R.end(), greater<int>()); Rsum = accumulate(R.begin(), R.end(), 0); r = Rsum / d; minKforD = 0; for (int i = 0; i < r; i++) { // R[i] != 0 の個数はr以上あるので考えなくていい minKforD += d - R[i]; } if (minKforD <= K) ans = max(ans, d); R.clear(); } cout << ans << endl; return 0; }
[ "assignment.add" ]
759,610
759,611
u320491590
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define ll long long //#define TEST /* kの約数を求める. 時間計算量O(√k) */ vector<ll> divisor(ll k) { vector<ll> d; for (ll i = 1; i * i <= k; ++i) { if (k % i == 0) { d.push_back(i); if (i * i != k) d.push_back(k / i); } } sort(d.begin(), d.end()); return d; } signed main() { int n, k; cin >> n >> k; ll *a = new ll[n]; for (int i = 0; i < n; ++i) cin >> a[i]; ll sum_a = accumulate(a, a + n, 0); // aの合計 /* sum_aの正の約数をすべて求める. */ auto ds = divisor(sum_a); /* dsの確認(TEST時のみ) */ #ifdef TEST cout << "-------ds-------" << endl; for (auto d : ds) cout << d << " "; cout << endl; #endif /* sum_aの正の約数dについて、 1. 各a[i]について、最低いくら加算するとdの倍数になるか求める 2. 1の結果をb[i]として、配列bをソート 3. 配列bの累積和を求める 4. 3を利用しながら、 b[0]+b[1]+...b[i]=d*(n-i-1)-(b[i+1]+b[i+2]+...+b[n-1]) かつ b[0]+b[1]+...+b[i]<=k なるiが存在するか調べる を、dが大きい方から実行する. 4の結果存在するならばそのdが求める答え. */ for (int j = ds.size() - 1; j >= 0; --j) { ll d = ds[j]; #ifdef TEST cout << "-------d=" << d << "------" << endl; #endif /* 上記の1 */ vector<ll> b; for (int i = 0; i < n; ++i) { b.push_back((d - (a[i] % d)) % d); } /* 上記の2 */ sort(b.begin(), b.end()); #ifdef TEST cout << "b" << endl << " "; for (auto bi : b) cout << bi << " "; cout << endl; #endif /* 上記の3 */ ll *sum = new ll[n + 1]; sum[0] = 0; for (int i = 0; i < n; ++i) { sum[i + 1] = sum[i] + b[i]; } #ifdef TEST cout << "sum" << endl << " "; for (int i = 0; i <= n; ++i) cout << sum[i] << " "; cout << endl; #endif /* 上記の4 */ bool f = false; // 存在するかのフラグ for (int i = 0; i < n - 1; ++i) { ll s1 = sum[i + 1] - sum[0]; ll s2 = d * (n - i - 1) - (sum[n] - sum[i + 1]); f = s1 == s2 && s1 <= k; if (f) break; } if (f) { #ifdef TEST cout << "-------ans------" << endl; #endif cout << d << endl; goto End; } } End:; delete[] a; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long //#define TEST /* kの約数を求める. 時間計算量O(√k) */ vector<ll> divisor(ll k) { vector<ll> d; for (ll i = 1; i * i <= k; ++i) { if (k % i == 0) { d.push_back(i); if (i * i != k) d.push_back(k / i); } } sort(d.begin(), d.end()); return d; } signed main() { int n, k; cin >> n >> k; ll *a = new ll[n]; for (int i = 0; i < n; ++i) cin >> a[i]; ll sum_a = accumulate(a, a + n, 0); // aの合計 /* sum_aの正の約数をすべて求める. */ auto ds = divisor(sum_a); /* dsの確認(TEST時のみ) */ #ifdef TEST cout << "-------ds-------" << endl; for (auto d : ds) cout << d << " "; cout << endl; #endif /* sum_aの正の約数dについて、 1. 各a[i]について、最低いくら加算するとdの倍数になるか求める 2. 1の結果をb[i]として、配列bをソート 3. 配列bの累積和を求める 4. 3を利用しながら、 b[0]+b[1]+...b[i]=d*(n-i-1)-(b[i+1]+b[i+2]+...+b[n-1]) かつ b[0]+b[1]+...+b[i]<=k なるiが存在するか調べる を、dが大きい方から実行する. 4の結果存在するならばそのdが求める答え. */ for (int j = ds.size() - 1; j >= 0; --j) { ll d = ds[j]; #ifdef TEST cout << "-------d=" << d << "------" << endl; #endif /* 上記の1 */ vector<ll> b; for (int i = 0; i < n; ++i) { b.push_back((d - (a[i] % d)) % d); } /* 上記の2 */ sort(b.begin(), b.end()); #ifdef TEST cout << "b" << endl << " "; for (auto bi : b) cout << bi << " "; cout << endl; #endif /* 上記の3 */ ll *sum = new ll[n + 1]; sum[0] = 0; for (int i = 0; i < n; ++i) { sum[i + 1] = sum[i] + b[i]; } #ifdef TEST cout << "sum" << endl << " "; for (int i = 0; i <= n; ++i) cout << sum[i] << " "; cout << endl; #endif /* 上記の4 */ bool f = false; // 存在するかのフラグ for (int i = 0; i < n; ++i) { ll s1 = sum[i + 1] - sum[0]; ll s2 = d * (n - i - 1) - (sum[n] - sum[i + 1]); f = s1 == s2 && s1 <= k; if (f) break; } if (f) { #ifdef TEST cout << "-------ans------" << endl; #endif cout << d << endl; goto End; } } End:; delete[] a; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
759,612
759,613
u177907787
cpp
p02955
#include <bits/stdc++.h> using namespace std; long long n, k, sum = 0; vector<long long> a, v; long long solve(); bool ch(long long x); int main() { cin >> n >> k; a.resize(n); for (int i = 0; i < n; ++i) cin >> a[i]; cout << solve() << endl; return 0; } long long solve() { long long ans = 1; for (int i = 0; i < n; ++i) sum += a[i]; for (long long i = 1; i * i <= sum; ++i) if (sum % i == 0) { if (ch(i)) ans = max(ans, i); if (ch(sum / i)) ans = max(ans, sum / i); } return ans; } bool ch(long long x) { v.assign(n + 1, 0); for (int i = 0; i < n; ++i) v[i + 1] = x % a[i]; sort(v.begin(), v.end()); for (int i = 1; i <= n; ++i) v[i] += v[i - 1]; for (int i = 0; i <= n; ++i) { long long now = v[n] - v[i]; now = x * (n - i) - now; if (max(now, v[i]) <= k) return 1; } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, k, sum = 0; vector<long long> a, v; long long solve(); bool ch(long long x); int main() { cin >> n >> k; a.resize(n); for (int i = 0; i < n; ++i) cin >> a[i]; cout << solve() << endl; return 0; } long long solve() { long long ans = 1; for (int i = 0; i < n; ++i) sum += a[i]; for (long long i = 1; i * i <= sum; ++i) if (sum % i == 0) { if (ch(i)) ans = max(ans, i); if (ch(sum / i)) ans = max(ans, sum / i); } return ans; } bool ch(long long x) { v.assign(n + 1, 0); for (int i = 0; i < n; ++i) v[i + 1] = a[i] % x; sort(v.begin(), v.end()); for (int i = 1; i <= n; ++i) v[i] += v[i - 1]; for (int i = 0; i <= n; ++i) { long long now = v[n] - v[i]; now = x * (n - i) - now; if (max(now, v[i]) <= k) return 1; } return 0; }
[ "expression.operation.binary.remove", "assignment.change" ]
759,616
759,617
u269963329
cpp
p02955
#include <bits/stdc++.h> using namespace std; long long n, k, sum = 0; vector<long long> a, v; long long solve(); bool ch(long long x); int main() { cin >> n >> k; a.resize(n); for (int i = 0; i < n; ++i) cin >> a[i]; cout << solve() << endl; return 0; } long long solve() { long long ans = 1; for (int i = 0; i < n; ++i) sum += a[i]; for (long long i = 1; i * i <= sum; ++i) if (sum % i == 0) { if (ch(i)) ans = max(ans, i); if (ch(sum / i)) ans = max(ans, sum / i); } return ans; } bool ch(long long x) { v.assign(n + 1, 0); for (int i = 0; i < n; ++i) v[i + 1] = x % a[i]; sort(v.begin(), v.end()); for (int i = 1; i <= n; ++i) v[i] += v[i - 1]; for (int i = 0; i < n; ++i) { long long now = v[n] - v[i]; now = x * (n - i) - now; if (max(now, v[i]) <= k) return 1; } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, k, sum = 0; vector<long long> a, v; long long solve(); bool ch(long long x); int main() { cin >> n >> k; a.resize(n); for (int i = 0; i < n; ++i) cin >> a[i]; cout << solve() << endl; return 0; } long long solve() { long long ans = 1; for (int i = 0; i < n; ++i) sum += a[i]; for (long long i = 1; i * i <= sum; ++i) if (sum % i == 0) { if (ch(i)) ans = max(ans, i); if (ch(sum / i)) ans = max(ans, sum / i); } return ans; } bool ch(long long x) { v.assign(n + 1, 0); for (int i = 0; i < n; ++i) v[i + 1] = a[i] % x; sort(v.begin(), v.end()); for (int i = 1; i <= n; ++i) v[i] += v[i - 1]; for (int i = 0; i <= n; ++i) { long long now = v[n] - v[i]; now = x * (n - i) - now; if (max(now, v[i]) <= k) return 1; } return 0; }
[ "expression.operation.binary.remove", "assignment.change", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
759,618
759,617
u269963329
cpp
p02955
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * f; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void pr1(int x) { write(x), putchar(' '); } inline void pr2(int x) { write(x), puts(""); } int top, a[510], b[510], sta[50010]; int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n = read(), cnt = read(), mx = 0, ans, sum = 0; for (int i = 1; i <= n; i++) a[i] = read(), mx = max(mx, a[i]), sum += a[i]; for (int i = 1; i <= sqrt(sum); i++) { if (sum % i == 0) { sta[++top] = i; if (i * i != sum) sta[++top] = sum / i; } } for (int i = 1; i <= top; i++) { int tot = 0; int k = sta[i]; for (int j = 1; j <= n; j++) b[j] = ceil(1.0 * a[j] / k) * k - a[j], tot += b[j]; sort(b + 1, b + n + 1); if (tot % k != 0) continue; int sum = tot; tot /= k; for (int j = n; j >= n - tot + 1; j--) sum -= b[j]; if (sum <= cnt) ans = max(ans, k); } pr2(ans); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * f; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x > 9) write(x / 10); putchar(x % 10 + '0'); } inline void pr1(int x) { write(x), putchar(' '); } inline void pr2(int x) { write(x), puts(""); } int top, a[510], b[510], sta[50010]; int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); int n = read(), cnt = read(), mx = 0, ans = 0, sum = 0; for (int i = 1; i <= n; i++) a[i] = read(), mx = max(mx, a[i]), sum += a[i]; for (int i = 1; i <= sqrt(sum); i++) { if (sum % i == 0) { sta[++top] = i; if (i * i != sum) sta[++top] = sum / i; } } for (int i = 1; i <= top; i++) { long long tot = 0; int k = sta[i]; for (int j = 1; j <= n; j++) b[j] = ceil(1.0 * a[j] / k) * k - a[j], tot += b[j]; sort(b + 1, b + n + 1); if (tot % k != 0) continue; long long sum = tot; tot /= k; for (int j = n; j >= n - tot + 1; j--) sum -= b[j]; if (sum <= cnt) ans = max(ans, k); } pr2(ans); return 0; }
[ "variable_declaration.value.change", "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
759,625
759,624
u741207575
cpp
p02955
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; const double EPS = 1e-9; typedef vector<int> vint; typedef vector<vector<int>> v2int; typedef vector<ll> vll; typedef vector<vector<ll>> v2ll; typedef list<int> liint; typedef pair<int, int> pint; const int INF = int(2e9); const ll LINF = ll(2e9) * ll(2e9); #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; } template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; } int main() { int N, K; cin >> N >> K; vint A(N); rep(i, N) { cin >> A[i]; } auto S = accumulate(A.begin(), A.end(), 0); vint p_list; for (int i = 1; i <= int(sqrt(S)) + 1; i++) { if (S % i == 0) { p_list.push_back(i); p_list.push_back(S / i); } } sort(p_list.begin(), p_list.end(), greater<int>()); for (auto &p : p_list) { vint B; int cnt = 0; rep(i, N) { if (A[i] % p != 0) B.push_back(A[i] % p); } int S1 = 0, S2 = 0; sort(B.begin(), B.end()); N = B.size(); if (N == 0) { cout << p << endl; return 0; } rep(i, N) { S2 += p - B[i]; } int need = INF; rep(i, N - 1) { S1 += B[i]; S2 -= p - B[i]; if (S1 == S2) need = min(need, S1); // need = min(need, max(S1, S2)); } if (need <= K) { cout << p << endl; return 0; } } return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; const double EPS = 1e-9; typedef vector<int> vint; typedef vector<vector<int>> v2int; typedef vector<ll> vll; typedef vector<vector<ll>> v2ll; typedef list<int> liint; typedef pair<int, int> pint; const int INF = int(2e9); const ll LINF = ll(2e9) * ll(2e9); #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; } template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; } int main() { int N, K; cin >> N >> K; vint A(N); rep(i, N) { cin >> A[i]; } auto S = accumulate(A.begin(), A.end(), 0); vint p_list; for (int i = 1; i <= int(sqrt(S)) + 1; i++) { if (S % i == 0) { p_list.push_back(i); p_list.push_back(S / i); } } sort(p_list.begin(), p_list.end(), greater<int>()); for (auto &p : p_list) { vint B; int cnt = 0; rep(i, N) { if (A[i] % p != 0) cnt++; B.push_back(A[i] % p); } int S1 = 0, S2 = 0; sort(B.begin(), B.end()); N = B.size(); if (cnt == 0) { cout << p << endl; return 0; } rep(i, N) { S2 += p - B[i]; } int need = INF; rep(i, N - 1) { S1 += B[i]; S2 -= p - B[i]; if (S1 == S2) need = min(need, S1); // need = min(need, max(S1, S2)); } if (need <= K) { cout << p << endl; return 0; } } return 0; }
[ "expression.unary.arithmetic.add", "identifier.change", "control_flow.branch.if.condition.change" ]
759,626
759,627
u391331433
cpp
p02955
#include <bits/stdc++.h> using namespace std; template <typename T> void prime_factorization(T &result, int x) { for (int i = 1; i * i <= x; i++) { if (x % i == 0) { result.insert(i); result.insert(x / i); } } } bool verify(const vector<int> &a, int k, int block_size, int block_num) { priority_queue<int> pq; for (int x : a) { pq.push(x); } while (0 < block_num) { int x = pq.top(); pq.pop(); int block_use = min(block_num, max(1, x / block_size)); pq.push(x - block_size * block_use); block_num -= block_use; } int diff = 0; while (!pq.empty()) { int x = pq.top(); pq.pop(); if (0 < x) { diff += x; } } return diff <= k; } int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } int sum = accumulate(a.begin(), a.end(), 0); unordered_set<int> s; prime_factorization(s, sum); int result = 0; for (int block_num : s) { int block_size = sum / block_num; if (result < block_size && verify(a, k, block_size, block_num)) { result = block_size; break; } } cout << result << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> void prime_factorization(T &result, int x) { for (int i = 1; i * i <= x; i++) { if (x % i == 0) { result.insert(i); result.insert(x / i); } } } bool verify(const vector<int> &a, int k, int block_size, int block_num) { priority_queue<int> pq; for (int x : a) { pq.push(x); } while (0 < block_num) { int x = pq.top(); pq.pop(); int block_use = min(block_num, max(1, x / block_size)); pq.push(x - block_size * block_use); block_num -= block_use; } int diff = 0; while (!pq.empty()) { int x = pq.top(); pq.pop(); if (0 < x) { diff += x; } } return diff <= k; } int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } int sum = accumulate(a.begin(), a.end(), 0); unordered_set<int> s; prime_factorization(s, sum); int result = 0; for (int block_num : s) { int block_size = sum / block_num; if (result < block_size && verify(a, k, block_size, block_num)) { result = block_size; } } cout << result << '\n'; return 0; }
[]
759,628
759,629
u901295506
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define M 1000000007 #define F first #define S second typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; #define pb push_back #define M6 1000009 #define M5 500009 #define pi 3.14159265 #define epsilon 1e-6 ll power(ll x, ll n, ll m) { ll res = 1; while (n > 0) { if (n & 1) res = (res * x) % m; n /= 2; x = (x * x) % m; } return res; } bool same(ld a, ld b) { return fabs(a - b) < epsilon; } // ll sp[M6*10]; // void sieve(){ // for(int i=2;i<M6*10;i++) sp[i]=i; // for(int i=2;i*i<M6*10;i++){ // if(sp[i]!=i) continue; // for(int j=i*2;j<M6*10;j+=i) { // if(sp[j]==j) sp[j]=i; // } // } // } ll n, m, A[M5]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); // sieve(); // init(); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ll tc = 1, t = 0, i, j, k, l, r, a, b, c; // cin>>tc; while (t++ < tc) { // cout<<"Case #"<<t<<": "; cin >> n >> k; ll sum = 0; for (i = 1; i <= n; i++) { cin >> A[i]; sum += A[i]; } vector<ll> v; for (i = 1; i * i <= sum; i++) { if (sum % i == 0) { v.pb(i); v.pb(sum / i); } } sort(A + 1, A + n + 1); sort(v.begin(), v.end()); ll ans; for (i = v.size() - 1; i >= 0; i--) { vector<ll> vs; for (j = 1; j <= n; j++) if (A[j] % v[i]) vs.pb(A[j] % v[i]); if (vs.size()) { ans = v[i]; break; } sort(vs.begin(), vs.end()); ll cur = 0; for (j = 0; j < vs.size(); j++) { if (cur + vs[j] <= k) { cur += vs[j]; vs[j] = 0; } else break; } for (; j < vs.size(); j++) { if ((v[i] - vs[j]) <= cur) { cur -= v[i] - vs[j]; vs[j] = 0; } else break; } if (vs[vs.size() - 1] == 0) { ans = v[i]; break; } } cout << ans; } return 0; }
#include <bits/stdc++.h> using namespace std; #define M 1000000007 #define F first #define S second typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; #define pb push_back #define M6 1000009 #define M5 500009 #define pi 3.14159265 #define epsilon 1e-6 ll power(ll x, ll n, ll m) { ll res = 1; while (n > 0) { if (n & 1) res = (res * x) % m; n /= 2; x = (x * x) % m; } return res; } bool same(ld a, ld b) { return fabs(a - b) < epsilon; } // ll sp[M6*10]; // void sieve(){ // for(int i=2;i<M6*10;i++) sp[i]=i; // for(int i=2;i*i<M6*10;i++){ // if(sp[i]!=i) continue; // for(int j=i*2;j<M6*10;j+=i) { // if(sp[j]==j) sp[j]=i; // } // } // } ll n, m, A[M5]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); // sieve(); // init(); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ll tc = 1, t = 0, i, j, k, l, r, a, b, c; // cin>>tc; while (t++ < tc) { // cout<<"Case #"<<t<<": "; cin >> n >> k; ll sum = 0; for (i = 1; i <= n; i++) { cin >> A[i]; sum += A[i]; } vector<ll> v; for (i = 1; i * i <= sum; i++) { if (sum % i == 0) { v.pb(i); v.pb(sum / i); } } sort(A + 1, A + n + 1); sort(v.begin(), v.end()); ll ans; for (i = v.size() - 1; i >= 0; i--) { vector<ll> vs; for (j = 1; j <= n; j++) if (A[j] % v[i]) vs.pb(A[j] % v[i]); if (vs.size() == 0) { ans = v[i]; break; } sort(vs.begin(), vs.end()); ll cur = 0; for (j = 0; j < vs.size(); j++) { if (cur + vs[j] <= k) { cur += vs[j]; vs[j] = 0; } else break; } for (; j < vs.size(); j++) { if ((v[i] - vs[j]) <= cur) { cur -= v[i] - vs[j]; vs[j] = 0; } else break; } if (vs[vs.size() - 1] == 0) { ans = v[i]; break; } } cout << ans; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
759,640
759,641
u374517378
cpp
p02955
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i) #define DEBUG(x) cout << #x << ": " << (x) << '\n' #define DEBUG_VEC(v) \ cout << #v << ":"; \ REP(i, v.size()) cout << ' ' << v[i]; \ cout << '\n' #define ALL(a) (a).begin(), (a).end() template <typename T> inline void CHMAX(T &a, const T b) { if (a < b) a = b; } template <typename T> inline void CHMIN(T &a, const T b) { if (a > b) a = b; } constexpr ll MOD = 1000000007ll; // constexpr ll MOD=998244353ll; #define FIX(a) ((a) % MOD + MOD) % MOD const double EPS = 1e-11; #define EQ0(x) (abs((x)) < EPS) #define EQ(a, b) (abs((a) - (b)) < EPS) // 約数を求める vl divisor(ll n) { vl res; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { res.push_back(i); if (i != n / i) { res.push_back(n / i); } } } return res; } const ll INF = 1e18; int main() { ios::sync_with_stdio(false); cin.tie(0); // cout<<setprecision(10)<<fixed; int n; ll k, a[525]; cin >> n >> k; ll sum = 0, ma = 0; REP(i, n) { cin >> a[i]; sum += a[i]; CHMAX(ma, a[i]); } sort(a, a + n); vl v = divisor(sum); ll ans = 1; for (auto &x : v) { if (x == 1) { continue; } if (x == sum) { if (sum - ma <= k) { ans = x; } continue; } vl b; REP(i, n) { if (a[i] % x == 0) { continue; } b.push_back(a[i] % x); } sort(ALL(b)); int m = b.size(); ll sum[2][525]; sum[0][0] = 0; REP(i, m) { sum[0][i + 1] = sum[0][i] + b[i]; } sum[1][m] = 0; FORR(i, 0, m) { sum[1][i] = sum[1][i + 1] + x - b[i]; } ll tmp = INF; REP(i, n + 1) { if (abs(sum[0][i] - sum[1][i]) % x == 0) { CHMIN(tmp, max(sum[0][i], sum[1][i])); } } if (tmp <= k) { CHMAX(ans, x); } } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, a, b) for (int i = (b)-1; i >= (a); --i) #define DEBUG(x) cout << #x << ": " << (x) << '\n' #define DEBUG_VEC(v) \ cout << #v << ":"; \ REP(i, v.size()) cout << ' ' << v[i]; \ cout << '\n' #define ALL(a) (a).begin(), (a).end() template <typename T> inline void CHMAX(T &a, const T b) { if (a < b) a = b; } template <typename T> inline void CHMIN(T &a, const T b) { if (a > b) a = b; } constexpr ll MOD = 1000000007ll; // constexpr ll MOD=998244353ll; #define FIX(a) ((a) % MOD + MOD) % MOD const double EPS = 1e-11; #define EQ0(x) (abs((x)) < EPS) #define EQ(a, b) (abs((a) - (b)) < EPS) // 約数を求める vl divisor(ll n) { vl res; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { res.push_back(i); if (i != n / i) { res.push_back(n / i); } } } return res; } const ll INF = 1e18; int main() { ios::sync_with_stdio(false); cin.tie(0); // cout<<setprecision(10)<<fixed; int n; ll k, a[525]; cin >> n >> k; ll sum = 0, ma = 0; REP(i, n) { cin >> a[i]; sum += a[i]; CHMAX(ma, a[i]); } sort(a, a + n); vl v = divisor(sum); ll ans = 1; for (auto &x : v) { if (x == 1) { continue; } if (x == sum) { if (sum - ma <= k) { ans = x; } continue; } vl b; REP(i, n) { if (a[i] % x == 0) { continue; } b.push_back(a[i] % x); } sort(ALL(b)); int m = b.size(); ll sum[2][525]; sum[0][0] = 0; REP(i, m) { sum[0][i + 1] = sum[0][i] + b[i]; } sum[1][m] = 0; FORR(i, 0, m) { sum[1][i] = sum[1][i + 1] + x - b[i]; } ll tmp = INF; REP(i, m + 1) { if (abs(sum[0][i] - sum[1][i]) % x == 0) { CHMIN(tmp, max(sum[0][i], sum[1][i])); } } if (tmp <= k) { CHMAX(ans, x); } } cout << ans << '\n'; return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
759,642
759,643
u833393891
cpp
p02955
#include <bits/stdc++.h> #include <chrono> #include <random> #define lowbit(i) (i & (-i)) using namespace std; namespace _ { bool rEOF = 1; //为0表示文件结尾 inline char nc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++; } template <class _T> inline bool read(_T &num) { char c = nc(), f = 1; num = 0; while (c < '0' || c > '9') c == '-' && (f = -1), c = nc(); while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = nc(); return (bool)(num *= f); } inline bool need(char &c) { return c >= 'A' && c <= 'z' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z'; } //读入的字符范围 inline bool read_str(char *a) { while ((*a = nc()) && need(*a) && rEOF) ++a; *a = '\0'; return rEOF; } } // namespace _ using namespace _; void file(bool opt) { if (opt && fopen("in.txt", "r")) { freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); } } long long n, k; long long sum = 0; long long a[505 + 5]; long long l[505], r[505]; vector<long long> que; bool check(long long g) { vector<pair<long long, long long>> q2; for (int i = 1; i <= n; i++) { long long x = a[i] % g; q2.push_back({x, g - x}); } sort(q2.begin(), q2.end()); for (int i = 1; i <= n; i++) l[i] = l[i - 1] + q2[i - 1].first; for (int i = n; i >= 1; i--) r[i] = r[i + 1] + q2[i - 1].second; for (int i = 1; i < n; i++) if (l[i] == r[i + 1] && l[i] <= k) return 1; return 0; } int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i]; sort(a + 1, a + 1 + n); for (long long i = 1; i * i <= sum; i++) { if (sum % i == 0) { que.push_back(i); if (i != sum / i) que.push_back(sum / i); } } sort(que.begin(), que.end(), [](long long a, long long b) { return a > b; }); for (int i = 0; i < que.size(); i++) { if (check(que[i])) { printf("%lld\n", que[i]); break; } } return 0; }
#include <bits/stdc++.h> #include <chrono> #include <random> #define lowbit(i) (i & (-i)) using namespace std; namespace _ { bool rEOF = 1; //为0表示文件结尾 inline char nc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++; } template <class _T> inline bool read(_T &num) { char c = nc(), f = 1; num = 0; while (c < '0' || c > '9') c == '-' && (f = -1), c = nc(); while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = nc(); return (bool)(num *= f); } inline bool need(char &c) { return c >= 'A' && c <= 'z' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z'; } //读入的字符范围 inline bool read_str(char *a) { while ((*a = nc()) && need(*a) && rEOF) ++a; *a = '\0'; return rEOF; } } // namespace _ using namespace _; void file(bool opt) { if (opt && fopen("in.txt", "r")) { freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); } } long long n, k; long long sum = 0; long long a[505 + 5]; long long l[505], r[505]; vector<long long> que; bool check(long long g) { vector<pair<long long, long long>> q2; for (int i = 1; i <= n; i++) { long long x = a[i] % g; q2.push_back({x, g - x}); } sort(q2.begin(), q2.end()); for (int i = 1; i <= n; i++) l[i] = l[i - 1] + q2[i - 1].first; for (int i = n; i >= 1; i--) r[i] = r[i + 1] + q2[i - 1].second; for (int i = 0; i <= n; i++) if (l[i] == r[i + 1] && l[i] <= k) return 1; return 0; } int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i]; sort(a + 1, a + 1 + n); for (long long i = 1; i * i <= sum; i++) { if (sum % i == 0) { que.push_back(i); if (i != sum / i) que.push_back(sum / i); } } sort(que.begin(), que.end(), [](long long a, long long b) { return a > b; }); for (int i = 0; i < que.size(); i++) { if (check(que[i])) { printf("%lld\n", que[i]); break; } } return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
759,648
759,649
u066917439
cpp
p02955
#include <algorithm> // sort #include <cmath> #include <iomanip> #include <iostream> #include <map> // pair #include <queue> #include <set> #include <string> #include <vector> #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) using namespace std; typedef long long ll; ll newton(long long int a, long long int b) { if (a == b) return a; while (a != 0 && b != 0) { if (a > b) { b += a; a = b - a; b -= a; } b %= a; } return a; } struct UnionFind { vector<int> p; UnionFind(int N) : p(N) { for (int i = 0; i < N; i++) { p[i] = i; } } int root(int x) { if (p[x] == x) return x; return p[x] = root(p[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; p[rx] = ry; } bool issame(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; //大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる ll div2mul_calc(ll a, ll b, ll m) { if (b == 0) { return 1; } else if (b % 2 == 0) { ll d = div2mul_calc(a, b / 2, m); return (d * d) % m; } else { return (a * div2mul_calc(a, b - 1, m)) % m; } } ll div2mul(ll n, ll mod) { return div2mul_calc(n, mod - 2, mod); } ll twoRow(ll a, ll b, ll mod) { ll ret = 1; for (ll i = 1; i <= a + b; ++i) { ret *= i; ret %= mod; } for (ll i = 1; i <= a; ++i) { ret *= div2mul(i, mod); ret %= mod; } for (ll i = 1; i <= b; ++i) { ret *= div2mul(i, mod); ret %= mod; } return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return (ret); } int main() { ll N, M, T; ll i, j, k; ll K, X, Y; ll A[512] = {0}; ll B[512] = {0}; ll px = 0; ll ans = 0; cin >> N >> M; for (i = 0; i < N; ++i) { cin >> A[i]; T += A[i]; } vector<ll> v; for (i = 1; i * i <= T; i++) { if (T % i == 0) { v.push_back(i); if (i * i != T) v.push_back(T / i); } } sort(v.begin(), v.end()); int v_len = v.size(); for (i = v_len - 1; i >= 0; --i) { K = v[i]; X = 0; for (j = 0; j < N; ++j) { k = A[j] - (ll)(A[j] / K) * K; X += k; B[j] = k; } sort(B, B + N); k = N - X / K; X = 0; for (j = 0; j < k; ++j) { X += B[j]; } if (X <= M) { ans = K; break; } } cout << ans << endl; return 0; }
#include <algorithm> // sort #include <cmath> #include <iomanip> #include <iostream> #include <map> // pair #include <queue> #include <set> #include <string> #include <vector> #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) using namespace std; typedef long long ll; ll newton(long long int a, long long int b) { if (a == b) return a; while (a != 0 && b != 0) { if (a > b) { b += a; a = b - a; b -= a; } b %= a; } return a; } struct UnionFind { vector<int> p; UnionFind(int N) : p(N) { for (int i = 0; i < N; i++) { p[i] = i; } } int root(int x) { if (p[x] == x) return x; return p[x] = root(p[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; p[rx] = ry; } bool issame(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; //大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる ll div2mul_calc(ll a, ll b, ll m) { if (b == 0) { return 1; } else if (b % 2 == 0) { ll d = div2mul_calc(a, b / 2, m); return (d * d) % m; } else { return (a * div2mul_calc(a, b - 1, m)) % m; } } ll div2mul(ll n, ll mod) { return div2mul_calc(n, mod - 2, mod); } ll twoRow(ll a, ll b, ll mod) { ll ret = 1; for (ll i = 1; i <= a + b; ++i) { ret *= i; ret %= mod; } for (ll i = 1; i <= a; ++i) { ret *= div2mul(i, mod); ret %= mod; } for (ll i = 1; i <= b; ++i) { ret *= div2mul(i, mod); ret %= mod; } return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return (ret); } int main() { ll N, M, T = 0; ll i, j, k; ll K, X, Y; ll A[512] = {0}; ll B[512] = {0}; ll px = 0; ll ans = 0; cin >> N >> M; for (i = 0; i < N; ++i) { cin >> A[i]; T += A[i]; } vector<ll> v; for (i = 1; i * i <= T; i++) { if (T % i == 0) { v.push_back(i); if (i * i != T) v.push_back(T / i); } } sort(v.begin(), v.end()); int v_len = v.size(); for (i = v_len - 1; i >= 0; --i) { K = v[i]; X = 0; for (j = 0; j < N; ++j) { k = A[j] - (ll)(A[j] / K) * K; X += k; B[j] = k; } sort(B, B + N); k = N - X / K; X = 0; for (j = 0; j < k; ++j) { X += B[j]; } if (X <= M) { ans = K; break; } } cout << ans << endl; return 0; }
[ "variable_declaration.value.change" ]
759,654
759,655
u869595612
cpp
p02955
#include <algorithm> // sort #include <cmath> #include <iomanip> #include <iostream> #include <map> // pair #include <queue> #include <set> #include <string> #include <vector> #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) using namespace std; typedef long long ll; ll newton(long long int a, long long int b) { if (a == b) return a; while (a != 0 && b != 0) { if (a > b) { b += a; a = b - a; b -= a; } b %= a; } return a; } struct UnionFind { vector<int> p; UnionFind(int N) : p(N) { for (int i = 0; i < N; i++) { p[i] = i; } } int root(int x) { if (p[x] == x) return x; return p[x] = root(p[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; p[rx] = ry; } bool issame(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; //大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる ll div2mul_calc(ll a, ll b, ll m) { if (b == 0) { return 1; } else if (b % 2 == 0) { ll d = div2mul_calc(a, b / 2, m); return (d * d) % m; } else { return (a * div2mul_calc(a, b - 1, m)) % m; } } ll div2mul(ll n, ll mod) { return div2mul_calc(n, mod - 2, mod); } ll twoRow(ll a, ll b, ll mod) { ll ret = 1; for (ll i = 1; i <= a + b; ++i) { ret *= i; ret %= mod; } for (ll i = 1; i <= a; ++i) { ret *= div2mul(i, mod); ret %= mod; } for (ll i = 1; i <= b; ++i) { ret *= div2mul(i, mod); ret %= mod; } return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return (ret); } int main() { ll N, M, T; ll i, j, k; ll K, X, Y; ll A[512] = {0}; ll B[512] = {0}; ll px = 0; ll ans = 0; cin >> N >> M; for (i = 0; i < N; ++i) { cin >> A[i]; T += A[i]; } vector<ll> v; for (i = 1; i * i <= T; i++) { if (T % i == 0) { v.push_back(i); if (i * i != T) v.push_back(T / i); } } sort(v.begin(), v.end()); int v_len = v.size(); for (i = v_len - 1; i >= 0; --i) { K = v[i]; X = 0; for (j = 0; j < N; ++j) { k = A[j] - (ll)(A[j] / K) * K; X += k; B[j] = k; } sort(B, B + N); k = N - X / K; X = 0; for (j = 0; j < k; ++j) { X += B[j]; } if (X <= M) { ans = K; break; } } cout << ans << endl; return 0; }
#include <algorithm> // sort #include <cmath> #include <iomanip> #include <iostream> #include <map> // pair #include <queue> #include <set> #include <string> #include <vector> #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0])) using namespace std; typedef long long ll; ll newton(long long int a, long long int b) { if (a == b) return a; while (a != 0 && b != 0) { if (a > b) { b += a; a = b - a; b -= a; } b %= a; } return a; } struct UnionFind { vector<int> p; UnionFind(int N) : p(N) { for (int i = 0; i < N; i++) { p[i] = i; } } int root(int x) { if (p[x] == x) return x; return p[x] = root(p[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if (rx == ry) return; p[rx] = ry; } bool issame(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; //大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる ll div2mul_calc(ll a, ll b, ll m) { if (b == 0) { return 1; } else if (b % 2 == 0) { ll d = div2mul_calc(a, b / 2, m); return (d * d) % m; } else { return (a * div2mul_calc(a, b - 1, m)) % m; } } ll div2mul(ll n, ll mod) { return div2mul_calc(n, mod - 2, mod); } ll twoRow(ll a, ll b, ll mod) { ll ret = 1; for (ll i = 1; i <= a + b; ++i) { ret *= i; ret %= mod; } for (ll i = 1; i <= a; ++i) { ret *= div2mul(i, mod); ret %= mod; } for (ll i = 1; i <= b; ++i) { ret *= div2mul(i, mod); ret %= mod; } return ret; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end()); return (ret); } int main() { ll N, M, T = 0; ll i, j, k; ll K, X, Y; ll A[512] = {0}; ll B[512] = {0}; ll px = 0; ll ans = 0; cin >> N >> M; for (i = 0; i < N; ++i) { cin >> A[i]; T += A[i]; } vector<ll> v; for (i = 1; i * i <= T; i++) { if (T % i == 0) { v.push_back(i); if (i * i != T) v.push_back(T / i); } } sort(v.begin(), v.end()); int v_len = v.size(); for (i = v_len - 1; i >= 0; --i) { K = v[i]; X = 0; for (j = 0; j < N; ++j) { k = A[j] - (ll)(A[j] / K) * K; X += k; B[j] = k; } sort(B, B + N); k = N - X / K; X = 0; for (j = 0; j < k; ++j) { X += B[j]; } if (X <= M) { ans = K; break; } } cout << ans << endl; return 0; }
[ "variable_declaration.value.change" ]
759,656
759,655
u869595612
cpp
p02955
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <time.h> #include <vector> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++) #define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--) #define all(v) (v).begin(), (v).end() #define mp(a, b) make_pair(a, b) #define pb(x) push_back(x) #define eb(x) emplace_back(x) #define F first #define S second typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vii; typedef vector<vii> vvii; const ll mod = 1e9 + 7; const int infi = 2147483600; const ll infl = 1e17; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, k; cin >> n >> k; vll a(n); ll A = 0; rep(i, n) { cin >> a[i]; A += a[i]; } set<ll> yaku; for (ll d = 1; d * d <= A; d++) { if (A % d == 0) { yaku.insert(d); yaku.insert(A / d); } } ll ans = 1; for (auto y : yaku) { vll res(n); rep(i, n) res[i] = a[i] % y; sort(all(res)); vll s(n + 1, 0); rep(i, n) s[i + 1] = s[i] + a[i]; int idx = 0; ll mae = 0; while (idx < n && mae + res[idx] <= k) { mae += res[idx]; idx++; } if (y * (n - idx) - s[n] + s[idx - 1] <= k) { ans = y; } } cout << ans << endl; }
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <time.h> #include <vector> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)n; i++) #define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++) #define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--) #define all(v) (v).begin(), (v).end() #define mp(a, b) make_pair(a, b) #define pb(x) push_back(x) #define eb(x) emplace_back(x) #define F first #define S second typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vii; typedef vector<vii> vvii; const ll mod = 1e9 + 7; const int infi = 2147483600; const ll infl = 1e17; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, k; cin >> n >> k; vll a(n); ll A = 0; rep(i, n) { cin >> a[i]; A += a[i]; } set<ll> yaku; for (ll d = 1; d * d <= A; d++) { if (A % d == 0) { yaku.insert(d); yaku.insert(A / d); } } ll ans = 1; for (auto y : yaku) { vll res(n); rep(i, n) res[i] = a[i] % y; sort(all(res)); vll s(n + 1, 0); rep(i, n) s[i + 1] = s[i] + res[i]; int idx = 0; ll mae = 0; while (idx < n && mae + res[idx] <= k) { mae += res[idx]; idx++; } if (y * (n - idx) - s[n] + s[idx] <= k) { ans = y; } } cout << ans << endl; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
759,659
759,660
u171366497
cpp
p02955
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using ll = long long; // LLONG_MAX #define int long long #define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end()) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define ARY_SORT(a, size) sort((a), (a) + (size)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end())) #define REVERSE(v) (reverse((v).begin(), (v).end())) #define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a))) #define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a))) #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define CONTAINS_MAP(m, a) (m).find((a)) != m.end() using namespace std; int N, K; int A[501]; int func(int n) { int a[501]; for (int i = 0; i < N; i++) { a[i] = A[i] % n; } ARY_SORT(a, N); int cnt = 0; int end = N - 1; for (int i = 0; i <= end; i++) { int end_rest = n - a[end]; if (a[i] == end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; end--; } else if (a[i] < end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; } else if (a[i] > end_rest) { int sub = n - a[end]; cnt += sub; a[i] -= sub; a[end] += sub; end--; i--; } } return cnt; } signed main() { cin >> N >> K; int sum = 0; REP(i, N) { cin >> A[i]; sum += A[i]; } int num = sum; int max = 0; for (int i = 1; i <= num; i++) { if (sum % i == 0) { num = sum / i; int a = func(i); int b = func(num); if (a <= K) max = MAX(max, i); if (b <= K) { cout << i << endl; return 0; } } } cout << max << endl; }
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using ll = long long; // LLONG_MAX #define int long long #define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end()) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define ARY_SORT(a, size) sort((a), (a) + (size)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end())) #define REVERSE(v) (reverse((v).begin(), (v).end())) #define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a))) #define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a))) #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define CONTAINS_MAP(m, a) (m).find((a)) != m.end() using namespace std; int N, K; int A[501]; int func(int n) { int a[501]; for (int i = 0; i < N; i++) { a[i] = A[i] % n; } ARY_SORT(a, N); int cnt = 0; int end = N - 1; for (int i = 0; i <= end; i++) { int end_rest = n - a[end]; if (a[i] == end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; end--; } else if (a[i] < end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; } else if (a[i] > end_rest) { int sub = n - a[end]; cnt += sub; a[i] -= sub; a[end] += sub; end--; i--; } } return cnt; } signed main() { cin >> N >> K; int sum = 0; REP(i, N) { cin >> A[i]; sum += A[i]; } int num = sum; int max = 0; for (int i = 1; i <= num; i++) { if (sum % i == 0) { num = sum / i; int a = func(i); int b = func(num); if (a <= K) max = MAX(max, i); if (b <= K) { cout << num << endl; return 0; } } } cout << max << endl; }
[ "identifier.change", "io.output.change" ]
759,661
759,662
u624800360
cpp
p02955
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using ll = long long; // LLONG_MAX #define int long long #define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end()) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define ARY_SORT(a, size) sort((a), (a) + (size)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end())) #define REVERSE(v) (reverse((v).begin(), (v).end())) #define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a))) #define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a))) #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define CONTAINS_MAP(m, a) (m).find((a)) != m.end() using namespace std; int N, K; int A[501]; int func(int n) { int a[501]; for (int i = 0; i < N; i++) { a[i] = A[i] % n; } ARY_SORT(a, N); int cnt = 0; int end = N - 1; for (int i = 0; i <= end; i++) { int end_rest = n - a[end]; if (a[i] == end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; end--; } else if (a[i] < end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; } else if (a[i] > end_rest) { int sub = n - a[end]; cnt += sub; a[i] -= sub; a[end] += sub; end--; i--; } } return cnt; } signed main() { cin >> N >> K; int sum = 0; REP(i, N) { cin >> A[i]; sum += A[i]; } int num = sum; int max = 0; for (int i = 1; i <= num; i++) { if (sum % i == 0) { num = sum / i; int a = func(i); int b = func(num); if (a <= K) max = MAX(max, i); if (b <= K) { cout << max << endl; return 0; } } } cout << max << endl; }
#define _USE_MATH_DEFINES #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <tuple> #include <vector> using ll = long long; // LLONG_MAX #define int long long #define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end()) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define ARY_SORT(a, size) sort((a), (a) + (size)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end())) #define REVERSE(v) (reverse((v).begin(), (v).end())) #define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a))) #define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a))) #define REP(i, n) for (int(i) = 0; (i) < (n); (i)++) #define CONTAINS_MAP(m, a) (m).find((a)) != m.end() using namespace std; int N, K; int A[501]; int func(int n) { int a[501]; for (int i = 0; i < N; i++) { a[i] = A[i] % n; } ARY_SORT(a, N); int cnt = 0; int end = N - 1; for (int i = 0; i <= end; i++) { int end_rest = n - a[end]; if (a[i] == end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; end--; } else if (a[i] < end_rest) { cnt += a[i]; a[end] += a[i]; a[i] = 0; } else if (a[i] > end_rest) { int sub = n - a[end]; cnt += sub; a[i] -= sub; a[end] += sub; end--; i--; } } return cnt; } signed main() { cin >> N >> K; int sum = 0; REP(i, N) { cin >> A[i]; sum += A[i]; } int num = sum; int max = 0; for (int i = 1; i <= num; i++) { if (sum % i == 0) { num = sum / i; int a = func(i); int b = func(num); if (a <= K) max = MAX(max, i); if (b <= K) { cout << num << endl; return 0; } } } cout << max << endl; }
[ "identifier.change", "io.output.change" ]
759,663
759,662
u624800360
cpp
p02955
#include <bits/stdc++.h> #define int long long using namespace std; int n, K, A[1010], sum, maxx, num[1010], suml[1010], sumr[1010], last; void work(int i) { for (int j = 1; j <= n; j++) { int res = (A[j] / i) * i; num[j] = A[j] - res; } sort(num + 1, num + 1 + n); suml[0] = 0, sumr[n + 1] = 0; int tmp = 2e9 + 7; for (int j = 1; j <= n; j++) suml[j] = suml[j - 1] + num[j]; for (int j = n; j >= 1; j--) sumr[j] = sumr[j + 1] + i - num[j]; for (int j = 0; j <= n; j++) { int res = max(suml[j], sumr[j + 1]); tmp = min(tmp, res); } if (tmp <= K) { last = max(last, i); } } signed main() { scanf("%lld %lld", &n, &K); for (int i = 1; i <= n; i++) scanf("%lld", &A[i]), sum += A[i], maxx = max(maxx, A[i]); for (int i = 1; i * i <= sum; i++) { if (sum % i != 0) continue; work(i); work(sum / i); } return 0; }
#include <bits/stdc++.h> #define int long long using namespace std; int n, K, A[1010], sum, maxx, num[1010], suml[1010], sumr[1010], last; void work(int i) { for (int j = 1; j <= n; j++) { int res = (A[j] / i) * i; num[j] = A[j] - res; } sort(num + 1, num + 1 + n); suml[0] = 0, sumr[n + 1] = 0; int tmp = 2e9 + 7; for (int j = 1; j <= n; j++) suml[j] = suml[j - 1] + num[j]; for (int j = n; j >= 1; j--) sumr[j] = sumr[j + 1] + i - num[j]; for (int j = 0; j <= n; j++) { int res = max(suml[j], sumr[j + 1]); tmp = min(tmp, res); } if (tmp <= K) { last = max(last, i); } } signed main() { scanf("%lld %lld", &n, &K); for (int i = 1; i <= n; i++) scanf("%lld", &A[i]), sum += A[i], maxx = max(maxx, A[i]); for (int i = 1; i * i <= sum; i++) { if (sum % i != 0) continue; work(i); work(sum / i); } cout << last; return 0; }
[]
759,664
759,665
u047371023
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define sd(x) scanf("%d", &x) #define slld(x) scanf("%lld", &x) #define all(x) x.begin(), x.end() #define For(i, st, en) for (ll i = st; i < en; i++) #define tr(x) for (auto it = x.begin(); it != x.end(); it++) #define fast \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define ll long long #define int long long #define mp make_pair #define F first #define S second typedef pair<int, int> pii; #define MOD 1000000007 #define INF 1000000000000000007 #define MAXN 505 // it's swapnil07 ;) int n, k; int arr[MAXN]; bool play(int x) { vector<int> up; int val = 0; int ans = 0; For(i, 0, n) { if (arr[i] % x == 0) { continue; } int v1 = arr[i] / x; int v2 = v1 + 1; int upp = x * v2 - arr[i]; val += upp; up.pb(upp); } if (up.size() == 0) return true; sort(all(up)); int j = up.size() - 1; For(i, 0, up.size()) { if (up[i] == x) { break; } int v = up[i]; ans += v; for (j; j >= 0; j--) { int vv = x - up[j]; up[j] += min(v, vv); v -= min(v, vv); if (v == 0) break; } } if (ans <= k) { return true; } else { return false; } } signed main() { fast #ifdef SWAPNIL07 freopen("/home/swapnil/Desktop/c++/input.txt", "r", stdin); freopen("/home/swapnil/Desktop/c++/output.txt", "w", stdout); #endif cin >> n >> k; int sumv = 0; For(i, 0, n) { cin >> arr[i]; sumv += arr[i]; } int ans = 1; if (k > sumv) { cout << sumv; return 0; } vector<int> div; for (int i = 1; i * i <= sumv; i++) { if (sumv % i == 0) { div.pb(i); div.pb(sumv / i); } } for (auto i : div) { if (sumv % i == 0) { bool v = play(i); if (v) ans = i; } } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define sd(x) scanf("%d", &x) #define slld(x) scanf("%lld", &x) #define all(x) x.begin(), x.end() #define For(i, st, en) for (ll i = st; i < en; i++) #define tr(x) for (auto it = x.begin(); it != x.end(); it++) #define fast \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); #define pb push_back #define ll long long #define int long long #define mp make_pair #define F first #define S second typedef pair<int, int> pii; #define MOD 1000000007 #define INF 1000000000000000007 #define MAXN 505 // it's swapnil07 ;) int n, k; int arr[MAXN]; bool play(int x) { vector<int> up; int val = 0; int ans = 0; For(i, 0, n) { if (arr[i] % x == 0) { continue; } int v1 = arr[i] / x; int v2 = v1 + 1; int upp = x * v2 - arr[i]; val += upp; up.pb(upp); } if (up.size() == 0) return true; sort(all(up)); int j = up.size() - 1; For(i, 0, up.size()) { if (up[i] == x) { break; } int v = up[i]; ans += v; for (j; j >= 0; j--) { int vv = x - up[j]; up[j] += min(v, vv); v -= min(v, vv); if (v == 0) break; } } if (ans <= k) { return true; } else { return false; } } signed main() { fast #ifdef SWAPNIL07 freopen("/home/swapnil/Desktop/c++/input.txt", "r", stdin); freopen("/home/swapnil/Desktop/c++/output.txt", "w", stdout); #endif cin >> n >> k; int sumv = 0; For(i, 0, n) { cin >> arr[i]; sumv += arr[i]; } int ans = 1; if (k > sumv) { cout << sumv; return 0; } vector<int> div; for (int i = 1; i * i <= sumv; i++) { if (sumv % i == 0) { div.pb(i); div.pb(sumv / i); } } for (auto i : div) { if (sumv % i == 0) { bool v = play(i); if (v) ans = max(i, ans); } } cout << ans; return 0; }
[ "call.add", "call.arguments.add" ]
759,666
759,667
u623300886
cpp
p02955
#include <algorithm> #include <iostream> #include <math.h> #include <string> using namespace std; long long int a[1000000]; int n; long long int hoge(int che) { long long int d[100000]; for (int i = 0; i < n; i++) { d[i] = a[i] % che; } sort(d, d + n); // for(long long int i=0;i<n;i++){cout<<d[i]<<endl;} int bid = -1; int lid = n; long long int b = 0; long long int l = 0; while (bid != lid - 1) { if (l >= b) { bid++; b += d[bid]; } else { lid--; l += (che - d[lid]); } } return l; } int main() { long long int sum = 0; cin >> n; long long int k; cin >> k; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (n == 1) { cout << a[0] << endl; return 0; } long long int div[100000]; int id = -1; for (long long int i = 1; i <= sqrt(sum); i++) { if (sum % i == 0) { id++; div[id] = i; if (i * i != sum) { id++; div[id] = sum / i; } } } sort(div, div + id + 1); long long int OK = 0; for (int i = 0; i < id; i++) { if (hoge(div[i]) <= k) { OK = i; } } cout << div[OK] << endl; }
#include <algorithm> #include <iostream> #include <math.h> #include <string> using namespace std; long long int a[1000000]; int n; long long int hoge(int che) { long long int d[100000]; for (int i = 0; i < n; i++) { d[i] = a[i] % che; } sort(d, d + n); // for(long long int i=0;i<n;i++){cout<<d[i]<<endl;} int bid = -1; int lid = n; long long int b = 0; long long int l = 0; while (bid != lid - 1) { if (l >= b) { bid++; b += d[bid]; } else { lid--; l += (che - d[lid]); } } return l; } int main() { long long int sum = 0; cin >> n; long long int k; cin >> k; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (n == 1) { cout << a[0] << endl; return 0; } long long int div[100000]; int id = -1; for (long long int i = 1; i <= sqrt(sum); i++) { if (sum % i == 0) { id++; div[id] = i; if (i * i != sum) { id++; div[id] = sum / i; } } } sort(div, div + id + 1); long long int OK = 0; for (int i = 0; i <= id; i++) { if (hoge(div[i]) <= k) { OK = i; } } cout << div[OK] << endl; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
759,670
759,671
u023751250
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1e9 + 7; #define int ll template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } signed main() { int N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; ll sum = 0; rep(i, N) { sum += A[i]; } vector<ll> div = divisor(sum); sort(all(div), greater<int>()); rep(i, div.size()) { ll cand = div[i]; vector<ll> diff(N); rep(j, N) { diff[j] = A[j] % cand; } sort(all(diff)); ll operation_num; repp(j, 0, N - 2) { ll l = 0, r = 0; repp(li, 0, j) { l += diff[li]; } repp(ri, j + 1, N - 1) { r += (cand - diff[ri]); } if (l == r) { operation_num = l; break; } } if (operation_num <= K) { cout << cand << endl; return 0; } } }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1e9 + 7; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { int N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; ll sum = 0; rep(i, N) { sum += A[i]; } vector<ll> div = divisor(sum); sort(all(div), greater<int>()); rep(i, div.size()) { ll cand = div[i]; vector<ll> diff(N); rep(j, N) { diff[j] = A[j] % cand; } sort(all(diff)); ll operation_num; repp(j, 0, N - 1) { ll l = 0, r = 0; repp(li, 0, j) { l += diff[li]; } repp(ri, j + 1, N - 1) { r += (cand - diff[ri]); } if (l == r) { operation_num = l; break; } } if (operation_num <= K) { cout << cand << endl; return 0; } } }
[ "function.return_type.change", "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
759,672
759,673
u995725911
cpp
p02955
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1e9 + 7; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { int N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; ll sum = 0; rep(i, N) { sum += A[i]; } vector<ll> div = divisor(sum); sort(all(div), greater<int>()); rep(i, div.size()) { ll cand = div[i]; vector<ll> diff(N); rep(j, N) { diff[j] = A[j] % cand; } sort(all(diff)); ll operation_num; repp(j, 0, N - 2) { ll l = 0, r = 0; repp(li, 0, j) { l += diff[li]; } repp(ri, j + 1, N - 1) { r += (cand - diff[ri]); } if (l == r) { operation_num = l; break; } } if (operation_num <= K) { cout << cand << endl; return 0; } } }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1e9 + 7; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { int N, K; cin >> N >> K; vector<int> A(N); rep(i, N) cin >> A[i]; ll sum = 0; rep(i, N) { sum += A[i]; } vector<ll> div = divisor(sum); sort(all(div), greater<int>()); rep(i, div.size()) { ll cand = div[i]; vector<ll> diff(N); rep(j, N) { diff[j] = A[j] % cand; } sort(all(diff)); ll operation_num; repp(j, 0, N - 1) { ll l = 0, r = 0; repp(li, 0, j) { l += diff[li]; } repp(ri, j + 1, N - 1) { r += (cand - diff[ri]); } if (l == r) { operation_num = l; break; } } if (operation_num <= K) { cout << cand << endl; return 0; } } }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
759,674
759,673
u995725911
cpp
p02955
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; int n, a[maxn], k; int sum, ans; int cur; vector<int> d; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } for (int i = (int)sqrt(sum); i >= 2; i--) { if (sum % i == 0) { d.push_back(i); if (i * i != sum) { d.push_back(sum / i); } } } d.push_back(sum); for (int x : d) { vector<int> b; for (int i = 1; i <= n; i++) { b.push_back(a[i] % x); } sort(b.rbegin(), b.rend()); while (!b.empty() && b.back() == 0) { b.pop_back(); } reverse(b.begin(), b.end()); int pt = 0; cur = 0; for (int i = 0; i < (int)b.size(); i++) { while (b[i] > 0) { if (b.empty()) break; if (x - b.back() == b[i]) { cur += (x - b.back()); b[i] = 0; b.pop_back(); break; } if (b[i] > x - b.back()) { cur += (x - b.back()); b[i] -= (x - b.back()); b.pop_back(); } else if (b[i] < x - b.back()) { cur += (b[i]); b.back() += b[i]; b[i] = 0; } } } if (cur <= k) { ans = max(ans, x); } } printf("%d\n", ans); } /* Good Luck -Lucina */
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; int n, a[maxn], k; int sum, ans; int cur; vector<int> d; int main() { ans = 1; scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } for (int i = (int)sqrt(sum); i >= 2; i--) { if (sum % i == 0) { d.push_back(i); if (i * i != sum) { d.push_back(sum / i); } } } d.push_back(sum); for (int x : d) { vector<int> b; for (int i = 1; i <= n; i++) { b.push_back(a[i] % x); } sort(b.rbegin(), b.rend()); while (!b.empty() && b.back() == 0) { b.pop_back(); } reverse(b.begin(), b.end()); int pt = 0; cur = 0; for (int i = 0; i < (int)b.size(); i++) { while (b[i] > 0) { if (b.empty()) break; if (x - b.back() == b[i]) { cur += (x - b.back()); b[i] = 0; b.pop_back(); break; } if (b[i] > x - b.back()) { cur += (x - b.back()); b[i] -= (x - b.back()); b.pop_back(); } else if (b[i] < x - b.back()) { cur += (b[i]); b.back() += b[i]; b[i] = 0; } } } if (cur <= k) { ans = max(ans, x); } } printf("%d\n", ans); } /* Good Luck -Lucina */
[ "assignment.add" ]
759,677
759,678
u047398677
cpp
p02955
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mp make_pair #define pb push_back #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; ll sum = 0; ll a[n]; rep(i, n) { cin >> a[i]; sum += a[i]; } vector<ll> yaku; yaku = divisor(sum); for (int j = yaku.size() - 1; j >= 0; j--) { ll mod_a[n]; rep(i, n) { mod_a[i] = a[i] % yaku[j]; } sort(mod_a, mod_a + n); ll si = 0; ll ei = n - 1; ll tot = 0; ll kaisu = 0; rep(i, n) { // cout << tot << endl; if (tot <= 0) { tot += mod_a[si]; // si++; kaisu += mod_a[si]; si++; } else { tot -= (yaku[j] - mod_a[ei]); // ei--; kaisu += (yaku[j] - mod_a[ei]); ei--; } // cout << kaisu << endl; } // cout << yaku[j] << " " << kaisu << " " <<tot << endl; if (tot == 0 && kaisu <= k) { cout << yaku[j] << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mp make_pair #define pb push_back #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; ll sum = 0; ll a[n]; rep(i, n) { cin >> a[i]; sum += a[i]; } vector<ll> yaku; yaku = divisor(sum); for (int j = yaku.size() - 1; j >= 0; j--) { ll mod_a[n]; rep(i, n) { mod_a[i] = a[i] % yaku[j]; } sort(mod_a, mod_a + n); ll si = 0; ll ei = n - 1; ll tot = 0; ll kaisu = 0; rep(i, n) { // cout << tot << endl; if (tot <= 0) { tot += mod_a[si]; // si++; kaisu += mod_a[si]; si++; } else { tot -= (yaku[j] - mod_a[ei]); // ei--; kaisu += (yaku[j] - mod_a[ei]); ei--; } // cout << kaisu << endl; } // cout << yaku[j] << " " << kaisu << " " <<tot << endl; if (tot == 0 && kaisu / 2 <= k) { cout << yaku[j] << endl; return 0; } } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
759,686
759,687
u949755084
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; ///////////////////////////////// int main() { ll a, b; cin >> a >> b; if ((a - b) % 2 == 0) cout << (a + b) / 2 << endl; else { cout << "IMPSSOBLE" << endl; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; ///////////////////////////////// int main() { ll a, b; cin >> a >> b; if ((a - b) % 2 == 0) cout << (a + b) / 2 << endl; else { cout << "IMPOSSIBLE" << endl; } }
[ "literal.string.change", "io.output.change" ]
759,701
759,702
u019359540
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; ///////////////////////////////// int main() { int a, b; cin >> a >> b; if ((a - b) % 2 == 0) cout << (a + b) / 2 << endl; else { cout << "IMPSSOBLE" << endl; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; ///////////////////////////////// int main() { ll a, b; cin >> a >> b; if ((a - b) % 2 == 0) cout << (a + b) / 2 << endl; else { cout << "IMPOSSIBLE" << endl; } }
[ "variable_declaration.type.change", "literal.string.change", "io.output.change" ]
759,703
759,702
u019359540
cpp
p02957
#include "iostream" using namespace std; int asb(int a) { if (a < 0) { return (-1 * a); } else { return (a); } } int main() { long long a; long long b; cin >> a >> b; double d = (a + b) / 2; if ((asb(a - d)) == (asb(b - d))) { cout << d << endl; } else { cout << "IMPOSSIBLE" << endl; } }
#include "iostream" using namespace std; int asb(int a) { if (a < 0) { return (-1 * a); } else { return (a); } } int main() { long long a; long long b; cin >> a >> b; long long d = (a + b) / 2; if ((asb(a - d)) == (asb(b - d))) { cout << d << endl; } else { cout << "IMPOSSIBLE" << endl; } }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
759,726
759,727
u243674187
cpp
p02957
// nani? #include <bits/stdc++.h> #define pi acos(-1); #define fs first #define sc second #define pb push_back #define mp make_pair #define f(i, a, b) for (int i = a; i < b; i++) #define sor(a) sort(a.begin(), a.end()) #define rsor(a) sort(a.rbegin(), a.rend()) #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0) //#define inf 1LL<<62 typedef long long ll; typedef double ld; using namespace std; const ll inf = 1e10 + 6; const ll MOD = 1e9 + 7; const ll mod = 998244353; // ac cmtr; const int MAX_N = 1e6 + 5; const int LG = 25; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cout << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) #endif //--------------------------- ll a[MAX_N]; int main() { fastio; ll a, b; cin >> a >> b; if ((a + b) & 1) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE"; }
// nani? #include <bits/stdc++.h> #define pi acos(-1); #define fs first #define sc second #define pb push_back #define mp make_pair #define f(i, a, b) for (int i = a; i < b; i++) #define sor(a) sort(a.begin(), a.end()) #define rsor(a) sort(a.rbegin(), a.rend()) #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0) //#define inf 1LL<<62 typedef long long ll; typedef double ld; using namespace std; const ll inf = 1e10 + 6; const ll MOD = 1e9 + 7; const ll mod = 998244353; // ac cmtr; const int MAX_N = 1e6 + 5; const int LG = 25; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cout << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) #endif //--------------------------- ll a[MAX_N]; int main() { fastio; ll a, b; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE"; }
[ "control_flow.branch.if.condition.change" ]
759,743
759,744
u083187983
cpp
p02957
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <vector> #pragma GCC optimize("Ofast") using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; typedef vector<vector<ll>> vvll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define mes(a) cout << (a) << endl #define dmes(a, b) cout << (a) << " " << (b) << endl #define re0 return 0 #define mp(p, q) make_pair(p, q) #define pb(n) push_back(n) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define rSort(a) sort(a.rbegin(), a.rend()) #define MATHPI acos(-1) #define itn int; int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } }; const int INF = INT_MAX; const ll LLINF = 1LL << 60; const ll MOD = 1000000007; const double EPS = 1e-9; signed main(void) { ll a, b; cin >> a >> b; if (a - b % 2 != 0) { mes("IMPOSSIBLE"); re0; } mes((a + b) / 2); }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <vector> #pragma GCC optimize("Ofast") using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typedef vector<pair<int, int>> vpii; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; typedef vector<vector<ll>> vvll; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define mes(a) cout << (a) << endl #define dmes(a, b) cout << (a) << " " << (b) << endl #define re0 return 0 #define mp(p, q) make_pair(p, q) #define pb(n) push_back(n) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define rSort(a) sort(a.rbegin(), a.rend()) #define MATHPI acos(-1) #define itn int; int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } }; const int INF = INT_MAX; const ll LLINF = 1LL << 60; const ll MOD = 1000000007; const double EPS = 1e-9; signed main(void) { ll a, b; cin >> a >> b; if ((a + b) % 2 == 1) { mes("IMPOSSIBLE"); re0; } mes((a + b) / 2); }
[ "control_flow.branch.if.condition.change", "misc.opposites", "expression.operator.arithmetic.change" ]
759,783
759,784
u038537254
cpp
p02957
#include <algorithm> #include <cmath> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <utility> #include <vector> const double PI = acos(-1); #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; const int mod = 1000000007; // map<string>a class mint { long long x; public: mint(long long x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint &a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //組み合わせ void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } // nCkの組み合わせに対して処理を実行する void foreach_comb(int n, int k, std::function<void(vector<int>)> f) { vector<int> indexes(k); recursive_comb(indexes, n - 1, k, f); } 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); }; // fixed << setprecision(2) int main() { ll a, b; cin >> a >> b; if ((a + b) % 2 == 1) { cout << (a + b) / 2; } else { cout << "IMPOSSIBLE"; } }
#include <algorithm> #include <cmath> #include <cstdlib> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <utility> #include <vector> const double PI = acos(-1); #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; const int mod = 1000000007; // map<string>a class mint { long long x; public: mint(long long x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint &a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //組み合わせ void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } // nCkの組み合わせに対して処理を実行する void foreach_comb(int n, int k, std::function<void(vector<int>)> f) { vector<int> indexes(k); recursive_comb(indexes, n - 1, k, f); } 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); }; // fixed << setprecision(2) int main() { ll a, b; cin >> a >> b; if ((a + b) % 2 == 0) { cout << (a + b) / 2; } else { cout << "IMPOSSIBLE"; } }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
759,790
759,791
u272628953
cpp
p02957
#include <bits/stdc++.h> #define pi 3.14159 using namespace std; int main() { long long int a, b, c, d, e; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSSIBLE" << endl; return 0; }
#include <bits/stdc++.h> #define pi 3.14159 using namespace std; int main() { long long int a, b, c, d, e; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE" << endl; return 0; }
[ "literal.string.change", "io.output.change" ]
759,820
759,821
u246218976
cpp
p02957
#include <bits/stdc++.h> #define pi 3.14159 using namespace std; int main() { int a, b, c, d, e; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSSIBLE" << endl; return 0; }
#include <bits/stdc++.h> #define pi 3.14159 using namespace std; int main() { long long int a, b, c, d, e; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE" << endl; return 0; }
[ "literal.string.change", "io.output.change" ]
759,822
759,821
u246218976
cpp
p02957
#include <bits/stdc++.h> #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define MAXX 100005 #define PI 3.14159265358979323846264338327950 #define ll signed long long int using namespace std; ll t, n, k, y = 2, m, h, s, ans = 0; ll a[MAXX] = {0}, b, c[MAXX]; vector<ll> adj[MAXX]; bool used[MAXX]; signed main() { FAST; cin >> t >> n; if (t + n % 2 == 0) { cout << t + n / 2; } else { cout << "IMPOSSIBLE"; } }
#include <bits/stdc++.h> #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define MAXX 100005 #define PI 3.14159265358979323846264338327950 #define ll signed long long int using namespace std; ll t, n, k, y = 2, m, h, s, ans = 0; ll a[MAXX] = {0}, b, c[MAXX]; vector<ll> adj[MAXX]; bool used[MAXX]; signed main() { FAST; cin >> t >> n; if ((t + n) % 2 == 0) { cout << (t + n) / 2; } else { cout << "IMPOSSIBLE"; } }
[ "control_flow.branch.if.condition.change" ]
759,920
759,921
u102842945
cpp
p02957
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll a, b; cin >> a >> b; if (a & 1 != b & 1) { puts("IMPOSSIBLE"); } else { cout << (a + b) / 2 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll a, b; cin >> a >> b; if ((a & 1) != (b & 1)) { puts("IMPOSSIBLE"); } else { cout << (a + b) / 2 << endl; } return 0; }
[ "control_flow.branch.if.condition.change" ]
759,927
759,928
u902387200
cpp
p02957
#include <bits/stdc++.h> using namespace std; void solve() { cout << fixed << setprecision(5); long long a, b; cin >> a >> b; double answer = (a + b) / 2.0; // 1.5 --> 15 // cout << "Test " << (long long)(10.0 * answer) << endl; if ((long long)(10.0 * answer) % 10 == 0) { cout << (long long)answer << endl; } else { // cout << answer << endl; cout << "Impossible" << endl; } } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { cout << fixed << setprecision(5); long long a, b; cin >> a >> b; double answer = (a + b) / 2.0; // 1.5 --> 15 // cout << "Test " << (long long)(10.0 * answer) << endl; if ((long long)(10.0 * answer) % 10 == 0) { cout << (long long)answer << endl; } else { // cout << answer << endl; cout << "IMPOSSIBLE" << endl; } } int main() { solve(); return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
759,937
759,938
u069951940
cpp
p02957
/* ╔═══╦═══╦═══╗ ║╔═╗║╔══╩╗╔╗║ ║║░║║╚══╗║║║║ ║║░║║╔══╝║║║║ ║╚═╝║╚══╦╝╚╝║ ╚══╗╠═══╩═══╝ ░░░╚╝░░░░░░░░ */ #include <bits/stdc++.h> #define ll long long #define MOD 1000000007 #define MAX 1e9 #define MIN -1e9 #define PI acos(-1.0) #define vi vector<int> #define vii vector<vi> #define vll vector<ll> #define mid(s, e) (s + (e - s) / 2) #define clz(n) __builtin_clzll(n)) using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } template <typename T> void printVec(const T &v, char sep = ' ') { for (auto &i : v) cout << i << sep; } template <typename T> void printVecPair(const T &v, char sep = ' ') { for (auto &i : v) cout << i.first << " " << i.second << sep; } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); ll a, b; cin >> a >> b; if (a == b) cout << 0; if (abs(a - ((a + b) / 2)) == abs(b - ((a + b) / 2))) { cout << (a + b) / 2; } else { cout << "Impossible"; } return 0; }
/* ╔═══╦═══╦═══╗ ║╔═╗║╔══╩╗╔╗║ ║║░║║╚══╗║║║║ ║║░║║╔══╝║║║║ ║╚═╝║╚══╦╝╚╝║ ╚══╗╠═══╩═══╝ ░░░╚╝░░░░░░░░ */ #include <bits/stdc++.h> #define ll long long #define MOD 1000000007 #define MAX 1e9 #define MIN -1e9 #define PI acos(-1.0) #define vi vector<int> #define vii vector<vi> #define vll vector<ll> #define mid(s, e) (s + (e - s) / 2) #define clz(n) __builtin_clzll(n)) using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } template <typename T> void printVec(const T &v, char sep = ' ') { for (auto &i : v) cout << i << sep; } template <typename T> void printVecPair(const T &v, char sep = ' ') { for (auto &i : v) cout << i.first << " " << i.second << sep; } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); ll a, b; cin >> a >> b; if (a == b) cout << 0; if (abs(a - ((a + b) / 2)) == abs(b - ((a + b) / 2))) { cout << (a + b) / 2; } else { cout << "IMPOSSIBLE"; } return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
759,939
759,940
u424544969
cpp
p02957
#include <bits/stdc++.h> using namespace std; int main() { long long A, B; cin >> A >> B; if ((A - B) % 2 != 0 || (B - A) % 2 != 0) { cout << "IMPOSSIBLE" << endl; return 0; } if (A > B) { cout << (A - B) / 2 << endl; } else { cout << (B - A) / 2 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long A, B; cin >> A >> B; if ((A + B) % 2 != 0 || (B + A) % 2 != 0) { cout << "IMPOSSIBLE" << endl; return 0; } if (A > B) { cout << (A + B) / 2 << endl; } else { cout << (B + A) / 2 << endl; } return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change", "io.output.change" ]
759,953
759,954
u319965179
cpp
p02957
#include <bits/stdc++.h> #define FOR(i, n) for (ll i = 0; i < n; i++) #define FORR(i, n) for (ll i = n; i >= 0; i--) #define FORS(i, m, n) for (int i = m; i < n; i++) #define ALL(v) accumulate(v.begin(), v.end(), 0) #define SORT(v) sort(v.begin(), v.end()) #define OUT(n) (cout << n << endl) #define IN1(a) (cin >> a) #define IN2(a, b) (cin >> a >> b) #define IN3(a, b, c) (cin >> a >> b >> c) #define IN4(a, b, c, d) (cin >> a >> b >> c >> d) using namespace std; typedef long long ll; int main() { ll a, b, ans; IN2(a, b); if ((b - a) % 2 == 1) { OUT("IMPOSSIBLE"); } else { ans = (a + b) / 2; OUT(ans); } }
#include <bits/stdc++.h> #define FOR(i, n) for (ll i = 0; i < n; i++) #define FORR(i, n) for (ll i = n; i >= 0; i--) #define FORS(i, m, n) for (int i = m; i < n; i++) #define ALL(v) accumulate(v.begin(), v.end(), 0) #define SORT(v) sort(v.begin(), v.end()) #define OUT(n) (cout << n << endl) #define IN1(a) (cin >> a) #define IN2(a, b) (cin >> a >> b) #define IN3(a, b, c) (cin >> a >> b >> c) #define IN4(a, b, c, d) (cin >> a >> b >> c >> d) using namespace std; typedef long long ll; int main() { ll a, b, ans; IN2(a, b); if (abs(b - a) % 2 == 1) { OUT("IMPOSSIBLE"); } else { ans = (a + b) / 2; OUT(ans); } }
[ "call.add", "control_flow.branch.if.condition.change" ]
759,974
759,975
u312666261
cpp
p02957
#include <bits/stdc++.h> #define int long long const int INF = 1e18L + 5; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int a, b; cin >> a >> b; if (a + b % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE" << endl; return 0; }
#include <bits/stdc++.h> #define int long long const int INF = 1e18L + 5; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int a, b; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE" << endl; return 0; }
[ "control_flow.branch.if.condition.change" ]
759,982
759,983
u590057656
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define int long long #define fo(a, b) for (int a = 0; a < b; a++) #define Sort(a) sort(a.begin(), a.end()) #define rev(a) reverse(a.begin(), a.end()) #define fi first #define se second #define co(a) cout << a << endl #define sz size() #define bgn begin() #define en end() #define pb(a) push_back(a) #define pp() pop_back() #define V vector #define P pair #define V2(a, b, c) V<V<int>> a(b, V<int>(c)) #define V2a(a, b, c, d) V<V<int>> a(b, V<int>(c, d)) #define incin(a) \ int a; \ cin >> a #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(), a.end()), a.end()) #define pri priority_queue #define syo <int,V<int> #define ff fi.fi #define fs fi.se #define sf se.fi #define ss se.se //#define min min<int> //#define max max<int> template <class T> void cou(vector<vector<T>> a) { int b = a.size(); int c = a[0].size(); fo(i, b) { fo(j, c) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } /*template<> void cou(vector<vector<char>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } }*/ int wari(int a, int b) { if (a % b == 0) return a / b; else return a / b + 1; } int keta(int a) { double b = a; b = log10(b); int c = b; return c + 1; } int souwa(int a) { return a * (a + 1) / 2; } /*int lcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return d*e/f; } */ int gcm(int a, int b) { int d = a, e = b, f; if (a < b) swap(a, b); int c, m = 1; while (m) { c = a % b; if (c == 0) { f = b; m--; } else { a = b; b = c; } } return f; } bool prime(int a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; double b = sqrt(a); for (int i = 3; i <= b; i += 2) { if (a % i == 0) { return false; } } return true; } struct Union { vector<int> par; Union(int a) { par = vector<int>(a, -1); } int find(int a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(int a, int b) { return find(a) == find(b); } int Size(int a) { return -par[find(a)]; } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<int>(a, b); par[a] += par[b]; par[b] = a; } }; int ketas(int a) { string b = to_string(a); int c = 0; fo(i, keta(a)) { c += b[i] - '0'; } return c; } /*int gcm(int a,int b){ if(b==0) return a; return gcm(b,a%b); }*/ int lcm(int a, int b) { return a / gcm(a, b) * b; } /*struct aa{ vector<int> gt; aa(int n){ gt= vector<int>(n, 1); } void c(V<int> d,int b){ if(d[b]==0){ gt[d[b]-1]++; gt[gt.sz-1]++; } else{ gt[d[b]-1]++; c(d,d[d[b]]-1); } } void cok(int a){ cout<<gt[a-1]<<endl; fo(i,a-1) cout<<gt[i]<<endl; } }; */ /*struct dfs(){ }*/ bool fe(int a, int b) { a %= 10; b %= 10; if (a == 0) a = 10; if (b == 0) b = 10; if (a > b) return true; else return false; } int INF = 1000000007; struct edge { int s, t, d; }; V<int> mojisyu(string a) { V<int> b(26, 0); fo(i, a.sz) { b[a[i] - 'a']++; } return b; } int wa2(int a) { if (a % 2 == 1) return a / 2; return a / 2 - 1; } signed main() { int a, b; cin >> a >> b; int c = a + b; if (c % 2 == 0) cout << c << endl; if (c % 2 == 1) cout << "IMPOSSIBLE" << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define fo(a, b) for (int a = 0; a < b; a++) #define Sort(a) sort(a.begin(), a.end()) #define rev(a) reverse(a.begin(), a.end()) #define fi first #define se second #define co(a) cout << a << endl #define sz size() #define bgn begin() #define en end() #define pb(a) push_back(a) #define pp() pop_back() #define V vector #define P pair #define V2(a, b, c) V<V<int>> a(b, V<int>(c)) #define V2a(a, b, c, d) V<V<int>> a(b, V<int>(c, d)) #define incin(a) \ int a; \ cin >> a #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(), a.end()), a.end()) #define pri priority_queue #define syo <int,V<int> #define ff fi.fi #define fs fi.se #define sf se.fi #define ss se.se //#define min min<int> //#define max max<int> template <class T> void cou(vector<vector<T>> a) { int b = a.size(); int c = a[0].size(); fo(i, b) { fo(j, c) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } /*template<> void cou(vector<vector<char>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } }*/ int wari(int a, int b) { if (a % b == 0) return a / b; else return a / b + 1; } int keta(int a) { double b = a; b = log10(b); int c = b; return c + 1; } int souwa(int a) { return a * (a + 1) / 2; } /*int lcm(int a,int b){ int d=a,e=b,f; if(a<b) swap(a,b); int c,m=1; while(m){ c=a%b; if(c==0){ f=b; m--; } else{ a=b; b=c; } } return d*e/f; } */ int gcm(int a, int b) { int d = a, e = b, f; if (a < b) swap(a, b); int c, m = 1; while (m) { c = a % b; if (c == 0) { f = b; m--; } else { a = b; b = c; } } return f; } bool prime(int a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; double b = sqrt(a); for (int i = 3; i <= b; i += 2) { if (a % i == 0) { return false; } } return true; } struct Union { vector<int> par; Union(int a) { par = vector<int>(a, -1); } int find(int a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(int a, int b) { return find(a) == find(b); } int Size(int a) { return -par[find(a)]; } void unite(int a, int b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<int>(a, b); par[a] += par[b]; par[b] = a; } }; int ketas(int a) { string b = to_string(a); int c = 0; fo(i, keta(a)) { c += b[i] - '0'; } return c; } /*int gcm(int a,int b){ if(b==0) return a; return gcm(b,a%b); }*/ int lcm(int a, int b) { return a / gcm(a, b) * b; } /*struct aa{ vector<int> gt; aa(int n){ gt= vector<int>(n, 1); } void c(V<int> d,int b){ if(d[b]==0){ gt[d[b]-1]++; gt[gt.sz-1]++; } else{ gt[d[b]-1]++; c(d,d[d[b]]-1); } } void cok(int a){ cout<<gt[a-1]<<endl; fo(i,a-1) cout<<gt[i]<<endl; } }; */ /*struct dfs(){ }*/ bool fe(int a, int b) { a %= 10; b %= 10; if (a == 0) a = 10; if (b == 0) b = 10; if (a > b) return true; else return false; } int INF = 1000000007; struct edge { int s, t, d; }; V<int> mojisyu(string a) { V<int> b(26, 0); fo(i, a.sz) { b[a[i] - 'a']++; } return b; } int wa2(int a) { if (a % 2 == 1) return a / 2; return a / 2 - 1; } signed main() { int a, b; cin >> a >> b; int c = a + b; if (c % 2 == 0) cout << c / 2 << endl; if (c % 2 == 1) cout << "IMPOSSIBLE" << endl; }
[ "expression.operation.binary.add" ]
760,058
760,059
u790461875
cpp
p02957
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll a, b; cin >> a >> b; if ((a + b) & 1) { cout << -1 << endl; } else { cout << (a + b) / 2 << endl; } }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll a, b; cin >> a >> b; if ((a + b) & 1) { cout << "IMPOSSIBLE" << endl; } else { cout << (a + b) / 2 << endl; } }
[]
760,062
760,063
u184929210
cpp
p02957
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long // 禁忌 using ll = long long; using lld = long double; #define P pair<ll, ll> #define Vi vector<ll> #define VVi vector<vector<ll>> #define Vd vector<double> #define Vb vector<bool> #define Vs vector<string> #define Vc vector<char> #define M map<ll, ll> #define S set<ll> #define PQ priority_queue<ll> #define PQG priority_queue < ll, V, greater<ll> // 重み付き辺 template <typename T> struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; // 重み付き辺集合 template <typename T> using Edges = vector<edge<T>>; // 重み付きグラフ template <typename T> using WeightedGraph = vector<Edges<T>>; using UnWeightedGraph = VVi; // 重みなしグラフ // 距離行列 template <typename T> using Matrix = vector<vector<T>>; const int MOD = 1000000007; const int INF = 1061109567; const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define PER(i, n) for (int i = (n - 1); i >= 0; --i) #define ALL(V) (V).begin(), (V).end() #define SORT(V) sort(ALL(V)) //小さい方からソート #define REV(V) reverse(ALL(V)) //リバース #define RSORT(V) \ SORT(V); \ REV(V) //大きい方からソート #define NEXP(V) next_permutation(ALL(V)) //順列 #define pb(n) emplace_back(n) #define popb pop_back() #define endl '\n' #define Endl '\n' #define DUMP(x) cout << #x << " = " << (x) << endl // UnionFind class UnionFind { public: vector<int> par; vector<int> siz; UnionFind(int sz_) : par(sz_), siz(sz_, 1LL) { for (int i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (int i = 0; i < sz_; ++i) par[i] = i; } int root(int x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(int x, int y) { return root(x) == root(y); } int size(int x) { return siz[root(x)]; } }; // modint template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<MOD>; // dijkstra O(E logV) template <typename T> vector<T> dijkstra(WeightedGraph<T> &g, int s) { const auto INF2 = numeric_limits<T>::max(); vector<T> dist(g.size(), INF2); using Pi = pair<T, int>; priority_queue<Pi, vector<Pi>, greater<Pi>> que; dist[s] = 0; que.emplace(dist[s], s); while (!que.empty()) { T cost; int idx; tie(cost, idx) = que.top(); que.pop(); if (dist[idx] < cost) continue; for (auto &e : g[idx]) { auto next_cost = cost + e.cost; if (dist[e.to] <= next_cost) continue; dist[e.to] = next_cost; que.emplace(dist[e.to], e.to); } } return dist; } // 負の辺を持つ単一始点最短路 O(VE) template <typename T> vector<T> bellman_ford(Edges<T> &edges, int V, int s) { const auto INF2 = numeric_limits<T>::max(); vector<T> dist(V, INF2); dist[s] = 0; REP(i, (V - 1)) { for (auto &e : edges) { if (dist[e.src] == INF2) continue; dist[e.to] = min(dist[e.to], dist[e.src] + e.cost); } } for (auto &e : edges) { if (dist[e.src] == INF2) continue; if (dist[e.src] + e.cost < dist[e.to]) return vector<T>(); } return dist; } // 全点対間最短路 O(V^3) template <typename T> void warshall_floyd(Matrix<T> &g, T lINF) { ll n = g.size(); REP(k, n) { REP(i, n) { REP(j, n) { if (g[i][k] == lINF || g[k][j] == lINF) continue; g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } return; } // 入出力高速化 void fast(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); return; } // vectorの合計値を返します ll vsum(Vi V) { ll res = 0LL; ll size = V.size(); REP(i, size) { res += V.at(i); } return res; } // vectorの平均値を返します lld vave(Vi V) { lld size = V.size(); return (lld)vsum(V) / size; } // vectorの最大値を返します ll vmax(Vi V) { RSORT(V); return V.at(0); } // vectorの最小値を返します ll vmin(Vi V) { SORT(V); return V.at(0); } // 数値 b が a より大きく、 c より小さいことを判定します template <typename T> bool mid1(T a, T b, T c) { return (a < b) && (b < c); } // 数値 b が a以上 で、c以下 であることを判定します template <typename T> bool mid2(T a, T b, T c) { return (a <= b) && (b <= c); } // YES or NO template <typename T> void YES(T n) { cout << ((n) ? "YES" : "NO") << endl; } // Yes or No template <typename T> void Yes(T n) { cout << ((n) ? "Yes" : "No") << endl; } // yes or no template <typename T> void yes(T n) { cout << ((n) ? "yes" : "no") << endl; } // Yay! or :( template <typename T> void Yay(T n) { cout << ((n) ? "Yay!" : ":(") << endl; } // 標準入力します inline void in(void) { return; } template <typename First, typename... Rest> void in(First &first, Rest &...rest) { cin >> first; in(rest...); return; } // vectorを標準入力 template <typename T> void vin(T &V) { ll size = V.size(); REP(i, size) { cin >> V[i]; } return; } // 標準出力します inline void out(void) { cout << endl; return; } template <typename T> void out(T only) { cout << only << endl; return; } template <typename First, typename... Rest> void out(First first, Rest... rest) { cout << first << " "; out(rest...); return; } // vectorを標準出力 template <typename T> void vout(T &V) { ll size = V.size(); REP(i, size) { cout << V.at(i) << endl; } } // vectorを1行に標準出力 template <typename T> void vout2(T &V) { ll size = V.size(); REP(i, size) { cout << V[i] << " \n"[i == (size - 1)]; } } // 最大公約数を求めます int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; } // 最小公倍数を求めます int lcm(int a, int b) { return a * b / gcd(a, b); } // 文字を全て大文字にします string toStrUp(string str) { char diff = 'A' - 'a'; REP(i, str.size()) str[i] += diff; return str; } // 素因数分解します (O(sqrt(n))) map<int, int> prime_factor(int n) { map<int, int> ret; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } // 素数判定 (O(sqrt(n))) bool is_prime(int x) { for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } // 進数変換 (O(log n)) template <typename T> vector<T> convert_base(T x, T b) { vector<T> ret; T t = 1, k = abs(b); while (x) { ret.emplace_back((x * t) % k); if (ret.back() < 0) ret.back() += k; x -= ret.back() * t; x /= k; t *= b / k; } if (ret.empty()) ret.emplace_back(0); reverse(begin(ret), end(ret)); return ret; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } signed main() { fast(); // 使えない変数名 // P, M, S, PQ, PQG // ここから int n, m, k; string s; int a, b; in(a, b); if ((a + b) % 2 == 0) { out((a + b) / 2); } else { out("IMMPOSSIBLE"); } }
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long // 禁忌 using ll = long long; using lld = long double; #define P pair<ll, ll> #define Vi vector<ll> #define VVi vector<vector<ll>> #define Vd vector<double> #define Vb vector<bool> #define Vs vector<string> #define Vc vector<char> #define M map<ll, ll> #define S set<ll> #define PQ priority_queue<ll> #define PQG priority_queue < ll, V, greater<ll> // 重み付き辺 template <typename T> struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; // 重み付き辺集合 template <typename T> using Edges = vector<edge<T>>; // 重み付きグラフ template <typename T> using WeightedGraph = vector<Edges<T>>; using UnWeightedGraph = VVi; // 重みなしグラフ // 距離行列 template <typename T> using Matrix = vector<vector<T>>; const int MOD = 1000000007; const int INF = 1061109567; const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define PER(i, n) for (int i = (n - 1); i >= 0; --i) #define ALL(V) (V).begin(), (V).end() #define SORT(V) sort(ALL(V)) //小さい方からソート #define REV(V) reverse(ALL(V)) //リバース #define RSORT(V) \ SORT(V); \ REV(V) //大きい方からソート #define NEXP(V) next_permutation(ALL(V)) //順列 #define pb(n) emplace_back(n) #define popb pop_back() #define endl '\n' #define Endl '\n' #define DUMP(x) cout << #x << " = " << (x) << endl // UnionFind class UnionFind { public: vector<int> par; vector<int> siz; UnionFind(int sz_) : par(sz_), siz(sz_, 1LL) { for (int i = 0; i < sz_; ++i) par[i] = i; } void init(ll sz_) { par.resize(sz_); siz.assign(sz_, 1LL); for (int i = 0; i < sz_; ++i) par[i] = i; } int root(int x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool issame(int x, int y) { return root(x) == root(y); } int size(int x) { return siz[root(x)]; } }; // modint template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<MOD>; // dijkstra O(E logV) template <typename T> vector<T> dijkstra(WeightedGraph<T> &g, int s) { const auto INF2 = numeric_limits<T>::max(); vector<T> dist(g.size(), INF2); using Pi = pair<T, int>; priority_queue<Pi, vector<Pi>, greater<Pi>> que; dist[s] = 0; que.emplace(dist[s], s); while (!que.empty()) { T cost; int idx; tie(cost, idx) = que.top(); que.pop(); if (dist[idx] < cost) continue; for (auto &e : g[idx]) { auto next_cost = cost + e.cost; if (dist[e.to] <= next_cost) continue; dist[e.to] = next_cost; que.emplace(dist[e.to], e.to); } } return dist; } // 負の辺を持つ単一始点最短路 O(VE) template <typename T> vector<T> bellman_ford(Edges<T> &edges, int V, int s) { const auto INF2 = numeric_limits<T>::max(); vector<T> dist(V, INF2); dist[s] = 0; REP(i, (V - 1)) { for (auto &e : edges) { if (dist[e.src] == INF2) continue; dist[e.to] = min(dist[e.to], dist[e.src] + e.cost); } } for (auto &e : edges) { if (dist[e.src] == INF2) continue; if (dist[e.src] + e.cost < dist[e.to]) return vector<T>(); } return dist; } // 全点対間最短路 O(V^3) template <typename T> void warshall_floyd(Matrix<T> &g, T lINF) { ll n = g.size(); REP(k, n) { REP(i, n) { REP(j, n) { if (g[i][k] == lINF || g[k][j] == lINF) continue; g[i][j] = min(g[i][j], g[i][k] + g[k][j]); } } } return; } // 入出力高速化 void fast(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); return; } // vectorの合計値を返します ll vsum(Vi V) { ll res = 0LL; ll size = V.size(); REP(i, size) { res += V.at(i); } return res; } // vectorの平均値を返します lld vave(Vi V) { lld size = V.size(); return (lld)vsum(V) / size; } // vectorの最大値を返します ll vmax(Vi V) { RSORT(V); return V.at(0); } // vectorの最小値を返します ll vmin(Vi V) { SORT(V); return V.at(0); } // 数値 b が a より大きく、 c より小さいことを判定します template <typename T> bool mid1(T a, T b, T c) { return (a < b) && (b < c); } // 数値 b が a以上 で、c以下 であることを判定します template <typename T> bool mid2(T a, T b, T c) { return (a <= b) && (b <= c); } // YES or NO template <typename T> void YES(T n) { cout << ((n) ? "YES" : "NO") << endl; } // Yes or No template <typename T> void Yes(T n) { cout << ((n) ? "Yes" : "No") << endl; } // yes or no template <typename T> void yes(T n) { cout << ((n) ? "yes" : "no") << endl; } // Yay! or :( template <typename T> void Yay(T n) { cout << ((n) ? "Yay!" : ":(") << endl; } // 標準入力します inline void in(void) { return; } template <typename First, typename... Rest> void in(First &first, Rest &...rest) { cin >> first; in(rest...); return; } // vectorを標準入力 template <typename T> void vin(T &V) { ll size = V.size(); REP(i, size) { cin >> V[i]; } return; } // 標準出力します inline void out(void) { cout << endl; return; } template <typename T> void out(T only) { cout << only << endl; return; } template <typename First, typename... Rest> void out(First first, Rest... rest) { cout << first << " "; out(rest...); return; } // vectorを標準出力 template <typename T> void vout(T &V) { ll size = V.size(); REP(i, size) { cout << V.at(i) << endl; } } // vectorを1行に標準出力 template <typename T> void vout2(T &V) { ll size = V.size(); REP(i, size) { cout << V[i] << " \n"[i == (size - 1)]; } } // 最大公約数を求めます int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; } // 最小公倍数を求めます int lcm(int a, int b) { return a * b / gcd(a, b); } // 文字を全て大文字にします string toStrUp(string str) { char diff = 'A' - 'a'; REP(i, str.size()) str[i] += diff; return str; } // 素因数分解します (O(sqrt(n))) map<int, int> prime_factor(int n) { map<int, int> ret; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } // 素数判定 (O(sqrt(n))) bool is_prime(int x) { for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } // 進数変換 (O(log n)) template <typename T> vector<T> convert_base(T x, T b) { vector<T> ret; T t = 1, k = abs(b); while (x) { ret.emplace_back((x * t) % k); if (ret.back() < 0) ret.back() += k; x -= ret.back() * t; x /= k; t *= b / k; } if (ret.empty()) ret.emplace_back(0); reverse(begin(ret), end(ret)); return ret; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } signed main() { fast(); // 使えない変数名 // P, M, S, PQ, PQG // ここから int n, m, k; string s; int a, b; in(a, b); if ((a + b) % 2 == 0) { out((a + b) / 2); } else { out("IMPOSSIBLE"); } }
[ "literal.string.change", "call.arguments.change" ]
760,068
760,069
u154645927
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define whole(x) (x).begin(), (x).end() #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) using ll = long long; using P = pair<int, int>; const int mod = 1000000007; int main() { ll a, b; cin >> a >> b; if (a + b % 2 == 1) { cout << "IMPOSSIBLE" << endl; return 0; } cout << (a + b) / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define whole(x) (x).begin(), (x).end() #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) using ll = long long; using P = pair<int, int>; const int mod = 1000000007; int main() { ll a, b; cin >> a >> b; if ((a + b) % 2 == 1) { cout << "IMPOSSIBLE" << endl; return 0; } cout << (a + b) / 2 << endl; return 0; }
[ "control_flow.branch.if.condition.change" ]
760,122
760,123
u488493347
cpp
p02957
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fi first #define se second #define pb push_back #define read(type, ...) \ type __VA_ARGS__; \ macro_scan(__VA_ARGS__); using namespace std; template <typename T> void macro_scan(T &t) { cin >> t; }; template <typename F, typename... R> void macro_scan(F &f, R &...r) { cin >> f; macro_scan(r...); } void deb() { cerr << endl; } template <typename T, typename... t> void deb(T a, t... b) { cerr << a << " "; deb(b...); } template <typename T> void dev(vector<T> v) { int c = 0; for (auto i : v) { cerr << i << " "; c++; } cerr << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int t; cin>>t;for(;t--;)done(); read(long long, a, b); if ((a + b) & 1) { cout << "Impossible\n"; } else { cout << (a + b) / 2 << "\n"; } }
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fi first #define se second #define pb push_back #define read(type, ...) \ type __VA_ARGS__; \ macro_scan(__VA_ARGS__); using namespace std; template <typename T> void macro_scan(T &t) { cin >> t; }; template <typename F, typename... R> void macro_scan(F &f, R &...r) { cin >> f; macro_scan(r...); } void deb() { cerr << endl; } template <typename T, typename... t> void deb(T a, t... b) { cerr << a << " "; deb(b...); } template <typename T> void dev(vector<T> v) { int c = 0; for (auto i : v) { cerr << i << " "; c++; } cerr << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int t; cin>>t;for(;t--;)done(); read(long long, a, b); if ((a + b) & 1) { cout << "IMPOSSIBLE\n"; } else { cout << (a + b) / 2 << "\n"; } }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
760,186
760,187
u048764593
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(s, i, n) for (int i = (int)s; i < (int)(n); i++) #define pb push_back typedef long long ll; int main() { ll a, b; cin >> a >> b; if ((a + b) % 2 == 1) { cout << "INPOSSIBLE" << endl; return 0; } else { cout << (a + b) / 2 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(s, i, n) for (int i = (int)s; i < (int)(n); i++) #define pb push_back typedef long long ll; int main() { ll a, b; cin >> a >> b; if ((a + b) % 2 == 1) { cout << "IMPOSSIBLE" << endl; return 0; } else { cout << (a + b) / 2 << endl; } return 0; }
[ "literal.string.change", "io.output.change" ]
760,218
760,219
u985524697
cpp
p02957
#include <bits/stdc++.h> #define REPI(i, n) for (int i = 0; i < n; i++) #define REPJ(j, n) for (int j = 0; j < n; j++) using ll = long long; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int a, b; cin >> a >> b; (a + b) % 2 ? cout << "IMPOSIBLE" : cout << (a + b) / 2; }
#include <bits/stdc++.h> #define REPI(i, n) for (int i = 0; i < n; i++) #define REPJ(j, n) for (int j = 0; j < n; j++) using ll = long long; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b; cin >> a >> b; (a + b) % 2 ? cout << "IMPOSSIBLE" : cout << (a + b) / 2; }
[ "variable_declaration.type.change", "literal.string.change", "expression.operation.binary.change" ]
760,240
760,241
u505466816
cpp
p02957
#include <bits/stdc++.h> using namespace std; int main() { long long A, B; cin >> A >> B; if (((A + B) / 2) % 2 == 0) cout << (A + B) / 2 << endl; else cout << "IMPOSSIBLE" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long A, B; cin >> A >> B; if ((A + B) % 2 == 0) cout << (A + B) / 2 << endl; else cout << "IMPOSSIBLE" << endl; }
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
760,242
760,243
u611836784
cpp
p02956
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #define ll long long #define mod 998244353 #define maxn 200010 inline ll read() { ll x = 0; char c = getchar(), f = 1; for (; c < '0' || '9' < c; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } inline void write(ll x) { static char buf[20], len; len = 0; if (x < 0) x = -x, putchar('-'); for (; x; x /= 10) buf[len++] = x % 10 + '0'; if (!len) putchar('0'); else while (len) putchar(buf[--len]); } inline void writesp(ll x) { write(x); putchar(' '); } inline void writeln(ll x) { write(x); putchar('\n'); } struct Data { int x, id; } num[maxn]; struct point { int x, y, rk; } a[maxn]; int n; bool cmp1(Data a, Data b) { return a.x < b.x; } bool cmp2(point a, point b) { return a.x < b.x; } inline ll power(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } int bit1[maxn], bit2[maxn]; void add1(int x, int k) { for (; x <= n; x += x & (-x)) bit1[x] += k; } int getsum1(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit1[x]; return sum; } void add2(int x, int k) { for (; x <= n; x += x & (-x)) bit2[x] += k; } int getsum2(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit2[x]; return sum; } int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); num[i].x = a[i].y; num[i].id = i; } std::sort(num + 1, num + n + 1, cmp1); for (int i = 1; i <= n; i++) a[num[i].id].rk = i; std::sort(a + 1, a + n + 1, cmp2); for (int i = 1; i <= n; i++) bit1[i] = 0, bit2[i] = i & (-i); ll ans = 0; for (int i = 1; i <= n; i++) { add2(a[i].rk, -1); int A = getsum1(a[i].rk), B = getsum1(n) - getsum1(a[i].rk), C = getsum2(a[i].rk), D = getsum2(n) - getsum2(a[i].rk); ll totA = power(2, A), totB = power(2, B), totC = power(2, C), totD = power(2, D); ans = (ans + (totA - 1) * (totB) % mod * totC % mod * (totD - 1)) % mod; ans = (ans + (totA) * (totB) % mod * (totC - 1) % mod * totD) % mod; ans = (ans - (totA - 1) * (totB - 1) % mod * (totC - 1) % mod * (totD - 1) % mod + mod) % mod; ans = (ans + power(2, n - 1)) % mod; add1(a[i].rk, 1); } writeln(ans); return 0; } /* | B | D --------|-------- A | C | */
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #define ll long long #define mod 998244353 #define maxn 200010 inline ll read() { ll x = 0; char c = getchar(), f = 1; for (; c < '0' || '9' < c; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } inline void write(ll x) { static char buf[20], len; len = 0; if (x < 0) x = -x, putchar('-'); for (; x; x /= 10) buf[len++] = x % 10 + '0'; if (!len) putchar('0'); else while (len) putchar(buf[--len]); } inline void writesp(ll x) { write(x); putchar(' '); } inline void writeln(ll x) { write(x); putchar('\n'); } struct Data { int x, id; } num[maxn]; struct point { int x, y, rk; } a[maxn]; int n; bool cmp1(Data a, Data b) { return a.x < b.x; } bool cmp2(point a, point b) { return a.x < b.x; } inline ll power(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } int bit1[maxn], bit2[maxn]; void add1(int x, int k) { for (; x <= n; x += x & (-x)) bit1[x] += k; } int getsum1(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit1[x]; return sum; } void add2(int x, int k) { for (; x <= n; x += x & (-x)) bit2[x] += k; } int getsum2(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit2[x]; return sum; } int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); num[i].x = a[i].y; num[i].id = i; } std::sort(num + 1, num + n + 1, cmp1); for (int i = 1; i <= n; i++) a[num[i].id].rk = i; std::sort(a + 1, a + n + 1, cmp2); for (int i = 1; i <= n; i++) bit1[i] = 0, bit2[i] = i & (-i); ll ans = 0; for (int i = 1; i <= n; i++) { add2(a[i].rk, -1); int A = getsum1(a[i].rk), B = getsum1(n) - getsum1(a[i].rk), C = getsum2(a[i].rk), D = getsum2(n) - getsum2(a[i].rk); ll totA = power(2, A), totB = power(2, B), totC = power(2, C), totD = power(2, D); ans = (ans + (totA - 1) * (totB) % mod * totC % mod * (totD - 1)) % mod; ans = (ans + (totA) * (totB - 1) % mod * (totC - 1) % mod * totD) % mod; ans = (ans - (totA - 1) * (totB - 1) % mod * (totC - 1) % mod * (totD - 1) % mod + mod) % mod; ans = (ans + power(2, n - 1)) % mod; add1(a[i].rk, 1); } writeln(ans); return 0; } /* | B | D --------|-------- A | C | */
[]
760,317
760,318
u491404948
cpp
p02956
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #define ll long long #define mod 998244353 #define maxn 200010 inline ll read() { ll x = 0; char c = getchar(), f = 1; for (; c < '0' || '9' < c; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } inline void write(ll x) { static char buf[20], len; len = 0; if (x < 0) x = -x, putchar('-'); for (; x; x /= 10) buf[len++] = x % 10 + '0'; if (!len) putchar('0'); else while (len) putchar(buf[--len]); } inline void writesp(ll x) { write(x); putchar(' '); } inline void writeln(ll x) { write(x); putchar('\n'); } struct Data { int x, id; } num[maxn]; struct point { int x, y, rk; } a[maxn]; int n; bool cmp1(Data a, Data b) { return a.x < b.x; } bool cmp2(point a, point b) { return a.x < b.x; } inline ll power(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } int bit1[maxn], bit2[maxn]; void add1(int x, int k) { for (; x <= n; x += x & (-x)) bit1[x] += k; } int getsum1(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit1[x]; return sum; } void add2(int x, int k) { for (; x <= n; x += x & (-x)) bit2[x] += k; } int getsum2(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit2[x]; return sum; } int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); num[i].x = a[i].y; num[i].id = i; } std::sort(num + 1, num + n + 1, cmp1); for (int i = 1; i <= n; i++) a[num[i].id].rk = i; std::sort(a + 1, a + n + 1, cmp2); for (int i = 1; i <= n; i++) bit1[i] = 0, bit2[i] = i & (-i); ll ans = 0; for (int i = 1; i <= n; i++) { add2(a[i].rk, -1); int A = getsum1(a[i].rk), B = getsum1(n) - getsum1(a[i].rk), C = getsum2(a[i].rk), D = getsum2(n) - getsum2(a[i].rk); ll totA = power(2, A), totB = power(2, B), totC = power(2, C), totD = power(2, D); ans = (ans + (totA - 1) * (totB - 1) % mod * totC % mod * (totD - 1)) % mod; ans = (ans + (totA - 1) * (totB) % mod * (totC - 1) % mod * totD) % mod; ans = (ans - (totA - 1) * (totB - 1) % mod * (totC - 1) % mod * (totD - 1) % mod + mod) % mod; ans = (ans + power(2, n - 1)) % mod; add1(a[i].rk, 1); } writeln(ans); return 0; } /* | B | D --------|-------- A | C | */
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #define ll long long #define mod 998244353 #define maxn 200010 inline ll read() { ll x = 0; char c = getchar(), f = 1; for (; c < '0' || '9' < c; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } inline void write(ll x) { static char buf[20], len; len = 0; if (x < 0) x = -x, putchar('-'); for (; x; x /= 10) buf[len++] = x % 10 + '0'; if (!len) putchar('0'); else while (len) putchar(buf[--len]); } inline void writesp(ll x) { write(x); putchar(' '); } inline void writeln(ll x) { write(x); putchar('\n'); } struct Data { int x, id; } num[maxn]; struct point { int x, y, rk; } a[maxn]; int n; bool cmp1(Data a, Data b) { return a.x < b.x; } bool cmp2(point a, point b) { return a.x < b.x; } inline ll power(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } int bit1[maxn], bit2[maxn]; void add1(int x, int k) { for (; x <= n; x += x & (-x)) bit1[x] += k; } int getsum1(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit1[x]; return sum; } void add2(int x, int k) { for (; x <= n; x += x & (-x)) bit2[x] += k; } int getsum2(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit2[x]; return sum; } int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); num[i].x = a[i].y; num[i].id = i; } std::sort(num + 1, num + n + 1, cmp1); for (int i = 1; i <= n; i++) a[num[i].id].rk = i; std::sort(a + 1, a + n + 1, cmp2); for (int i = 1; i <= n; i++) bit1[i] = 0, bit2[i] = i & (-i); ll ans = 0; for (int i = 1; i <= n; i++) { add2(a[i].rk, -1); int A = getsum1(a[i].rk), B = getsum1(n) - getsum1(a[i].rk), C = getsum2(a[i].rk), D = getsum2(n) - getsum2(a[i].rk); ll totA = power(2, A), totB = power(2, B), totC = power(2, C), totD = power(2, D); ans = (ans + (totA - 1) * (totB) % mod * totC % mod * (totD - 1)) % mod; ans = (ans + (totA) * (totB - 1) % mod * (totC - 1) % mod * totD) % mod; ans = (ans - (totA - 1) * (totB - 1) % mod * (totC - 1) % mod * (totD - 1) % mod + mod) % mod; ans = (ans + power(2, n - 1)) % mod; add1(a[i].rk, 1); } writeln(ans); return 0; } /* | B | D --------|-------- A | C | */
[]
760,319
760,318
u491404948
cpp
p02956
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #define ll long long #define mod 998244353 #define maxn 200010 inline ll read() { ll x = 0; char c = getchar(), f = 1; for (; c < '0' || '9' < c; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } inline void write(ll x) { static char buf[20], len; len = 0; if (x < 0) x = -x, putchar('-'); for (; x; x /= 10) buf[len++] = x % 10 + '0'; if (!len) putchar('0'); else while (len) putchar(buf[--len]); } inline void writesp(ll x) { write(x); putchar(' '); } inline void writeln(ll x) { write(x); putchar('\n'); } struct Data { int x, id; } num[maxn]; struct point { int x, y, rk; } a[maxn]; int n; bool cmp1(Data a, Data b) { return a.x < b.x; } bool cmp2(point a, point b) { return a.x < b.x; } inline ll power(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } int bit1[maxn], bit2[maxn]; void add1(int x, int k) { for (; x <= n; x += x & (-x)) bit1[x] += k; } int getsum1(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit1[x]; return sum; } void add2(int x, int k) { for (; x <= n; x += x & (-x)) bit2[x] += k; } int getsum2(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit2[x]; return sum; } int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); num[i].x = a[i].y; num[i].id = i; } std::sort(num + 1, num + n + 1, cmp1); for (int i = 1; i <= n; i++) a[num[i].id].rk = i; std::sort(a + 1, a + n + 1, cmp2); for (int i = 1; i <= n; i++) bit1[i] = 0, bit2[i] = i & (-i); ll ans = 0; for (int i = 1; i <= n; i++) { add2(a[i].rk, -1); int A = getsum1(a[i].rk), B = getsum1(n) - getsum1(a[i].rk), C = getsum2(a[i].rk), D = getsum2(n) - getsum2(a[i].rk); ll totA = power(2, A), totB = power(2, B), totC = power(2, C), totD = power(2, D); ans = (ans + (totA - 1) * (totB - 1) % mod * totC % mod * (totD - 1)) % mod; ans = (ans + (totA - 1) * (totB) % mod * (totC - 1) % mod * totD) % mod; ans = (ans - (totA - 1) * (totB - 1) % mod * (totC - 1) % mod * (totD - 1) % mod + mod) % mod; ans = (ans + power(2, n - 1)) % mod; add1(a[i].rk, 1); } writeln(ans); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #define ll long long #define mod 998244353 #define maxn 200010 inline ll read() { ll x = 0; char c = getchar(), f = 1; for (; c < '0' || '9' < c; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } inline void write(ll x) { static char buf[20], len; len = 0; if (x < 0) x = -x, putchar('-'); for (; x; x /= 10) buf[len++] = x % 10 + '0'; if (!len) putchar('0'); else while (len) putchar(buf[--len]); } inline void writesp(ll x) { write(x); putchar(' '); } inline void writeln(ll x) { write(x); putchar('\n'); } struct Data { int x, id; } num[maxn]; struct point { int x, y, rk; } a[maxn]; int n; bool cmp1(Data a, Data b) { return a.x < b.x; } bool cmp2(point a, point b) { return a.x < b.x; } inline ll power(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; } int bit1[maxn], bit2[maxn]; void add1(int x, int k) { for (; x <= n; x += x & (-x)) bit1[x] += k; } int getsum1(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit1[x]; return sum; } void add2(int x, int k) { for (; x <= n; x += x & (-x)) bit2[x] += k; } int getsum2(int x) { int sum = 0; for (; x; x -= x & (-x)) sum += bit2[x]; return sum; } int main() { n = read(); for (int i = 1; i <= n; i++) { a[i].x = read(); a[i].y = read(); num[i].x = a[i].y; num[i].id = i; } std::sort(num + 1, num + n + 1, cmp1); for (int i = 1; i <= n; i++) a[num[i].id].rk = i; std::sort(a + 1, a + n + 1, cmp2); for (int i = 1; i <= n; i++) bit1[i] = 0, bit2[i] = i & (-i); ll ans = 0; for (int i = 1; i <= n; i++) { add2(a[i].rk, -1); int A = getsum1(a[i].rk), B = getsum1(n) - getsum1(a[i].rk), C = getsum2(a[i].rk), D = getsum2(n) - getsum2(a[i].rk); ll totA = power(2, A), totB = power(2, B), totC = power(2, C), totD = power(2, D); ans = (ans + (totA - 1) * (totB) % mod * totC % mod * (totD - 1)) % mod; ans = (ans + (totA) * (totB - 1) % mod * (totC - 1) % mod * totD) % mod; ans = (ans - (totA - 1) * (totB - 1) % mod * (totC - 1) % mod * (totD - 1) % mod + mod) % mod; ans = (ans + power(2, n - 1)) % mod; add1(a[i].rk, 1); } writeln(ans); return 0; } /* | B | D --------|-------- A | C | */
[]
760,320
760,318
u491404948
cpp
p02957
#include <bits/stdc++.h> using namespace std; int main() { int64_t A, B; cin >> A >> B; int64_t x = A + B; if (x % 2 == 0) { cout << x / 2 << endl; } else { cout << "IMPOSSIBL" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int64_t A, B; cin >> A >> B; int64_t x = A + B; if (x % 2 == 0) { cout << x / 2 << endl; } else { cout << "IMPOSSIBLE" << endl; } }
[ "literal.string.change", "io.output.change" ]
760,379
760,380
u030246664
cpp
p02957
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina cout << ' ' #define in(n) cin >> n #define in2(n, m) cin >> n >> m #define in3(n, m, l) cin >> n >> m >> l #define out(n) cout << n const ll mei = (ll)1e9 + 7; int main() { ll a, b; in2(a, b); if ((a + b) % 2 == 0) out((a + b) / 2); else out("Impossible"); memi; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina cout << ' ' #define in(n) cin >> n #define in2(n, m) cin >> n >> m #define in3(n, m, l) cin >> n >> m >> l #define out(n) cout << n const ll mei = (ll)1e9 + 7; int main() { ll a, b; in2(a, b); if ((a + b) % 2 == 0) out((a + b) / 2); else out("IMPOSSIBLE"); memi; }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
760,404
760,405
u917049698
cpp
p02957
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = 1e9 + 7; // constexpr ll MOD = 998244353; // constexpr ll MOD = ; ll mod(ll A, ll M) { return (A % M + M) % M; } constexpr ll INF = 1LL << 60; template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll divceil(ll A, ll B) { return (A + (B - 1)) / B; } #define FINALANS(A) \ do { \ cout << (A) << '\n'; \ exit(0); \ } while (false) int main() { ll A, B; cin >> A >> B; if ((A + B) % 2 == 0) cout << "IMPOSSIBLE" << endl; else cout << (A + B) / 2 << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll MOD = 1e9 + 7; // constexpr ll MOD = 998244353; // constexpr ll MOD = ; ll mod(ll A, ll M) { return (A % M + M) % M; } constexpr ll INF = 1LL << 60; template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll divceil(ll A, ll B) { return (A + (B - 1)) / B; } #define FINALANS(A) \ do { \ cout << (A) << '\n'; \ exit(0); \ } while (false) int main() { ll A, B; cin >> A >> B; if ((A + B) % 2 == 1) cout << "IMPOSSIBLE" << endl; else cout << (A + B) / 2 << endl; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
760,410
760,411
u811472478
cpp
p02957
#include "bits/stdc++.h" #define rep(i, b) for (ll i = 0; i < b; i++) #define ll long long using namespace std; /*--Input//////////////////////////////////////////////////*/ inline void IN(void) { return; } template <typename First, typename... Rest> void IN(First &first, Rest &...rest) { cin >> first; IN(rest...); return; } #define SS(T, ...) \ T __VA_ARGS__; \ IN(__VA_ARGS__); #define SV(type, c, n) \ vector<type> c(n); \ for (auto &i : c) \ cin >> i; /*--Output/////////////////////////////////////////////////*/ #define Yes(n) cout << ((n) ? "Yes" : "No") << endl inline int p(void) { cout << endl; return 0; } template <class Head> int p(Head &&head) { cout << head; p(); return 0; } template <class Head, class... Tail> int p(Head &&head, Tail &&...tail) { cout << head << " "; p(forward<Tail>(tail)...); return 0; } struct ProconInit { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false; ProconInit() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } PROCON_INIT; #define vl vector<ll> #define vvl vector<vector<ll>> #define vvvl vector<vector<vector<ll>>> #define debug(x) cerr << #x << " " << x << '\n'; #define all(x) (x).begin(), (x).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 (b < a) { a = b; return 1; } return 0; } bool cmp(pair<ll, ll> a, pair<ll, ll> b) { return a.second < b.second; } const int MOD = 1000000007; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int main() { SS(ll, n, k) if (n * k % 2 == 0) p(n * k / 2); else { p("IMPOSSIBLE"); } }
#include "bits/stdc++.h" #define rep(i, b) for (ll i = 0; i < b; i++) #define ll long long using namespace std; /*--Input//////////////////////////////////////////////////*/ inline void IN(void) { return; } template <typename First, typename... Rest> void IN(First &first, Rest &...rest) { cin >> first; IN(rest...); return; } #define SS(T, ...) \ T __VA_ARGS__; \ IN(__VA_ARGS__); #define SV(type, c, n) \ vector<type> c(n); \ for (auto &i : c) \ cin >> i; /*--Output/////////////////////////////////////////////////*/ #define Yes(n) cout << ((n) ? "Yes" : "No") << endl inline int p(void) { cout << endl; return 0; } template <class Head> int p(Head &&head) { cout << head; p(); return 0; } template <class Head, class... Tail> int p(Head &&head, Tail &&...tail) { cout << head << " "; p(forward<Tail>(tail)...); return 0; } struct ProconInit { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false; ProconInit() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } PROCON_INIT; #define vl vector<ll> #define vvl vector<vector<ll>> #define vvvl vector<vector<vector<ll>>> #define debug(x) cerr << #x << " " << x << '\n'; #define all(x) (x).begin(), (x).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 (b < a) { a = b; return 1; } return 0; } bool cmp(pair<ll, ll> a, pair<ll, ll> b) { return a.second < b.second; } const int MOD = 1000000007; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int main() { SS(ll, n, k) if ((n + k) % 2 == 0) p((n + k) / 2); else { p("IMPOSSIBLE"); } }
[ "control_flow.branch.if.condition.change", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
760,442
760,443
u782733831
cpp
p02957
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b; cin >> a >> b; a = a + b; (a % 2 != 0) ? cout << "impossible" : cout << (long long int)a / 2 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b; cin >> a >> b; a = a + b; (a % 2 != 0) ? cout << "IMPOSSIBLE" << endl : cout << (long long int)a / 2 << endl; }
[ "literal.string.change", "literal.string.case.change", "expression.operation.binary.change", "io.output.newline.add" ]
760,631
760,632
u353919145
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int A, B; cin >> A >> B; if (B >= A) { int C; C = B; B = A; A = C; } if ((A - B) % 2 == 0) { cout << (A - B) / 2 + B << endl; } else { cout << "IMPPOSSIBLE" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int A, B; cin >> A >> B; if (B >= A) { int C; C = B; B = A; A = C; } if ((A - B) % 2 == 0) { cout << (A - B) / 2 + B << endl; } else { cout << "IMPOSSIBLE" << endl; } return 0; }
[ "literal.string.change", "io.output.change" ]
760,633
760,634
u934329211
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める int main() { ll a, b; cin >> a >> b; ll ans = a + b; if (ans % 2 == 1) cout << "Impossible" << endl; else cout << ans / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める int main() { ll a, b; cin >> a >> b; ll ans = a + b; if (ans % 2 == 1) cout << "IMPOSSIBLE" << endl; else cout << ans / 2 << endl; return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
760,638
760,639
u848148267
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める int main() { int a, b; cin >> a >> b; int ans = a + b; if (ans % 2 == 1) cout << "Impossible" << endl; else cout << ans / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める int main() { ll a, b; cin >> a >> b; ll ans = a + b; if (ans % 2 == 1) cout << "IMPOSSIBLE" << endl; else cout << ans / 2 << endl; return 0; }
[ "variable_declaration.type.change", "literal.string.change", "literal.string.case.change", "io.output.change" ]
760,640
760,639
u848148267
cpp
p02957
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long a, b; cin >> a >> b; if (a + b % 2 == 0) cout << (a + b) / 2 << '\n'; else cout << "IMPOSSIBLE" << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long a, b; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << '\n'; else cout << "IMPOSSIBLE" << '\n'; return 0; }
[ "control_flow.branch.if.condition.change" ]
760,658
760,659
u712429027
cpp
p02957
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) \ ; \ for (ll i = 0; i < (ll)n; i++) int main() { ll a, b; cin >> a >> b; if (a + b % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE" << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) \ ; \ for (ll i = 0; i < (ll)n; i++) int main() { ll a, b; cin >> a >> b; if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl; else cout << "IMPOSSIBLE" << endl; }
[ "control_flow.branch.if.condition.change" ]
760,674
760,675
u678961336
cpp
p02957
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(a) (a).begin(), (a).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using ll = long long; using ld = long double; using P = pair<int, int>; using DoP = pair<double, double>; using edge = struct { int to; ll cost; }; // edge x = {to, cost} const int di[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int INF = INT_MAX; const ll INF64 = 1ll << 40; const int mod = 1000000007; struct Sieve { int n; vector<int> f, primes; Sieve(int n = 1) : n(n), f(n + 1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i * i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x; } vector<int> factorList(int x) { vector<int> res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector<P> factor(int x) { vector<int> fl = factorList(x); if (fl.size() == 0) return {}; vector<P> res(1, P(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } }; struct UnionFind { vector<int> par; vector<int> siz; UnionFind(int N) : par(N), siz(N, 1) { for (int i = 0; i < N; i++) par[i] = i; } void init(int N) { siz.assign(N, 1); par.resize(N); for (int i = 0; i < N; ++i) par[i] = i; } int root(int x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool isSame(int x, int y) { return root(x) == root(y); } int size(int x) { return siz[root(x)]; } }; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; // h(n, r) = c(n+r-1, r) struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; ll modpow(ll a, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } bool compair_by_b(pair<ll, ll> a, pair<ll, ll> b) { if (a.second != b.second) return a.second < b.second; else return a.first < b.first; } int main() { double a, b; cin >> a >> b; double k = (a + b) / 2; if (k == (int)k) cout << k << endl; else cout << "IMPOSSIBLE" << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(a) (a).begin(), (a).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using ll = long long; using ld = long double; using P = pair<int, int>; using DoP = pair<double, double>; using edge = struct { int to; ll cost; }; // edge x = {to, cost} const int di[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int INF = INT_MAX; const ll INF64 = 1ll << 40; const int mod = 1000000007; struct Sieve { int n; vector<int> f, primes; Sieve(int n = 1) : n(n), f(n + 1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i * i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x; } vector<int> factorList(int x) { vector<int> res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector<P> factor(int x) { vector<int> fl = factorList(x); if (fl.size() == 0) return {}; vector<P> res(1, P(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } }; struct UnionFind { vector<int> par; vector<int> siz; UnionFind(int N) : par(N), siz(N, 1) { for (int i = 0; i < N; i++) par[i] = i; } void init(int N) { siz.assign(N, 1); par.resize(N); for (int i = 0; i < N; ++i) par[i] = i; } int root(int x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool isSame(int x, int y) { return root(x) == root(y); } int size(int x) { return siz[root(x)]; } }; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; // h(n, r) = c(n+r-1, r) struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; ll modpow(ll a, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } bool compair_by_b(pair<ll, ll> a, pair<ll, ll> b) { if (a.second != b.second) return a.second < b.second; else return a.first < b.first; } int main() { double a, b; cin >> a >> b; double k = (a + b) / 2; if (k == (int)k) cout << (int)k << endl; else cout << "IMPOSSIBLE" << endl; }
[ "type_conversion.add" ]
760,684
760,685
u740054550
cpp