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
p03061
#include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (a); i > (b); i--) #define ALL(a) (a).begin(), (a).end() int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int N, A[100000], l[100000], r[100000]; cin >> N; REP(i, N) cin >> A[i]; l[0] = A[0]; r[N - 1] = A[N - 1]; FOR(i, 1, N - 1) l[i] = gcd(l[i - 1], A[i]); RFOR(i, N - 2, 0) r[i] = gcd(r[i + 1], A[i]); int ans = 0; FOR(i, 1, N - 1) ans = max(ans, gcd(l[i - 1], r[i + 1])); ans = max(ans, max(l[N - 1], r[1])); cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (a); i > (b); i--) #define ALL(a) (a).begin(), (a).end() int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int N, A[100000], l[100000], r[100000]; cin >> N; REP(i, N) cin >> A[i]; l[0] = A[0]; r[N - 1] = A[N - 1]; FOR(i, 1, N - 1) l[i] = gcd(l[i - 1], A[i]); RFOR(i, N - 2, 0) r[i] = gcd(r[i + 1], A[i]); int ans = 0; FOR(i, 1, N - 1) ans = max(ans, gcd(l[i - 1], r[i + 1])); ans = max(ans, max(l[N - 2], r[1])); cout << ans << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,108
875,109
u472675932
cpp
p03061
#include <algorithm> #include <iomanip> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { bool counter = true, judge = true; ; int n, a[100010]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = a[n / 2]; i > 0; i--) { judge = true; counter = true; for (int j = 0; j < n / 2; j++) { if (n % 2 == 1 && j == 0) { if (a[n / 2] != 0) { if (counter) { counter = false; } else { judge = false; break; } } } if (a[j] % i != 0) { if (counter) { counter = false; } else { judge = false; break; } } if (a[n - j - 1] % i != 0) { if (counter) { counter = false; } else { judge = false; break; } } } if (judge) { cout << i << endl; break; } } if (!judge) { cout << 1 << endl; } return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <math.h> #include <stdio.h> #include <string> #include <vector> using namespace std; int main(void) { bool counter = true, judge = true; ; int n, a[100010]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = a[n / 2]; i > 0; i--) { judge = true; counter = true; for (int j = 0; j < n / 2; j++) { if (n % 2 == 1 && j == 0) { if (a[n / 2] % i != 0) { if (counter) { counter = false; } else { judge = false; break; } } } if (a[j] % i != 0) { if (counter) { counter = false; } else { judge = false; break; } } if (a[n - j - 1] % i != 0) { if (counter) { counter = false; } else { judge = false; break; } } } if (judge) { cout << i << endl; break; } } if (!judge) { cout << 1 << endl; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
875,117
875,118
u114838227
cpp
p03061
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i--;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define Reverse(x) reverse(all(x)) #define PQ priority_queue #define NP(x) next_permutation(all(x)) #define M_PI 3.14159265358979323846 #define popcount __builtin_popcount using namespace std; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef unsigned long long ull; typedef vector<ull> vu; typedef vector<vu> vvu; typedef double dbl; typedef vector<dbl> vd; typedef vector<vd> vvd; typedef string str; typedef vector<str> vs; typedef vector<vs> vvs; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef map<int, int> mii; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef map<ll, ll> mll; typedef pair<dbl, dbl> pdd; typedef vector<pdd> vpdd; typedef map<dbl, dbl> mdd; typedef pair<str, str> pss; typedef vector<pss> vpss; typedef map<str, str> mss; typedef pair<int, ll> pil; typedef vector<pil> vpil; typedef map<int, ll> mil; typedef pair<ll, int> pli; typedef vector<pli> vpli; typedef map<ll, int> mli; typedef pair<dbl, int> pdi; typedef vector<pdi> vpdi; typedef map<dbl, int> mdi; template <typename T> vector<T> &operator<<(vector<T> &v, const T t) { v.push_back(t); return v; } template <typename T> multiset<T> &operator<<(multiset<T> &m, const T t) { m.insert(t); return m; } template <typename T> set<T> &operator<<(set<T> &s, const T t) { s.insert(t); return s; } template <typename T> stack<T> &operator<<(stack<T> &s, const T t) { s.push(t); return s; } template <typename T> stack<T> &operator>>(stack<T> &s, T &t) { t = s.top(); s.pop(); return s; } template <typename T> queue<T> &operator<<(queue<T> &q, const T t) { q.push(t); return q; } template <typename T> queue<T> &operator>>(queue<T> &q, T &t) { t = q.front(); q.pop(); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator<<(PQ<T, vector<T>, U> &q, const T t) { q.push(t); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator>>(PQ<T, vector<T>, U> &q, T &t) { t = q.top(); q.pop(); return q; } template <typename T, typename U> istream &operator>>(istream &s, pair<T, U> &p) { return s >> p.first >> p.second; } template <typename T> istream &operator>>(istream &s, vector<T> &v) { fr(i, v.size()) { s >> v[i]; } return s; } template <typename T, typename U> ostream &operator<<(ostream &s, const pair<T, U> p) { return s << p.first << " " << p.second; } // template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto // a:v){s<<a<<endl;}return s;} template <typename T> ostream &operator<<(ostream &s, const vector<T> v) { fr(i, v.size()) { i ? s << " " << v[i] : s << v[i]; } return s; } template <typename T> ostream &operator<<(ostream &s, const deque<T> d) { fr(i, d.size()) { i ? s << " " << d[i] : s << d[i]; } return s; } template <typename T> _Bit_reference operator&=(_Bit_reference b, T t) { return b = b & t; } template <typename T> _Bit_reference operator^=(_Bit_reference b, T t) { return b = b ^ t; } template <typename T> _Bit_reference operator|=(_Bit_reference b, T t) { return b = b | t; } template <typename T, typename U> pair<T, U> operator+(pair<T, U> a, pair<T, U> b) { return {a.first + b.first, a.second + b.second}; } template <typename T, typename U> pair<T, U> operator-(pair<T, U> a, pair<T, U> b) { return {a.first - b.first, a.second - b.second}; } void print(void) { cout << endl; } template <typename T> void print(T t) { cout << t << endl; } template <typename T, typename... U> void print(T &&t, U &&...u) { cout << t << " "; print(forward<U>(u)...); } bool YN(bool b) { print(b ? "YES" : "NO"); return b; } bool PI(bool b) { print(b ? "POSSIBLE" : "IMPOSSIBLE"); return b; } bool Yn(bool b) { print(b ? "Yes" : "No"); return b; } bool Pi(bool b) { print(b ? "Possible" : "Impossible"); return b; } bool yn(bool b) { print(b ? "yes" : "no"); return b; } bool pi(bool b) { print(b ? "possible" : "impossible"); return b; } const int e5 = 1e5; const int e9 = 1e9; const int MD = 1e9 + 7; const ll e18 = 1e18; template <typename T> str to_string(const T &n) { ostringstream s; s << n; return s.str(); } template <typename T> T &chmax(T &a, T b) { return a = max(a, b); } template <typename T> T &chmin(T &a, T b) { return a = min(a, b); } template <typename T, typename U> vector<pair<T, U>> dijkstra(const vector<vector<pair<T, U>>> &E, const U s, const T inf) { using P = pair<T, U>; vector<P> d; fr(i, E.size()) { d << P{inf, i}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } template <typename T, typename U> map<U, pair<T, U>> dijkstra(map<U, vector<pair<T, U>>> E, const U s, const T inf) { using P = pair<T, U>; map<U, P> d; for (pair<U, vector<P>> e : E) { d[e.first] = P{inf, e.first}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } ll maxflow(vector<mil> &E, int s, int t) { ll z = 0; vi b(E.size(), -1); for (int i = 0;; ++i) { static auto dfs = [&](int v, ll f, auto &dfs) -> ll { if (v == t) return f; b[v] = i; for (auto &p : E[v]) { if (b[p.first] < i && p.second) { if (ll r = dfs(p.first, min(f, p.second), dfs)) { p.second -= r; E[p.first][v] += r; return r; } } } return 0; }; ll x = dfs(s, ll(1e18), dfs); z += x; if (x == 0) return z; } } template <typename T> T distsq(pair<T, T> a, pair<T, T> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } template <typename T> T max(const vector<T> a) { T m = a[0]; for (T e : a) { m = max(m, e); } return m; } template <typename T> T min(const vector<T> a) { T m = a[0]; for (T e : a) { m = min(m, e); } return m; } template <typename T> T gcd(const T a, const T b) { return a ? gcd(b % a, a) : b; } template <typename T> T gcd(const vector<T> a) { T g = a[0]; for (T e : a) { g = gcd(g, e); } return g; } template <typename T> vector<T> LIS(const vector<T> A) { vector<T> B; for (T a : A) { auto it = lower_bound(all(B), a); if (it == B.end()) { B << a; } else { *it = a; } } return B; } template <typename T> vector<T> LCS(vector<T> A, vector<T> B) { int N = A.size(), M = B.size(); vector<vector<pair<int, pii>>> d(N + 1, vector<pair<int, pii>>(M + 1)); fr(i, N) { fr(j, M) { if (A[i] == B[j]) { d[i + 1][j + 1] = {d[i][j].first + 1, {i, j}}; } else { d[i + 1][j + 1] = max(d[i][j + 1], d[i + 1][j]); } } } vector<T> r; for (pii p = {N, M}; d[p.first][p.second].first; p = d[p.first][p.second].second) { r << A[d[p.first][p.second].second.first]; } Reverse(r); return r; } str LCS(str S, str T) { vector<char> s = LCS(vector<char>(S.begin(), S.end()), vector<char>(T.begin(), T.end())); return str(s.begin(), s.end()); } template <typename T> vector<pair<T, T>> ConvexHull(vector<pair<T, T>> V) { if (V.size() <= 3) { return V; } Sort(V); rf(i, V.size() - 1) V << V[i]; vector<pair<T, T>> r; for (pair<T, T> p : V) { int s = r.size(); while (s >= 2 && (p.second - r[s - 1].second) * (p.first - r[s - 2].first) < (p.second - r[s - 2].second) * (p.first - r[s - 1].first)) { r.pop_back(); --s; } r << p; } r.pop_back(); return r; } class UnionFind { vi p, s; void extend(int N) { foor(i, p.size(), N) { p << i; s << 1; } } public: UnionFind(void) {} UnionFind(int N) { extend(N - 1); } int find(int i) { extend(i); return p[i] = p[i] == i ? i : find(p[i]); } void unite(int a, int b) { extend(a); extend(b); if ((a = find(a)) != (b = find(b))) { if (s[a] > s[b]) { swap(a, b); } s[b] += s[a]; p[a] = b; } } void unite(pii p) { return unite(p.first, p.second); } bool same(int a, int b) { extend(a); extend(b); return find(a) == find(b); } bool same(pii p) { return same(p.first, p.second); } int size(int x) { extend(x); return s[find(x)]; } }; ll MST(vector<pair<ll, pii>> &E) { Sort(E); UnionFind uf; ll z = 0; for (auto &e : E) { if (!uf.same(e.second)) { z += e.first; uf.unite(e.second); } } return z; } ll strmod(const str &s, const int m) { ll x = 0; fr(i, s.size()) { x = (x * 10 + s[i] - 48) % m; } return x; } vvl mul(const vvl &A, const vvl &B, const int m) { vvl C; fr(y, A.size()) { C << vl(B[y].size()); } fr(y, C.size()) { fr(x, C[y].size()) { fr(i, A[0].size()) { (C[y][x] += A[y][i] * B[i][x]) %= m; } } } return C; } vvl pow(const vvl &A, const ll n, const int m) { vvl B; fr(y, A.size()) { B << vl(A.size()); } if (n == 0) { fr(i, B.size()) { B[i][i] = 1; } } elsif(n % 2) { B = mul(A, pow(A, n - 1, m), m); } else { vvl C = pow(A, n / 2, m); B = mul(C, C, m); } return B; } ll pow(const ll a, const ll n, const int m) { ll t; return n ? (n & 1 ? a >= 0 ? a % m : (m - (-a % m)) % m : 1) * (t = pow(a, n >> 1, m), t * t % m) % m : !!a; } ll inv(const ll x, const int p) { return pow(x, p - 2, p); } ll inv(const ll x) { return inv(x, MD); } vpll fact(const int n, const int p) { vpll v(n + 1); v[0].first = 1; foor(i, 1, n) { v[i].first = v[i - 1].first * i % p; } v[n].second = inv(v[n].first, p); roof(i, n, 1) { v[i - 1].second = v[i].second * i % p; } return v; } class Combination { const vpll f; const int M; public: Combination(int n, int m) : f(fact(n, m)), M(m) {} Combination(int n) : Combination(n, MD) {} ll P(int n, int k) { return n < 0 || k < 0 || n < k ? 0ll : f[n].first * f[n - k].second % M; } ll C(int n, int k) { return P(n, k) * f[k].second % M; } ll H(int n, int k) { return n == 0 && k == 0 ? 1ll : C(n + k - 1, k); } }; ll C2(const int n) { return (ll)n * ~-n / 2; } ll sum(const vi a) { ll s = 0; for (int e : a) { s += e; } return s; } ll sum(const vl a) { ll s = 0; for (ll e : a) { s += e; } return s; } template <typename T> int MSB(T N) { int r = -1; for (; N > 0; N /= 2) { ++r; } return r; } template <typename T> class SegmentTree { vector<T> S; T (*const op)(T a, T b); const T zero; const int B; public: SegmentTree(int N, T (*f)(T a, T b), const T zero) : S(1 << MSB(N - 1) + 2, zero), op(f), zero(zero), B(1 << MSB(N - 1) + 1) {} SegmentTree(vector<T> v, T (*f)(T a, T b), const T zero) : SegmentTree(v.size(), f, zero) { fr(i, v.size()) { S[S.size() / 2 + i] = v[i]; } roof(i, S.size() / 2 - 1, 1) { S[i] = op(S[i * 2], S[i * 2 + 1]); } } T calc(int l, int r) { l += B; r += B; if (l > r) { return zero; } if (l == r) { return S[l]; } T L = S[l], R = S[r]; for (; l / 2 < r / 2; l /= 2, r /= 2) { if (l % 2 == 0) { L = op(L, S[l + 1]); } if (r % 2 == 1) { R = op(S[r - 1], R); } } return op(L, R); } void replace(int i, T x) { for (S[i += B] = x; i != 1; i /= 2) { if (i % 2) { S[i / 2] = op(S[i - 1], S[i]); } else { S[i / 2] = op(S[i], S[i + 1]); } } } void add(int i, T x) { replace(i, op(S[B + i], x)); } T top() { return S[1]; } }; ll BITsum(vl &B, int i) { ll z = 0; while (i > 0) { z += B[i]; i -= i & -i; } return z; } void BITadd(vl &B, int i, ll x) { while (i < B.size()) { B[i] += x; i += i & -i; } } ll fib(const ll n, const int m) { ll a, b, c, d, A, B, C, D; a = 1; b = 0; c = 0; d = 1; rf(i, 63) { A = a * a + b * c; B = a * b + b * d; C = c * a + d * c; D = c * b + d * d; if (n >> i & 1) { a = A; b = B; c = C; d = D; A = a + b; B = a; C = c + d; D = c; } a = A % m; b = B % m; c = C % m; d = D % m; } return b; } vi primes(int n) { vb b(n + 1); vi p; foor(i, 2, n) { if (!b[i]) { p << i; for (int j = 2 * i; j <= n; j += i) { b[j] = true; } } } return p; } vb isprime(const int n) { vb v(n + 1, true); v[0] = v[1] = false; foor(i, 2, n) { if (v[i]) { for (int j = 2 * i; j <= n; j += i) { v[j] = false; } } } return v; } int g(int a, int b) { return b ? gcd(a, b) : a; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vi A(N); cin >> A; SegmentTree<int> S(A, g, 0); int z = max(S.calc(1, N - 1), S.calc(0, N - 1)); foor(i, 1, N - 2) { chmax(z, gcd(S.calc(0, i - 1), S.calc(i + 1, N - 1))); } print(z); return 0; }
#include <bits/stdc++.h> #define fr(i, n) for (int i = 0; i < (n); ++i) #define foor(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, n) for (int i = (n); i--;) #define roof(i, b, a) for (int i = (b); i >= (a); --i) #define elsif else if #define all(x) x.begin(), x.end() #define Sort(x) sort(all(x)) #define Reverse(x) reverse(all(x)) #define PQ priority_queue #define NP(x) next_permutation(all(x)) #define M_PI 3.14159265358979323846 #define popcount __builtin_popcount using namespace std; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<int> vi; typedef vector<vi> vvi; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef unsigned long long ull; typedef vector<ull> vu; typedef vector<vu> vvu; typedef double dbl; typedef vector<dbl> vd; typedef vector<vd> vvd; typedef string str; typedef vector<str> vs; typedef vector<vs> vvs; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef map<int, int> mii; typedef pair<ll, ll> pll; typedef vector<pll> vpll; typedef map<ll, ll> mll; typedef pair<dbl, dbl> pdd; typedef vector<pdd> vpdd; typedef map<dbl, dbl> mdd; typedef pair<str, str> pss; typedef vector<pss> vpss; typedef map<str, str> mss; typedef pair<int, ll> pil; typedef vector<pil> vpil; typedef map<int, ll> mil; typedef pair<ll, int> pli; typedef vector<pli> vpli; typedef map<ll, int> mli; typedef pair<dbl, int> pdi; typedef vector<pdi> vpdi; typedef map<dbl, int> mdi; template <typename T> vector<T> &operator<<(vector<T> &v, const T t) { v.push_back(t); return v; } template <typename T> multiset<T> &operator<<(multiset<T> &m, const T t) { m.insert(t); return m; } template <typename T> set<T> &operator<<(set<T> &s, const T t) { s.insert(t); return s; } template <typename T> stack<T> &operator<<(stack<T> &s, const T t) { s.push(t); return s; } template <typename T> stack<T> &operator>>(stack<T> &s, T &t) { t = s.top(); s.pop(); return s; } template <typename T> queue<T> &operator<<(queue<T> &q, const T t) { q.push(t); return q; } template <typename T> queue<T> &operator>>(queue<T> &q, T &t) { t = q.front(); q.pop(); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator<<(PQ<T, vector<T>, U> &q, const T t) { q.push(t); return q; } template <typename T, typename U> PQ<T, vector<T>, U> &operator>>(PQ<T, vector<T>, U> &q, T &t) { t = q.top(); q.pop(); return q; } template <typename T, typename U> istream &operator>>(istream &s, pair<T, U> &p) { return s >> p.first >> p.second; } template <typename T> istream &operator>>(istream &s, vector<T> &v) { fr(i, v.size()) { s >> v[i]; } return s; } template <typename T, typename U> ostream &operator<<(ostream &s, const pair<T, U> p) { return s << p.first << " " << p.second; } // template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto // a:v){s<<a<<endl;}return s;} template <typename T> ostream &operator<<(ostream &s, const vector<T> v) { fr(i, v.size()) { i ? s << " " << v[i] : s << v[i]; } return s; } template <typename T> ostream &operator<<(ostream &s, const deque<T> d) { fr(i, d.size()) { i ? s << " " << d[i] : s << d[i]; } return s; } template <typename T> _Bit_reference operator&=(_Bit_reference b, T t) { return b = b & t; } template <typename T> _Bit_reference operator^=(_Bit_reference b, T t) { return b = b ^ t; } template <typename T> _Bit_reference operator|=(_Bit_reference b, T t) { return b = b | t; } template <typename T, typename U> pair<T, U> operator+(pair<T, U> a, pair<T, U> b) { return {a.first + b.first, a.second + b.second}; } template <typename T, typename U> pair<T, U> operator-(pair<T, U> a, pair<T, U> b) { return {a.first - b.first, a.second - b.second}; } void print(void) { cout << endl; } template <typename T> void print(T t) { cout << t << endl; } template <typename T, typename... U> void print(T &&t, U &&...u) { cout << t << " "; print(forward<U>(u)...); } bool YN(bool b) { print(b ? "YES" : "NO"); return b; } bool PI(bool b) { print(b ? "POSSIBLE" : "IMPOSSIBLE"); return b; } bool Yn(bool b) { print(b ? "Yes" : "No"); return b; } bool Pi(bool b) { print(b ? "Possible" : "Impossible"); return b; } bool yn(bool b) { print(b ? "yes" : "no"); return b; } bool pi(bool b) { print(b ? "possible" : "impossible"); return b; } const int e5 = 1e5; const int e9 = 1e9; const int MD = 1e9 + 7; const ll e18 = 1e18; template <typename T> str to_string(const T &n) { ostringstream s; s << n; return s.str(); } template <typename T> T &chmax(T &a, T b) { return a = max(a, b); } template <typename T> T &chmin(T &a, T b) { return a = min(a, b); } template <typename T, typename U> vector<pair<T, U>> dijkstra(const vector<vector<pair<T, U>>> &E, const U s, const T inf) { using P = pair<T, U>; vector<P> d; fr(i, E.size()) { d << P{inf, i}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } template <typename T, typename U> map<U, pair<T, U>> dijkstra(map<U, vector<pair<T, U>>> E, const U s, const T inf) { using P = pair<T, U>; map<U, P> d; for (pair<U, vector<P>> e : E) { d[e.first] = P{inf, e.first}; } PQ<P, vector<P>, greater<P>> pq; pq << (d[s] = P{0, s}); while (pq.size()) { P a = pq.top(); pq.pop(); U v = a.second; if (d[v].first >= a.first) { for (P e : E[v]) { if (d[v].first + e.first < d[e.second].first) { d[e.second] = P{d[v].first + e.first, v}; pq << P{d[v].first + e.first, e.second}; } } } } return d; } ll maxflow(vector<mil> &E, int s, int t) { ll z = 0; vi b(E.size(), -1); for (int i = 0;; ++i) { static auto dfs = [&](int v, ll f, auto &dfs) -> ll { if (v == t) return f; b[v] = i; for (auto &p : E[v]) { if (b[p.first] < i && p.second) { if (ll r = dfs(p.first, min(f, p.second), dfs)) { p.second -= r; E[p.first][v] += r; return r; } } } return 0; }; ll x = dfs(s, ll(1e18), dfs); z += x; if (x == 0) return z; } } template <typename T> T distsq(pair<T, T> a, pair<T, T> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } template <typename T> T max(const vector<T> a) { T m = a[0]; for (T e : a) { m = max(m, e); } return m; } template <typename T> T min(const vector<T> a) { T m = a[0]; for (T e : a) { m = min(m, e); } return m; } template <typename T> T gcd(const T a, const T b) { return a ? gcd(b % a, a) : b; } template <typename T> T gcd(const vector<T> a) { T g = a[0]; for (T e : a) { g = gcd(g, e); } return g; } template <typename T> vector<T> LIS(const vector<T> A) { vector<T> B; for (T a : A) { auto it = lower_bound(all(B), a); if (it == B.end()) { B << a; } else { *it = a; } } return B; } template <typename T> vector<T> LCS(vector<T> A, vector<T> B) { int N = A.size(), M = B.size(); vector<vector<pair<int, pii>>> d(N + 1, vector<pair<int, pii>>(M + 1)); fr(i, N) { fr(j, M) { if (A[i] == B[j]) { d[i + 1][j + 1] = {d[i][j].first + 1, {i, j}}; } else { d[i + 1][j + 1] = max(d[i][j + 1], d[i + 1][j]); } } } vector<T> r; for (pii p = {N, M}; d[p.first][p.second].first; p = d[p.first][p.second].second) { r << A[d[p.first][p.second].second.first]; } Reverse(r); return r; } str LCS(str S, str T) { vector<char> s = LCS(vector<char>(S.begin(), S.end()), vector<char>(T.begin(), T.end())); return str(s.begin(), s.end()); } template <typename T> vector<pair<T, T>> ConvexHull(vector<pair<T, T>> V) { if (V.size() <= 3) { return V; } Sort(V); rf(i, V.size() - 1) V << V[i]; vector<pair<T, T>> r; for (pair<T, T> p : V) { int s = r.size(); while (s >= 2 && (p.second - r[s - 1].second) * (p.first - r[s - 2].first) < (p.second - r[s - 2].second) * (p.first - r[s - 1].first)) { r.pop_back(); --s; } r << p; } r.pop_back(); return r; } class UnionFind { vi p, s; void extend(int N) { foor(i, p.size(), N) { p << i; s << 1; } } public: UnionFind(void) {} UnionFind(int N) { extend(N - 1); } int find(int i) { extend(i); return p[i] = p[i] == i ? i : find(p[i]); } void unite(int a, int b) { extend(a); extend(b); if ((a = find(a)) != (b = find(b))) { if (s[a] > s[b]) { swap(a, b); } s[b] += s[a]; p[a] = b; } } void unite(pii p) { return unite(p.first, p.second); } bool same(int a, int b) { extend(a); extend(b); return find(a) == find(b); } bool same(pii p) { return same(p.first, p.second); } int size(int x) { extend(x); return s[find(x)]; } }; ll MST(vector<pair<ll, pii>> &E) { Sort(E); UnionFind uf; ll z = 0; for (auto &e : E) { if (!uf.same(e.second)) { z += e.first; uf.unite(e.second); } } return z; } ll strmod(const str &s, const int m) { ll x = 0; fr(i, s.size()) { x = (x * 10 + s[i] - 48) % m; } return x; } vvl mul(const vvl &A, const vvl &B, const int m) { vvl C; fr(y, A.size()) { C << vl(B[y].size()); } fr(y, C.size()) { fr(x, C[y].size()) { fr(i, A[0].size()) { (C[y][x] += A[y][i] * B[i][x]) %= m; } } } return C; } vvl pow(const vvl &A, const ll n, const int m) { vvl B; fr(y, A.size()) { B << vl(A.size()); } if (n == 0) { fr(i, B.size()) { B[i][i] = 1; } } elsif(n % 2) { B = mul(A, pow(A, n - 1, m), m); } else { vvl C = pow(A, n / 2, m); B = mul(C, C, m); } return B; } ll pow(const ll a, const ll n, const int m) { ll t; return n ? (n & 1 ? a >= 0 ? a % m : (m - (-a % m)) % m : 1) * (t = pow(a, n >> 1, m), t * t % m) % m : !!a; } ll inv(const ll x, const int p) { return pow(x, p - 2, p); } ll inv(const ll x) { return inv(x, MD); } vpll fact(const int n, const int p) { vpll v(n + 1); v[0].first = 1; foor(i, 1, n) { v[i].first = v[i - 1].first * i % p; } v[n].second = inv(v[n].first, p); roof(i, n, 1) { v[i - 1].second = v[i].second * i % p; } return v; } class Combination { const vpll f; const int M; public: Combination(int n, int m) : f(fact(n, m)), M(m) {} Combination(int n) : Combination(n, MD) {} ll P(int n, int k) { return n < 0 || k < 0 || n < k ? 0ll : f[n].first * f[n - k].second % M; } ll C(int n, int k) { return P(n, k) * f[k].second % M; } ll H(int n, int k) { return n == 0 && k == 0 ? 1ll : C(n + k - 1, k); } }; ll C2(const int n) { return (ll)n * ~-n / 2; } ll sum(const vi a) { ll s = 0; for (int e : a) { s += e; } return s; } ll sum(const vl a) { ll s = 0; for (ll e : a) { s += e; } return s; } template <typename T> int MSB(T N) { int r = -1; for (; N > 0; N /= 2) { ++r; } return r; } template <typename T> class SegmentTree { vector<T> S; T (*const op)(T a, T b); const T zero; const int B; public: SegmentTree(int N, T (*f)(T a, T b), const T zero) : S(1 << MSB(N - 1) + 2, zero), op(f), zero(zero), B(1 << MSB(N - 1) + 1) {} SegmentTree(vector<T> v, T (*f)(T a, T b), const T zero) : SegmentTree(v.size(), f, zero) { fr(i, v.size()) { S[S.size() / 2 + i] = v[i]; } roof(i, S.size() / 2 - 1, 1) { S[i] = op(S[i * 2], S[i * 2 + 1]); } } T calc(int l, int r) { l += B; r += B; if (l > r) { return zero; } if (l == r) { return S[l]; } T L = S[l], R = S[r]; for (; l / 2 < r / 2; l /= 2, r /= 2) { if (l % 2 == 0) { L = op(L, S[l + 1]); } if (r % 2 == 1) { R = op(S[r - 1], R); } } return op(L, R); } void replace(int i, T x) { for (S[i += B] = x; i != 1; i /= 2) { if (i % 2) { S[i / 2] = op(S[i - 1], S[i]); } else { S[i / 2] = op(S[i], S[i + 1]); } } } void add(int i, T x) { replace(i, op(S[B + i], x)); } T top() { return S[1]; } }; ll BITsum(vl &B, int i) { ll z = 0; while (i > 0) { z += B[i]; i -= i & -i; } return z; } void BITadd(vl &B, int i, ll x) { while (i < B.size()) { B[i] += x; i += i & -i; } } ll fib(const ll n, const int m) { ll a, b, c, d, A, B, C, D; a = 1; b = 0; c = 0; d = 1; rf(i, 63) { A = a * a + b * c; B = a * b + b * d; C = c * a + d * c; D = c * b + d * d; if (n >> i & 1) { a = A; b = B; c = C; d = D; A = a + b; B = a; C = c + d; D = c; } a = A % m; b = B % m; c = C % m; d = D % m; } return b; } vi primes(int n) { vb b(n + 1); vi p; foor(i, 2, n) { if (!b[i]) { p << i; for (int j = 2 * i; j <= n; j += i) { b[j] = true; } } } return p; } vb isprime(const int n) { vb v(n + 1, true); v[0] = v[1] = false; foor(i, 2, n) { if (v[i]) { for (int j = 2 * i; j <= n; j += i) { v[j] = false; } } } return v; } int g(int a, int b) { return b ? gcd(a, b) : a; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vi A(N); cin >> A; SegmentTree<int> S(A, g, 0); int z = max(S.calc(1, N - 1), S.calc(0, N - 2)); foor(i, 1, N - 2) { chmax(z, gcd(S.calc(0, i - 1), S.calc(i + 1, N - 1))); } print(z); return 0; }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
875,125
875,126
u283869437
cpp
p03061
#include <algorithm> #include <iostream> #include <vector> using ull = unsigned long long; using ui = unsigned int; int main() { ui n; std::cin >> n; std::vector<ull> an(n, ull{}); for (auto &a : an) std::cin >> a; std::sort(std::begin(an), std::end(an)); const auto min_ = an[0]; ull ans = 1; for (ull i{min_}; i >= 2; --i) { ui discount_{}; for (ui j{}; j < n; ++j) { discount_ += an[j] % i != 0 ? 1 : 0; if (discount_ >= 2) break; } if (discount_ <= 1) { ans = i; break; } } std::cout << ans << "\n"; return 0; }
#include <algorithm> #include <iostream> #include <vector> using ull = unsigned long long; using ui = unsigned int; int main() { ui n; std::cin >> n; std::vector<ull> an(n, ull{}); for (auto &a : an) std::cin >> a; std::sort(std::begin(an), std::end(an)); const auto min_2 = an[1]; ull ans = 1; for (ull i{min_2}; i >= 2; --i) { ui discount_{}; for (ui j{}; j < n; ++j) { discount_ += an[j] % i != 0 ? 1 : 0; if (discount_ >= 2) break; } if (discount_ <= 1) { ans = i; break; } } std::cout << ans << "\n"; return 0; }
[ "variable_declaration.name.change", "identifier.change", "literal.number.change", "variable_access.subscript.index.change", "control_flow.loop.for.initializer.change" ]
875,129
875,128
u837286475
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define fi first #define se second typedef pair<ll, ll> P; #define Mod 1000000007 using VP = vector<P>; using VVP = vector<VP>; using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>; #define INF 1ll << 59 int main() { ll i, j; ll n; cin >> n; ll a[n]; for (i = 0; i < n; i++) cin >> a[i]; vector<ll> v; for (j = 0; j < 2; j++) { for (i = 2; i * i <= a[j]; i++) { if (a[j] % i == 0) { v.pb(i); v.pb(a[j] / i); } } } ll m = 1; for (i = 0; i < v.size(); i++) { ll f = 0; for (j = 0; j < n; j++) { if (a[j] % v[i] != 0) { if (f == 1) break; else f = 1; } if (j == n - 1) m = max(m, v[i]); } } cout << m << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define fi first #define se second typedef pair<ll, ll> P; #define Mod 1000000007 using VP = vector<P>; using VVP = vector<VP>; using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>; #define INF 1ll << 59 int main() { ll i, j; ll n; cin >> n; ll a[n]; for (i = 0; i < n; i++) cin >> a[i]; vector<ll> v; for (j = 0; j < 2; j++) { for (i = 1; i * i <= a[j]; i++) { if (a[j] % i == 0) { v.pb(i); v.pb(a[j] / i); } } } ll m = 1; for (i = 0; i < v.size(); i++) { ll f = 0; for (j = 0; j < n; j++) { if (a[j] % v[i] != 0) { if (f == 1) break; else f = 1; } if (j == n - 1) m = max(m, v[i]); } } cout << m << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
875,130
875,131
u586567203
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { if (a < b) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } int main() { ll n; cin >> n; ll a[n]; for (int i = 0; i < n; i++) cin >> a[i]; ll u = pow(n, 0.5); vector<ll> v; ll now = a[0]; for (int i = 1; i < n; i++) { if (i % u == 0) { v.push_back(now); now = a[i]; } else { now = gcd(now, a[i]); } } v.push_back(now); // cout<<u;return 0; // cout<<t[0]<<t[1]<<t[2];return 0; ll ans = 0; for (int i = 0; i < n; i++) { ll y = i / u; ll r; if (y == 0) r = v[1]; else r = v[0]; for (int j = 0; j < v.size(); j++) { if (j == y) continue; r = gcd(r, v[j]); } for (int j = y * u; j < y * u + u; j++) { if (j == i) continue; r = gcd(r, a[j]); } ans = max(r, ans); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { if (a < b) swap(a, b); if (a % b == 0) return b; return gcd(b, a % b); } int main() { ll n; cin >> n; ll a[n]; for (int i = 0; i < n; i++) cin >> a[i]; ll u = pow(n, 0.5); vector<ll> v; ll now = a[0]; for (int i = 1; i < n; i++) { if (i % u == 0) { v.push_back(now); now = a[i]; } else { now = gcd(now, a[i]); } } v.push_back(now); // cout<<u;return 0; // cout<<t[0]<<t[1]<<t[2];return 0; ll ans = 0; for (int i = 0; i < n; i++) { ll y = i / u; ll r; if (y == 0) r = v[1]; else r = v[0]; for (int j = 0; j < v.size(); j++) { if (j == y) continue; r = gcd(r, v[j]); } for (int j = y * u; j < y * u + u; j++) { if (j == i || j >= n) continue; r = gcd(r, a[j]); } ans = max(r, ans); } cout << ans << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
875,134
875,135
u357265888
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define frep(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) frep(i, 0, (n)) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define all(i, x) for (typeof(x.begin()) i = x.begin(); i != x.end(); i++) #define pb push_back const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const int MAX = 100010; const int INF = 1e9; const int MOD = 1000000007; const ll M = 998244353; const string END = "\n"; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n, a[100001], b[100001], c[100001]; cin >> n; rep(i, n) { cin >> a[i]; } rep(i, n) { if (i == 0) { b[i] = a[i]; c[n - 1 - i] = a[n - 1 - i]; } else { b[i] = gcd(a[i], b[i - 1]); c[n - 1 - i] = gcd(a[n - 1 - i], c[n - i]); } } ll ans = 0; ans = max(b[n - 2], c[1]); frep(i, 1, n - 1) { ans = max(ans, gcd(b[i - 1], c[n - i])); } cout << ans << END; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define frep(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) frep(i, 0, (n)) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define all(i, x) for (typeof(x.begin()) i = x.begin(); i != x.end(); i++) #define pb push_back const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const int MAX = 100010; const int INF = 1e9; const int MOD = 1000000007; const ll M = 998244353; const string END = "\n"; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } signed main() { cin.tie(0); ios::sync_with_stdio(false); ll n, a[100001], b[100001], c[100001]; cin >> n; rep(i, n) { cin >> a[i]; } rep(i, n) { if (i == 0) { b[i] = a[i]; c[n - 1 - i] = a[n - 1 - i]; } else { b[i] = gcd(a[i], b[i - 1]); c[n - 1 - i] = gcd(a[n - 1 - i], c[n - i]); } } ll ans = 0; ans = max(b[n - 2], c[1]); frep(i, 1, n - 1) { ans = max(ans, gcd(b[i - 1], c[i + 1])); } cout << ans << END; return 0; }
[ "expression.operation.binary.remove", "assignment.change" ]
875,136
875,137
u916290449
cpp
p03061
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define isNum(a) (a >= '0' && a <= '9') #define SP putchar(' ') #define EL putchar('\n') #define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout) template <class T> inline void read(T &); template <class T> inline void write(const T &); typedef long long ll; typedef const long long &cll; typedef const int &ci; typedef std::pair<int, int> pii; const int iinf = 2147483647; const ll llinf = 9223372036854775807ll; using std::abs; using std::max; using std::min; using std::sort; const int N = 100005; bool check(int); int a[N]; int n; int main() { read(n); for (int i = 1; i <= n; ++i) { read(a[i]); } int ans = 0; int k = a[1]; for (int i = 2; i * i <= k; ++i) { if (k % i == 0) { if (check(i)) { ans = max(ans, i); } if (check(k / i)) { ans = max(ans, k / i); } } } k = a[2]; for (int i = 2; i * i <= k; ++i) { if (k % i == 0) { if (check(i)) { ans = max(ans, i); } if (check(k / i)) { ans = max(ans, k / i); } } } write(ans), EL; return 0; } template <class T> void read(T &Re) { T k = 0; char ch = getchar(); int flag = 1; while (!isNum(ch)) { if (ch == '-') { flag = -1; } ch = getchar(); } while (isNum(ch)) { k = (k << 1) + (k << 3) + ch - '0'; ch = getchar(); } Re = flag * k; } template <class T> void write(const T &Wr) { if (Wr < 0) { putchar('-'); write(-Wr); } else { if (Wr < 10) { putchar(Wr + '0'); } else { write(Wr / 10); putchar((Wr % 10) + '0'); } } } bool check(int x) { int num = 0; for (int i = 1; i <= n; ++i) { if (a[i] % x == 0) { ++num; } if (num < i - 1) { break; } } return num >= n - 1; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define isNum(a) (a >= '0' && a <= '9') #define SP putchar(' ') #define EL putchar('\n') #define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout) template <class T> inline void read(T &); template <class T> inline void write(const T &); typedef long long ll; typedef const long long &cll; typedef const int &ci; typedef std::pair<int, int> pii; const int iinf = 2147483647; const ll llinf = 9223372036854775807ll; using std::abs; using std::max; using std::min; using std::sort; const int N = 100005; bool check(int); int a[N]; int n; int main() { read(n); for (int i = 1; i <= n; ++i) { read(a[i]); } int ans = 0; int k = a[1]; for (int i = 1; i * i <= k; ++i) { if (k % i == 0) { if (check(i)) { ans = max(ans, i); } if (check(k / i)) { ans = max(ans, k / i); } } } k = a[2]; for (int i = 1; i * i <= k; ++i) { if (k % i == 0) { if (check(i)) { ans = max(ans, i); } if (check(k / i)) { ans = max(ans, k / i); } } } write(ans), EL; return 0; } template <class T> void read(T &Re) { T k = 0; char ch = getchar(); int flag = 1; while (!isNum(ch)) { if (ch == '-') { flag = -1; } ch = getchar(); } while (isNum(ch)) { k = (k << 1) + (k << 3) + ch - '0'; ch = getchar(); } Re = flag * k; } template <class T> void write(const T &Wr) { if (Wr < 0) { putchar('-'); write(-Wr); } else { if (Wr < 10) { putchar(Wr + '0'); } else { write(Wr / 10); putchar((Wr % 10) + '0'); } } } bool check(int x) { int num = 0; for (int i = 1; i <= n; ++i) { if (a[i] % x == 0) { ++num; } if (num < i - 1) { break; } } return num >= n - 1; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
875,138
875,139
u740122945
cpp
p03061
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define INF ((int)1e9) #define INFLL ((ll)1e18) #define MOD (1000000007LL) int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N); for (int n = 0; n < N; ++n) { cin >> A[n]; } set<ll, greater<ll>> Cand; for (int k = 0; k < 2; ++k) { ll Tmp = A[k]; for (int i = 1; i * i < Tmp; ++i) { if (Tmp % i == 0) { Cand.insert(i); Cand.insert(Tmp / i); } } } for (auto tmp : Cand) { int NG = 0; for (int n = 0; n < N; ++n) { if (A[n] % tmp != 0) { ++NG; if (NG >= 2) { break; } } } if (NG <= 1) { cout << tmp << endl; break; } } return 0; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; #define INF ((int)1e9) #define INFLL ((ll)1e18) #define MOD (1000000007LL) int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N); for (int n = 0; n < N; ++n) { cin >> A[n]; } set<ll, greater<ll>> Cand; for (int k = 0; k < 2; ++k) { ll Tmp = A[k]; for (int i = 1; i * i <= Tmp; ++i) { if (Tmp % i == 0) { Cand.insert(i); Cand.insert(Tmp / i); } } } for (auto tmp : Cand) { int NG = 0; for (int n = 0; n < N; ++n) { if (A[n] % tmp != 0) { ++NG; if (NG >= 2) { break; } } } if (NG <= 1) { cout << tmp << endl; break; } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
875,140
875,141
u816910105
cpp
p03061
#include <bits/stdc++.h> using namespace std; #define int long long int arr[100005]; int dpl[100005]; int dpr[100005]; int32_t main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); if (n == 1) { cout << 1000000000 << endl; return 0; } dpl[0] = arr[0]; dpr[n - 1] = arr[n - 1]; for (int i = 1; i < n; i++) { dpl[i] = __gcd(dpl[i - 1], arr[i]); // cout << dpl[i] << " "; } // cout << '\n'; for (int i = n - 2; i >= 0; i--) { dpr[i] = __gcd(dpl[i + 1], arr[i]); // cout << dpr[i] << " "; } int ans = 0; for (int i = 0; i < n; i++) { int tmp; if (i == 0) { tmp = dpr[i + 1]; } else { if (i == n - 1) { tmp = dpl[i - 1]; } else { tmp = __gcd(dpl[i - 1], dpr[i + 1]); } } ans = max(ans, tmp); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long int arr[100005]; int dpl[100005]; int dpr[100005]; int32_t main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); if (n == 1) { cout << 1000000000 << endl; return 0; } dpl[0] = arr[0]; dpr[n - 1] = arr[n - 1]; for (int i = 1; i < n; i++) { dpl[i] = __gcd(dpl[i - 1], arr[i]); // cout << dpl[i] << " "; } // cout << '\n'; for (int i = n - 2; i >= 0; i--) { dpr[i] = __gcd(dpr[i + 1], arr[i]); // cout << dpr[i] << " "; } int ans = 0; for (int i = 0; i < n; i++) { int tmp; if (i == 0) { tmp = dpr[i + 1]; } else { if (i == n - 1) { tmp = dpl[i - 1]; } else { tmp = __gcd(dpl[i - 1], dpr[i + 1]); } } ans = max(ans, tmp); } cout << ans << endl; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
875,142
875,143
u786670922
cpp
p03061
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define int64 long long #define modbig (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7) using namespace std; int gcd(int a, int b) { if (a < b) { int64 tmp = a; a = b; b = tmp; } int64 r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } int main() { int n; cin >> n; int a[n]; rep(i, n) { cin >> a[i]; } if (n == 2) { cout << max(a[0], a[1]); } else { int left[n - 1], right[n - 1]; left[0] = a[0]; right[0] = a[n - 1]; rep1(i, n - 1) { left[i] = gcd(left[i - 1], a[i]); right[i] = gcd(right[i - 1], a[n - 1 - i]); } int ans = gcd(left[n - 2], right[n - 2]); rep(i, n - 2) { ans = max(ans, gcd(left[i], right[n - 3 - i])); } cout << ans; } }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define int64 long long #define modbig (10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 + 7) using namespace std; int gcd(int a, int b) { if (a < b) { int64 tmp = a; a = b; b = tmp; } int64 r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } int main() { int n; cin >> n; int a[n]; rep(i, n) { cin >> a[i]; } if (n == 2) { cout << max(a[0], a[1]); } else { int left[n - 1], right[n - 1]; left[0] = a[0]; right[0] = a[n - 1]; rep1(i, n - 1) { left[i] = gcd(left[i - 1], a[i]); right[i] = gcd(right[i - 1], a[n - 1 - i]); } int ans = max(left[n - 2], right[n - 2]); rep(i, n - 2) { ans = max(ans, gcd(left[i], right[n - 3 - i])); } cout << ans; } }
[ "identifier.change", "call.function.change" ]
875,144
875,145
u170301438
cpp
p03061
/***************************************************** @author: vichitr Compiled On: 27th April 2019 *****************************************************/ #include <bits/stdc++.h> #define MAX 9223372036854775807 #define endl "\n" #define ll long long #define int long long #define pb push_back #define pf push_front #define ppf pop_front #define mp make_pair #define ip pair<int, int> #define loop(i, n) for (int i = 0; i < n; i++) #define fast \ ios::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL) using namespace std; const ll MOD = 1e9 + 7; const ll SZ = 107; const ll N = 2e5 + 7; int pow(int x, int y) { ll r = 1LL; while (y) { if (y & 1) r = (r * x); y >>= 1; x = (x * x); } return r; } void solve() { int n; cin >> n; // int n;cin>>n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int gcd1[n], gcd2[n]; gcd1[0] = a[0]; for (int i = 1; i < n; i++) { gcd1[i] = __gcd(gcd1[i - 1], a[i]); } gcd2[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { gcd2[i] = __gcd(gcd2[i + 1], a[i]); } // cout<<gcd<<" "<<lcm<<endl; int ans = 1; for (int i = 1; i < n - 1; i++) { ans = max(ans, __gcd(gcd1[i - 1], gcd2[i + 1])); } ans = max(ans, gcd1[1]); ans = max(ans, gcd2[n - 2]); cout << ans; } signed main() { fast; int t = 1; // cin >>t; while (t--) { solve(); } return 0; } /***************************** ****************************/
/***************************************************** @author: vichitr Compiled On: 27th April 2019 *****************************************************/ #include <bits/stdc++.h> #define MAX 9223372036854775807 #define endl "\n" #define ll long long #define int long long #define pb push_back #define pf push_front #define ppf pop_front #define mp make_pair #define ip pair<int, int> #define loop(i, n) for (int i = 0; i < n; i++) #define fast \ ios::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL) using namespace std; const ll MOD = 1e9 + 7; const ll SZ = 107; const ll N = 2e5 + 7; int pow(int x, int y) { ll r = 1LL; while (y) { if (y & 1) r = (r * x); y >>= 1; x = (x * x); } return r; } void solve() { int n; cin >> n; // int n;cin>>n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int gcd1[n], gcd2[n]; gcd1[0] = a[0]; for (int i = 1; i < n; i++) { gcd1[i] = __gcd(gcd1[i - 1], a[i]); } gcd2[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { gcd2[i] = __gcd(gcd2[i + 1], a[i]); } // cout<<gcd<<" "<<lcm<<endl; int ans = 1; for (int i = 1; i < n - 1; i++) { ans = max(ans, __gcd(gcd1[i - 1], gcd2[i + 1])); } ans = max(ans, gcd1[n - 2]); ans = max(ans, gcd2[1]); cout << ans; } signed main() { fast; int t = 1; // cin >>t; while (t--) { solve(); } return 0; } /***************************** ****************************/
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "call.arguments.change", "assignment.change", "identifier.replace.remove", "literal.replace.add", "expression.operation.binary.change", "expression.operation.binary.remove" ]
875,154
875,155
u483366732
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (x < y) swap(x, y); while (y != 0) { int z = y; y = x % y; x = z; } return x; } int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } int le[N], ri[N]; le[0] = A[0], ri[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { le[i] = gcd(le[i - 1], A[i]); } for (int i = N - 2; i >= 0; i--) { ri[i] = gcd(ri[i + 1], A[i]); } int ans = -1; for (int i = 0; i < N - 2; i++) { if (gcd(le[i], ri[i + 2]) > ans) { ans = gcd(le[i], ri[i + 2]); } } if (ans < ri[1]) ans = ri[1]; if (ans < le[N - 2]) ans = le[N - 1]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (x < y) swap(x, y); while (y != 0) { int z = y; y = x % y; x = z; } return x; } int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } int le[N], ri[N]; le[0] = A[0], ri[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { le[i] = gcd(le[i - 1], A[i]); } for (int i = N - 2; i >= 0; i--) { ri[i] = gcd(ri[i + 1], A[i]); } int ans = -1; for (int i = 0; i < N - 2; i++) { if (gcd(le[i], ri[i + 2]) > ans) { ans = gcd(le[i], ri[i + 2]); } } if (ans < ri[1]) ans = ri[1]; if (ans < le[N - 2]) ans = le[N - 2]; cout << ans << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
875,156
875,157
u077536797
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (x < y) swap(x, y); while (y != 0) { int z = y; y = x % y; x = z; } return x; } int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } int le[N], ri[N]; le[0] = A[0], ri[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { le[i] = gcd(le[i - 1], A[i]); } for (int i = N - 2; i >= 0; i--) { ri[i] = gcd(ri[i + 1], A[i]); } int ans = -1; for (int i = 0; i < N; i++) { if (gcd(le[i], ri[i + 2]) > ans) { ans = gcd(le[i], ri[i + 2]); } } if (ans < ri[1]) ans = ri[1]; if (ans < le[N - 1]) ans = le[N - 1]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (x < y) swap(x, y); while (y != 0) { int z = y; y = x % y; x = z; } return x; } int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } int le[N], ri[N]; le[0] = A[0], ri[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { le[i] = gcd(le[i - 1], A[i]); } for (int i = N - 2; i >= 0; i--) { ri[i] = gcd(ri[i + 1], A[i]); } int ans = -1; for (int i = 0; i < N - 2; i++) { if (gcd(le[i], ri[i + 2]) > ans) { ans = gcd(le[i], ri[i + 2]); } } if (ans < ri[1]) ans = ri[1]; if (ans < le[N - 2]) ans = le[N - 2]; cout << ans << endl; return 0; }
[ "control_flow.loop.for.condition.change", "literal.number.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "assignment.value.change", "expression.operation.binary.change" ]
875,158
875,157
u077536797
cpp
p03061
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A; for (int i = 0; i < N; ++i) { int a; cin >> a; A.push_back(a); } sort(A.begin(), A.end()); int ans = 0; for (int i = A[0]; i > 0; --i) { int count = 0; if ((A[0] % i == 0) || (A[1] % i == 0)) { for (int j = 0; j < N; ++j) { if (A[j] % i == 0) count++; } if (count >= N - 1) { ans = i; break; } } } cout << ans << endl; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A; for (int i = 0; i < N; ++i) { int a; cin >> a; A.push_back(a); } sort(A.begin(), A.end()); int ans = 0; for (int i = A[1]; i > 0; --i) { int count = 0; if ((A[0] % i == 0) || (A[1] % i == 0)) { for (int j = 0; j < N; ++j) { if (A[j] % i == 0) count++; } if (count >= N - 1) { ans = i; break; } } } cout << ans << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
875,161
875,162
u041282550
cpp
p03061
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A; for (int i = 0; i < N; ++i) { int a; cin >> a; A.push_back(a); } sort(A.begin(), A.end()); int ans = 0; for (int i = A[0]; i > 0; --i) { int count = 0; if ((A[0] % i == 0) && (A[0] % i == 0)) { for (int j = 0; j < N; ++j) { if (A[j] % i == 0) count++; } if (count >= N - 1) { ans = i; break; } } } cout << ans << endl; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A; for (int i = 0; i < N; ++i) { int a; cin >> a; A.push_back(a); } sort(A.begin(), A.end()); int ans = 0; for (int i = A[1]; i > 0; --i) { int count = 0; if ((A[0] % i == 0) || (A[1] % i == 0)) { for (int j = 0; j < N; ++j) { if (A[j] % i == 0) count++; } if (count >= N - 1) { ans = i; break; } } } cout << ans << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "misc.opposites", "control_flow.branch.if.condition.change" ]
875,164
875,162
u041282550
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() #define REP(i, N) for (int i = 0; i < N; i++) int gcd(int a, int b) { int t; while (b != 0) { t = b; b = a % b; a = t; } return a; } int main() { int n; cin >> n; vector<unsigned int> a(n); REP(i, n) { cin >> a[i]; } vector<unsigned int> f(n); vector<unsigned int> l(n); f[0] = a[0]; l[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { f[i] = gcd(f[i - 1], a[i]); } for (int i = n - 2; i >= 0; i--) { l[i] = gcd(l[i + 1], a[i]); } int ans = max(f[1], l[n - 2]); for (int i = 1; i < n - 1; i++) { int b = gcd(f[i - 1], l[i + 1]); if (ans < b) { ans = b; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() #define REP(i, N) for (int i = 0; i < N; i++) int gcd(int a, int b) { int t; while (b != 0) { t = b; b = a % b; a = t; } return a; } int main() { int n; cin >> n; vector<unsigned int> a(n); REP(i, n) { cin >> a[i]; } vector<unsigned int> f(n); vector<unsigned int> l(n); f[0] = a[0]; l[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { f[i] = gcd(f[i - 1], a[i]); } for (int i = n - 2; i >= 0; i--) { l[i] = gcd(l[i + 1], a[i]); } int ans = max(l[1], f[n - 2]); for (int i = 1; i < n - 1; i++) { int b = gcd(f[i - 1], l[i + 1]); if (ans < b) { ans = b; } } cout << ans << endl; return 0; }
[ "identifier.change", "call.arguments.change" ]
875,170
875,171
u286493216
cpp
p03061
#include <algorithm> #include <cstdio> #include <vector> using namespace std; inline int Gcd(int a, int b) { while (b) { int tmp = a % b; a = b; b = tmp; } return a; } int main(int argc, char **argv) { int N; // 2 1e5 scanf("%d", &N); vector<int> A(N); // Ai 1 1e9 inside [1, 1e9] for (int i = 0; i < N; i++) { scanf("%d", &A[i]); } vector<int> pre(N), suf(N); pre[0] = A[0]; for (int i = 1; i < N; i++) { pre[i] = Gcd(pre[i - 1], A[i]); } suf[N - 1] = A[N - 1]; for (int i = N - 2; i >= 0; i--) { suf[i] = Gcd(A[i], suf[i + 1]); } int res = max(suf[1], pre[N - 1]); // N >= 2 for (int i = 1; i + 1 < N; i++) { res = max(res, Gcd(pre[i - 1], suf[i + 1])); } printf("%d\n", res); return 0; }
#include <algorithm> #include <cstdio> #include <vector> using namespace std; inline int Gcd(int a, int b) { while (b) { int tmp = a % b; a = b; b = tmp; } return a; } int main(int argc, char **argv) { int N; // 2 1e5 scanf("%d", &N); vector<int> A(N); // Ai 1 1e9 inside [1, 1e9] for (int i = 0; i < N; i++) { scanf("%d", &A[i]); } vector<int> pre(N), suf(N); pre[0] = A[0]; for (int i = 1; i < N; i++) { pre[i] = Gcd(pre[i - 1], A[i]); } suf[N - 1] = A[N - 1]; for (int i = N - 2; i >= 0; i--) { suf[i] = Gcd(A[i], suf[i + 1]); } int res = max(suf[1], pre[N - 2]); // N >= 2 for (int i = 1; i + 1 < N; i++) { res = max(res, Gcd(pre[i - 1], suf[i + 1])); } printf("%d\n", res); return 0; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,174
875,175
u874343985
cpp
p03061
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define rep(index, num) for (int index = 0; index < num; index++) #define rep1(index, num) for (int index = 1; index <= num; index++) #define scan(argument) cin >> argument #define prin(argument) cout << argument << endl #define kaigyo cout << endl #define eps 1e-7 #define mp(a1, a2) make_pair(a1, a2) typedef long long ll; typedef long double ld; using namespace std; typedef pair<ll, ll> pll; typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<pint> vpint; typedef vector<pll> vpll; ll INFl = 1e+18 + 1; int INF = 1e+9 + 1; ll gcd(ll x, ll y) { if (y == 0) return x; return gcd(y, x % y); } int main() { int N, A[100001]; ll lgc[100001], rgc[100001]; scan(N); rep(i, N) { scan(A[i]); } lgc[0] = A[0], rgc[N - 1] = A[N - 1]; rep(i, N - 1) { lgc[i + 1] = gcd(lgc[i], A[i + 1]); } for (int i = N - 1; i > 0; i--) { rgc[i - 1] = gcd(rgc[i], A[i - 1]); } ll ans = max(lgc[N - 1], rgc[1]); for (int i = 1; i <= N - 2; i++) { ans = max(ans, gcd(lgc[i - 1], rgc[i + 1])); } prin(ans); return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define rep(index, num) for (int index = 0; index < num; index++) #define rep1(index, num) for (int index = 1; index <= num; index++) #define scan(argument) cin >> argument #define prin(argument) cout << argument << endl #define kaigyo cout << endl #define eps 1e-7 #define mp(a1, a2) make_pair(a1, a2) typedef long long ll; typedef long double ld; using namespace std; typedef pair<ll, ll> pll; typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<ll> vll; typedef vector<pint> vpint; typedef vector<pll> vpll; ll INFl = 1e+18 + 1; int INF = 1e+9 + 1; ll gcd(ll x, ll y) { if (y == 0) return x; return gcd(y, x % y); } int main() { int N, A[100001]; ll lgc[100001], rgc[100001]; scan(N); rep(i, N) { scan(A[i]); } lgc[0] = A[0], rgc[N - 1] = A[N - 1]; rep(i, N - 1) { lgc[i + 1] = gcd(lgc[i], A[i + 1]); } for (int i = N - 1; i > 0; i--) { rgc[i - 1] = gcd(rgc[i], A[i - 1]); } ll ans = max(lgc[N - 2], rgc[1]); for (int i = 1; i <= N - 2; i++) { ans = max(ans, gcd(lgc[i - 1], rgc[i + 1])); } prin(ans); return 0; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,179
875,180
u222030240
cpp
p03061
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <limits> #include <map> #include <memory> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int gcd(int m, int n) { return n == 0 ? m : gcd(n, m % n); } int main() { int N; std::cin >> N; std::vector<int> a(N); for (auto &val : a) std::cin >> val; std::vector<int> g1(N); g1[0] = a[0]; std::vector<int> g2(N); g2.back() = a.back(); for (int i = 1; i < N; ++i) { g1[i] = gcd(a[i], a[i - 1]); } for (int i = N - 2; 0 <= i; --i) { g2[i] = gcd(a[i], a[i + 1]); } int ans = std::max(g2[1], g1[N - 2]); for (int i = 1; i < N - 1; ++i) { int tmp = gcd(g1[i - 1], g2[i + 1]); ans = std::max(tmp, ans); } std::cout << ans << std::endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <limits> #include <map> #include <memory> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int gcd(int m, int n) { return n == 0 ? m : gcd(n, m % n); } int main() { int N; std::cin >> N; std::vector<int> a(N); for (auto &val : a) std::cin >> val; std::vector<int> g1(N); g1[0] = a[0]; std::vector<int> g2(N); g2.back() = a.back(); for (int i = 1; i < N; ++i) { g1[i] = gcd(a[i], g1[i - 1]); } for (int i = N - 2; 0 <= i; --i) { g2[i] = gcd(a[i], g2[i + 1]); } int ans = std::max(g2[1], g1[N - 2]); for (int i = 1; i < N - 1; ++i) { int tmp = gcd(g1[i - 1], g2[i + 1]); ans = std::max(tmp, ans); } std::cout << ans << std::endl; return 0; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
875,188
875,189
u866733412
cpp
p03061
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define float long double int32_t main() { IOS int n, ans = LLONG_MIN, g; cin >> n; vector<int> A(n + 1), L(n + 1), R(n + 1); for (int i = 1; i <= n; i++) cin >> A[i]; g = A[1]; for (int i = 1; i <= n; i++) { g = __gcd(g, A[i]); L[i] = g; } g = A[n]; for (int i = n; i >= 1; i--) { g = __gcd(A[i], g); R[i] = g; } for (int i = 2; i <= n - 1; i++) { ans = max(ans, __gcd(L[i - 1], R[i + 1])); } cout << max({ans, L[2], R[n - 1]}) << endl; }
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define float long double int32_t main() { IOS int n, ans = LLONG_MIN, g; cin >> n; vector<int> A(n + 1), L(n + 1), R(n + 1); for (int i = 1; i <= n; i++) cin >> A[i]; g = A[1]; for (int i = 1; i <= n; i++) { g = __gcd(g, A[i]); L[i] = g; } g = A[n]; for (int i = n; i >= 1; i--) { g = __gcd(A[i], g); R[i] = g; } for (int i = 2; i <= n - 1; i++) { ans = max(ans, __gcd(L[i - 1], R[i + 1])); } cout << max({ans, R[2], L[n - 1]}) << endl; }
[ "identifier.change", "io.output.change" ]
875,192
875,193
u392058778
cpp
p03061
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <ciso646> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define inf 0x3f3f3f3f3f3f3f3f #define ALL(a) (a).begin(), (a).end() #define DEBUG(x) // cerr<<#x<<": "<<x<<endl #define ll long long #define ull unsigned long long using pii = pair<ll, ll>; #define eps 1e-14 #define SETUP \ cin.tie(0), ios::sync_with_stdio(false), \ cout << setprecision(15) << std::fixed; #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) template <class T> using vec2 = std::vector<vector<T>>; namespace { struct input_returnner { ll N; input_returnner(ll N_ = 0) : N(N_) {} template <typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); } template <typename T> operator T() const { T res; cin >> res; return res; } template <typename T> T operator-(T right) { return T(input_returnner()) - right; } template <typename T> T operator+(T right) { return T(input_returnner()) + right; } template <typename T> T operator*(T right) { return T(input_returnner()) * right; } template <typename T> T operator/(T right) { return T(input_returnner()) / right; } template <typename T> T operator<<(T right) { return T(input_returnner()) << right; } template <typename T> T operator>>(T right) { return T(input_returnner()) >> right; } }; template <typename T> input_returnner in() { return in<T>(); } input_returnner in() { return input_returnner(); } input_returnner in(ll N) { return std::move(input_returnner(N)); } } // namespace template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <typename T> struct is_vector : std::false_type {}; template <typename T> struct is_vector<std::vector<T>> : std::true_type {}; template <typename T> constexpr bool is_vector_v = is_vector<T>::value; template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { if (!v.empty()) { for (int i = 0; i < v.size(); ++i) { out << v[i] << (i == v.size() - 1 ? "\n" : (is_vector_v<T> ? "" : ", ")); } } return out; } namespace std { // ref: // https://stackoverflow.com/questions/7110301/generic-hash-for-tuples-in-unordered-map-unordered-set template <class T> inline void hash_combine(std::size_t &seed, T const &v) { seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t &seed, Tuple const &tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t &seed, Tuple const &tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const &tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...>>::apply(seed, tt); return seed; } }; template <class T, class U> class hash<std::pair<T, U>> { public: size_t operator()(const std::pair<T, U> &x) const { return hash<std::tuple<T, U>>()(std::tie(x.first, x.second)); } }; } // namespace std // ref: https://stackoverflow.com/questions/6245735/pretty-print-stdtuple namespace aux { template <std::size_t...> struct seq {}; template <std::size_t N, std::size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <std::size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, std::size_t... Is> void print_tuple(std::basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using swallow = int[]; (void)swallow{0, (void(os << (Is == 0 ? "" : ", ") << std::get<Is>(t)), 0)...}; } } // namespace aux template <class Ch, class Tr, class... Args> auto operator<<(std::basic_ostream<Ch, Tr> &os, std::tuple<Args...> const &t) -> std::basic_ostream<Ch, Tr> & { os << "("; aux::print_tuple(os, t, aux::gen_seq<sizeof...(Args)>()); return os << ")"; } template <class S, class T> std::ostream &operator<<(std::ostream &os, const std::pair<S, T> &p) { return os << "(" << p.first << ", " << p.second << ")"; } // ref: // https://stackoverflow.com/questions/8542591/c11-reverse-range-based-for-loo�Fp template <typename T> struct reversion_wrapper { T &iterable; }; template <typename T> auto begin(reversion_wrapper<T> w) { return std::rbegin(w.iterable); } template <typename T> auto end(reversion_wrapper<T> w) { return std::rend(w.iterable); } template <typename T> reversion_wrapper<T> REV(T &&iterable) { return {iterable}; } template <class T> bool inside(T left, T val, T right) { return left <= val and val < right; } template <class T> T bitCount(T num) { T res = 0; while (num > 0) { if (num & 1) ++res; num >>= 1; } return res; } // ll MOD = 1e9 + 7; ll MOD = 998244353; void solve(); signed main() { SETUP; #ifdef _DEBUG while (true) { #endif solve(); #ifdef _DEBUG cout << "-------" << endl; } #endif #ifdef _DEBUG system("pause"); #endif return 0; } #define int ll // template struct mint { int64_t value; mint() : value(0) {} mint(int64_t value_) : value(value_ % MOD) {} inline mint &operator+=(const mint &rhs) { value += rhs.value; if (value >= MOD) { value -= MOD; } return *this; } inline mint &operator-=(const mint &rhs) { value -= rhs.value; if (value < 0) { value += MOD; } return *this; } inline mint &operator*=(const mint &rhs) { value *= rhs.value; value %= MOD; return *this; } inline mint &operator%=(const mint &rhs) { return *this; } }; inline mint operator+(const mint &lhs, const mint &rhs) { mint res = lhs; res += rhs; return res; } inline mint operator-(const mint &lhs, const mint &rhs) { mint res = lhs; res -= rhs; return res; } inline mint operator*(const mint &lhs, const mint &rhs) { mint res = lhs; res *= rhs; return res; } inline mint operator%(const mint &lhs, const uint64_t &rhs) { return lhs; } ostream &operator<<(ostream &out, mint n) { return out << n.value; } 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); } // a x + b y = gcd(a, b) int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } // x^n % mod // O(log n) mint mod_pow(mint x, uint64_t n) { mint res = 1; while (n > 0) { if (n & 1) res = res * x; x = x * x; n >>= 1; } return res; } void solve() { int N; cin >> N; vector<int> A(N); for (auto &a : A) cin >> a; vector<int> left = A; vector<int> right = A; FOR(i, 1, N) { left[i] = gcd(left[i - 1], left[i]); } RFOR(i, 0, N - 1) { right[i] = gcd(right[i + 1], right[i]); } int res = max(right[1], left[N - 1]); FOR(i, 1, N - 1) { res = max(res, gcd(left[i - 1], right[i + 1])); } cout << res << endl; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <ciso646> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define inf 0x3f3f3f3f3f3f3f3f #define ALL(a) (a).begin(), (a).end() #define DEBUG(x) // cerr<<#x<<": "<<x<<endl #define ll long long #define ull unsigned long long using pii = pair<ll, ll>; #define eps 1e-14 #define SETUP \ cin.tie(0), ios::sync_with_stdio(false), \ cout << setprecision(15) << std::fixed; #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) template <class T> using vec2 = std::vector<vector<T>>; namespace { struct input_returnner { ll N; input_returnner(ll N_ = 0) : N(N_) {} template <typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); } template <typename T> operator T() const { T res; cin >> res; return res; } template <typename T> T operator-(T right) { return T(input_returnner()) - right; } template <typename T> T operator+(T right) { return T(input_returnner()) + right; } template <typename T> T operator*(T right) { return T(input_returnner()) * right; } template <typename T> T operator/(T right) { return T(input_returnner()) / right; } template <typename T> T operator<<(T right) { return T(input_returnner()) << right; } template <typename T> T operator>>(T right) { return T(input_returnner()) >> right; } }; template <typename T> input_returnner in() { return in<T>(); } input_returnner in() { return input_returnner(); } input_returnner in(ll N) { return std::move(input_returnner(N)); } } // namespace template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <typename T> struct is_vector : std::false_type {}; template <typename T> struct is_vector<std::vector<T>> : std::true_type {}; template <typename T> constexpr bool is_vector_v = is_vector<T>::value; template <typename T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) { if (!v.empty()) { for (int i = 0; i < v.size(); ++i) { out << v[i] << (i == v.size() - 1 ? "\n" : (is_vector_v<T> ? "" : ", ")); } } return out; } namespace std { // ref: // https://stackoverflow.com/questions/7110301/generic-hash-for-tuples-in-unordered-map-unordered-set template <class T> inline void hash_combine(std::size_t &seed, T const &v) { seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t &seed, Tuple const &tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t &seed, Tuple const &tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const &tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...>>::apply(seed, tt); return seed; } }; template <class T, class U> class hash<std::pair<T, U>> { public: size_t operator()(const std::pair<T, U> &x) const { return hash<std::tuple<T, U>>()(std::tie(x.first, x.second)); } }; } // namespace std // ref: https://stackoverflow.com/questions/6245735/pretty-print-stdtuple namespace aux { template <std::size_t...> struct seq {}; template <std::size_t N, std::size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <std::size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, std::size_t... Is> void print_tuple(std::basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using swallow = int[]; (void)swallow{0, (void(os << (Is == 0 ? "" : ", ") << std::get<Is>(t)), 0)...}; } } // namespace aux template <class Ch, class Tr, class... Args> auto operator<<(std::basic_ostream<Ch, Tr> &os, std::tuple<Args...> const &t) -> std::basic_ostream<Ch, Tr> & { os << "("; aux::print_tuple(os, t, aux::gen_seq<sizeof...(Args)>()); return os << ")"; } template <class S, class T> std::ostream &operator<<(std::ostream &os, const std::pair<S, T> &p) { return os << "(" << p.first << ", " << p.second << ")"; } // ref: // https://stackoverflow.com/questions/8542591/c11-reverse-range-based-for-loo�Fp template <typename T> struct reversion_wrapper { T &iterable; }; template <typename T> auto begin(reversion_wrapper<T> w) { return std::rbegin(w.iterable); } template <typename T> auto end(reversion_wrapper<T> w) { return std::rend(w.iterable); } template <typename T> reversion_wrapper<T> REV(T &&iterable) { return {iterable}; } template <class T> bool inside(T left, T val, T right) { return left <= val and val < right; } template <class T> T bitCount(T num) { T res = 0; while (num > 0) { if (num & 1) ++res; num >>= 1; } return res; } // ll MOD = 1e9 + 7; ll MOD = 998244353; void solve(); signed main() { SETUP; #ifdef _DEBUG while (true) { #endif solve(); #ifdef _DEBUG cout << "-------" << endl; } #endif #ifdef _DEBUG system("pause"); #endif return 0; } #define int ll // template struct mint { int64_t value; mint() : value(0) {} mint(int64_t value_) : value(value_ % MOD) {} inline mint &operator+=(const mint &rhs) { value += rhs.value; if (value >= MOD) { value -= MOD; } return *this; } inline mint &operator-=(const mint &rhs) { value -= rhs.value; if (value < 0) { value += MOD; } return *this; } inline mint &operator*=(const mint &rhs) { value *= rhs.value; value %= MOD; return *this; } inline mint &operator%=(const mint &rhs) { return *this; } }; inline mint operator+(const mint &lhs, const mint &rhs) { mint res = lhs; res += rhs; return res; } inline mint operator-(const mint &lhs, const mint &rhs) { mint res = lhs; res -= rhs; return res; } inline mint operator*(const mint &lhs, const mint &rhs) { mint res = lhs; res *= rhs; return res; } inline mint operator%(const mint &lhs, const uint64_t &rhs) { return lhs; } ostream &operator<<(ostream &out, mint n) { return out << n.value; } 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); } // a x + b y = gcd(a, b) int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } // x^n % mod // O(log n) mint mod_pow(mint x, uint64_t n) { mint res = 1; while (n > 0) { if (n & 1) res = res * x; x = x * x; n >>= 1; } return res; } void solve() { int N; cin >> N; vector<int> A(N); for (auto &a : A) cin >> a; vector<int> left = A; vector<int> right = A; FOR(i, 1, N) { left[i] = gcd(left[i - 1], left[i]); } RFOR(i, 0, N - 1) { right[i] = gcd(right[i + 1], right[i]); } int res = max(right[1], left[N - 2]); FOR(i, 1, N - 1) { res = max(res, gcd(left[i - 1], right[i + 1])); } cout << res << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,196
875,197
u579875569
cpp
p03061
#include <bits/stdc++.h> using namespace std; #define int long long #define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++) #define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++) #define ALL(obj) begin(obj), end(obj) #define RALL(obj) rbegin(obj), rend(obj) #define fi first #define se second using ii = pair<int, int>; vector<ii> dirs = { {1, 0}, {0, 1}, {-1, 0}, {0, -1}, // 4方向 {1, 1}, {-1, 1}, {-1, -1}, {1, -1}, // 斜め {0, 0}, // 自身 }; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); } template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); } // debug template <class T> ostream &operator<<(ostream &s, vector<T> &d) { REP(i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; } template <class T> ostream &operator<<(ostream &s, vector<vector<T>> &d) { REP(i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; } template <class T, class S> ostream &operator<<(ostream &s, pair<T, S> &p) { s << "{" << p.first << ", " << p.second << "}"; return s; } template <class T, class S> ostream &operator<<(ostream &s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; } #ifdef _MY_DEBUG #define dump(...) \ cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ \ << "]" << endl, \ dump_func(__VA_ARGS__), cerr << "*/\n\n"; #else #define dump(...) #define endl "\n" #endif void dump_func() { cerr << endl; } template <class Head, class... Tail> void dump_func(Head &&h, Tail &&...t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); } struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); constexpr int MOD = 1000000007; // *************** TEMPLATE END *************** signed main() { int n; cin >> n; vector<int> a(n); REP(i, n) cin >> a[i]; vector<int> accl(n, a[0]), accr(n, a[n - 1]); REP(i, n - 1) accl[i + 1] = __gcd(accl[i], a[i + 1]); for (int i = n - 2; i >= 0; i--) accr[i] = __gcd(accr[i + 1], a[i]); int ans = max(accl[n - 1], accr[1]); REPI(i, 1, n - 1) { chmax(ans, __gcd(accl[i - 1], accr[i + 1])); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++) #define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++) #define ALL(obj) begin(obj), end(obj) #define RALL(obj) rbegin(obj), rend(obj) #define fi first #define se second using ii = pair<int, int>; vector<ii> dirs = { {1, 0}, {0, 1}, {-1, 0}, {0, -1}, // 4方向 {1, 1}, {-1, 1}, {-1, -1}, {1, -1}, // 斜め {0, 0}, // 自身 }; template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); } template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); } // debug template <class T> ostream &operator<<(ostream &s, vector<T> &d) { REP(i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; } template <class T> ostream &operator<<(ostream &s, vector<vector<T>> &d) { REP(i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; } template <class T, class S> ostream &operator<<(ostream &s, pair<T, S> &p) { s << "{" << p.first << ", " << p.second << "}"; return s; } template <class T, class S> ostream &operator<<(ostream &s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; } #ifdef _MY_DEBUG #define dump(...) \ cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ \ << "]" << endl, \ dump_func(__VA_ARGS__), cerr << "*/\n\n"; #else #define dump(...) #define endl "\n" #endif void dump_func() { cerr << endl; } template <class Head, class... Tail> void dump_func(Head &&h, Tail &&...t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); } struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); constexpr int MOD = 1000000007; // *************** TEMPLATE END *************** signed main() { int n; cin >> n; vector<int> a(n); REP(i, n) cin >> a[i]; vector<int> accl(n, a[0]), accr(n, a[n - 1]); REP(i, n - 1) accl[i + 1] = __gcd(accl[i], a[i + 1]); for (int i = n - 2; i >= 0; i--) accr[i] = __gcd(accr[i + 1], a[i]); int ans = max(accl[n - 2], accr[1]); REPI(i, 1, n - 1) { chmax(ans, __gcd(accl[i - 1], accr[i + 1])); } cout << ans << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,198
875,199
u852113235
cpp
p03061
#define _USE_MATH_DEFINES #include <bits/stdc++.h> ////////////////////////////////////////// #define deb(...) ///////////////////////////////////////////////// #define DBP(...) ///////////////////////////////////////////////// #ifdef LOC /////////////////////////////////////////////////////// #include "debuglib.h" ///////////////////////////////////////////// #endif /////////////////////////////////////////////////////////// #define x first ////////////////////////////////////////////////// #define y second ///////////////////////////////////////////////// #define pb push_back ///////////////////////////////////////////// #define sz(x) int((x).size()) ///////////////////////////////////// #define each(a, x) for (auto &a : (x)) ///////////////////////////////// #define all(x) (x).begin(), (x).end() ////////////////////////////// #define rep(i, b, e) for (int i = (b); i < (e); i++) /////////////////////// using namespace std; using ll = long long; using Pii = pair<int, int>; // using Vi = vector<int>; void run(); int main() { cin.sync_with_stdio /// (0); cin.tie(0); cout << fixed << setprecision(18); run(); return 0; } //// //-------------------------------------------------------------// int gcd(int a, int b) { while (b) { a %= b; swap(a, b); } return a; } void run() { int n; cin >> n; Vi elems(n); each(e, elems) cin >> e; Vi prefs(n), sufs(n); prefs[0] = elems[0]; rep(i, 1, n) prefs[i] = gcd(prefs[i - 1], elems[i]); sufs[n - 1] = elems[n - 1]; for (int i = n - 2; i >= 0; i--) sufs[i] = gcd(sufs[i + 1], elems[i]); int ans = max(prefs[n - 1], sufs[1]); rep(i, 1, n - 1) { ans = max(ans, gcd(prefs[i - 1], sufs[i + 1])); } cout << ans << endl; }
#define _USE_MATH_DEFINES #include <bits/stdc++.h> ////////////////////////////////////////// #define deb(...) ///////////////////////////////////////////////// #define DBP(...) ///////////////////////////////////////////////// #ifdef LOC /////////////////////////////////////////////////////// #include "debuglib.h" ///////////////////////////////////////////// #endif /////////////////////////////////////////////////////////// #define x first ////////////////////////////////////////////////// #define y second ///////////////////////////////////////////////// #define pb push_back ///////////////////////////////////////////// #define sz(x) int((x).size()) ///////////////////////////////////// #define each(a, x) for (auto &a : (x)) ///////////////////////////////// #define all(x) (x).begin(), (x).end() ////////////////////////////// #define rep(i, b, e) for (int i = (b); i < (e); i++) /////////////////////// using namespace std; using ll = long long; using Pii = pair<int, int>; // using Vi = vector<int>; void run(); int main() { cin.sync_with_stdio /// (0); cin.tie(0); cout << fixed << setprecision(18); run(); return 0; } //// //-------------------------------------------------------------// int gcd(int a, int b) { while (b) { a %= b; swap(a, b); } return a; } void run() { int n; cin >> n; Vi elems(n); each(e, elems) cin >> e; Vi prefs(n), sufs(n); prefs[0] = elems[0]; rep(i, 1, n) prefs[i] = gcd(prefs[i - 1], elems[i]); sufs[n - 1] = elems[n - 1]; for (int i = n - 2; i >= 0; i--) sufs[i] = gcd(sufs[i + 1], elems[i]); int ans = max(prefs[n - 2], sufs[1]); rep(i, 1, n - 1) { ans = max(ans, gcd(prefs[i - 1], sufs[i + 1])); } cout << ans << endl; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,202
875,203
u018915813
cpp
p03061
#include <bits/stdc++.h> using namespace std; int N, A[101010], gl[101010], gr[101010]; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; if (i > 0) gl[i] = __gcd(gl[i - 1], A[i]); else gl[i] = A[i]; } for (int i = N - 1; i >= 0; i--) { if (i < N - 1) gr[i] = __gcd(gr[i + 1], A[i]); else gr[i] = A[i]; } int result = 0; for (int i = 0; i < N; i++) { if (i == 0) result = max(result, gl[i + 1]); else if (i == N - 1) result = max(result, gr[i - 1]); else result = max(result, __gcd(gl[i - 1], gr[i + 1])); } cout << result << endl; }
#include <bits/stdc++.h> using namespace std; int N, A[101010], gl[101010], gr[101010]; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; if (i > 0) gl[i] = __gcd(gl[i - 1], A[i]); else gl[i] = A[i]; } for (int i = N - 1; i >= 0; i--) { if (i < N - 1) gr[i] = __gcd(gr[i + 1], A[i]); else gr[i] = A[i]; } int result = 0; for (int i = 0; i < N; i++) { if (i == 0) result = max(result, gr[i + 1]); else if (i == N - 1) result = max(result, gl[i - 1]); else result = max(result, __gcd(gl[i - 1], gr[i + 1])); } cout << result << endl; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
875,204
875,205
u375661411
cpp
p03061
#include <algorithm> #include <cmath> #include <cstdio> using namespace std; int n, a[100005], q[100005], h[100005], ans; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); q[1] = a[1]; h[n] = a[n]; for (int i = 2; i <= n; ++i) q[i] = __gcd(q[i - 1], a[i]); for (int i = n - 1; i; --i) h[i] = __gcd(h[i + 1], a[i]); ans = max(ans, q[2]); ans = max(ans, h[n - 1]); for (int i = 2; i <= n - 1; ++i) ans = max(ans, __gcd(q[i - 1], h[i + 1])); printf("%d", ans); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> using namespace std; int n, a[100005], q[100005], h[100005], ans; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); q[1] = a[1]; h[n] = a[n]; for (int i = 2; i <= n; ++i) q[i] = __gcd(q[i - 1], a[i]); for (int i = n - 1; i; --i) h[i] = __gcd(h[i + 1], a[i]); ans = max(ans, q[n - 1]); ans = max(ans, h[2]); for (int i = 2; i <= n - 1; ++i) ans = max(ans, __gcd(q[i - 1], h[i + 1])); printf("%d", ans); return 0; }
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "call.arguments.change", "assignment.change", "identifier.replace.remove", "literal.replace.add", "expression.operation.binary.change", "expression.operation.binary.remove" ]
875,210
875,211
u423335028
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef int _loop_int; #define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i) #define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i) #define FORR(i, a, b) \ for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i) #define DEBUG(x) cout << #x << ": " << x << endl #define DEBUG_VEC(v) \ cout << #v << ":"; \ REP(i, v.size()) cout << " " << v[i]; \ cout << endl #define ALL(a) (a).begin(), (a).end() #define CHMIN(a, b) a = min((a), (b)) #define CHMAX(a, b) a = max((a), (b)) // mod const ll MOD = 1000000007ll; #define FIX(a) ((a) % MOD + MOD) % MOD // floating typedef double Real; const Real EPS = 1e-11; #define EQ0(x) (abs(x) < EPS) #define EQ(a, b) (abs(a - b) < EPS) typedef complex<Real> P; int n; int a[125252]; int l[125252], r[125252]; int main() { scanf("%d", &n); REP(i, n) scanf("%d", a + i); l[0] = a[0]; FOR(i, 1, n) l[i] = __gcd(l[i - 1], a[i]); r[n - 1] = a[n - 1]; FORR(i, 0, n - 1) r[i] = __gcd(r[i + 1], a[i]); int ans = max(r[1], l[n - 1]); FOR(i, 1, n - 1) { CHMAX(ans, __gcd(l[i - 1], r[i + 1])); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef int _loop_int; #define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i) #define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i) #define FORR(i, a, b) \ for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i) #define DEBUG(x) cout << #x << ": " << x << endl #define DEBUG_VEC(v) \ cout << #v << ":"; \ REP(i, v.size()) cout << " " << v[i]; \ cout << endl #define ALL(a) (a).begin(), (a).end() #define CHMIN(a, b) a = min((a), (b)) #define CHMAX(a, b) a = max((a), (b)) // mod const ll MOD = 1000000007ll; #define FIX(a) ((a) % MOD + MOD) % MOD // floating typedef double Real; const Real EPS = 1e-11; #define EQ0(x) (abs(x) < EPS) #define EQ(a, b) (abs(a - b) < EPS) typedef complex<Real> P; int n; int a[125252]; int l[125252], r[125252]; int main() { scanf("%d", &n); REP(i, n) scanf("%d", a + i); l[0] = a[0]; FOR(i, 1, n) l[i] = __gcd(l[i - 1], a[i]); r[n - 1] = a[n - 1]; FORR(i, 0, n - 1) r[i] = __gcd(r[i + 1], a[i]); int ans = max(r[1], l[n - 2]); FOR(i, 1, n - 1) { CHMAX(ans, __gcd(l[i - 1], r[i + 1])); } printf("%d\n", ans); return 0; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,212
875,213
u462560753
cpp
p03061
#include <algorithm> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define eps LDBL_EPSILON #define moder 1000000007 #define int long long #define ll long long #define double long double #define INF LLONG_MAX / 3 #define P pair<int, int> #define prique priority_queue<int, vector<int>, greater<int>> using namespace std; int n, a[100010], b[100010], c[100010]; int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } signed main() { cin >> n; rep(i, n) cin >> a[i]; b[0] = a[0]; for (int i = 1; i < n; i++) { b[i] = gcd(b[i - 1], a[i]); } c[n - 1] = a[n - 1]; for (int i = n - 1; i >= 0; i--) { c[i] = gcd(c[i + 1], a[i]); } int ans = c[1]; for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(b[i - 1], c[i + 1])); } ans = max(ans, b[n - 1]); cout << ans << endl; }
#include <algorithm> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <string.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i <= n; i++) #define eps LDBL_EPSILON #define moder 1000000007 #define int long long #define ll long long #define double long double #define INF LLONG_MAX / 3 #define P pair<int, int> #define prique priority_queue<int, vector<int>, greater<int>> using namespace std; int n, a[100010], b[100010], c[100010]; int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } signed main() { cin >> n; rep(i, n) cin >> a[i]; b[0] = a[0]; for (int i = 1; i < n; i++) { b[i] = gcd(b[i - 1], a[i]); } c[n - 1] = a[n - 1]; for (int i = n - 1; i >= 0; i--) { c[i] = gcd(c[i + 1], a[i]); } int ans = c[1]; for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(b[i - 1], c[i + 1])); } ans = max(ans, b[n - 2]); cout << ans << endl; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
875,214
875,215
u379822620
cpp
p03062
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef tuple<int, int, int> tii; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) int main() { int N; cin >> N; ll sum = 0; ll cnt = 0; ll mn = 0; for (int i = 0; i < N; i++) { ll x; cin >> x; if (x < 0) { x *= -1; cnt++; } sum += x; mn = min(mn, x); } if (cnt % 2 == 1) sum -= 2 * mn; cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef tuple<int, int, int> tii; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) int main() { int N; cin >> N; ll sum = 0; ll cnt = 0; ll mn = 1000000000; for (int i = 0; i < N; i++) { ll x; cin >> x; if (x < 0) { x *= -1; cnt++; } sum += x; mn = min(mn, x); } if (cnt % 2 == 1) sum -= 2 * mn; cout << sum << endl; }
[ "literal.number.change", "variable_declaration.value.change" ]
875,222
875,223
u442665143
cpp
p03062
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = long long; using pi = pair<int, int>; const ll INF = 1LL << 60; int main() { ll n, mcnt = 0; ll a, sum; cin >> n; vector<ll> arr; rep(i, n) { cin >> a; if (a < 0) mcnt++; arr.push_back(abs(a)); } sort(all(arr)); sum = accumulate(all(arr), 0); if (mcnt % 2 == 0) { cout << sum << endl; } else { sum -= (arr[0] * 2LL); cout << sum << endl; } return 0; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = long long; using pi = pair<int, int>; const ll INF = 1LL << 60; int main() { ll n, mcnt = 0; ll a, sum; cin >> n; vector<ll> arr; rep(i, n) { cin >> a; if (a < 0) mcnt++; arr.push_back(abs(a)); } sort(all(arr)); sum = accumulate(all(arr), 0LL); if (mcnt % 2 == 0) { cout << sum << endl; } else { sum -= (arr[0] * 2LL); cout << sum << endl; } return 0; }
[ "literal.number.type.widen.change" ]
875,236
875,237
u730499268
cpp
p03062
/* C++ */ #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pint; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = ll(0); i < ll(n); i++) #define Rep(i, n) for (ll i = ll(1); i < ll(n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define PI 3.14159265358979323846 #define ifYN(x) cout << (x ? "Yes" : "No") << "\n" ll fac[MAX], finv[MAX], inv[MAX]; 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; } bool palindrome(string s) { bool flag = true; rep(i, (ll)s.size()) if (s[i] != s[s.size() - 1 - i]) flag = false; return flag; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll ans = 0; while (n != 0) ans += n % 10, n /= 10; return ans; } ll Svec(vector<ll> v) { ll n = 0; rep(i, (ll)v.size()) n += v[i]; return n; } ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } ll LCM(ll a, ll b) { return a / GCD(a, b) * b; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } void runlength(string s, vector<pair<char, ll>> &p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); } rep(i, (ll)s.size() - 1) { if (s[i] == s[i + 1]) { x++; if (i == (ll)s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == (ll)s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } string Toupper(string s) { string ans = ""; rep(i, s.size()) { if ('a' <= s[i] && s[i] <= 'z') ans += (char)s[i] - 32; else ans += s[i]; } return ans; } string Tolower(string s) { string ans = ""; rep(i, s.size()) { if ('A' <= s[i] && s[i] <= 'Z') ans += (char)s[i] + 32; else ans += s[i]; } return ans; } void dis(vector<ll> v) { rep(i, v.size()) cout << v[i] << endl; } void dis2(vector<vector<ll>> v) { rep(i, v.size()) { rep(j, v[0].size()) cout << v[i][j] << ' '; cout << endl; } } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); /* isPrime[1]=false; */ for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } vector<pint> prime_factorize(ll n) { vector<pint> ans; for (ll p = 2; p <= sqrt(n); p++) { if (n % p != 0) continue; ll cnt = 0; while (n % p == 0) { n /= p; cnt++; } ans.push_back(make_pair(p, cnt)); } if (n != 1) ans.push_back(make_pair(n, 1)); return ans; } /*bool cmp(pint a, pint b) { return a.second < b.second; }*/ /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n; cin >> n; vector<ll> v(n); rep(i, n) cin >> v[i]; ll cnt = 0; rep(i, n) { if (v[i] < 0) cnt++; } if (cnt % 2 == 0) { ll ans = 0; rep(i, n) { ans += abs(v[i]); } cout << ans << endl; } else { vector<ll> w(n); rep(i, n) { w[i] = abs(v[i]); } sort(ALL(w)); cout << Svec(w) - w[0] << endl; } }
/* C++ */ #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pint; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = ll(0); i < ll(n); i++) #define Rep(i, n) for (ll i = ll(1); i < ll(n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define PI 3.14159265358979323846 #define ifYN(x) cout << (x ? "Yes" : "No") << "\n" ll fac[MAX], finv[MAX], inv[MAX]; 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; } bool palindrome(string s) { bool flag = true; rep(i, (ll)s.size()) if (s[i] != s[s.size() - 1 - i]) flag = false; return flag; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll ans = 0; while (n != 0) ans += n % 10, n /= 10; return ans; } ll Svec(vector<ll> v) { ll n = 0; rep(i, (ll)v.size()) n += v[i]; return n; } ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; } ll LCM(ll a, ll b) { return a / GCD(a, b) * b; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } void runlength(string s, vector<pair<char, ll>> &p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); } rep(i, (ll)s.size() - 1) { if (s[i] == s[i + 1]) { x++; if (i == (ll)s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == (ll)s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } string Toupper(string s) { string ans = ""; rep(i, s.size()) { if ('a' <= s[i] && s[i] <= 'z') ans += (char)s[i] - 32; else ans += s[i]; } return ans; } string Tolower(string s) { string ans = ""; rep(i, s.size()) { if ('A' <= s[i] && s[i] <= 'Z') ans += (char)s[i] + 32; else ans += s[i]; } return ans; } void dis(vector<ll> v) { rep(i, v.size()) cout << v[i] << endl; } void dis2(vector<vector<ll>> v) { rep(i, v.size()) { rep(j, v[0].size()) cout << v[i][j] << ' '; cout << endl; } } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); /* isPrime[1]=false; */ for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } vector<pint> prime_factorize(ll n) { vector<pint> ans; for (ll p = 2; p <= sqrt(n); p++) { if (n % p != 0) continue; ll cnt = 0; while (n % p == 0) { n /= p; cnt++; } ans.push_back(make_pair(p, cnt)); } if (n != 1) ans.push_back(make_pair(n, 1)); return ans; } /*bool cmp(pint a, pint b) { return a.second < b.second; }*/ /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n; cin >> n; vector<ll> v(n); rep(i, n) cin >> v[i]; ll cnt = 0; rep(i, n) { if (v[i] < 0) cnt++; } if (cnt % 2 == 0) { ll ans = 0; rep(i, n) { ans += abs(v[i]); } cout << ans << endl; } else { vector<ll> w(n); rep(i, n) { w[i] = abs(v[i]); } sort(ALL(w)); cout << Svec(w) - 2 * w[0] << endl; } }
[ "expression.operation.binary.add" ]
875,245
875,246
u264265458
cpp
p03062
/*Function Template*/ #include <bits/stdc++.h> using namespace std; typedef long long int ll; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (n); i++) #define Rep(i, n) for (ll i = 1; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); ll fac[MAX], finv[MAX], inv[MAX]; 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; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (ll i = s - 1; i >= 0; i--) m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10; return m; } ll Svec(vector<ll> v) { ll n = 0; for (ll i = 0; i < v.size(); i++) n += v[i]; return n; } ll GCD(ll a, ll b) { ll r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return b; } ll LCM(ll a, ll b) { ll c = a, d = b, r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return c / b * d; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } vector<pair<char, ll>> runlength(string s, vector<pair<char, ll>> p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); return p; } for (ll i = 0; i < s.size() - 1; i++) { if (s[i] == s[i + 1]) { x++; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } return p; } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n, cnt = 0; bool flag = false; cin >> n; vector<ll> v(n); rep(i, n) { cin >> v[i]; if (v[i] < 0) cnt++; else if (v[i] == 0) flag = true; v[i] = abs(v[i]); } ll ans = Svec(v); if (flag || cnt % 2 == 0) { cout << ans << endl; return 0; } sort(ALL(v)); cout << ans - v[0] << endl; }
/*Function Template*/ #include <bits/stdc++.h> using namespace std; typedef long long int ll; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (n); i++) #define Rep(i, n) for (ll i = 1; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); ll fac[MAX], finv[MAX], inv[MAX]; 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; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (ll i = s - 1; i >= 0; i--) m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10; return m; } ll Svec(vector<ll> v) { ll n = 0; for (ll i = 0; i < v.size(); i++) n += v[i]; return n; } ll GCD(ll a, ll b) { ll r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return b; } ll LCM(ll a, ll b) { ll c = a, d = b, r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return c / b * d; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } vector<pair<char, ll>> runlength(string s, vector<pair<char, ll>> p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); return p; } for (ll i = 0; i < s.size() - 1; i++) { if (s[i] == s[i + 1]) { x++; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } return p; } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n, cnt = 0; bool flag = false; cin >> n; vector<ll> v(n); rep(i, n) { cin >> v[i]; if (v[i] < 0) cnt++; else if (v[i] == 0) flag = true; v[i] = abs(v[i]); } ll ans = Svec(v); if (flag || cnt % 2 == 0) { cout << ans << endl; return 0; } sort(ALL(v)); cout << ans - 2 * v[0] << endl; }
[ "expression.operation.binary.add" ]
875,247
875,248
u264265458
cpp
p03062
/*Function Template*/ #include <bits/stdc++.h> using namespace std; typedef long long int ll; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (n); i++) #define Rep(i, n) for (ll i = 1; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); ll fac[MAX], finv[MAX], inv[MAX]; 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; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (ll i = s - 1; i >= 0; i--) m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10; return m; } ll Svec(vector<ll> v) { ll n = 0; for (ll i = 0; i < v.size(); i++) n += v[i]; return n; } ll GCD(ll a, ll b) { ll r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return b; } ll LCM(ll a, ll b) { ll c = a, d = b, r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return c / b * d; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } vector<pair<char, ll>> runlength(string s, vector<pair<char, ll>> p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); return p; } for (ll i = 0; i < s.size() - 1; i++) { if (s[i] == s[i + 1]) { x++; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } return p; } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n, cnt = 0; bool flag = false; cin >> n; vector<ll> v(n); rep(i, n) { cin >> v[i]; if (v[i] < 0) cnt++; else if (v[i]) flag = true; v[i] = abs(v[i]); } ll ans = Svec(v); if (flag || cnt % 2 == 0) { cout << ans << endl; return 0; } sort(ALL(v)); cout << ans - v[0] << endl; }
/*Function Template*/ #include <bits/stdc++.h> using namespace std; typedef long long int ll; const int MAX = 510000; const int MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (n); i++) #define Rep(i, n) for (ll i = 1; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); ll fac[MAX], finv[MAX], inv[MAX]; 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; } // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } ll Len(ll n) { ll s = 0; while (n != 0) s++, n /= 10; return s; } ll Sint(ll n) { ll m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (ll i = s - 1; i >= 0; i--) m += n / ((ll)pow(10, i)) - (n / ((ll)pow(10, i + 1))) * 10; return m; } ll Svec(vector<ll> v) { ll n = 0; for (ll i = 0; i < v.size(); i++) n += v[i]; return n; } ll GCD(ll a, ll b) { ll r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return b; } ll LCM(ll a, ll b) { ll c = a, d = b, r, tmp; /*自然数 a > b を確認・入替*/ if (a < b) { tmp = a, a = b, b = tmp; } /*ユークリッドの互除法*/ r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return c / b * d; } ll Factorial(ll n) { ll m = 1; while (n >= 1) m *= n, n--; return m; } vector<pair<char, ll>> runlength(string s, vector<pair<char, ll>> p) { ll x = 1; if (s.size() == 1) { p.push_back(pair<char, ll>(s[0], 1)); return p; } for (ll i = 0; i < s.size() - 1; i++) { if (s[i] == s[i + 1]) { x++; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[i], x)); } } else { p.push_back(pair<char, ll>(s[i], x)); x = 1; if (i == s.size() - 2) { p.push_back(pair<char, ll>(s[s.size() - 1], x)); } } } return p; } ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } const int MAX_N = 100010; vector<bool> sieve_of_eratosthenes() { vector<bool> isPrime(MAX_N + 1, true); for (int i = 2; i <= MAX_N; i++) { if (isPrime[i]) { for (int j = 2 * i; j <= MAX_N; j += i) { isPrime[j] = false; } } } return isPrime; } /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { IOS; ll n, cnt = 0; bool flag = false; cin >> n; vector<ll> v(n); rep(i, n) { cin >> v[i]; if (v[i] < 0) cnt++; else if (v[i] == 0) flag = true; v[i] = abs(v[i]); } ll ans = Svec(v); if (flag || cnt % 2 == 0) { cout << ans << endl; return 0; } sort(ALL(v)); cout << ans - 2 * v[0] << endl; }
[ "control_flow.branch.if.condition.change" ]
875,249
875,248
u264265458
cpp
p03062
#include <iostream> #include <string> #include <vector> #define ll long long #define MOD 1000000007 using namespace std; int main() { int n; cin >> n; vector<ll> a(n); int res = 0; ll sum = 0; ll m = 10000000000; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] <= 0) { res++; sum -= a[i]; m = min(m, -a[i]); } else { sum += a[i]; m = min(m, a[i]); } } if (res == 0) cout << sum; else cout << sum - 2 * m; return 0; }
#include <iostream> #include <string> #include <vector> #define ll long long #define MOD 1000000007 using namespace std; int main() { int n; cin >> n; vector<ll> a(n); int res = 0; ll sum = 0; ll m = 10000000000; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] <= 0) { res++; sum -= a[i]; m = min(m, -a[i]); } else { sum += a[i]; m = min(m, a[i]); } } if (res % 2 == 0) cout << sum; else cout << sum - 2 * m; return 0; }
[ "control_flow.branch.if.condition.change" ]
875,250
875,251
u139300044
cpp
p03062
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { ll n, ans = 0, c = 0, i; cin >> n; vector<ll> a(n); for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] < 0) c++; } for (i = 0; i < n; i++) { a[i] = abs(a[i]); } sort(a.rbegin(), a.rend()); for (i = 0; i < n - 1; i++) { ans += a[i]; if (c % 2 == 0) { ans += a[n - 1]; } else { ans -= a[n - 1]; } } cout << ans; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { ll n, ans = 0, c = 0, i; cin >> n; vector<ll> a(n); for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] < 0) c++; } for (i = 0; i < n; i++) { a[i] = abs(a[i]); } sort(a.rbegin(), a.rend()); for (i = 0; i < n - 1; i++) ans += a[i]; if (c % 2 == 0) ans += a[n - 1]; else ans -= a[n - 1]; cout << ans; }
[]
875,254
875,255
u607003364
cpp
p03062
#include <bits/stdc++.h> using namespace std; struct Edge { int to; // 辺の行き先 int weight; // 辺の重み Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reprep(i, j, w, h) rep(j, h) rep(i, w) #define rrep(i, m, n) for (int i = m; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define aall(x, n) (x).begin(), (x).begin() + (n) #define VEC(type, name, n) \ std::vector<type> a(n); \ rep(i, n) std::cin >> a[i]; #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sum accumulate #define keta fixed << setprecision #define vvector(name, typ, m, n, a) \ vector<vector<typ>> name(m, vector<typ>(n, a)) #define vvvector(name, t, l, m, n, a) \ vector<vector<vector<t>>> name(l, vector<vector<t>>(m, vector<int>(n, a))); typedef long long ll; const int INF = 2000000000; const long INF64 = 1000000000000000ll; const ll MOD = 1000000007LL; typedef unsigned int uint; int main() { int n, c = 0; std::cin >> n; std::vector<int> a(n); rep(i, n) { std::cin >> a[i]; if (a[i] < 0) { a[i] = -a[i]; c++; } } sort(all(a)); if (c % 2 == 0) std::cout << sum(all(a), 0) << std::endl; else std::cout << sum(a.begin() + 1, a.end(), 0) - a[0] << std::endl; }
#include <bits/stdc++.h> using namespace std; struct Edge { int to; // 辺の行き先 int weight; // 辺の重み Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reprep(i, j, w, h) rep(j, h) rep(i, w) #define rrep(i, m, n) for (int i = m; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define aall(x, n) (x).begin(), (x).begin() + (n) #define VEC(type, name, n) \ std::vector<type> a(n); \ rep(i, n) std::cin >> a[i]; #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sum accumulate #define keta fixed << setprecision #define vvector(name, typ, m, n, a) \ vector<vector<typ>> name(m, vector<typ>(n, a)) #define vvvector(name, t, l, m, n, a) \ vector<vector<vector<t>>> name(l, vector<vector<t>>(m, vector<int>(n, a))); typedef long long ll; const int INF = 2000000000; const long INF64 = 1000000000000000ll; const ll MOD = 1000000007LL; typedef unsigned int uint; int main() { ll n, c = 0; std::cin >> n; std::vector<ll> a(n); rep(i, n) { std::cin >> a[i]; if (a[i] < 0) { a[i] = -a[i]; c++; } } sort(all(a)); if (c % 2 == 0) std::cout << sum(all(a), 0ll) << std::endl; else std::cout << sum(a.begin() + 1, a.end(), 0ll) - a[0] << std::endl; }
[ "variable_declaration.type.change", "call.arguments.change" ]
875,260
875,261
u539011156
cpp
p03062
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; typedef pair<int, int> P; typedef pair<long long, long long> Pll; typedef vector<int> vi; typedef vector<ll> vll; const long long mod = 1000000007LL; int main() { ll n; cin >> n; vll a(n); ll cnt = 0LL; ll b = 10000000000LL; ll ans = 0LL; bool check = true; rep(i, n) { cin >> a[i]; if (a[i] == 0) check = false; ans += abs(a[i]); b = min(b, abs(a[i])); if (a[i] < 0) cnt++; } if (b % 2 == 1 && check) ans -= b * 2; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) typedef long long ll; typedef pair<int, int> P; typedef pair<long long, long long> Pll; typedef vector<int> vi; typedef vector<ll> vll; const long long mod = 1000000007LL; int main() { ll n; cin >> n; vll a(n); ll cnt = 0LL; ll b = 10000000000LL; ll ans = 0LL; bool check = true; rep(i, n) { cin >> a[i]; if (a[i] == 0) check = false; ans += abs(a[i]); b = min(b, abs(a[i])); if (a[i] < 0) cnt++; } if (cnt % 2 == 1 && check) ans -= b * 2; cout << ans << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
875,266
875,267
u615662061
cpp
p03062
#include <algorithm> #include <cstdint> #include <iostream> #include <map> #include <math.h> #include <sstream> #include <string> #include <vector> using namespace std; typedef long long ll; ll ans, mx, sum, mn = 1e18, cnt, flag; ll b[100000], idx; int main() { ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; if (a[i] <= 0) b[idx++] = i; } for (ll i = 0; i < n; i++) { if (a[i] < 0) { bool ok = false; for (ll j = 0; j < idx; j++) { if (b[j] > i) { a[i] = abs(a[i]); a[b[j]] = abs(a[b[j]]); ok = true; break; } } if (ok == false) { for (ll j = i; j < n; j++) { if (abs(a[j]) < mn) { flag = j; mn = abs(a[j]); } } a[i] = abs(a[i]); a[flag] *= -1; } } } for (ll i = 0; i < n; i++) { sum += a[i]; } cout << sum; }
#include <algorithm> #include <cstdint> #include <iostream> #include <map> #include <math.h> #include <sstream> #include <string> #include <vector> using namespace std; typedef long long ll; ll ans, mx, sum, mn = 1e18, cnt, flag; ll b[100000], idx; int main() { ll n; cin >> n; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; if (a[i] <= 0) b[idx++] = i; } for (ll i = 0; i < n; i++) { if (a[i] < 0) { bool ok = false; for (ll j = 0; j < idx; j++) { if (b[j] > i) { a[i] = abs(a[i]); a[b[j]] = abs(a[b[j]]); ok = true; break; } } if (ok == false) { for (ll j = 0; j < n; j++) { if (abs(a[j]) < mn) { flag = j; mn = abs(a[j]); } } a[i] = abs(a[i]); a[flag] *= -1; } } } for (ll i = 0; i < n; i++) { sum += a[i]; } cout << sum; }
[ "variable_declaration.value.change", "identifier.replace.remove", "literal.replace.add", "control_flow.loop.for.initializer.change" ]
875,268
875,269
u620390714
cpp
p03062
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using st = string; using ch = char; typedef pair<ll, ll> P; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<P> vP; typedef vector<ch> vc; typedef vector<vc> vvc; #define FOR(i, a, b) for (ll i = a; i < b; i++) #define rep(i, n) FOR(i, 0, n) #define ROF(i, a, b) for (ll i = a; i >= b; i--) #define per(i, a) ROF(i, a, 0) const ll MOD = 1000000007; const ll MOD2 = 998244353; const ld PI = acos(-1); const ll INF = 1e18; st abc = "abcdefghijklmnopqrstuvwxyz"; st ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; struct edge { ll to, cost; }; int main() { ll n; vl a(n); ll cnt = 0; ll sum = 0; rep(i, n) { cin >> a[i]; if (a[i] < 0) { cnt++; } a[i] = abs(a[i]); sum += a[i]; } sort(a.begin(), a.end()); if (cnt % 2 == 0) { cout << sum << endl; } else { cout << sum - 2 * a[0] << endl; } }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using st = string; using ch = char; typedef pair<ll, ll> P; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<P> vP; typedef vector<ch> vc; typedef vector<vc> vvc; #define FOR(i, a, b) for (ll i = a; i < b; i++) #define rep(i, n) FOR(i, 0, n) #define ROF(i, a, b) for (ll i = a; i >= b; i--) #define per(i, a) ROF(i, a, 0) const ll MOD = 1000000007; const ll MOD2 = 998244353; const ld PI = acos(-1); const ll INF = 1e18; st abc = "abcdefghijklmnopqrstuvwxyz"; st ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; struct edge { ll to, cost; }; int main() { ll n; cin >> n; vl a(n); ll cnt = 0; ll sum = 0; rep(i, n) { cin >> a[i]; if (a[i] < 0) { cnt++; } a[i] = abs(a[i]); sum += a[i]; } sort(a.begin(), a.end()); if (cnt % 2 == 0) { cout << sum << endl; } else { cout << sum - 2 * a[0] << endl; } }
[]
875,270
875,271
u328811800
cpp
p03062
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int N; cin >> N; ll A[N]; int minus = 0; ll absmin = 1000000000; ll ans = 0; for (int i = 0; i < N; i++) { cin >> A[i]; ans += abs(A[i]); if (A[i] < 0) minus++; if (abs(A[i]) < absmin) absmin = A[i]; } if (minus % 2) { cout << ans - 2 * absmin << endl; } else { cout << ans << endl; } }
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int N; cin >> N; ll A[N]; int minus = 0; ll absmin = 1000000000; ll ans = 0; for (int i = 0; i < N; i++) { cin >> A[i]; ans += abs(A[i]); if (A[i] < 0) minus++; if (abs(A[i]) < absmin) absmin = abs(A[i]); } if (minus % 2) { cout << ans - 2 * absmin << endl; } else { cout << ans << endl; } }
[ "call.add", "call.arguments.change" ]
875,277
875,278
u538808095
cpp
p03062
#include <bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> P; ll Mod = 1000000007; int main() { int N; cin >> N; ll A[N]; ll sum = 0; ll small = 1000000007; ll nega = 0; for (int i = 0; i < N; i++) { cin >> A[i]; small = min(small, abs(A[i])); sum += abs(A[i]); if (A[i] < 0) { nega++; } } if (nega % 2 == 0) { cout << sum << endl; } else { cout << sum - small << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> P; ll Mod = 1000000007; int main() { int N; cin >> N; ll A[N]; ll sum = 0; ll small = 1000000007; ll nega = 0; for (int i = 0; i < N; i++) { cin >> A[i]; small = min(small, abs(A[i])); sum += abs(A[i]); if (A[i] < 0) { nega++; } } if (nega % 2 == 0) { cout << sum << endl; } else { cout << sum - (small * 2) << endl; } return 0; }
[]
875,289
875,290
u083494782
cpp
p03062
#include <bits/stdc++.h> using namespace std; #define ll long long ll dp[5001][5001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; ll a[n]; ll countneg = 0; ll sum = 0; for (ll i = 0; i < n; i++) { cin >> a[i]; sum += abs(a[i]); if (a[i] < 0) { countneg++; } a[i] = abs(a[i]); } sort(a, a + n); if (countneg % 2 == 0) { cout << sum; } else { cout << sum - a[0]; } }
#include <bits/stdc++.h> using namespace std; #define ll long long ll dp[5001][5001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; ll a[n]; ll countneg = 0; ll sum = 0; for (ll i = 0; i < n; i++) { cin >> a[i]; sum += abs(a[i]); if (a[i] < 0) { countneg++; } a[i] = abs(a[i]); } // cout<<countneg<<endl; sort(a, a + n); if (countneg % 2 == 0) { cout << sum; } else { cout << sum - 2 * a[0]; } }
[ "expression.operation.binary.add" ]
875,298
875,299
u781076291
cpp
p03062
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, n) for (int i = 1; i <= (n); i++) #define lol long long #define SUM(n) ((n) + 1) * (n) / 2 // 1〜nまでの総和を求める式 #define mp make_pair #define fi first #define se second #define pu push_back #define SYOU(x) fixed << setprecision(x + 1) //小数点桁数を指定する #define abs(x, y) max(x, y) - min(x, y) #define all(v) v.begin(), v.end() #define UPDight(a, b) (a + b - 1) / b //小数点切り上げ const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const int MOD = int(1e9) + 7; using namespace std; using pii = pair<int, int>; typedef vector<int> vit; //最大公約数 lol gcd(lol x, lol y) { if (x < y) swap(x, y); lol r = x % y; while (r != 0) { x = y; y = r; r = x % y; } return y; } //最小公倍数 lol lcm(lol x, lol y) { lol a = x * y; return (a / gcd(x, y)); } signed main(void) { cin.tie(nullptr); ios_base::sync_with_stdio(false); lol n; cin >> n; lol a[n + 5]; reps(i, n) { cin >> a[i]; } lol sum = 0, nasu = INF; for (int i = 1; i < n; i++) { if (a[i] < 0) { a[i] *= -1; a[i + 1] *= -1; } else if (a[i] == 0) { a[i + 1] = max(a[i + 1], -a[i + 1]); } nasu = min(nasu, a[i]); sum += a[i]; } if (a[n] >= 0) { cout << sum + a[n] << '\n'; } else { if (nasu <= max(a[n], -a[n])) { cout << sum - nasu + -a[n] << '\n'; } else { cout << sum + a[n] << '\n'; } } return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, n) for (int i = 1; i <= (n); i++) #define lol long long #define SUM(n) ((n) + 1) * (n) / 2 // 1〜nまでの総和を求める式 #define mp make_pair #define fi first #define se second #define pu push_back #define SYOU(x) fixed << setprecision(x + 1) //小数点桁数を指定する #define abs(x, y) max(x, y) - min(x, y) #define all(v) v.begin(), v.end() #define UPDight(a, b) (a + b - 1) / b //小数点切り上げ const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const int MOD = int(1e9) + 7; using namespace std; using pii = pair<int, int>; typedef vector<int> vit; //最大公約数 lol gcd(lol x, lol y) { if (x < y) swap(x, y); lol r = x % y; while (r != 0) { x = y; y = r; r = x % y; } return y; } //最小公倍数 lol lcm(lol x, lol y) { lol a = x * y; return (a / gcd(x, y)); } signed main(void) { cin.tie(nullptr); ios_base::sync_with_stdio(false); lol n; cin >> n; lol a[n + 5]; reps(i, n) { cin >> a[i]; } lol sum = 0, nasu = INF; for (int i = 1; i < n; i++) { if (a[i] < 0) { a[i] *= -1; a[i + 1] *= -1; } else if (a[i] == 0) { a[i + 1] = max(a[i + 1], -a[i + 1]); } nasu = min(nasu, a[i]); sum += a[i]; } if (a[n] >= 0) { cout << sum + a[n] << '\n'; } else { if (nasu <= max(a[n], -a[n])) { cout << sum - 2 * nasu + -a[n] << '\n'; } else { cout << sum + a[n] << '\n'; } } return 0; }
[ "expression.operation.binary.add" ]
875,313
875,314
u623468376
cpp
p03062
bool DBG = false; // #pragma GCC optimize("Ofast") // #pragma GCC // target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> //#include <boost/multiprecision/cpp_dec_float.hpp> //#include <boost/multiprecision/cpp_int.hpp> using namespace std; using ll = long long; using ld = long double; // using i128 = __int128_t; // using bint = boost::multiprecision::cpp_int // using d1024 = boost::multiprecision::number<mp::cpp_dec_float<1024>>; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define IFOR(i, a, b) for (int i = ((b)-1); i >= (a); --i) #define RPT(i, a, b) for (int i = (a); i < ((a) + (b)); ++i) #define IRPT(i, a, b) for (int i = ((a) + (b)-1); i >= (a); --i) #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() #define fs first #define sd second #define couts(x) cout << (x) << (" ") #define coutn(x) cout << (x) << ("\n") #define ncouts(x) numout(x), outst[outst_N++] = ' ' #define ncoutn(x) numout(x), outst[outst_N++] = '\n' #define scouts(x) strout(x), outst[outst_N++] = ' ' #define scoutn(x) strout(x), outst[outst_N++] = '\n' #define dcouts(x) \ if (DBG) \ couts(x) #define dcoutn(x) \ if (DBG) \ coutn(x) #define endl "\n" #define psb push_back #define ppb pop_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define LBIT(x, a) (((x) >> (a)) & 1LL) #define IBIT(x, a) (((x) >> (a)) & 1) #define BCOUNT(x) (__builtin_popcount(x)) template <typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec) { os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <class T> using V = vector<T>; template <class T> using V2 = V<V<T>>; template <class T> using V3 = V<V2<T>>; template <class T> using V4 = V<V3<T>>; char outst[20'000'000]; int outst_N = 0; char outst_tmp[200]; template <class NUM> void numout(NUM n) { if (n < 0) { n *= -1; outst[outst_N++] = '-'; } if (n == 0) { outst[outst_N++] = '0'; return; } int cnt = 0; while (n > 0) { outst_tmp[cnt++] = '0' + (n % 10); n /= 10; } IFOR(i, 0, cnt) { outst[outst_N++] = outst_tmp[i]; } } void strout(std::string s) { for (auto x : s) { outst[outst_N++] = x; } } constexpr ll LINF = 1LL << 60; constexpr int IINF = 1 << 28; constexpr ll mod = 1'000'000'007; void solve() { int n; cin >> n; V<ll> a(n); cin >> a; sort(ALL(a)); int sgn = lb(ALL(a), 0) - a.begin(); sgn %= 2; ll ans = 0; if (sgn) { ll hiki = 0; FOR(i, 0, n) { a[i] = abs(a[i]); ans += a[i]; hiki = min(hiki, a[i]); } ans -= 2 * hiki; } else { FOR(i, 0, n) ans += abs(a[i]); } coutn(ans); } int main(void) { // std::cout << std::fixed << std::setprecision(20); cin.tie(0); // ios::sync_with_stdio(false); solve(); // printf("%s", outst); return 0; }
bool DBG = false; // #pragma GCC optimize("Ofast") // #pragma GCC // target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> //#include <boost/multiprecision/cpp_dec_float.hpp> //#include <boost/multiprecision/cpp_int.hpp> using namespace std; using ll = long long; using ld = long double; // using i128 = __int128_t; // using bint = boost::multiprecision::cpp_int // using d1024 = boost::multiprecision::number<mp::cpp_dec_float<1024>>; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define IFOR(i, a, b) for (int i = ((b)-1); i >= (a); --i) #define RPT(i, a, b) for (int i = (a); i < ((a) + (b)); ++i) #define IRPT(i, a, b) for (int i = ((a) + (b)-1); i >= (a); --i) #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() #define fs first #define sd second #define couts(x) cout << (x) << (" ") #define coutn(x) cout << (x) << ("\n") #define ncouts(x) numout(x), outst[outst_N++] = ' ' #define ncoutn(x) numout(x), outst[outst_N++] = '\n' #define scouts(x) strout(x), outst[outst_N++] = ' ' #define scoutn(x) strout(x), outst[outst_N++] = '\n' #define dcouts(x) \ if (DBG) \ couts(x) #define dcoutn(x) \ if (DBG) \ coutn(x) #define endl "\n" #define psb push_back #define ppb pop_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define LBIT(x, a) (((x) >> (a)) & 1LL) #define IBIT(x, a) (((x) >> (a)) & 1) #define BCOUNT(x) (__builtin_popcount(x)) template <typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec) { os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <class T> using V = vector<T>; template <class T> using V2 = V<V<T>>; template <class T> using V3 = V<V2<T>>; template <class T> using V4 = V<V3<T>>; char outst[20'000'000]; int outst_N = 0; char outst_tmp[200]; template <class NUM> void numout(NUM n) { if (n < 0) { n *= -1; outst[outst_N++] = '-'; } if (n == 0) { outst[outst_N++] = '0'; return; } int cnt = 0; while (n > 0) { outst_tmp[cnt++] = '0' + (n % 10); n /= 10; } IFOR(i, 0, cnt) { outst[outst_N++] = outst_tmp[i]; } } void strout(std::string s) { for (auto x : s) { outst[outst_N++] = x; } } constexpr ll LINF = 1LL << 60; constexpr int IINF = 1 << 28; constexpr ll mod = 1'000'000'007; void solve() { int n; cin >> n; V<ll> a(n); cin >> a; sort(ALL(a)); int sgn = lb(ALL(a), 0) - a.begin(); sgn %= 2; ll ans = 0; if (sgn) { ll hiki = LINF; FOR(i, 0, n) { a[i] = abs(a[i]); ans += a[i]; hiki = min(hiki, a[i]); } ans -= 2 * hiki; } else { FOR(i, 0, n) ans += abs(a[i]); } coutn(ans); } int main(void) { // std::cout << std::fixed << std::setprecision(20); cin.tie(0); // ios::sync_with_stdio(false); solve(); // printf("%s", outst); return 0; }
[ "variable_declaration.value.change", "identifier.replace.add", "literal.replace.remove" ]
875,315
875,316
u952090000
cpp
p03062
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define pii pair<ll, ll> #define piii pair<ll, pair<ll, ll>> #define INF 0x3f3f3f3f #define LINF 98765432123456789 #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define rep(i, start, end) for (int i = start; i < end; i++) #define debug cout << "Hello\n"; #define debug1(x) cout << #x << " " << x << "\n"; #define debug2(x, y) cout << #x << " " << x << " " << #y << " " << y << "\n"; #define debug3(x, y, z) \ cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z \ << "\n"; #define debug4(w, x, y, z) \ cout << #w << " " << w << " " << #x << " " << x << " " << #y << " " << y \ << " " << #z << " " << z << "\n"; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (ll)(x).size() ////////////////////////////////////////////////////////////////////////////////////////////////// #define N 100005 ll dp[N][2][2], v[N]; ll n; ll func(ll idx, bool curr_flipped, bool next_flipped) { if (idx == n - 2) return (curr_flipped ? -1 * v[idx] : v[idx]) + (next_flipped ? -1 * v[idx + 1] : v[idx + 1]); if (dp[idx][curr_flipped][next_flipped] != -1) return dp[idx][curr_flipped][next_flipped]; return dp[idx][curr_flipped][next_flipped] = curr_flipped ? -1 * v[idx] : v[idx]; +max(func(idx + 1, !next_flipped, true), func(idx + 1, next_flipped, false)); } int main() { cin >> n; for (ll i = 0; i < n; i++) cin >> v[i]; memset(dp, -1, sizeof(dp)); ll ans = max(func(0, 0, 0), func(0, 1, 1)); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define pii pair<ll, ll> #define piii pair<ll, pair<ll, ll>> #define INF 0x3f3f3f3f #define LINF 98765432123456789 #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define rep(i, start, end) for (int i = start; i < end; i++) #define debug cout << "Hello\n"; #define debug1(x) cout << #x << " " << x << "\n"; #define debug2(x, y) cout << #x << " " << x << " " << #y << " " << y << "\n"; #define debug3(x, y, z) \ cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z \ << "\n"; #define debug4(w, x, y, z) \ cout << #w << " " << w << " " << #x << " " << x << " " << #y << " " << y \ << " " << #z << " " << z << "\n"; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (ll)(x).size() ////////////////////////////////////////////////////////////////////////////////////////////////// #define N 100005 ll dp[N][2][2], v[N]; ll n; ll func(ll idx, bool curr_flipped, bool next_flipped) { if (idx == n - 2) return (curr_flipped ? -1 * v[idx] : v[idx]) + (next_flipped ? -1 * v[idx + 1] : v[idx + 1]); if (dp[idx][curr_flipped][next_flipped] != -1) return dp[idx][curr_flipped][next_flipped]; return dp[idx][curr_flipped][next_flipped] = (curr_flipped ? -1 * v[idx] : v[idx]) + max(func(idx + 1, !next_flipped, true), func(idx + 1, next_flipped, false)); } int main() { cin >> n; for (ll i = 0; i < n; i++) cin >> v[i]; memset(dp, -1, sizeof(dp)); ll ans = max(func(0, 0, 0), func(0, 1, 1)); cout << ans; return 0; }
[ "function.return_value.change", "assignment.value.change" ]
875,325
875,326
u266433281
cpp
p03062
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int flag = 0; long long int MIN = 0; long long int ans = 0; for (int i = 0; i < n; i++) { if (a[i] < 0) { a[i] *= -1; flag++; } MIN = min(MIN, a[i]); ans += a[i]; } if (flag % 2 == 1) ans -= (MIN * 2); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int flag = 0; long long int MIN = 1e9; long long int ans = 0; for (int i = 0; i < n; i++) { if (a[i] < 0) { a[i] *= -1; flag++; } MIN = min(MIN, a[i]); ans += a[i]; } if (flag % 2 == 1) ans -= (MIN * 2); cout << ans << endl; }
[ "literal.number.change", "variable_declaration.value.change" ]
875,327
875,328
u983681697
cpp
p03062
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(vec) vec.begin(), vec.end() typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef tuple<ll, ll, ll> tlll; typedef tuple<int, int, int> tiii; const ll mod = 1e9 + 7; const int inf = 1 << 30; int main() { int n; cin >> n; vector<ll> a(n); int hu = 0; ll sum = 0; rep(i, n) { cin >> a[i]; if (a[i] < 0) { hu++; a[i] = -a[i]; } sum += a[i]; } sort(all(a)); if (hu % 2 == 0) { cout << sum << endl; } else { cout << sum - a[0] << endl; } }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; template <typename T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(vec) vec.begin(), vec.end() typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef tuple<ll, ll, ll> tlll; typedef tuple<int, int, int> tiii; const ll mod = 1e9 + 7; const int inf = 1 << 30; int main() { int n; cin >> n; vector<ll> a(n); int hu = 0; ll sum = 0; rep(i, n) { cin >> a[i]; if (a[i] < 0) { hu++; a[i] = -a[i]; } sum += a[i]; } sort(all(a)); if (hu % 2 == 0) { cout << sum << endl; } else { cout << sum - 2 * a[0] << endl; } }
[ "expression.operation.binary.add" ]
875,333
875,334
u136342563
cpp
p03062
#include <bits/stdc++.h> #include <cstring> using namespace std; int main() { long long counter1, counter2; counter1 = 0; counter2 = 0; long long counter3 = 0; long long N; cin >> N; long long a[N]; vector<long long> b(N); for (int i = 0; i < N; i++) { cin >> a[i]; b.at(i) = abs(a[N]); counter1 += abs(a[i]); if (a[i] < 0) counter2++; } if (counter2 % 2 == 0) cout << counter1 << endl; else { sort(b.begin(), b.end()); for (int i = 1; i < N; i++) { counter3 += b[i]; } cout << counter3 - b.at(0) << endl; } }
#include <bits/stdc++.h> #include <cstring> using namespace std; int main() { long long counter1, counter2; counter1 = 0; counter2 = 0; long long counter3 = 0; long long N; cin >> N; long long a[N]; vector<long long> b(N); for (int i = 0; i < N; i++) { cin >> a[i]; b.at(i) = abs(a[i]); counter1 += abs(a[i]); if (a[i] < 0) counter2++; } if (counter2 % 2 == 0) cout << counter1 << endl; else { sort(b.begin(), b.end()); for (int i = 1; i < N; i++) { counter3 += b[i]; } cout << counter3 - b.at(0) << endl; } }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "call.arguments.change" ]
875,337
875,338
u722640678
cpp
p03062
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define erep(i, n) for (int i = 0; i <= n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define erep1(i, n) for (int i = 1; i <= n; i++) typedef long long ll; #define vint vector<int> #define vvint vector<vector<int>> #define vstring vector<string> #define vdouble vector<double> #define vll vector<ll>: #define vbool vector<bool> #define INF 1101010101010101010 #define MOD 1000000007 #define int long long using P = pair<int, int>; signed main() { int n; cin >> n; vint A(n); int minus = 0; int zero = 0; int MIN = INF; int sum; rep(i, n) { cin >> A[i]; if (A[i] < 0) minus++; if (A[i] == 0) zero++; MIN = min(MIN, abs(A[i])); sum += abs(A[i]); } if (minus % 2 == 1 && zero == 0) { cout << sum - MIN * 2 << endl; } else { cout << sum << endl; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define erep(i, n) for (int i = 0; i <= n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define erep1(i, n) for (int i = 1; i <= n; i++) typedef long long ll; #define vint vector<int> #define vvint vector<vector<int>> #define vstring vector<string> #define vdouble vector<double> #define vll vector<ll>: #define vbool vector<bool> #define INF 1101010101010101010 #define MOD 1000000007 #define int long long using P = pair<int, int>; signed main() { int n; cin >> n; vint A(n); int minus = 0; int zero = 0; int MIN = INF; int sum = 0; rep(i, n) { cin >> A[i]; if (A[i] < 0) minus++; if (A[i] == 0) zero++; MIN = min(MIN, abs(A[i])); sum += abs(A[i]); } if (minus % 2 == 1 && zero == 0) { cout << sum - MIN * 2 << endl; } else { cout << sum << endl; } }
[ "variable_declaration.value.change" ]
875,347
875,348
u613960672
cpp
p03062
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long LL; int main() { int N; cin >> N; vector<LL> A(N); rep(i, N) cin >> A[i]; sort(A.begin(), A.end()); for (int i = 0; i < N - 1; i += 2) { if (A[i] > 0) break; if (A[i] < 0 && A[i + 1] > 0) { if (A[i] + A[i + 1] < 0) { A[i] *= -1, A[i + 1] *= -1; } } else A[i] *= -1, A[i + 1] *= -1; } LL ans = 0; rep(i, N) ans += A[i]; cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long LL; int main() { int N; cin >> N; vector<LL> A(N); rep(i, N) cin >> A[i]; sort(A.begin(), A.end()); for (int i = 0; i < N - 1; i += 2) { if (A[i] >= 0) break; if (A[i] < 0 && A[i + 1] > 0) { if (A[i] + A[i + 1] < 0) { A[i] *= -1, A[i + 1] *= -1; } } else A[i] *= -1, A[i + 1] *= -1; } LL ans = 0; rep(i, N) ans += A[i]; cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
875,353
875,354
u226233437
cpp
p03062
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; const int MOD = 1000000007; /* const int MOD = 998244353; */ const int INF = 1e18; const double PI = acos(-1); using namespace std; struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } INIT; signed main() { int N; cin >> N; int ans = 0; int cnt = 0; int MIN = INF; REP(i, N) { int a; cin >> a; ans += abs(a); if (a < 0) cnt++; chmin(MIN, abs(a)); } if (cnt % 2 == 1) ans -= MIN; cout << ans << "\n"; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; const int MOD = 1000000007; /* const int MOD = 998244353; */ const int INF = 1e18; const double PI = acos(-1); using namespace std; struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } INIT; signed main() { int N; cin >> N; int ans = 0; int cnt = 0; int MIN = INF; REP(i, N) { int a; cin >> a; ans += abs(a); if (a < 0) cnt++; chmin(MIN, abs(a)); } if (cnt % 2 == 1) ans -= 2 * MIN; cout << ans << "\n"; return 0; }
[ "assignment.change" ]
875,355
875,356
u812973725
cpp
p03062
#include <iostream> using namespace std; long long int res = 0, mymin = 99999999999999999, odd = 0, n, a[200005], zero = 0; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] < 0) { odd++; } res += abs(a[i]); mymin = min(mymin, abs(a[i])); } if (odd % 2 == 0) cout << res << endl; if (odd % 2 == 1) cout << res - mymin << endl; }
#include <iostream> using namespace std; long long int res = 0, mymin = 99999999999999999, odd = 0, n, a[200005], zero = 0; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] < 0) { odd++; } res += abs(a[i]); mymin = min(mymin, abs(a[i])); } if (odd % 2 == 0) cout << res << endl; if (odd % 2 == 1) cout << res - 2 * mymin << endl; }
[ "expression.operation.binary.add" ]
875,357
875,358
u018872912
cpp
p03062
#include <bits/stdc++.h> #include <type_traits> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define ddrep(i, n) for (int i = n; i > 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define ssrep(i, s, t) for (int i = s; i <= t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define pb push_back #define eb emplace_back #define fi first #define se second #define chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) using pi = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using ld = long double; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; rep(i, (int)v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } template <typename T, size_t S> void printArray(const T (&array)[S]) { for (auto val : array) std::cout << val << ", "; std::cout << "\n"; } const int mod = 1e9 + 7; const int inf = 1e9 + 5; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << std::setprecision(10); int n; std::cin >> n; ll mi = inf, mcnt = 0, ans = 0; rep(i, n) { ll a; std::cin >> a; if (a < 0) a *= -1, mcnt++; chmin(mi, a); ans += a; } if (mcnt & 1) ans -= mi; std::cout << ans << "\n"; }
#include <bits/stdc++.h> #include <type_traits> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define ddrep(i, n) for (int i = n; i > 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define ssrep(i, s, t) for (int i = s; i <= t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define pb push_back #define eb emplace_back #define fi first #define se second #define chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) using pi = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using ld = long double; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; rep(i, (int)v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } template <typename T, size_t S> void printArray(const T (&array)[S]) { for (auto val : array) std::cout << val << ", "; std::cout << "\n"; } const int mod = 1e9 + 7; const int inf = 1e9 + 5; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << std::setprecision(10); int n; std::cin >> n; ll mi = inf, mcnt = 0, ans = 0; rep(i, n) { ll a; std::cin >> a; if (a < 0) a *= -1, mcnt++; chmin(mi, a); ans += a; } if (mcnt & 1) ans -= mi * 2; std::cout << ans << "\n"; }
[ "assignment.change" ]
875,359
875,360
u700484101
cpp
p03062
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, a, n) for (ll i = a; i < (ll)(n); i++) #define repd(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() ll k, l, m, n; const int M = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ll sum = 0, num = 0, min = M, a; rep(i, n) { cin >> a; if (a < 0) { num++; a *= -1; } sum += a; if (a < min) min = a; } if (num % 2 == 0) { cout << sum << endl; } else { cout << sum - min << endl; } }
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, a, n) for (ll i = a; i < (ll)(n); i++) #define repd(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() ll k, l, m, n; const int M = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ll sum = 0, num = 0, min = M, a; rep(i, n) { cin >> a; if (a < 0) { num++; a *= -1; } sum += a; if (a < min) min = a; } if (num % 2 == 0) { cout << sum << endl; } else { cout << sum - 2 * min << endl; } }
[ "expression.operation.binary.add" ]
875,361
875,362
u715288765
cpp
p03062
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, a, n) for (ll i = a; i < (ll)(n); i++) #define repd(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() ll k, l, m, n; const ll M = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ll sum = 0, num = 0, min = M, a; rep(i, n) { cin >> a; if (a < 0) { num++; a *= -1; } sum += a; if (a < min) min = a; } if (num % 2 == 0) { cout << sum << endl; } else { cout << sum - min << endl; } }
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repp(i, a, n) for (ll i = a; i < (ll)(n); i++) #define repd(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() ll k, l, m, n; const int M = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ll sum = 0, num = 0, min = M, a; rep(i, n) { cin >> a; if (a < 0) { num++; a *= -1; } sum += a; if (a < min) min = a; } if (num % 2 == 0) { cout << sum << endl; } else { cout << sum - 2 * min << endl; } }
[ "variable_declaration.type.change" ]
875,363
875,362
u715288765
cpp
p03062
#include <iostream> using namespace std; using ll = long long; int main() { int n, i, cnt = 0; ll a, m = 1e9 + 7, ans = 0; cin >> n; for (i = 0; i < n; ++i) { cin >> a; if (a < 0) { ++cnt; a *= -1; } m = min(m, a); ans += a; } if (cnt % 2 == 0) cout << ans << endl; else cout << ans - m << endl; return 0; }
#include <iostream> using namespace std; using ll = long long; int main() { int n, i, cnt = 0; ll a, m = 1e9 + 7, ans = 0; cin >> n; for (i = 0; i < n; ++i) { cin >> a; if (a < 0) { ++cnt; a *= -1; } m = min(m, a); ans += a; } if (cnt % 2 == 0) cout << ans << endl; else cout << ans - 2 * m << endl; return 0; }
[ "expression.operation.binary.add" ]
875,372
875,373
u714732628
cpp
p03062
#include <algorithm> #include <iostream> using namespace std; int main() { int n, sum = 0, he = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; he += abs(a[i]); if (a[i] < 0) sum++; a[i] = abs(a[i]); } sort(a, a + n); if (sum % 2 == 0) cout << he << endl; else cout << he - a[0] * 2 << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { long long n, sum = 0, he = 0; cin >> n; long long a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; he += abs(a[i]); if (a[i] < 0) sum++; a[i] = abs(a[i]); } sort(a, a + n); if (sum % 2 == 0) cout << he << endl; else cout << he - a[0] * 2 << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
875,376
875,377
u214584864
cpp
p03062
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vb = vector<bool>; using vl = vector<long>; using vs = vector<string>; using vvi = vector<vector<int>>; using vvb = vector<vector<bool>>; using vvc = vector<vector<char>>; using vvl = vector<vector<long>>; using pii = pair<int, int>; using pil = pair<int, long>; using pll = pair<long, long>; #define fix20 cout << fixed << setprecision(20) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, s, t) for (int i = s; i < t; i++) #define RNG(i, s, t, u) for (int i = s; i < t; i += u) #define MOD 1000000007 #define all(vec) vec.begin(), vec.end() template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main() { int n; cin >> n; vl a(n); int cnt = 0; long sum = 0; rep(i, n) { cin >> a.at(i); if (a[i] < 0) { cnt++; a[i] *= -1; } sum = a[i]; } sort(all(a)); if (cnt % 2 == 0) { cout << sum << endl; } else { cout << sum - a[0] * 2 << endl; } }
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vb = vector<bool>; using vl = vector<long>; using vs = vector<string>; using vvi = vector<vector<int>>; using vvb = vector<vector<bool>>; using vvc = vector<vector<char>>; using vvl = vector<vector<long>>; using pii = pair<int, int>; using pil = pair<int, long>; using pll = pair<long, long>; #define fix20 cout << fixed << setprecision(20) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, s, t) for (int i = s; i < t; i++) #define RNG(i, s, t, u) for (int i = s; i < t; i += u) #define MOD 1000000007 #define all(vec) vec.begin(), vec.end() template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int main() { int n; cin >> n; vl a(n); int cnt = 0; long sum = 0; rep(i, n) { cin >> a.at(i); if (a[i] < 0) { cnt++; a[i] *= -1; } sum += a[i]; } sort(all(a)); if (cnt % 2 == 0) { cout << sum << endl; } else { cout << sum - a[0] * 2 << endl; } }
[ "assignment.value.change" ]
875,382
875,383
u184335045
cpp
p03062
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; using namespace std; int mod = 1000000007; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int cnt_neg = 0; ll min_abs = mod; ll sum = 0; rep(i, N) { ll a; cin >> a; if (a < 0) cnt_neg++; min_abs = min(min_abs, abs(a)); sum += abs(a); } if (cnt_neg % 2) cout << sum - min_abs << endl; else cout << sum << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; using namespace std; int mod = 1000000007; int main(void) { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; int cnt_neg = 0; ll min_abs = mod; ll sum = 0; rep(i, N) { ll a; cin >> a; if (a < 0) cnt_neg++; min_abs = min(min_abs, abs(a)); sum += abs(a); } if (cnt_neg % 2) cout << sum - min_abs - min_abs << endl; else cout << sum << endl; return 0; }
[ "expression.operation.binary.add" ]
875,393
875,394
u882620594
cpp
p03062
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define repi(i, x) \ for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #define mp make_pair #define pb push_back #define solve(a) ((a) ? "Yes" : "No") typedef vector<int> Vi; typedef vector<Vi> VVi; typedef pair<int, int> Pi; typedef vector<Pi> VPi; typedef vector<long long> V; typedef vector<V> VV; typedef pair<long long, long long> P; typedef vector<P> VP; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INFLL = 1LL << 60; const int INF = 1 << 30; const double PI = acos(-1); int main() { int n; ll ans = 0LL; cin >> n; int minabs = INF; int zero = 0; int negat = 0; V a(n); rep(i, n) { cin >> a[i]; if (a[i] < 0) { negat++; } else if (a[i] == 0) { zero++; } if (abs(a[i]) < minabs) { minabs = abs(a[i]); } ans += abs(a[i]); } if (zero == 0 and negat % 2 == 1) { ans -= minabs; } cout << ans << endl; }
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i > 0; i--) #define repi(i, x) \ for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++) #define all(x) (x).begin(), (x).end() #define F first #define S second #define mp make_pair #define pb push_back #define solve(a) ((a) ? "Yes" : "No") typedef vector<int> Vi; typedef vector<Vi> VVi; typedef pair<int, int> Pi; typedef vector<Pi> VPi; typedef vector<long long> V; typedef vector<V> VV; typedef pair<long long, long long> P; typedef vector<P> VP; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INFLL = 1LL << 60; const int INF = 1 << 30; const double PI = acos(-1); int main() { int n; ll ans = 0LL; cin >> n; int minabs = INF; int zero = 0; int negat = 0; V a(n); rep(i, n) { cin >> a[i]; if (a[i] < 0) { negat++; } else if (a[i] == 0) { zero++; } if (abs(a[i]) < minabs) { minabs = abs(a[i]); } ans += abs(a[i]); } if (zero == 0 and negat % 2 == 1) { ans -= minabs * 2; } cout << ans << endl; }
[ "assignment.change" ]
875,395
875,396
u179778090
cpp
p03062
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define all(x) (x).begin(), (x).end() #define PI 3.14159265358979323846264338327950L #define NUM 1000000010 using namespace std; typedef long long ll; typedef long double ld; int main() { int n, minus = 0; bool zero = false; cin >> n; ll sum = 0, mini = NUM; vector<ll> a(n); rep(i, n) { cin >> a[i]; mini = min(mini, abs(a[i])); if (a[i] < 0) minus++; if (a[i] == 0) zero = true; sum += abs(a[i]); } if (minus % 2 == 1 && !zero) sum -= mini; cout << sum << endl; }
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (n); ++i) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define all(x) (x).begin(), (x).end() #define PI 3.14159265358979323846264338327950L #define NUM 1000000010 using namespace std; typedef long long ll; typedef long double ld; int main() { int n, minus = 0; bool zero = false; cin >> n; ll sum = 0, mini = NUM; vector<ll> a(n); rep(i, n) { cin >> a[i]; mini = min(mini, abs(a[i])); if (a[i] < 0) minus++; if (a[i] == 0) zero = true; sum += abs(a[i]); } if (minus % 2 == 1 && !zero) sum -= 2 * mini; cout << sum << endl; }
[ "assignment.change" ]
875,409
875,410
u151236434
cpp
p03062
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #pragma region Macros #define int long long #define double long double constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; const int INF = 1e12; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; #define krep(i, k, n) for (int i = (k); i < n + k; i++) #define Krep(i, k, n) for (int i = (k); i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define Rrep(i, n) for (int i = n; i > 0; i--) #define REP(i, n) for (int i = 1; i <= n; i++) #define LAST(x) x[x.size() - 1] #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x) #define swap(a, b) (a += b, b = a - b, a -= b) #define DIVCEIL(a, b) ((a + b - 1) / b) #define SUM1n(n) ((n) * (n + 1) / 2) #define SUM1n2(n) (n * (2 * n + 1) * (n + 1)) / 6 #define SUMkn(k, n) (SUM1n(n) - SUM1n(k - 1)) #define PB push_back #define Fi first #define Se second int intpow(int a, int n) { // a^nのint ver int ans = a; if (n == 0) return 1; else { rep(i, n - 1) ans *= a; return ans; } } int MODPOW(int a, int n, int mod) { // a^n mod int ans = 1; while (n > 0) { if (n & 1) ans = ans * a % mod; a = a * a % mod; n >>= 1; } return ans; } int factorial(int a) { if (a == 0) return 1; else return a * factorial(a - 1); } int MODFACT(int a, int mod) { int ans = 1; REP(i, a) { ans *= i; ans %= MOD; } return ans; } int nPr(int n, int r) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) sum *= i; return sum; } int MODnPr(int n, int r, int mod) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) { sum *= i; sum = sum % MOD; } return sum; } // int nCr(int n, int r) int nCr2(int n, int r) { return factorial(n) / (factorial(r) * factorial(n - r)); } int GCD(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; if (a % b == 0) return b; return GCD(b, a % b); } int LCM(int a, int b) { return a * b / GCD(a, b); } int divisor_count(int n) { //約数の数(だっけ?) int ans = 0; REP(i, n) { if (n % i == 0) ans++; } return ans; } int CEIL1(int n) { // 1桁目切り上げ return (n + 9) / 10 * 10; } int getdigit(int n) { return log10(n) + 1; } int digit(int n, int k) { // nのk桁目 rep(i, k - 1) n /= 10; return n % 10; } int digit_sum(int n) { int sum = 0, dig; while (n) { dig = n % 10; sum += dig; n /= 10; } return sum; } int DIVTIME(int n, int k) { // nをkで何回割れるか的な int div = 0; while (n % k == 0) { div++; n /= k; } return div; } int binary(int n) { // 10進数→2進数 int ans = 0; for (int i = 0; n > 0; i++) { ans += n % 2 * intpow(10, i); n /= 2; } return ans; } int binary_2to10(string n) { int ans = 0; rep(i, n.size()) { if (n[i] == '1') ans += intpow(2, n.size() - i - 1); } return ans; } int intabs(int n) { if (n < 0) return -1 * n; else return n; } int Kaibun(int n) { int ans = 0; int d = getdigit(n); REP(i, d) ans += digit(n, i) * pow(10, d - i); return ans; } inline bool is_uru(int y) { if (y % 400 == 0) return 1; if (y % 100 == 0) return 0; if (y % 4 == 0) return 1; return 0; } void next_date(int &y, int &m, int &d) { int day = days[m]; if (m == 2 && is_uru(y)) day++; d++; if (day < d) { m++; d = 1; } if (m == 13) { y++; m = 1; } } double LOG(int a, int b) { return log(b) / log(a); } double DISTANCE(int x1, int y1, int x2, int y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } double clock_angle(int h, int m) { h %= 12; double mm = 6.0 * m; double nn = 30.0 * h + 0.5 * m; return std::min(fabs(mm - nn), 360.0 - fabs(nn - mm)); } inline bool BETWEEN(int x, int min, int max) { if (min <= x && x <= max) return true; else return false; } inline bool between(int x, int min, int max) { if (min < x && x < max) return true; else return false; } inline bool is_prime(int x) { if (x == 1) return false; if (x == 2) return true; if (x % 2 == 0) return false; double sqrtx = sqrt(x); for (int i = 3; i <= sqrtx; i += 2) { if (x % i == 0) return false; } return true; } inline bool is_sqrt(int n) { if (sqrt(n) == (int)sqrt(n)) return true; else return false; } 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; } #pragma endregion typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<string> vstring; typedef map<int, int> mint; typedef pair<int, int> pint; using Graph = vector<vint>; mint m; const int MAX = 510000; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } vector<pint> prime_factorize(int N) { vector<pint> res; Krep(i, 2, sqrt(N)) { if (N % i != 0) continue; int ex = 0; while (N % i == 0) { ++ex; N /= i; } res.push_back({i, ex}); } if (N != 1) res.push_back({N, 1}); return res; } double median(vint a) { int N = a.size(); if (N % 2 == 1) return (double)a[N / 2]; else return (double)(a[N / 2 - 1] + a[N / 2]) / 2; } int collatz(int n, int cou) { if (m.count(n)) return m[n] + cou; if (n == 1) return cou; if (n % 2 == 0) return collatz(n / 2, cou + 1); return collatz(3 * n + 1, cou + 1); } signed main() { int N; cin >> N; vint a(N); vvint dp(N + 1, vint(2)); rep(i, N) cin >> a[i]; dp[0][0] = 0; dp[0][1] = 1; rep(i, N) { dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]); dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]); } cout << dp[N][0]; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #pragma region Macros #define int long long #define double long double constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; const int INF = 1e12; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; #define krep(i, k, n) for (int i = (k); i < n + k; i++) #define Krep(i, k, n) for (int i = (k); i < n; i++) #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define Rrep(i, n) for (int i = n; i > 0; i--) #define REP(i, n) for (int i = 1; i <= n; i++) #define LAST(x) x[x.size() - 1] #define ALL(x) (x).begin(), (x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x) #define swap(a, b) (a += b, b = a - b, a -= b) #define DIVCEIL(a, b) ((a + b - 1) / b) #define SUM1n(n) ((n) * (n + 1) / 2) #define SUM1n2(n) (n * (2 * n + 1) * (n + 1)) / 6 #define SUMkn(k, n) (SUM1n(n) - SUM1n(k - 1)) #define PB push_back #define Fi first #define Se second int intpow(int a, int n) { // a^nのint ver int ans = a; if (n == 0) return 1; else { rep(i, n - 1) ans *= a; return ans; } } int MODPOW(int a, int n, int mod) { // a^n mod int ans = 1; while (n > 0) { if (n & 1) ans = ans * a % mod; a = a * a % mod; n >>= 1; } return ans; } int factorial(int a) { if (a == 0) return 1; else return a * factorial(a - 1); } int MODFACT(int a, int mod) { int ans = 1; REP(i, a) { ans *= i; ans %= MOD; } return ans; } int nPr(int n, int r) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) sum *= i; return sum; } int MODnPr(int n, int r, int mod) { int s = n - r + 1; int sum = 1; for (int i = s; i <= n; i++) { sum *= i; sum = sum % MOD; } return sum; } // int nCr(int n, int r) int nCr2(int n, int r) { return factorial(n) / (factorial(r) * factorial(n - r)); } int GCD(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; if (a % b == 0) return b; return GCD(b, a % b); } int LCM(int a, int b) { return a * b / GCD(a, b); } int divisor_count(int n) { //約数の数(だっけ?) int ans = 0; REP(i, n) { if (n % i == 0) ans++; } return ans; } int CEIL1(int n) { // 1桁目切り上げ return (n + 9) / 10 * 10; } int getdigit(int n) { return log10(n) + 1; } int digit(int n, int k) { // nのk桁目 rep(i, k - 1) n /= 10; return n % 10; } int digit_sum(int n) { int sum = 0, dig; while (n) { dig = n % 10; sum += dig; n /= 10; } return sum; } int DIVTIME(int n, int k) { // nをkで何回割れるか的な int div = 0; while (n % k == 0) { div++; n /= k; } return div; } int binary(int n) { // 10進数→2進数 int ans = 0; for (int i = 0; n > 0; i++) { ans += n % 2 * intpow(10, i); n /= 2; } return ans; } int binary_2to10(string n) { int ans = 0; rep(i, n.size()) { if (n[i] == '1') ans += intpow(2, n.size() - i - 1); } return ans; } int intabs(int n) { if (n < 0) return -1 * n; else return n; } int Kaibun(int n) { int ans = 0; int d = getdigit(n); REP(i, d) ans += digit(n, i) * pow(10, d - i); return ans; } inline bool is_uru(int y) { if (y % 400 == 0) return 1; if (y % 100 == 0) return 0; if (y % 4 == 0) return 1; return 0; } void next_date(int &y, int &m, int &d) { int day = days[m]; if (m == 2 && is_uru(y)) day++; d++; if (day < d) { m++; d = 1; } if (m == 13) { y++; m = 1; } } double LOG(int a, int b) { return log(b) / log(a); } double DISTANCE(int x1, int y1, int x2, int y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } double clock_angle(int h, int m) { h %= 12; double mm = 6.0 * m; double nn = 30.0 * h + 0.5 * m; return std::min(fabs(mm - nn), 360.0 - fabs(nn - mm)); } inline bool BETWEEN(int x, int min, int max) { if (min <= x && x <= max) return true; else return false; } inline bool between(int x, int min, int max) { if (min < x && x < max) return true; else return false; } inline bool is_prime(int x) { if (x == 1) return false; if (x == 2) return true; if (x % 2 == 0) return false; double sqrtx = sqrt(x); for (int i = 3; i <= sqrtx; i += 2) { if (x % i == 0) return false; } return true; } inline bool is_sqrt(int n) { if (sqrt(n) == (int)sqrt(n)) return true; else return false; } 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; } #pragma endregion typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<string> vstring; typedef map<int, int> mint; typedef pair<int, int> pint; using Graph = vector<vint>; mint m; const int MAX = 510000; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } vector<pint> prime_factorize(int N) { vector<pint> res; Krep(i, 2, sqrt(N)) { if (N % i != 0) continue; int ex = 0; while (N % i == 0) { ++ex; N /= i; } res.push_back({i, ex}); } if (N != 1) res.push_back({N, 1}); return res; } double median(vint a) { int N = a.size(); if (N % 2 == 1) return (double)a[N / 2]; else return (double)(a[N / 2 - 1] + a[N / 2]) / 2; } int collatz(int n, int cou) { if (m.count(n)) return m[n] + cou; if (n == 1) return cou; if (n % 2 == 0) return collatz(n / 2, cou + 1); return collatz(3 * n + 1, cou + 1); } signed main() { int N; cin >> N; vint a(N); vvint dp(N + 1, vint(2)); rep(i, N) cin >> a[i]; dp[0][0] = 0; dp[0][1] = -INF; rep(i, N) { dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]); dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]); } cout << dp[N][0]; }
[ "assignment.value.change", "expression.operation.unary.add" ]
875,421
875,422
u545364250
cpp
p03062
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define watch(x) cout << (#x) << " is " << (x) << endl #define debug cout << "hi" << endl using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const ll mod = 1e9 + 7; const int INF32 = 1 << 30; const ll INF64 = 1LL << 60; const ld pi = 3.141592653589793; void solve() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int cnt = 0; ll sum = 0; ll mini = 0; for (int i = 0; i < n; i++) { if (a[i] < 0) cnt++; sum += abs(a[i]); mini = min(abs(a[i]), mini); } if (cnt % 2) cout << sum - mini; else cout << sum; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define watch(x) cout << (#x) << " is " << (x) << endl #define debug cout << "hi" << endl using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const ll mod = 1e9 + 7; const int INF32 = 1 << 30; const ll INF64 = 1LL << 60; const ld pi = 3.141592653589793; void solve() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int cnt = 0; ll sum = 0; ll mini = INT_MAX; for (int i = 0; i < n; i++) { if (a[i] < 0) cnt++; sum += abs(a[i]); mini = min(abs(a[i]), mini); // cout << sum <<endl; } if (cnt % 2) cout << sum - 2 * mini; else cout << sum; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
[ "variable_declaration.value.change", "identifier.replace.add", "literal.replace.remove" ]
875,423
875,424
u633066470
cpp
p03062
#include <bits/stdc++.h> using namespace std; using ll = long long int; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll n; cin >> n; vector<ll> v(n); ll sum = 0, cm = 0, m; rep(i, n) { cin >> v[i]; if (i == 0) { m = abs(v[0]); } sum += abs(v[i]); if (v[i] < 0) { cm++; } m = min(m, abs(v[i])); } if (cm % 2 == 0 || m == 0) { cout << sum; } else { cout << "fcjsk" << sum - 2 * m; } }
#include <bits/stdc++.h> using namespace std; using ll = long long int; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll n; cin >> n; vector<ll> v(n); ll sum = 0, cm = 0, m; rep(i, n) { cin >> v[i]; if (i == 0) { m = abs(v[0]); } sum += abs(v[i]); if (v[i] < 0) { cm++; } m = min(m, abs(v[i])); } if (cm % 2 == 0 || m == 0) { cout << sum; } else { cout << sum - 2 * m; } }
[ "expression.operation.binary.remove" ]
875,437
875,438
u007463213
cpp
p03062
#include "bits/stdc++.h" #define int long long #define all(c) (c).begin(), (c).end() #define cpresent(c, x) ((c).find(x) != (c).end()) #define vpresent(c, x) (find(all(c), x) != (c).end()) #define endl '\n' #ifdef LOCAL #include "/home/iggaboi/Desktop/CP/debug.h" #else #define debug(x...) #endif using namespace std; int n; void solve() { cin >> n; vector<int> ara(n); int negs = 0; int minpos = 1e9 + 69; bool zeroes = false; for (int &i : ara) { cin >> i; if (i == 0) zeroes = true; if (i < 0) ++negs; else minpos = min(minpos, i); } int sum = 0; for (int i : ara) sum += abs(i); if (zeroes) cout << sum << endl; else if (negs & 1 ^ 1) cout << sum << endl; else cout << sum - 2 * minpos << endl; } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); // int t; cin >> t; // while(t--) solve(); return 0; }
#include "bits/stdc++.h" #define int long long #define all(c) (c).begin(), (c).end() #define cpresent(c, x) ((c).find(x) != (c).end()) #define vpresent(c, x) (find(all(c), x) != (c).end()) #define endl '\n' #ifdef LOCAL #include "/home/iggaboi/Desktop/CP/debug.h" #else #define debug(x...) #endif using namespace std; int n; void solve() { cin >> n; vector<int> ara(n); int negs = 0; int minpos = 1e9 + 69; bool zeroes = false; for (int &i : ara) { cin >> i; if (i == 0) zeroes = true; if (i < 0) ++negs; minpos = min(minpos, abs(i)); } int sum = 0; for (int i : ara) sum += abs(i); if (zeroes) cout << sum << endl; else if (negs & 1 ^ 1) cout << sum << endl; else cout << sum - 2 * minpos << endl; } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); // int t; cin >> t; // while(t--) solve(); return 0; }
[ "control_flow.branch.else.remove", "call.add", "call.arguments.change" ]
875,444
875,445
u514461570
cpp
p03062
#include <bits/stdc++.h> #define ll long long int using namespace std; const ll mod = 1000000007; const ll inf = 1e18; int main() { ll n; cin >> n; ll a[n]; ll s = 0; ll b = inf; ll o = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += abs(a[i]); b = min(b, abs(a[i])); if (a[i] < 0) o++; } if (o % 2 == 1) cout << s - b << endl; else cout << s << endl; }
#include <bits/stdc++.h> #define ll long long int using namespace std; const ll mod = 1000000007; const ll inf = 1e18; int main() { ll n; cin >> n; ll a[n]; ll s = 0; ll b = inf; ll o = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += abs(a[i]); b = min(b, abs(a[i])); if (a[i] < 0) o++; } if (o % 2 == 1) cout << s - 2 * b << endl; else cout << s << endl; }
[ "expression.operation.binary.add" ]
875,450
875,451
u016987091
cpp
p03055
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #if __cplusplus >= 201103L #include <array> #include <forward_list> #include <initializer_list> #include <tuple> #define cauto const auto & #else #endif using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; #define VV(T) vector<vector<T>> template <class T> void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t) { stringstream ss; ss << f; ss >> t; } #define GET_MACRO(_1, _2, _3, NAME, ...) NAME #define _rep(i, n) _rep2((i), 0, (n)) #define _rep2(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define fi first #define se second #define mkp make_pair #define DEBUG #ifdef DEBUG #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #else #define dump(x) #define debug(x) #endif #define MOD 1000000007LL #define EPS 1e-8 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL #define maxs(x, y) x = max(x, y) #define mins(x, y) x = min(x, y) vvint vv; void dfs(int ind, int d, int pre, vint &vis) { if (vis[ind] != -1) { return; } vis[ind] = d; for (int x : vv[ind]) { if (x == pre) { continue; } dfs(x, d + 1, ind, vis); } } void main2() { int N; cin >> N; vv = vvint(N); rep(i, N) { int a, b; cin >> a >> b; a--, b--; vv[a].PB(b); swap(a, b); vv[a].PB(b); } vint vis(N, -1); dfs(0, 0, -1, vis); int ind = 0; rep(i, N) { if (vis[ind] < vis[i]) { ind = i; } } vis = vint(N, -1); dfs(ind, 0, -1, vis); int ans = 0; rep(i, N) { maxs(ans, vis[i]); } if (ans % 3 == 1) { cout << "Second" << endl; } else { cout << "First" << endl; } } signed main() { main2(); }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #if __cplusplus >= 201103L #include <array> #include <forward_list> #include <initializer_list> #include <tuple> #define cauto const auto & #else #endif using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; #define VV(T) vector<vector<T>> template <class T> void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t) { stringstream ss; ss << f; ss >> t; } #define GET_MACRO(_1, _2, _3, NAME, ...) NAME #define _rep(i, n) _rep2((i), 0, (n)) #define _rep2(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define fi first #define se second #define mkp make_pair #define DEBUG #ifdef DEBUG #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) \ cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #else #define dump(x) #define debug(x) #endif #define MOD 1000000007LL #define EPS 1e-8 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL #define maxs(x, y) x = max(x, y) #define mins(x, y) x = min(x, y) vvint vv; void dfs(int ind, int d, int pre, vint &vis) { if (vis[ind] != -1) { return; } vis[ind] = d; for (int x : vv[ind]) { if (x == pre) { continue; } dfs(x, d + 1, ind, vis); } } void main2() { int N; cin >> N; vv = vvint(N); rep(i, N - 1) { int a, b; cin >> a >> b; a--, b--; vv[a].PB(b); swap(a, b); vv[a].PB(b); } vint vis(N, -1); dfs(0, 0, -1, vis); int ind = 0; rep(i, N) { if (vis[ind] < vis[i]) { ind = i; } } vis = vint(N, -1); dfs(ind, 0, -1, vis); int ans = 0; rep(i, N) { maxs(ans, vis[i]); } if (ans % 3 == 1) { cout << "Second" << endl; } else { cout << "First" << endl; } } signed main() { main2(); }
[ "expression.operation.binary.add" ]
875,458
875,459
u673823726
cpp
p03055
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #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; vector<int> G[234567]; pair<int, int> dfs(int v, int las) { pair<int, int> res = {1, v}; for (int nx : G[v]) { if (las == nx) continue; auto tmp = dfs(nx, v); tmp.first++; res = max(res, tmp); } return res; } int main() { cin >> N; for (int i = 1; i < N; ++i) { int a, b; cin >> a >> b; --a; --b; G[a].push_back(b); G[b].push_back(a); } auto r1 = dfs(0, -1); auto r2 = dfs(r1.first, -1); if (r2.second % 3 == 2) { cout << "Second" << endl; } else { cout << "First" << 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 <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; vector<int> G[234567]; pair<int, int> dfs(int v, int las) { pair<int, int> res = {1, v}; for (int nx : G[v]) { if (las == nx) continue; auto tmp = dfs(nx, v); tmp.first++; res = max(res, tmp); } return res; } int main() { cin >> N; for (int i = 1; i < N; ++i) { int a, b; cin >> a >> b; --a; --b; G[a].push_back(b); G[b].push_back(a); } auto r1 = dfs(0, -1); auto r2 = dfs(r1.second, -1); if (r2.first % 3 == 2) { cout << "Second" << endl; } else { cout << "First" << endl; } return 0; }
[ "call.arguments.change", "control_flow.branch.if.condition.change" ]
875,460
875,461
u558671021
cpp
p03055
#include <iostream> #include <vector> using namespace std; vector<vector<int>> edge; void dfs(int idx, int y, int d, vector<int> &vv) { if (vv[idx] >= 0) return; vv[idx] = d; for (int x : edge[idx]) { if (x == y) continue; dfs(x, idx, d + 1, vv); } } int main() { int N; cin >> N; edge = vector<vector<int>>(N); for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; a--, b--; edge[a].push_back(b); edge[b].push_back(a); } vector<int> vv(N, -1); dfs(0, -1, 0, vv); int idx = 0; for (int i = 0; i < N; i++) { if (vv[idx] < vv[i]) { idx = i; } } vv = vector<int>(N, -1); dfs(idx, -1, 0, vv); int mx = 0; for (int i = 0; i < N; i++) { mx = max(mx, vv[i]); } cout << (mx % 3 == 1 ? "Second" : "First") << endl; }
#include <iostream> #include <vector> using namespace std; vector<vector<int>> edge; void dfs(int idx, int y, int d, vector<int> &vv) { if (vv[idx] >= 0) return; vv[idx] = d; for (int x : edge[idx]) { if (x == y) continue; dfs(x, idx, d + 1, vv); } } int main() { int N; cin >> N; edge = vector<vector<int>>(N); for (int i = 0; i < N - 1; i++) { int a, b; cin >> a >> b; a--, b--; edge[a].push_back(b); edge[b].push_back(a); } vector<int> vv(N, -1); dfs(0, -1, 0, vv); int idx = 0; for (int i = 0; i < N; i++) { if (vv[idx] < vv[i]) { idx = i; } } vv = vector<int>(N, -1); dfs(idx, -1, 0, vv); int mx = 0; for (int i = 0; i < N; i++) { mx = max(mx, vv[i]); } cout << (mx % 3 == 1 ? "Second" : "First") << endl; }
[ "control_flow.loop.for.condition.change", "misc.off_by_one" ]
875,462
875,463
u224109982
cpp
p03055
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef pair<int, int> pi; const int MAXN = 200005; int n; int dp[MAXN]; vector<int> gph[MAXN]; pi dfs(int x, int p) { pi ret(0, x); for (auto &i : gph[x]) { if (i != p) { auto w = dfs(i, x); w.first++; ret = max(ret, w); } } return ret; } int main() { dp[1] = 1; cin >> n; for (int i = 0; i < n - 1; i++) { int s, e; scanf("%d %d", &s, &e); gph[s].push_back(e); gph[e].push_back(s); } auto diam = dfs(dfs(1, 0).second, 0).first; if (diam % 3 == 2) puts("First"); else puts("Second"); }
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef pair<int, int> pi; const int MAXN = 200005; int n; int dp[MAXN]; vector<int> gph[MAXN]; pi dfs(int x, int p) { pi ret(0, x); for (auto &i : gph[x]) { if (i != p) { auto w = dfs(i, x); w.first++; ret = max(ret, w); } } return ret; } int main() { dp[1] = 1; cin >> n; for (int i = 0; i < n - 1; i++) { int s, e; scanf("%d %d", &s, &e); gph[s].push_back(e); gph[e].push_back(s); } auto diam = dfs(dfs(1, 0).second, 0).first; if (diam % 3 != 1) puts("First"); else puts("Second"); }
[]
875,464
875,465
u329802369
cpp
p03056
#include <cstdio> #include <iostream> #define RI register int #define CI const int & using namespace std; const int N = 200; int n, m, f[N][N][N], g[N][N][N]; char a[N][N]; int main() { RI i, j, k, p, t; for (scanf("%d%d", &n, &m), i = 1; i <= n; ++i) scanf("%s", a[i] + 1); for (i = 1; i <= n; ++i) for (j = i; j <= n; ++j) for (f[i][j][m + 1] = k = m; k; --k) if (i == j || (a[i][k] == a[j][k] && f[i][j - 1][k] >= k)) f[i][j][k] = a[i][k] == a[i][k + 1] ? f[i][j][k + 1] : k; else f[i][j][k] = k - 1; for (i = 1; i <= m; ++i) for (j = i; j <= m; ++j) for (g[i][j][n + 1] = k = n; k; --k) if (i == j || (a[k][i] == a[k][j] && g[i][j - 1][k]) >= k) g[i][j][k] = a[k][i] == a[k + 1][i] ? g[i][j][k + 1] : k; else g[i][j][k] = k - 1; if (f[1][n][1] == m) return puts("0"), 0; for (t = 1;; ++t) { for (i = 1; i <= n; ++i) for (j = i; j <= n; ++j) for (k = 1; k <= m; ++k) f[i][j][k] = f[i][j][f[i][j][k] + 1]; for (i = 1; i <= m; ++i) for (j = i; j <= m; ++j) for (k = 1; k <= n; ++k) g[i][j][k] = g[i][j][g[i][j][k] + 1]; for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) { for (f[i][n + 1][j] = j - 1, k = i; k <= n; ++k) for (p = f[i][k][j]; p > f[i][k + 1][j]; --p) g[j][p][i] = max(g[j][p][i], k); for (g[j][m + 1][i] = i - 1, k = j; k <= m; ++k) for (p = g[j][k][i]; p > g[j][k + 1][i]; --p) f[i][p][j] = max(f[i][p][j], k); } if (f[1][n][1] == m) return printf("%d", t), 0; } return 0; }
#include <cstdio> #include <iostream> #define RI register int #define CI const int & using namespace std; const int N = 200; int n, m, f[N][N][N], g[N][N][N]; char a[N][N]; int main() { RI i, j, k, p, t; for (scanf("%d%d", &n, &m), i = 1; i <= n; ++i) scanf("%s", a[i] + 1); for (i = 1; i <= n; ++i) for (j = i; j <= n; ++j) for (f[i][j][m + 1] = k = m; k; --k) if (i == j || (a[i][k] == a[j][k] && f[i][j - 1][k] >= k)) f[i][j][k] = a[i][k] == a[i][k + 1] ? f[i][j][k + 1] : k; else f[i][j][k] = k - 1; for (i = 1; i <= m; ++i) for (j = i; j <= m; ++j) for (g[i][j][n + 1] = k = n; k; --k) if (i == j || (a[k][i] == a[k][j] && g[i][j - 1][k] >= k)) g[i][j][k] = a[k][i] == a[k + 1][i] ? g[i][j][k + 1] : k; else g[i][j][k] = k - 1; if (f[1][n][1] == m) return puts("0"), 0; for (t = 1;; ++t) { for (i = 1; i <= n; ++i) for (j = i; j <= n; ++j) for (k = 1; k <= m; ++k) f[i][j][k] = f[i][j][f[i][j][k] + 1]; for (i = 1; i <= m; ++i) for (j = i; j <= m; ++j) for (k = 1; k <= n; ++k) g[i][j][k] = g[i][j][g[i][j][k] + 1]; for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) { for (f[i][n + 1][j] = j - 1, k = i; k <= n; ++k) for (p = f[i][k][j]; p > f[i][k + 1][j]; --p) g[j][p][i] = max(g[j][p][i], k); for (g[j][m + 1][i] = i - 1, k = j; k <= m; ++k) for (p = g[j][k][i]; p > g[j][k + 1][i]; --p) f[i][p][j] = max(f[i][p][j], k); } if (f[1][n][1] == m) return printf("%d", t), 0; } return 0; }
[ "control_flow.branch.if.condition.change" ]
875,475
875,476
u803115645
cpp
p03056
#include <cstdio> #include <cstring> #define N 190 inline int min(int x, int y) { return x < y ? x : y; } inline int max(int x, int y) { return x < y ? y : x; } int a[N][N][N], b[N], d[N][N], e[N], f[N][N][N], i, j, k, l, m, n, r, s; char c[N][N]; int main() { scanf("%d%d", &n, &m); for (i = 1; i <= n; i++) scanf("%s", c[e[i] = i] + 1); for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) d[i][j] = d[i][j - 1] + (c[i][j] == '.'); for (i = 1; i <= m; i++) for (j = i; j <= m; j++) for (k = 1, l = 0, a[i][j][n + 1] = n; k <= n; a[i][j][k++] = l) while ( l < n && (l + 1 < k || l + 1 == k && (d[l + 1][j] - d[l + 1][i - 1] == j - i + 1 || d[l + 1][j] == d[l + 1][i - 1]) || k <= l && d[l + 1][j] - d[l + 1][i - 1] == d[l][j] - d[l][i - 1])) l++; for (s = 0; a[1][m][1] < n; s++) { for (k = 1; k <= n; k++) for (memcpy(b + 1, e + 1, n << 2), j = 0; j < m; j++) for (i = 1; i + j <= m; f[i][i + j][k] = max(a[i][i + j][a[i][i + j][k] + 1], min(a[i][b[i]][k], a[b[i] + 1][i + j][k])), i++) while (b[i] < i + j && min(a[i][b[i] + 1][k], a[b[i] + 2][i + j][k]) >= min(a[i][b[i]][k], a[b[i] + 1][i + j][k])) b[i]++; for (i = 1; i <= m; i++) for (j = 1; j <= m; j++) for (k = 1; k <= n; k++) a[i][j][k] = f[i][j][k]; } return 0 * printf("%d\n", s); }
#include <cstdio> #include <cstring> #define N 190 inline int min(int x, int y) { return x < y ? x : y; } inline int max(int x, int y) { return x < y ? y : x; } int a[N][N][N], b[N], d[N][N], e[N], f[N][N][N], i, j, k, l, m, n, r, s; char c[N][N]; int main() { scanf("%d%d", &n, &m); for (i = 1; i <= n; i++) scanf("%s", c[e[i] = i] + 1); for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) d[i][j] = d[i][j - 1] + (c[i][j] == '.'); for (i = 1; i <= m; i++) for (j = i; j <= m; j++) for (k = 1, l = 0, a[i][j][n + 1] = n; k <= n; a[i][j][k++] = l) while ( l < n && (l + 1 < k || l + 1 == k && (d[l + 1][j] - d[l + 1][i - 1] == j - i + 1 || d[l + 1][j] == d[l + 1][i - 1]) || k <= l && d[l + 1][j] - d[l + 1][i - 1] == d[l][j] - d[l][i - 1])) l++; for (s = 0; a[1][m][1] < n; s++) { for (k = 1; k <= n; k++) for (memcpy(b + 1, e + 1, m << 2), j = 0; j < m; j++) for (i = 1; i + j <= m; f[i][i + j][k] = max(a[i][i + j][a[i][i + j][k] + 1], min(a[i][b[i]][k], a[b[i] + 1][i + j][k])), i++) while (b[i] < i + j && min(a[i][b[i] + 1][k], a[b[i] + 2][i + j][k]) >= min(a[i][b[i]][k], a[b[i] + 1][i + j][k])) b[i]++; for (i = 1; i <= m; i++) for (j = i; j <= m; j++) for (k = 1; k <= n; k++) a[i][j][k] = f[i][j][k]; } return 0 * printf("%d\n", s); }
[ "identifier.change", "control_flow.loop.for.initializer.change", "call.arguments.change", "expression.operation.binary.change", "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
875,482
875,483
u587186090
cpp
p03056
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> //#define int long long #define lowbit(x) ((x) & (-x)) using namespace std; const int maxn = 190; int n, m, sum[maxn][maxn], a[maxn][maxn], dp[maxn][maxn][maxn][20]; char ch[maxn][maxn]; 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 << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } return x * f; } inline void write(int a) { if (a < 0) { putchar('-'); putchar('1'); } else { if (a >= 10) write(a / 10); putchar(a % 10 + '0'); } } signed main() { cin >> n >> m; for (int i = 1; i <= n; ++i) scanf("%s", ch[i] + 1); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { if (ch[i][j] == '.') a[i][j] = 1; else a[i][j] = 0; sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j]; } for (int shang = 1; shang <= n; ++shang) for (int zuo = 1; zuo <= m; ++zuo) for (int you = zuo; you <= m; ++you) { int l = shang, r = n, xia = shang - 1; while (l <= r) { int mid = (l + r) >> 1; int geshu = sum[mid][you] - sum[mid][zuo - 1] - sum[shang - 1][you] + sum[shang - 1][zuo - 1]; if (!geshu || geshu == (mid - shang + 1) * (you - zuo + 1)) xia = mid, l = mid + 1; else r = mid - 1; } dp[shang][zuo][you][0] = xia; // cout<<shang<<' '<<zuo<<' '<<you<<' //'<<xia<<endl; } int k; for (k = 1; dp[1][1][m][k - 1] < n; ++k) for (int kuan = 1; kuan <= m; ++kuan) for (int shang = 1; shang <= n; ++shang) for (int zuo = 1, you = zuo + kuan - 1; you <= m; ++zuo, ++you) { if (dp[shang][zuo][you][k - 1] == n) { dp[shang][zuo][you][k] = n; continue; } dp[shang][zuo][you][k] = dp[dp[shang][zuo][you][k - 1] + 1][zuo][you][k - 1]; if (dp[shang][zuo][you][k] == n) continue; int l = zuo, r = you - 1, kotae = 0; while (l <= r) { int mid = (l + r) >> 1; int x = dp[shang][zuo][mid][k - 1], y = dp[shang][mid + 1][you][k - 1]; kotae = max(kotae, min(x, y)); if (x < y) r = mid - 1; else l = mid + 1; } dp[shang][zuo][you][k] = max(dp[shang][zuo][you][k], kotae); } write(k - 1); return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> //#define int long long #define lowbit(x) ((x) & (-x)) using namespace std; const int maxn = 190; int n, m, sum[maxn][maxn], a[maxn][maxn], dp[maxn][maxn][maxn][15]; char ch[maxn][maxn]; 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 << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } return x * f; } inline void write(int a) { if (a < 0) { putchar('-'); putchar('1'); } else { if (a >= 10) write(a / 10); putchar(a % 10 + '0'); } } signed main() { cin >> n >> m; for (int i = 1; i <= n; ++i) scanf("%s", ch[i] + 1); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { if (ch[i][j] == '.') a[i][j] = 1; else a[i][j] = 0; sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j]; } for (int shang = 1; shang <= n; ++shang) for (int zuo = 1; zuo <= m; ++zuo) for (int you = zuo; you <= m; ++you) { int l = shang, r = n, xia = shang - 1; while (l <= r) { int mid = (l + r) >> 1; int geshu = sum[mid][you] - sum[mid][zuo - 1] - sum[shang - 1][you] + sum[shang - 1][zuo - 1]; if (!geshu || geshu == (mid - shang + 1) * (you - zuo + 1)) xia = mid, l = mid + 1; else r = mid - 1; } dp[shang][zuo][you][0] = xia; // cout<<shang<<' '<<zuo<<' '<<you<<' //'<<xia<<endl; } int k; for (k = 1; dp[1][1][m][k - 1] < n; ++k) for (int kuan = 1; kuan <= m; ++kuan) for (int shang = 1; shang <= n; ++shang) for (int zuo = 1, you = zuo + kuan - 1; you <= m; ++zuo, ++you) { if (dp[shang][zuo][you][k - 1] == n) { dp[shang][zuo][you][k] = n; continue; } dp[shang][zuo][you][k] = dp[dp[shang][zuo][you][k - 1] + 1][zuo][you][k - 1]; if (dp[shang][zuo][you][k] == n) continue; int l = zuo, r = you - 1, kotae = 0; while (l <= r) { int mid = (l + r) >> 1; int x = dp[shang][zuo][mid][k - 1], y = dp[shang][mid + 1][you][k - 1]; kotae = max(kotae, min(x, y)); if (x < y) r = mid - 1; else l = mid + 1; } dp[shang][zuo][you][k] = max(dp[shang][zuo][you][k], kotae); } write(k - 1); return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change" ]
875,485
875,486
u536150318
cpp
p03056
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> #define int long long #define lowbit(x) ((x) & (-x)) using namespace std; const int maxn = 190; int n, m, sum[maxn][maxn], a[maxn][maxn], dp[maxn][maxn][maxn][20]; char ch[maxn][maxn]; 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 << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } return x * f; } inline void write(int a) { if (a < 0) { putchar('-'); putchar('1'); } else { if (a >= 10) write(a / 10); putchar(a % 10 + '0'); } } signed main() { cin >> n >> m; for (int i = 1; i <= n; ++i) scanf("%s", ch[i] + 1); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { if (ch[i][j] == '.') a[i][j] = 1; else a[i][j] = 0; sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j]; } for (int shang = 1; shang <= n; ++shang) for (int zuo = 1; zuo <= m; ++zuo) for (int you = zuo; you <= m; ++you) { int l = shang, r = n, xia = shang - 1; while (l <= r) { int mid = (l + r) >> 1; int geshu = sum[mid][you] - sum[mid][zuo - 1] - sum[shang - 1][you] + sum[shang - 1][zuo - 1]; if (!geshu || geshu == (mid - shang + 1) * (you - zuo + 1)) xia = mid, l = mid + 1; else r = mid - 1; } dp[shang][zuo][you][0] = xia; // cout<<shang<<' '<<zuo<<' '<<you<<' //'<<xia<<endl; } int k; for (k = 1; dp[1][1][m][k - 1] < n; ++k) for (int kuan = 1; kuan <= m; ++kuan) for (int shang = 1; shang <= n; ++shang) for (int zuo = 1, you = zuo + kuan - 1; you <= m; ++zuo, ++you) { if (dp[shang][zuo][you][k - 1] == n) { dp[shang][zuo][you][k] = n; continue; } dp[shang][zuo][you][k] = dp[dp[shang][zuo][you][k - 1] + 1][zuo][you][k - 1]; if (dp[shang][zuo][you][k] == n) continue; int l = zuo, r = you - 1, kotae = 0; while (l <= r) { int mid = (l + r) >> 1; int x = dp[shang][zuo][mid][k - 1], y = dp[shang][mid + 1][you][k - 1]; kotae = max(kotae, min(x, y)); if (x < y) r = mid - 1; else l = mid + 1; } dp[shang][zuo][you][k] = max(dp[shang][zuo][you][k], kotae); } write(k - 1); return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <vector> //#define int long long #define lowbit(x) ((x) & (-x)) using namespace std; const int maxn = 190; int n, m, sum[maxn][maxn], a[maxn][maxn], dp[maxn][maxn][maxn][15]; char ch[maxn][maxn]; 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 << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } return x * f; } inline void write(int a) { if (a < 0) { putchar('-'); putchar('1'); } else { if (a >= 10) write(a / 10); putchar(a % 10 + '0'); } } signed main() { cin >> n >> m; for (int i = 1; i <= n; ++i) scanf("%s", ch[i] + 1); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { if (ch[i][j] == '.') a[i][j] = 1; else a[i][j] = 0; sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j]; } for (int shang = 1; shang <= n; ++shang) for (int zuo = 1; zuo <= m; ++zuo) for (int you = zuo; you <= m; ++you) { int l = shang, r = n, xia = shang - 1; while (l <= r) { int mid = (l + r) >> 1; int geshu = sum[mid][you] - sum[mid][zuo - 1] - sum[shang - 1][you] + sum[shang - 1][zuo - 1]; if (!geshu || geshu == (mid - shang + 1) * (you - zuo + 1)) xia = mid, l = mid + 1; else r = mid - 1; } dp[shang][zuo][you][0] = xia; // cout<<shang<<' '<<zuo<<' '<<you<<' //'<<xia<<endl; } int k; for (k = 1; dp[1][1][m][k - 1] < n; ++k) for (int kuan = 1; kuan <= m; ++kuan) for (int shang = 1; shang <= n; ++shang) for (int zuo = 1, you = zuo + kuan - 1; you <= m; ++zuo, ++you) { if (dp[shang][zuo][you][k - 1] == n) { dp[shang][zuo][you][k] = n; continue; } dp[shang][zuo][you][k] = dp[dp[shang][zuo][you][k - 1] + 1][zuo][you][k - 1]; if (dp[shang][zuo][you][k] == n) continue; int l = zuo, r = you - 1, kotae = 0; while (l <= r) { int mid = (l + r) >> 1; int x = dp[shang][zuo][mid][k - 1], y = dp[shang][mid + 1][you][k - 1]; kotae = max(kotae, min(x, y)); if (x < y) r = mid - 1; else l = mid + 1; } dp[shang][zuo][you][k] = max(dp[shang][zuo][you][k], kotae); } write(k - 1); return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change" ]
875,487
875,486
u536150318
cpp
p03056
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef short Int; typedef pair<Int, Int> P; Int ldp[185][185][185][20]; Int udp[185][185][185][20]; int h, w; string field[185]; int cnt[185][185]; int cnt_white(Int x1, Int y1, Int x2, Int y2) { int ans = 0; if (x1 > 0 && y1 > 0) ans += cnt[x1 - 1][y1 - 1]; if (x1 > 0) ans -= cnt[x1 - 1][y2]; if (y1 > 0) ans -= cnt[x2][y1 - 1]; ans += cnt[x2][y2]; return ans; } int main() { cin >> h >> w; for (Int i = 0; i < h; i++) { cin >> field[i]; for (Int j = 0; j < w; j++) { if (field[i][j] == '#') cnt[i][j]++; } } for (Int i = 1; i < h; i++) for (Int j = 0; j < w; j++) cnt[i][j] += cnt[i - 1][j]; for (Int i = 0; i < h; i++) for (Int j = 1; j < w; j++) cnt[i][j] += cnt[i][j - 1]; for (Int c = 0; c < 20; c++) { for (Int i = 0; i < h; i++) { for (Int j = i; j < h; j++) { for (Int k = w - 1; k >= 0; k--) { // cout << (int)c<< " " << (int)i << " " << (int)j // << " " << (int)k << endl; if (c == 0) { Int &r = ldp[i][j][k][c]; if (cnt_white(i, k, j, k) == 0 || cnt_white(i, k, j, k) == j - i + 1) { if (k == w - 1 || ldp[i][j][k + 1][c] == -1 || field[i][k] != field[i][k + 1]) r = k + 1; else r = ldp[i][j][k + 1][c]; } else r = -1; } else { Int &r = ldp[i][j][k][c]; Int nxt = ldp[i][j][k][c - 1]; if (nxt == -1) r = -1; else if (nxt == w || ldp[i][j][nxt][c - 1] == -1) r = w; else r = ldp[i][j][nxt][c - 1]; } } } } for (Int i = 0; i < w; i++) { for (Int j = i; j < w; j++) { for (Int k = h - 1; k >= 0; k--) { if (c == 0) { Int &r = udp[i][j][k][c]; if (cnt_white(k, i, k, j) == 0 || cnt_white(k, i, k, j) == j - i + 1) { if (k == h - 1 || udp[i][j][k + 1][c] == -1 || field[k][i] != field[k + 1][j]) r = k + 1; else r = udp[i][j][k + 1][c]; } else r = -1; } else { Int &r = udp[i][j][k][c]; Int nxt = udp[i][j][k][c - 1]; if (nxt == -1) r = -1; else if (nxt == h || udp[i][j][nxt][c - 1] == -1) r = h; else r = udp[i][j][nxt][c - 1]; } } } } for (Int i = 0; i < h; i++) { for (Int j = 0; j < w; j++) { Int l = j; for (Int k = h - 1; k >= 0; k--) { if (ldp[i][k][j][c] == -1) continue; while (l < ldp[i][k][j][c]) { udp[j][l][i][c] = max(udp[j][l][i][c], (Int)(k + 1)); l++; } } Int k = i; for (Int l = w - 1; l >= 0; l--) { if (udp[j][l][i][c] == -1) continue; while (k < udp[j][l][i][c]) { ldp[i][k][j][c] = max(ldp[i][k][j][c], (Int)(l + 1)); k++; } } } } /* for(Int i = 0;i < h;i++){ for(Int j = i;j < h;j++){ for(Int k = 0;k < w;k++){ if(c < 3) cout << c << " " << i << " " << j << " " << k << " " << ldp[i][j][k][c] << endl; } } }*/ } int c = 0; while (c < 20 && ldp[0][h - 1][0][c] < w) c++; cout << c << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef short Int; typedef pair<Int, Int> P; Int ldp[185][185][185][20]; Int udp[185][185][185][20]; int h, w; string field[185]; int cnt[185][185]; int cnt_white(Int x1, Int y1, Int x2, Int y2) { int ans = 0; if (x1 > 0 && y1 > 0) ans += cnt[x1 - 1][y1 - 1]; if (x1 > 0) ans -= cnt[x1 - 1][y2]; if (y1 > 0) ans -= cnt[x2][y1 - 1]; ans += cnt[x2][y2]; return ans; } int main() { cin >> h >> w; for (Int i = 0; i < h; i++) { cin >> field[i]; for (Int j = 0; j < w; j++) { if (field[i][j] == '#') cnt[i][j]++; } } for (Int i = 1; i < h; i++) for (Int j = 0; j < w; j++) cnt[i][j] += cnt[i - 1][j]; for (Int i = 0; i < h; i++) for (Int j = 1; j < w; j++) cnt[i][j] += cnt[i][j - 1]; for (Int c = 0; c < 20; c++) { for (Int i = 0; i < h; i++) { for (Int j = i; j < h; j++) { for (Int k = w - 1; k >= 0; k--) { // cout << (int)c<< " " << (int)i << " " << (int)j // << " " << (int)k << endl; if (c == 0) { Int &r = ldp[i][j][k][c]; if (cnt_white(i, k, j, k) == 0 || cnt_white(i, k, j, k) == j - i + 1) { if (k == w - 1 || ldp[i][j][k + 1][c] == -1 || field[i][k] != field[i][k + 1]) r = k + 1; else r = ldp[i][j][k + 1][c]; } else r = -1; } else { Int &r = ldp[i][j][k][c]; Int nxt = ldp[i][j][k][c - 1]; if (nxt == -1) r = -1; else if (nxt == w || ldp[i][j][nxt][c - 1] == -1) r = nxt; else r = ldp[i][j][nxt][c - 1]; } } } } for (Int i = 0; i < w; i++) { for (Int j = i; j < w; j++) { for (Int k = h - 1; k >= 0; k--) { if (c == 0) { Int &r = udp[i][j][k][c]; if (cnt_white(k, i, k, j) == 0 || cnt_white(k, i, k, j) == j - i + 1) { if (k == h - 1 || udp[i][j][k + 1][c] == -1 || field[k][i] != field[k + 1][j]) r = k + 1; else r = udp[i][j][k + 1][c]; } else r = -1; } else { Int &r = udp[i][j][k][c]; Int nxt = udp[i][j][k][c - 1]; if (nxt == -1) r = -1; else if (nxt == h || udp[i][j][nxt][c - 1] == -1) r = nxt; else r = udp[i][j][nxt][c - 1]; } } } } for (Int i = 0; i < h; i++) { for (Int j = 0; j < w; j++) { Int l = j; for (Int k = h - 1; k >= 0; k--) { if (ldp[i][k][j][c] == -1) continue; while (l < ldp[i][k][j][c]) { udp[j][l][i][c] = max(udp[j][l][i][c], (Int)(k + 1)); l++; } } Int k = i; for (Int l = w - 1; l >= 0; l--) { if (udp[j][l][i][c] == -1) continue; while (k < udp[j][l][i][c]) { ldp[i][k][j][c] = max(ldp[i][k][j][c], (Int)(l + 1)); k++; } } } } /* for(Int i = 0;i < h;i++){ for(Int j = i;j < h;j++){ for(Int k = 0;k < w;k++){ if(c < 3) cout << c << " " << i << " " << j << " " << k << " " << ldp[i][j][k][c] << endl; } } }*/ } int c = 0; while (c < 20 && ldp[0][h - 1][0][c] < w) c++; cout << c << endl; return 0; }
[ "identifier.change" ]
875,490
875,491
u299869545
cpp
p03056
#include <bits/stdc++.h> #define fo(i, x, y) for (int i = x, B = y; i <= B; i++) #define ff(i, x, y) for (int i = x, B = y; i < B; i++) #define fd(i, x, y) for (int i = x, B = y; i >= B; i--) #define ll long long #define pp printf #define hh pp("\n") using namespace std; const int N = 225; int n, m; char s[N][N]; int f[N][N][N], g[N][N][N]; int main() { scanf("%d %d", &n, &m); fo(i, 1, n) scanf("%s", s[i] + 1); fd(k, m, 1) { fo(i, 1, n) { int ky = 1; fo(j, i, n) { if (j > i && s[j][k] != s[j - 1][k]) ky = 0; if (!ky) f[k][i][j] = 0; else { f[k][i][j] = k; if (k < m && s[i][k] == s[i][k + 1]) { f[k][i][j] = max(f[k][i][j], f[k + 1][i][j]); } } } } } fo(ans, 0, 16) { if (f[1][1][n] == m) { pp("%d\n", ans); return 0; } fo(k, 1, m) fo(i, 1, n) fo(j, i, n) g[k][i][j] = f[k][i][j]; fo(k, 1, m) fo(i, 1, n) { int l = i; fo(j, i, n) { if (g[k][i][j]) f[k][i][j] = max(f[k][i][j], g[g[k][i][j] + 1][i][j]); if (l + 1 < j - 1 && g[k][i][l + 1] >= g[k][l + 2][j]) l++; f[k][i][j] = max(f[k][i][j], min(g[k][i][l], g[k][l + 1][j])), f[k][i][j] = max(f[k][i][j], min(g[k][i][l + 1], g[k][l + 2][j])); } } } }
#include <bits/stdc++.h> #define fo(i, x, y) for (int i = x, B = y; i <= B; i++) #define ff(i, x, y) for (int i = x, B = y; i < B; i++) #define fd(i, x, y) for (int i = x, B = y; i >= B; i--) #define ll long long #define pp printf #define hh pp("\n") using namespace std; const int N = 225; int n, m; char s[N][N]; int f[N][N][N], g[N][N][N]; int main() { scanf("%d %d", &n, &m); fo(i, 1, n) scanf("%s", s[i] + 1); fd(k, m, 1) { fo(i, 1, n) { int ky = 1; fo(j, i, n) { if (j > i && s[j][k] != s[j - 1][k]) ky = 0; if (!ky) f[k][i][j] = 0; else { f[k][i][j] = k; if (k < m && s[i][k] == s[i][k + 1]) { f[k][i][j] = max(f[k][i][j], f[k + 1][i][j]); } } } } } fo(ans, 0, 16) { if (f[1][1][n] == m) { pp("%d\n", ans); return 0; } fo(k, 1, m) fo(i, 1, n) fo(j, i, n) g[k][i][j] = f[k][i][j]; fo(k, 1, m) fo(i, 1, n) { int l = i; fo(j, i, n) { if (g[k][i][j]) f[k][i][j] = max(f[k][i][j], g[g[k][i][j] + 1][i][j]); while (l + 1 < j - 1 && g[k][i][l + 1] >= g[k][l + 2][j]) l++; f[k][i][j] = max(f[k][i][j], min(g[k][i][l], g[k][l + 1][j])), f[k][i][j] = max(f[k][i][j], min(g[k][i][l + 1], g[k][l + 2][j])); } } } }
[ "control_flow.branch.while.replace.add", "control_flow.loop.if.replace.remove" ]
875,497
875,498
u173123334
cpp
p03056
#include <bits/stdc++.h> #define llong long long #define mkpr make_pair #define riterator reverse_iterator using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) { if (ch == '-') f = -1; } for (; isdigit(ch); ch = getchar()) { x = x * 10 + ch - 48; } return x * f; } const int N = 185; int fx[N + 3][N + 3], fy[N + 3][N + 3]; int gx[N + 3][N + 3][N + 3], gy[N + 3][N + 3][N + 3]; int hx[N + 3][N + 3][N + 3], hy[N + 3][N + 3][N + 3]; char a[N + 3][N + 3]; int n, m; void updmax(int &x, int y) { x = max(x, y); } void dp() { for (int lx = 1; lx <= n; lx++) for (int ly = 1; ly <= m; ly++) for (int rx = lx; rx <= n; rx++) { gx[lx][ly][rx] += gx[lx][ly + gx[lx][ly][rx]][rx]; if (gx[lx][ly][rx] > 0) { updmax(hy[lx][ly][ly + gx[lx][ly][rx] - 1], rx - lx + 1); } } for (int lx = 1; lx <= n; lx++) for (int ly = 1; ly <= m; ly++) for (int ry = ly; ry <= m; ry++) { gy[lx][ly][ry] += gy[lx + gy[lx][ly][ry]][ly][ry]; if (gy[lx][ly][ry] > 0) { updmax(hx[lx][ly][lx + gy[lx][ly][ry] - 1], ry - ly + 1); } } for (int lx = 1; lx <= n; lx++) for (int ly = 1; ly <= m; ly++) for (int rx = n; rx >= lx; rx--) { if (rx < n) updmax(hx[lx][ly][rx], hx[lx][ly][rx + 1]); updmax(gx[lx][ly][rx], hx[lx][ly][rx]); } for (int lx = 1; lx >= n; lx++) for (int ly = 1; ly <= m; ly++) for (int ry = m; ry >= ly; ry--) { if (ry < m) updmax(hy[lx][ly][ry], hy[lx][ly][ry + 1]); updmax(gy[lx][ly][ry], hy[lx][ly][ry]); } } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1); for (int i = 1; i <= n; i++) for (int j = m; j >= 1; j--) { fx[i][j] = a[i][j] == a[i][j + 1] ? fx[i][j + 1] + 1 : 1; } for (int j = 1; j <= m; j++) for (int i = n; i >= 1; i--) { fy[i][j] = a[i][j] == a[i + 1][j] ? fy[i + 1][j] + 1 : 1; } for (int lx = n; lx >= 1; lx--) for (int ly = 1; ly <= m; ly++) { int z = gx[lx][ly][lx] = fx[lx][ly]; if (a[lx][ly] == a[lx + 1][ly]) { for (int rx = lx + 1; rx <= n; rx++) { gx[lx][ly][rx] = min(z, gx[lx + 1][ly][rx]); } } } for (int ly = m; ly >= 1; ly--) for (int lx = 1; lx <= n; lx++) { int z = gy[lx][ly][ly] = fy[lx][ly]; if (a[lx][ly] == a[lx][ly + 1]) { for (int ry = ly + 1; ry <= m; ry++) { gy[lx][ly][ry] = min(z, gy[lx][ly + 1][ry]); } } } int ans = 0; while (gx[1][1][n] < m) { ans++; dp(); } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> #define llong long long #define mkpr make_pair #define riterator reverse_iterator using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) { if (ch == '-') f = -1; } for (; isdigit(ch); ch = getchar()) { x = x * 10 + ch - 48; } return x * f; } const int N = 185; int fx[N + 3][N + 3], fy[N + 3][N + 3]; int gx[N + 3][N + 3][N + 3], gy[N + 3][N + 3][N + 3]; int hx[N + 3][N + 3][N + 3], hy[N + 3][N + 3][N + 3]; char a[N + 3][N + 3]; int n, m; void updmax(int &x, int y) { x = max(x, y); } void dp() { for (int lx = 1; lx <= n; lx++) for (int ly = 1; ly <= m; ly++) for (int rx = lx; rx <= n; rx++) { gx[lx][ly][rx] += gx[lx][ly + gx[lx][ly][rx]][rx]; if (gx[lx][ly][rx] > 0) { updmax(hy[lx][ly][ly + gx[lx][ly][rx] - 1], rx - lx + 1); } } for (int lx = 1; lx <= n; lx++) for (int ly = 1; ly <= m; ly++) for (int ry = ly; ry <= m; ry++) { gy[lx][ly][ry] += gy[lx + gy[lx][ly][ry]][ly][ry]; if (gy[lx][ly][ry] > 0) { updmax(hx[lx][ly][lx + gy[lx][ly][ry] - 1], ry - ly + 1); } } for (int lx = 1; lx <= n; lx++) for (int ly = 1; ly <= m; ly++) for (int rx = n; rx >= lx; rx--) { if (rx < n) updmax(hx[lx][ly][rx], hx[lx][ly][rx + 1]); updmax(gx[lx][ly][rx], hx[lx][ly][rx]); } for (int lx = 1; lx <= n; lx++) for (int ly = 1; ly <= m; ly++) for (int ry = m; ry >= ly; ry--) { if (ry < m) updmax(hy[lx][ly][ry], hy[lx][ly][ry + 1]); updmax(gy[lx][ly][ry], hy[lx][ly][ry]); } } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1); for (int i = 1; i <= n; i++) for (int j = m; j >= 1; j--) { fx[i][j] = a[i][j] == a[i][j + 1] ? fx[i][j + 1] + 1 : 1; } for (int j = 1; j <= m; j++) for (int i = n; i >= 1; i--) { fy[i][j] = a[i][j] == a[i + 1][j] ? fy[i + 1][j] + 1 : 1; } for (int lx = n; lx >= 1; lx--) for (int ly = 1; ly <= m; ly++) { int z = gx[lx][ly][lx] = fx[lx][ly]; if (a[lx][ly] == a[lx + 1][ly]) { for (int rx = lx + 1; rx <= n; rx++) { gx[lx][ly][rx] = min(z, gx[lx + 1][ly][rx]); } } } for (int ly = m; ly >= 1; ly--) for (int lx = 1; lx <= n; lx++) { int z = gy[lx][ly][ly] = fy[lx][ly]; if (a[lx][ly] == a[lx][ly + 1]) { for (int ry = ly + 1; ry <= m; ry++) { gy[lx][ly][ry] = min(z, gy[lx][ly + 1][ry]); } } } int ans = 0; while (gx[1][1][n] < m) { ans++; dp(); } printf("%d\n", ans); return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
875,502
875,503
u396278429
cpp
p03056
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; #define MP make_pair #define PB push_back #define inf 1000000007 #define mod 1000000007 #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define all(x) (x).begin(), (x).end() template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int h, w; vector<string> s; unsigned char dp[186][186][186][36]; unsigned char dp2[186][186][186][36]; int sm[186][186]; bool calc(int a, int b, int c, int d) { int res = sm[c + 1][d + 1] - sm[a][d + 1] - sm[c + 1][b] + sm[a][b]; if (res != (c - a + 1) * (d - b + 1) && res != 0) return false; return true; } int main() { cin >> h >> w; s.resize(h); rep(i, h) cin >> s[i]; rep(i, h) { rep(j, w) { if (s[i][j] == '#') { sm[i + 1][j + 1]++; } } } rep(i, h) { rep(j, w) { if (j != 0) { sm[i + 1][j + 1] += sm[i + 1][j]; } } } rep(j, w) { rep(i, h) { if (i != 0) { sm[i + 1][j + 1] += sm[i][j + 1]; } } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { for (int k = j; k < w; k++) { int ok = i - 1; int ng = h; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (calc(i, j, mid, k)) { ok = mid; } else { ng = mid; } } if (ok == i - 1) { ok = -1; } ok++; dp[i + 1][j + 1][k + 1][0] = (unsigned char)ok; } } } for (int j = 0; j < w; j++) { for (int i = 0; i < h; i++) { for (int k = i; k < h; k++) { int ok = j - 1; int ng = w; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (calc(i, j, k, mid)) { ok = mid; } else { ng = mid; } } if (ok == j - 1) { ok = -1; } ok++; dp2[j + 1][i + 1][k + 1][0] = (unsigned char)ok; } } } for (int x = 0; x < 35; x++) { for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { for (unsigned char k = j; k <= w; k++) { chmax(dp[i][j][k][x + 1], dp[i][j][k][x]); if (dp[i][j][k][x] != 0) { unsigned char nx = dp[i][j][k][x]; chmax(dp[i][j][k][x + 1], nx); if (nx == h || nx == 0) continue; if (dp[nx + 1][j][k][x] != 0) { unsigned char dd = dp[nx + 1][j][k][x]; chmax(dp[i][j][k][x + 1], dd); for (int ss = i; ss <= dd; ss++) { chmax(dp2[j][i][ss][x + 1], k); } chmax(dp2[j][i][dd][x + 1], k); } } } } } for (int i = 1; i <= w; i++) { for (int j = 1; j <= h; j++) { for (unsigned char k = j; k <= h; k++) { chmax(dp2[i][j][k][x + 1], dp2[i][j][k][x]); if (dp2[i][j][k][x] != 0) { unsigned char nx = dp2[i][j][k][x]; chmax(dp2[i][j][k][x + 1], nx); if (nx == w || nx == 0) continue; if (dp2[nx + 1][j][k][x] != 0) { unsigned char dd = dp2[nx + 1][j][k][x]; chmax(dp2[i][j][k][x + 1], dd); for (int ss = i; ss <= dd; ss++) { chmax(dp2[j][i][ss][x + 1], k); } chmax(dp[j][i][dd][x + 1], k); } } } } } } // rep(i,h){ // rep(j,w){ // for(int k=j;k<w;k++){ // for(int x = 0;x<10;x++){ // cout << i+1 << " " << j+1 << " " << k+1 << " " << x << ":1 // " << (int)dp[i+1][j+1][k+1][x] << endl; cout << i+1 << " " // << j+1 << " " << k+1 << " " << x << ":2 " << // (int)dp2[i+1][j+1][k+1][x] << endl; // } // } // } // } for (int i = 0; i <= 35; i++) { if ((int)dp[1][1][w][i] == h) { cout << i << endl; return 0; } } assert(0); return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; #define MP make_pair #define PB push_back #define inf 1000000007 #define mod 1000000007 #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define all(x) (x).begin(), (x).end() template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int h, w; vector<string> s; unsigned char dp[186][186][186][36]; unsigned char dp2[186][186][186][36]; int sm[186][186]; bool calc(int a, int b, int c, int d) { int res = sm[c + 1][d + 1] - sm[a][d + 1] - sm[c + 1][b] + sm[a][b]; if (res != (c - a + 1) * (d - b + 1) && res != 0) return false; return true; } int main() { cin >> h >> w; s.resize(h); rep(i, h) cin >> s[i]; rep(i, h) { rep(j, w) { if (s[i][j] == '#') { sm[i + 1][j + 1]++; } } } rep(i, h) { rep(j, w) { if (j != 0) { sm[i + 1][j + 1] += sm[i + 1][j]; } } } rep(j, w) { rep(i, h) { if (i != 0) { sm[i + 1][j + 1] += sm[i][j + 1]; } } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { for (int k = j; k < w; k++) { int ok = i - 1; int ng = h; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (calc(i, j, mid, k)) { ok = mid; } else { ng = mid; } } if (ok == i - 1) { ok = -1; } ok++; dp[i + 1][j + 1][k + 1][0] = (unsigned char)ok; } } } for (int j = 0; j < w; j++) { for (int i = 0; i < h; i++) { for (int k = i; k < h; k++) { int ok = j - 1; int ng = w; while (ng - ok > 1) { int mid = (ok + ng) / 2; if (calc(i, j, k, mid)) { ok = mid; } else { ng = mid; } } if (ok == j - 1) { ok = -1; } ok++; dp2[j + 1][i + 1][k + 1][0] = (unsigned char)ok; } } } for (int x = 0; x < 35; x++) { for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { for (unsigned char k = j; k <= w; k++) { chmax(dp[i][j][k][x + 1], dp[i][j][k][x]); if (dp[i][j][k][x] != 0) { unsigned char nx = dp[i][j][k][x]; chmax(dp[i][j][k][x + 1], nx); if (nx == h || nx == 0) continue; if (dp[nx + 1][j][k][x] != 0) { unsigned char dd = dp[nx + 1][j][k][x]; chmax(dp[i][j][k][x + 1], dd); for (int ss = i; ss <= dd; ss++) { chmax(dp2[j][i][ss][x + 1], k); } chmax(dp2[j][i][dd][x + 1], k); } } } } } for (int i = 1; i <= w; i++) { for (int j = 1; j <= h; j++) { for (unsigned char k = j; k <= h; k++) { chmax(dp2[i][j][k][x + 1], dp2[i][j][k][x]); if (dp2[i][j][k][x] != 0) { unsigned char nx = dp2[i][j][k][x]; chmax(dp2[i][j][k][x + 1], nx); if (nx == w || nx == 0) continue; if (dp2[nx + 1][j][k][x] != 0) { unsigned char dd = dp2[nx + 1][j][k][x]; chmax(dp2[i][j][k][x + 1], dd); for (int ss = i; ss <= dd; ss++) { chmax(dp[j][i][ss][x + 1], k); } chmax(dp[j][i][dd][x + 1], k); } } } } } } // rep(i,h){ // rep(j,w){ // for(int k=j;k<w;k++){ // for(int x = 0;x<10;x++){ // cout << i+1 << " " << j+1 << " " << k+1 << " " << x << ":1 // " << (int)dp[i+1][j+1][k+1][x] << endl; cout << i+1 << " " // << j+1 << " " << k+1 << " " << x << ":2 " << // (int)dp2[i+1][j+1][k+1][x] << endl; // } // } // } // } for (int i = 0; i <= 35; i++) { if ((int)dp[1][1][w][i] == h) { cout << i << endl; return 0; } } assert(0); return 0; }
[ "identifier.change", "call.arguments.change" ]
875,506
875,507
u007610006
cpp
p03056
#include <bits/stdc++.h> #define rep(xx, yy) \ for (j = xx; j; j--) \ for (pos = yy - 1; ~pos; pos--) \ for (l = 1; (r = l + pos) <= yy; l++) const int N = 190; using namespace std; int n, m, f[N][N][N], g[N][N][N], // x l r,y l r i, j, l, r, pos; char mp[N][N], tr; bool fl; int main() { scanf("%d%d", &n, &m); for (i = 1, l, r; i <= n; i++) { scanf("%s", mp[i] + 1); for (l = 1; l <= m; l++) { fl = 1, tr = mp[i][l]; for (r = l; r <= m; r++) { fl &= mp[i][r] == tr; if (fl) f[i][l][r] = mp[i - 1][l] == tr ? f[i - 1][l][r] : i - 1; else f[i][l][r] = i; } } } for (i = 1; i <= m; i++) for (l = 1; l <= n; l++) { fl = 1, tr = mp[l][i]; for (r = l; r <= m; r++) { fl &= mp[r][i] == tr; if (fl) g[i][l][r] = mp[l][i - 1] == tr ? g[i - 1][l][r] : i - 1; else g[i][l][r] = i; } } for (i = 0; f[n][1][m]; i++) { /* cerr<<"F["<<i<<"]===========\n"; rep(n,m)cerr<<"("<<j<<','<<l<<','<<r<<")"<<f[j][l][r]<<endl; cerr<<"G["<<i<<"]===========\n"; rep(m,n)cerr<<"("<<j<<','<<l<<','<<r<<")"<<g[j][l][r]<<endl;*/ rep(n, m) f[j][l][r] = f[f[j][l][r]][l][r]; rep(m, n) g[j][l][r] = g[g[j][l][r]][l][r]; rep(n, m) g[r][f[j][l][r] + 1][j] = min(g[r][f[j][l][r] + 1][j], l - 1); /* cerr<<"J["<<i<<"]===========\n"; rep(m,n)cerr<<"("<<j<<','<<l<<','<<r<<")"<<g[j][l][r]<<endl;*/ rep(m, n) { if (l > 1) g[j][l][r] = min(g[j][l][r], g[j][l - 1][r]); if (r < n) g[j][l][r] = min(g[j][l][r], g[j][l][r + 1]); // if(r==3&&j==3) // cerr<<"g("<<j<<','<<l<<','<<r<<") upd // f("<<r<<','<<g[j][l][r]+1<<","<<j<<")\n"; f[r][g[j][l][r] + 1][j] = min(f[r][g[j][l][r] + 1][j], l - 1); } rep(n, m) { if (l > 1) f[j][l][r] = min(f[j][l][r], f[j][l - 1][r]); if (r < m) f[j][l][r] = min(f[j][l][r], f[j][l][r + 1]); } } printf("%d", i); }
#include <bits/stdc++.h> #define rep(xx, yy) \ for (j = xx; j; j--) \ for (pos = yy - 1; ~pos; pos--) \ for (l = 1; (r = l + pos) <= yy; l++) const int N = 190; using namespace std; int n, m, f[N][N][N], g[N][N][N], i, j, l, r, pos; char mp[N][N], tr; bool fl; int main() { scanf("%d%d", &n, &m); for (i = 1, l, r; i <= n; i++) { scanf("%s", mp[i] + 1); for (l = 1; l <= m; l++) { fl = 1, tr = mp[i][l]; for (r = l; r <= m; r++) { fl &= mp[i][r] == tr; if (fl) f[i][l][r] = mp[i - 1][l] == tr ? f[i - 1][l][r] : i - 1; else f[i][l][r] = i; } } } for (i = 1; i <= m; i++) for (l = 1; l <= n; l++) { fl = 1, tr = mp[l][i]; for (r = l; r <= n; r++) { fl &= mp[r][i] == tr; if (fl) g[i][l][r] = mp[l][i - 1] == tr ? g[i - 1][l][r] : i - 1; else g[i][l][r] = i; } } for (i = 0; f[n][1][m]; i++) { rep(n, m) f[j][l][r] = f[f[j][l][r]][l][r]; rep(m, n) g[j][l][r] = g[g[j][l][r]][l][r]; rep(n, m) g[r][f[j][l][r] + 1][j] = min(g[r][f[j][l][r] + 1][j], l - 1); rep(m, n) { if (l > 1) g[j][l][r] = min(g[j][l][r], g[j][l - 1][r]); if (r < n) g[j][l][r] = min(g[j][l][r], g[j][l][r + 1]); f[r][g[j][l][r] + 1][j] = min(f[r][g[j][l][r] + 1][j], l - 1); } rep(n, m) { if (l > 1) f[j][l][r] = min(f[j][l][r], f[j][l - 1][r]); if (r < m) f[j][l][r] = min(f[j][l][r], f[j][l][r + 1]); } } printf("%d", i); }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
875,508
875,509
u067825483
cpp
p03056
#include <bits/stdc++.h> #define ll long long using namespace std; int s[210][210], f1[210][210][210], f2[210][210][210], n, m; char a[210][210]; bool chk(int x1, int y1, int x2, int y2) { int tmp = s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]; return tmp == 0 || tmp == (x2 - x1 + 1) * (y2 - y1 + 1); } int main() { ios::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i] + 1; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (a[i][j] == '.'); for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) for (int k = m; k; k--) { if (k < m && chk(i, k, j, f1[i][j][k + 1])) f1[i][j][k] = f1[i][j][k + 1]; else if (chk(i, k, j, k)) f1[i][j][k] = k; } for (int i = 1; i <= m; i++) for (int j = i; j <= m; j++) for (int k = n; k; k--) if (k < n && chk(k, i, f2[i][j][k + 1], j)) f2[i][j][k] = f2[i][j][k + 1]; else if (chk(k, i, k, j)) f2[i][j][k] = k; if (f1[1][n][1] == m) { puts("0"); return 0; } int ans = 1; while (1) { for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) for (int k = 1; k <= m; k++) if (f1[i][j][f1[j][i][k] + 1]) f1[i][j][k] = f1[i][j][f1[i][j][k] + 1]; for (int i = 1; i <= m; i++) for (int j = i; j <= m; j++) for (int k = 1; k <= n; k++) if (f2[i][j][f2[i][j][k] + 1]) f2[i][j][k] = f2[i][j][f2[i][j][k] + 1]; for (int x = 1; x <= n; x++) for (int y = 1; y <= m; y++) { int now = m; for (int i = x; i <= n; i++) { while (now && f2[y][now][x] < i) now--; f1[x][i][y] = max(f1[x][i][y], now); } now = n; for (int i = y; i <= m; i++) { while (now && f1[x][now][y] < i) now--; f2[y][i][x] = max(f2[y][i][x], now); } } if (f1[1][n][1] == m) { cout << ans << '\n'; return 0; } ans++; } return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; int s[210][210], f1[210][210][210], f2[210][210][210], n, m; char a[210][210]; bool chk(int x1, int y1, int x2, int y2) { int tmp = s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]; return tmp == 0 || tmp == (x2 - x1 + 1) * (y2 - y1 + 1); } int main() { ios::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i] + 1; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (a[i][j] == '.'); for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) for (int k = m; k; k--) { if (k < m && chk(i, k, j, f1[i][j][k + 1])) f1[i][j][k] = f1[i][j][k + 1]; else if (chk(i, k, j, k)) f1[i][j][k] = k; } for (int i = 1; i <= m; i++) for (int j = i; j <= m; j++) for (int k = n; k; k--) if (k < n && chk(k, i, f2[i][j][k + 1], j)) f2[i][j][k] = f2[i][j][k + 1]; else if (chk(k, i, k, j)) f2[i][j][k] = k; if (f1[1][n][1] == m) { puts("0"); return 0; } int ans = 1; while (1) { for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) for (int k = 1; k <= m; k++) if (f1[i][j][f1[i][j][k] + 1] > 0) f1[i][j][k] = f1[i][j][f1[i][j][k] + 1]; for (int i = 1; i <= m; i++) for (int j = i; j <= m; j++) for (int k = 1; k <= n; k++) if (f2[i][j][f2[i][j][k] + 1]) f2[i][j][k] = f2[i][j][f2[i][j][k] + 1]; for (int x = 1; x <= n; x++) for (int y = 1; y <= m; y++) { int now = m; for (int i = x; i <= n; i++) { while (now && f2[y][now][x] < i) now--; f1[x][i][y] = max(f1[x][i][y], now); } now = n; for (int i = y; i <= m; i++) { while (now && f1[x][now][y] < i) now--; f2[y][i][x] = max(f2[y][i][x], now); } } if (f1[1][n][1] == m) { cout << ans << '\n'; return 0; } ans++; } return 0; }
[ "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "identifier.change", "control_flow.loop.for.condition.change" ]
875,514
875,515
u684730254
cpp
p03056
#include <bits/stdc++.h> using namespace std; int H, W, down[186][186], d[2][186][186][186], pos[186][186][186]; char A[186][186]; int main() { scanf("%d%d", &H, &W); for (int i = 1; i <= H; ++i) scanf("%s", A[i] + 1); for (int i = H; i; --i) for (int j = 1; j <= W; ++j) if (i < H && A[i + 1][j] == A[i][j]) down[i][j] = down[i + 1][j]; else down[i][j] = i; for (int i = 1; i <= H; ++i) for (int l = W; l; --l) { d[0][i][l][l] = down[i][l]; int p = l - 1; for (int r = l + 1; r <= W; ++r) { d[0][i][l][r] = A[i][r] != A[i][l] ? 0 : min(d[0][i][l][r - 1], down[i][r]); while (p + 1 < r && d[0][i][l][p + 1] > d[0][i][p + 2][r]) ++p; pos[i][l][r] = p; } } if (d[0][1][1][W] == H) return puts("0"), 0; for (int k = 1;; ++k) { memset(d[k & 1], 0, sizeof d[k & 1]); for (int i = 1; i <= H; ++i) for (int l = W; l; --l) for (int r = l, p = l - 1; r <= W; ++r) { d[k & 1][i][l][r] = max({d[k - 1 & 1][i][l][r], d[k - 1 & 1][d[k - 1 & 1][i][l][r] + 1][l][r], pos[i][l][r] >= l && pos[i][l][r] < r ? d[k - 1 & 1][i][pos[i][l][r] + 1][r] : 0, pos[i][l][r] + 1 >= l && pos[i][l][r] + 1 < r ? d[k - 1 & 1][i][l][pos[i][l][r] + 1] : 0}); while (p + 1 < r && d[k & 1][i][l][p + 1] > d[k & 1][i][p + 2][r]) ++p; pos[i][l][r] = p; } if (d[k & 1][1][1][W] == H) return printf("%d\n", k - 2), 0; } }
#include <bits/stdc++.h> using namespace std; int H, W, down[186][186], d[2][186][186][186], pos[186][186][186]; char A[186][186]; int main() { scanf("%d%d", &H, &W); for (int i = 1; i <= H; ++i) scanf("%s", A[i] + 1); for (int i = H; i; --i) for (int j = 1; j <= W; ++j) if (i < H && A[i + 1][j] == A[i][j]) down[i][j] = down[i + 1][j]; else down[i][j] = i; for (int i = 1; i <= H; ++i) for (int l = W; l; --l) { d[0][i][l][l] = down[i][l]; int p = l - 1; for (int r = l + 1; r <= W; ++r) { d[0][i][l][r] = A[i][r] != A[i][l] ? 0 : min(d[0][i][l][r - 1], down[i][r]); while (p + 1 < r && d[0][i][l][p + 1] > d[0][i][p + 2][r]) ++p; pos[i][l][r] = p; } } if (d[0][1][1][W] == H) return puts("0"), 0; for (int k = 1;; ++k) { memset(d[k & 1], 0, sizeof d[k & 1]); for (int i = 1; i <= H; ++i) for (int l = W; l; --l) for (int r = l, p = l - 1; r <= W; ++r) { d[k & 1][i][l][r] = max({d[k - 1 & 1][i][l][r], d[k - 1 & 1][d[k - 1 & 1][i][l][r] + 1][l][r], pos[i][l][r] >= l && pos[i][l][r] < r ? d[k - 1 & 1][i][pos[i][l][r] + 1][r] : 0, pos[i][l][r] + 1 >= l && pos[i][l][r] + 1 < r ? d[k - 1 & 1][i][l][pos[i][l][r] + 1] : 0}); while (p + 1 < r && d[k & 1][i][l][p + 1] > d[k & 1][i][p + 2][r]) ++p; pos[i][l][r] = p; } if (d[k & 1][1][1][W] == H) return printf("%d\n", k), 0; } }
[ "expression.operation.binary.remove" ]
875,532
875,533
u330144145
cpp
p03056
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef vector<int> vi; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define ALL(c) (c).begin(), (c).end() #define dump(x) cout << #x << " = " << (x) << endl constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T, class U> void chmin(T &t, const U &u) { if (t > u) t = u; } template <class T, class U> void chmax(T &t, const U &u) { if (t < u) t = u; } template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; rep(i, v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } const int MX = 190; const int B = 18; int r[MX][MX]; string s[MX]; int tor[B][MX][MX][MX], tou[B][MX][MX][MX]; int main() { int h, w; cin >> h >> w; rep(i, h) { cin >> s[i]; rep(j, w) { r[i + 1][j + 1] = r[i][j + 1] + r[i + 1][j] - r[i][j]; if (s[i][j] == '#') { ++r[i + 1][j + 1]; } } } memset(tor, -1, sizeof(tor)); memset(tou, -1, sizeof(tou)); auto get = [&](int a, int b, int c, int d) { int num = r[c + 1][d + 1] - r[a][d + 1] - r[c + 1][b] + r[a][b]; return num == 0 || num == (c - a + 1) * (d - b + 1); }; for (int i = 0; i < h; ++i) { for (int j = i; j < h; ++j) { int l = -1; for (int k = 0; k < w; ++k) { chmax(l, k - 1); while (l + 1 < w) { if (get(i, k, j, l + 1)) { ++l; } else { break; } } tor[0][i][j][k] = l; } } } for (int k = 0; k < w; ++k) { for (int l = k; l < w; ++l) { int j = -1; for (int i = 0; i < h; ++i) { chmax(j, i - 1); while (j + 1 < h) { if (get(i, k, j + 1, l)) { ++j; } else { break; } } tou[0][k][l][i] = j; } } } for (int t = 1; t < B; ++t) { if (tor[t - 1][0][h - 1][0] == w - 1) { cout << t - 1 << endl; return 0; } for (int i = 0; i < h; ++i) { for (int j = i; j < h; ++j) { int r = -1; for (int k = 0; k < w; ++k) { chmax(tor[t][i][j][k], tor[t - 1][i][j][k]); if (tor[t - 1][i][j][k] >= k) { chmax(tor[t][i][j][k], tor[t - 1][i][j][tor[t - 1][i][j][k] + 1]); } chmax(r, k - 1); while (r + 1 < w) { if (tou[t - 1][k][r + 1][i] >= j || (tou[t - 1][k][r + 1][i] >= i && tou[t - 1][k][r + 1][tou[t - 1][k][r + 1][i] + 1] >= j)) { ++r; } else { break; } } chmax(tor[t][i][j][k], r); } } } for (int k = 0; k < w; ++k) { for (int l = k; l < w; ++l) { int u = -1; for (int i = 0; i < h; ++i) { chmax(tou[t][k][l][i], tou[t - 1][k][l][i]); if (tou[t - 1][k][l][i] >= i) { chmax(tou[t][k][l][i], tou[t - 1][k][l][tou[t - 1][k][l][i] + 1]); } chmax(u, i - 1); while (u + 1 < h) { if (tor[t - 1][i][u + 1][k] >= l || (tor[t - 1][i][u + 1][k] >= k && tor[t - 1][i][u + 1][tor[t - 1][i][u + 1][k] + 1] >= l)) { ++u; } else { break; } } chmax(tou[t][k][l][i], u); } } } } return 0; }
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef vector<int> vi; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define ALL(c) (c).begin(), (c).end() #define dump(x) cout << #x << " = " << (x) << endl constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T, class U> void chmin(T &t, const U &u) { if (t > u) t = u; } template <class T, class U> void chmax(T &t, const U &u) { if (t < u) t = u; } template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; rep(i, v.size()) { if (i) os << ","; os << v[i]; } os << "}"; return os; } const int MX = 190; const int B = 18; int r[MX][MX]; string s[MX]; short tor[B][MX][MX][MX], tou[B][MX][MX][MX]; int main() { int h, w; cin >> h >> w; rep(i, h) { cin >> s[i]; rep(j, w) { r[i + 1][j + 1] = r[i][j + 1] + r[i + 1][j] - r[i][j]; if (s[i][j] == '#') { ++r[i + 1][j + 1]; } } } memset(tor, -1, sizeof(tor)); memset(tou, -1, sizeof(tou)); auto get = [&](int a, int b, int c, int d) { int num = r[c + 1][d + 1] - r[a][d + 1] - r[c + 1][b] + r[a][b]; return num == 0 || num == (c - a + 1) * (d - b + 1); }; for (int i = 0; i < h; ++i) { for (int j = i; j < h; ++j) { int l = -1; for (int k = 0; k < w; ++k) { chmax(l, k - 1); while (l + 1 < w) { if (get(i, k, j, l + 1)) { ++l; } else { break; } } tor[0][i][j][k] = l; } } } for (int k = 0; k < w; ++k) { for (int l = k; l < w; ++l) { int j = -1; for (int i = 0; i < h; ++i) { chmax(j, i - 1); while (j + 1 < h) { if (get(i, k, j + 1, l)) { ++j; } else { break; } } tou[0][k][l][i] = j; } } } for (int t = 1; t < B; ++t) { if (tor[t - 1][0][h - 1][0] == w - 1) { cout << t - 1 << endl; return 0; } for (int i = 0; i < h; ++i) { for (int j = i; j < h; ++j) { int r = -1; for (int k = 0; k < w; ++k) { chmax(tor[t][i][j][k], tor[t - 1][i][j][k]); if (tor[t - 1][i][j][k] >= k) { chmax(tor[t][i][j][k], tor[t - 1][i][j][tor[t - 1][i][j][k] + 1]); } chmax(r, k - 1); while (r + 1 < w) { if (tou[t - 1][k][r + 1][i] >= j || (tou[t - 1][k][r + 1][i] >= i && tou[t - 1][k][r + 1][tou[t - 1][k][r + 1][i] + 1] >= j)) { ++r; } else { break; } } chmax(tor[t][i][j][k], r); } } } for (int k = 0; k < w; ++k) { for (int l = k; l < w; ++l) { int u = -1; for (int i = 0; i < h; ++i) { chmax(tou[t][k][l][i], tou[t - 1][k][l][i]); if (tou[t - 1][k][l][i] >= i) { chmax(tou[t][k][l][i], tou[t - 1][k][l][tou[t - 1][k][l][i] + 1]); } chmax(u, i - 1); while (u + 1 < h) { if (tor[t - 1][i][u + 1][k] >= l || (tor[t - 1][i][u + 1][k] >= k && tor[t - 1][i][u + 1][tor[t - 1][i][u + 1][k] + 1] >= l)) { ++u; } else { break; } } chmax(tou[t][k][l][i], u); } } } } return 0; }
[ "variable_declaration.type.primitive.change" ]
875,537
875,538
u742529680
cpp
p03056
/* `-:://:::- `//:-------:/:` .+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .o:--...```..---+/` `/y+o/---....---:+o. `...````-os+/:---:/+o/--.` `-/+++++/:. `...` :h+d+oooo+/+-` ... `/++//:::://++-`....` -.`//````````:` `..` `o+/::------://o/` `-` -. -` `..` `---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..`` `....o+:-++/:--.```..-://s. `-` .- -` `-o: .-//::::/:-` `:s+/:--....-::/+s-` .- `- -` -///:--------:/:` ./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ `+:--........--:/` .:ooo+++++osso-` `.:-...`/` ./::-------:/:` -` :+--..``````.--:+:...-+:-` `.-/+++++/+-.-` -. ``:so:/:--.......--:+` `-```````o+/+--..`````..--:o/-..:s+:. ```````:``.. `-` -` `+:--..`````..--/+-.../.`````..-o:--.......---/o. ` `: `:- -. .o:--..`` ``..--:o` `-` `:o+:--------:+o-` `-`-... .. .o/--...```..--:+/` `-` `oy/so/////++o/.` -/` `-` `- ``+s/o/:---...---:++. `-` .-../d://///:-.` `.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-. ```` `:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `- -++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `- `` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.- -----ss+:++/:--.```..-://s. /. `:: `-:. ./` `````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-` `-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-` `:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-` `./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:. ``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `- `.:--h.``..``` -.-`.- .- `+:--..`````..--//` `- /s-//::::::::. -` `/- .. .o:--..`` ``..--:o.```.- `//:--------://` -` .-`.-` -.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+` ..`-. `-. ``:os:o/:---...---:++. `- ``///+:-..``````.--:+-````-.` `.:///////.-` .:-..` -``-+o+/:::::/+o/. `- `:+:-..`````..--:o/:--/ys+- `-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o. `.` `++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-` `````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.` -----syo/o+/:--.```..-://s. .-` `- .- `... ``-:////:-`` .` `/s//:--....-::/+s. -. `-` .- `..` .+o+/:::--:://+s/-..` .::+y ``` .- `..` ./oo++////+oso-` `.... :y-+:::::::/` ... `.:+oooooo/-` `....-. .//:-------:/:-.` ``...`` /+:+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .+/--...```..--:+/` `-o/:---...---:++. `-+o+/:---:/+o/. `.:+oooo+/-.` `````` */ #ifdef aimbot #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #endif #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <istream> #include <limits> #include <list> #include <map> #include <ostream> #include <queue> #include <random> #include <set> #include <string> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <vector> #define random escape__from__random__aetuhoetnuhshe #define mt make_tuple #define x first #define y second #define pb push_back #define ppb pop_back #define mp make_pair #define umap unordered_map #define uset unordered_set #define elif else if #define len(v) ((int)v.size()) #define f(i, n) for (int i = 0; i < (n); i++) #define rof(i, n) for (int i = ((n)-1); i >= 0; i--) #define apply(v, act) \ for (auto &x : v) { \ act; \ } #define log(args...) \ { \ string s = #args; \ deque<string> deq; \ string buf = ""; \ int bal = 0; \ for (char c : s) { \ if (c == '(' || c == '[' || c == '{') { \ bal++; \ } else if (c == ')' || c == ']' || c == '}') { \ bal--; \ } else { \ if (bal == 0) { \ if (c == ',') { \ deq.pb(buf); \ buf = ""; \ } else { \ if (c != ' ') { \ buf += c; \ } \ } \ } \ } \ } \ if (!buf.empty()) { \ deq.pb(buf); \ } \ smart_io::precall_print(); \ smart_io::_print(deq, args); \ } inline int min(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; } inline int max(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; } inline long long min(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x; } inline long long max(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y; } #define print \ smart_io::precall_print(); \ cout, #define scan cin, #ifdef fast_allocator const int MAXMEM = 200 * 1000 * 1024; char _memory[MAXMEM]; size_t _ptr = 0; void *operator new(size_t _x) { _ptr += _x; assert(_ptr < MAXMEM); return _memory + _ptr - _x; } void operator delete(void *) noexcept {} #endif using namespace std; char string_in_buffer[(int)260]; void fast_scan(int &x) { scanf("%d", &x); } void fast_scan(long long &x) { scanf("%lld", &x); } void fast_scan(unsigned long long &x) { scanf("%llu", &x); } void fast_scan(double &x) { scanf("%lf", &x); } void fast_scan(long double &x) { scanf("%Lf", &x); } void fast_scan(char &x) { scanf("%c", &x); if (x == '\n') { fast_scan(x); } } void fast_scan(string &x) { scanf("%s", string_in_buffer); x = string(string_in_buffer); } template <class TFirst, class TSecond> void fast_scan(pair<TFirst, TSecond> &p) { fast_scan(p.first); fast_scan(p.second); } template <class T> void fast_scan(vector<T> &v) { for (auto &x : v) fast_scan(x); } void fast_print(const int &x) { printf("%d", x); } void fast_print(const unsigned int &x) { printf("%u", x); } void fast_print(const long long &x) { printf("%lld", x); } void fast_print(const unsigned long long &x) { printf("%llu", x); } void fast_print(const double &x) { printf("%.15lf", x); } void fast_print(const long double &x) { printf("%.15Lf", x); } void fast_print(const char &x) { printf("%c", x); }; void fast_print(const string &x) { printf("%s", x.c_str()); } void fast_print(const char v[]) { fast_print((string)v); } template <class TFirst, class TSecond> void fast_print(const pair<TFirst, TSecond> &p) { fast_print(p.first); fast_print(' '); fast_print(p.second); } template <class T> void fast_print(const vector<T> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print(' '); fast_print(v[i]); } } template <class T> void fast_print(const vector<vector<T>> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print('\n'); fast_print(v[i]); } } template <class T> void fast_print(const T &v) { for (const auto &x : v) { fast_print(x); fast_print(' '); } } using namespace std; namespace smart_io { string print_start = ""; string sep = " "; bool first_print = false; void precall_print() { fast_print(print_start); print_start = "\n"; first_print = true; } void _print(deque<string>) {} template <class T, class... Args> void _print(deque<string> names, T elem, Args... args) { if (!first_print) { fast_print("\n"); } else { first_print = false; } fast_print(names.front()); fast_print(" = "); fast_print(elem); names.pop_front(); _print(names, args...); } } // namespace smart_io template <class T> ostream &operator,(ostream &os, const T &object) { if (!smart_io::first_print) { fast_print(smart_io::sep); } else { smart_io::first_print = false; } fast_print(object); return os; } template <class T> istream &operator,(istream &is, T &object) { fast_scan(object); return is; } namespace random { using namespace std::chrono; mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch()) .count()); uniform_real_distribution<> prob_dist(0.0, 1.0); }; // namespace random namespace typedefs { typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef long double ld; } // namespace typedefs namespace numbers_operation { template <class T> T floor_mod(T a, T b) { if (a >= 0 && b >= 0) return a % b; if (a <= 0 && b <= 0) return a % b; return abs(b) - (abs(a) % abs(b)); } } // namespace numbers_operation using namespace numbers_operation; using namespace typedefs; using namespace random; const int N = 186; string v[N]; int pr[N][N]; int __sm(int x, int y, int w, int h) { int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm; } bool zero(int x, int y, int w, int h) { if (w == 0 || h == 0) return true; x++, y++; int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm == 0 || sm == w * h; } int dpL[2][187][187][187]; int dpR[2][187][187][187]; signed main(signed argc, char *argv[]) { int n, m; scan n, m; f(i, n) { string s; scan s; f(j, m) { pr[i + 1][j + 1] = (s[j] == '.'); pr[i + 1][j + 1] += pr[i][j + 1]; pr[i + 1][j + 1] += pr[i + 1][j]; pr[i + 1][j + 1] -= pr[i][j]; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = m; for (int k = i; k < n; k++) { while (!zero(i, j, k - i + 1, cur - j)) cur--; dpL[0][i][j][k] = cur; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = n; for (int k = j; k < m; k++) { while (!zero(i, j, cur - i, k - j + 1)) cur--; dpR[0][i][j][k] = cur; } } for (int c = 1; c < 26; c++) { if (dpL[0][0][0][n - 1] == m || dpR[0][0][0][m - 1] == n) { print c - 1; return 0; } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int ver = m - 1; for (int k = i; k < n; k++) { int sub = dpL[0][i][j][k]; if (sub < m) sub = dpL[0][i][sub][k]; dpL[1][i][j][k] = sub; if (k > i) { while (ver >= i) { int up = dpR[0][i][j][ver]; if (up <= k) up = dpR[0][up][j][ver]; if (up > k) break; ver--; } dpL[1][i][j][k] = max(dpL[1][i][j][k], ver + 1); } } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int hor = n - 1; for (int k = j; k < m; k++) { int sub = dpR[0][i][j][k]; if (sub < n) sub = dpR[0][sub][j][k]; dpR[1][i][j][k] = sub; if (k > j) { while (hor >= j) { int right = dpL[0][i][j][hor]; if (right <= k) right = dpL[0][i][right][hor]; if (right > k) break; hor--; } dpR[1][i][j][k] = max(dpR[1][i][j][k], hor + 1); } } } swap(dpL[0], dpL[1]); swap(dpR[0], dpR[1]); } }
/* `-:://:::- `//:-------:/:` .+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .o:--...```..---+/` `/y+o/---....---:+o. `...````-os+/:---:/+o/--.` `-/+++++/:. `...` :h+d+oooo+/+-` ... `/++//:::://++-`....` -.`//````````:` `..` `o+/::------://o/` `-` -. -` `..` `---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..`` `....o+:-++/:--.```..-://s. `-` .- -` `-o: .-//::::/:-` `:s+/:--....-::/+s-` .- `- -` -///:--------:/:` ./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ `+:--........--:/` .:ooo+++++osso-` `.:-...`/` ./::-------:/:` -` :+--..``````.--:+:...-+:-` `.-/+++++/+-.-` -. ``:so:/:--.......--:+` `-```````o+/+--..`````..--:o/-..:s+:. ```````:``.. `-` -` `+:--..`````..--/+-.../.`````..-o:--.......---/o. ` `: `:- -. .o:--..`` ``..--:o` `-` `:o+:--------:+o-` `-`-... .. .o/--...```..--:+/` `-` `oy/so/////++o/.` -/` `-` `- ``+s/o/:---...---:++. `-` .-../d://///:-.` `.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-. ```` `:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `- -++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `- `` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.- -----ss+:++/:--.```..-://s. /. `:: `-:. ./` `````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-` `-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-` `:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-` `./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:. ``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `- `.:--h.``..``` -.-`.- .- `+:--..`````..--//` `- /s-//::::::::. -` `/- .. .o:--..`` ``..--:o.```.- `//:--------://` -` .-`.-` -.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+` ..`-. `-. ``:os:o/:---...---:++. `- ``///+:-..``````.--:+-````-.` `.:///////.-` .:-..` -``-+o+/:::::/+o/. `- `:+:-..`````..--:o/:--/ys+- `-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o. `.` `++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-` `````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.` -----syo/o+/:--.```..-://s. .-` `- .- `... ``-:////:-`` .` `/s//:--....-::/+s. -. `-` .- `..` .+o+/:::--:://+s/-..` .::+y ``` .- `..` ./oo++////+oso-` `.... :y-+:::::::/` ... `.:+oooooo/-` `....-. .//:-------:/:-.` ``...`` /+:+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .+/--...```..--:+/` `-o/:---...---:++. `-+o+/:---:/+o/. `.:+oooo+/-.` `````` */ #ifdef aimbot #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #endif #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <istream> #include <limits> #include <list> #include <map> #include <ostream> #include <queue> #include <random> #include <set> #include <string> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <vector> #define random escape__from__random__aetuhoetnuhshe #define mt make_tuple #define x first #define y second #define pb push_back #define ppb pop_back #define mp make_pair #define umap unordered_map #define uset unordered_set #define elif else if #define len(v) ((int)v.size()) #define f(i, n) for (int i = 0; i < (n); i++) #define rof(i, n) for (int i = ((n)-1); i >= 0; i--) #define apply(v, act) \ for (auto &x : v) { \ act; \ } #define log(args...) \ { \ string s = #args; \ deque<string> deq; \ string buf = ""; \ int bal = 0; \ for (char c : s) { \ if (c == '(' || c == '[' || c == '{') { \ bal++; \ } else if (c == ')' || c == ']' || c == '}') { \ bal--; \ } else { \ if (bal == 0) { \ if (c == ',') { \ deq.pb(buf); \ buf = ""; \ } else { \ if (c != ' ') { \ buf += c; \ } \ } \ } \ } \ } \ if (!buf.empty()) { \ deq.pb(buf); \ } \ smart_io::precall_print(); \ smart_io::_print(deq, args); \ } inline int min(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; } inline int max(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; } inline long long min(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x; } inline long long max(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y; } #define print \ smart_io::precall_print(); \ cout, #define scan cin, #ifdef fast_allocator const int MAXMEM = 200 * 1000 * 1024; char _memory[MAXMEM]; size_t _ptr = 0; void *operator new(size_t _x) { _ptr += _x; assert(_ptr < MAXMEM); return _memory + _ptr - _x; } void operator delete(void *) noexcept {} #endif using namespace std; char string_in_buffer[(int)260]; void fast_scan(int &x) { scanf("%d", &x); } void fast_scan(long long &x) { scanf("%lld", &x); } void fast_scan(unsigned long long &x) { scanf("%llu", &x); } void fast_scan(double &x) { scanf("%lf", &x); } void fast_scan(long double &x) { scanf("%Lf", &x); } void fast_scan(char &x) { scanf("%c", &x); if (x == '\n') { fast_scan(x); } } void fast_scan(string &x) { scanf("%s", string_in_buffer); x = string(string_in_buffer); } template <class TFirst, class TSecond> void fast_scan(pair<TFirst, TSecond> &p) { fast_scan(p.first); fast_scan(p.second); } template <class T> void fast_scan(vector<T> &v) { for (auto &x : v) fast_scan(x); } void fast_print(const int &x) { printf("%d", x); } void fast_print(const unsigned int &x) { printf("%u", x); } void fast_print(const long long &x) { printf("%lld", x); } void fast_print(const unsigned long long &x) { printf("%llu", x); } void fast_print(const double &x) { printf("%.15lf", x); } void fast_print(const long double &x) { printf("%.15Lf", x); } void fast_print(const char &x) { printf("%c", x); }; void fast_print(const string &x) { printf("%s", x.c_str()); } void fast_print(const char v[]) { fast_print((string)v); } template <class TFirst, class TSecond> void fast_print(const pair<TFirst, TSecond> &p) { fast_print(p.first); fast_print(' '); fast_print(p.second); } template <class T> void fast_print(const vector<T> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print(' '); fast_print(v[i]); } } template <class T> void fast_print(const vector<vector<T>> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print('\n'); fast_print(v[i]); } } template <class T> void fast_print(const T &v) { for (const auto &x : v) { fast_print(x); fast_print(' '); } } using namespace std; namespace smart_io { string print_start = ""; string sep = " "; bool first_print = false; void precall_print() { fast_print(print_start); print_start = "\n"; first_print = true; } void _print(deque<string>) {} template <class T, class... Args> void _print(deque<string> names, T elem, Args... args) { if (!first_print) { fast_print("\n"); } else { first_print = false; } fast_print(names.front()); fast_print(" = "); fast_print(elem); names.pop_front(); _print(names, args...); } } // namespace smart_io template <class T> ostream &operator,(ostream &os, const T &object) { if (!smart_io::first_print) { fast_print(smart_io::sep); } else { smart_io::first_print = false; } fast_print(object); return os; } template <class T> istream &operator,(istream &is, T &object) { fast_scan(object); return is; } namespace random { using namespace std::chrono; mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch()) .count()); uniform_real_distribution<> prob_dist(0.0, 1.0); }; // namespace random namespace typedefs { typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef long double ld; } // namespace typedefs namespace numbers_operation { template <class T> T floor_mod(T a, T b) { if (a >= 0 && b >= 0) return a % b; if (a <= 0 && b <= 0) return a % b; return abs(b) - (abs(a) % abs(b)); } } // namespace numbers_operation using namespace numbers_operation; using namespace typedefs; using namespace random; const int N = 186; string v[N]; int pr[N][N]; int __sm(int x, int y, int w, int h) { int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm; } bool zero(int x, int y, int w, int h) { if (w == 0 || h == 0) return true; x++, y++; int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm == 0 || sm == w * h; } int dpL[2][187][187][187]; int dpR[2][187][187][187]; signed main(signed argc, char *argv[]) { int n, m; scan n, m; f(i, n) { string s; scan s; f(j, m) { pr[i + 1][j + 1] = (s[j] == '.'); pr[i + 1][j + 1] += pr[i][j + 1]; pr[i + 1][j + 1] += pr[i + 1][j]; pr[i + 1][j + 1] -= pr[i][j]; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = m; for (int k = i; k < n; k++) { while (!zero(i, j, k - i + 1, cur - j)) cur--; dpL[0][i][j][k] = cur; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = n; for (int k = j; k < m; k++) { while (!zero(i, j, cur - i, k - j + 1)) cur--; dpR[0][i][j][k] = cur; } } for (int c = 1; c < 26; c++) { if (dpL[0][0][0][n - 1] == m || dpR[0][0][0][m - 1] == n) { print c - 1; return 0; } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int ver = m - 1; for (int k = i; k < n; k++) { int sub = dpL[0][i][j][k]; if (sub < m) sub = dpL[0][i][sub][k]; dpL[1][i][j][k] = sub; if (k > i) { while (ver >= j) { int up = dpR[0][i][j][ver]; if (up <= k) up = dpR[0][up][j][ver]; if (up > k) break; ver--; } dpL[1][i][j][k] = max(dpL[1][i][j][k], ver + 1); } } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int hor = n - 1; for (int k = j; k < m; k++) { int sub = dpR[0][i][j][k]; if (sub < n) sub = dpR[0][sub][j][k]; dpR[1][i][j][k] = sub; if (k > j) { while (hor >= i) { int right = dpL[0][i][j][hor]; if (right <= k) right = dpL[0][i][right][hor]; if (right > k) break; hor--; } dpR[1][i][j][k] = max(dpR[1][i][j][k], hor + 1); } } } swap(dpL[0], dpL[1]); swap(dpR[0], dpR[1]); } }
[ "identifier.change", "control_flow.loop.condition.change" ]
875,539
875,540
u656721037
cpp
p03056
/* `-:://:::- `//:-------:/:` .+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .o:--...```..---+/` `/y+o/---....---:+o. `...````-os+/:---:/+o/--.` `-/+++++/:. `...` :h+d+oooo+/+-` ... `/++//:::://++-`....` -.`//````````:` `..` `o+/::------://o/` `-` -. -` `..` `---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..`` `....o+:-++/:--.```..-://s. `-` .- -` `-o: .-//::::/:-` `:s+/:--....-::/+s-` .- `- -` -///:--------:/:` ./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ `+:--........--:/` .:ooo+++++osso-` `.:-...`/` ./::-------:/:` -` :+--..``````.--:+:...-+:-` `.-/+++++/+-.-` -. ``:so:/:--.......--:+` `-```````o+/+--..`````..--:o/-..:s+:. ```````:``.. `-` -` `+:--..`````..--/+-.../.`````..-o:--.......---/o. ` `: `:- -. .o:--..`` ``..--:o` `-` `:o+:--------:+o-` `-`-... .. .o/--...```..--:+/` `-` `oy/so/////++o/.` -/` `-` `- ``+s/o/:---...---:++. `-` .-../d://///:-.` `.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-. ```` `:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `- -++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `- `` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.- -----ss+:++/:--.```..-://s. /. `:: `-:. ./` `````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-` `-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-` `:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-` `./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:. ``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `- `.:--h.``..``` -.-`.- .- `+:--..`````..--//` `- /s-//::::::::. -` `/- .. .o:--..`` ``..--:o.```.- `//:--------://` -` .-`.-` -.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+` ..`-. `-. ``:os:o/:---...---:++. `- ``///+:-..``````.--:+-````-.` `.:///////.-` .:-..` -``-+o+/:::::/+o/. `- `:+:-..`````..--:o/:--/ys+- `-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o. `.` `++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-` `````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.` -----syo/o+/:--.```..-://s. .-` `- .- `... ``-:////:-`` .` `/s//:--....-::/+s. -. `-` .- `..` .+o+/:::--:://+s/-..` .::+y ``` .- `..` ./oo++////+oso-` `.... :y-+:::::::/` ... `.:+oooooo/-` `....-. .//:-------:/:-.` ``...`` /+:+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .+/--...```..--:+/` `-o/:---...---:++. `-+o+/:---:/+o/. `.:+oooo+/-.` `````` */ #ifdef aimbot #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #endif #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <istream> #include <limits> #include <list> #include <map> #include <ostream> #include <queue> #include <random> #include <set> #include <string> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <vector> #define random escape__from__random__aetuhoetnuhshe #define mt make_tuple #define x first #define y second #define pb push_back #define ppb pop_back #define mp make_pair #define umap unordered_map #define uset unordered_set #define elif else if #define len(v) ((int)v.size()) #define f(i, n) for (int i = 0; i < (n); i++) #define rof(i, n) for (int i = ((n)-1); i >= 0; i--) #define apply(v, act) \ for (auto &x : v) { \ act; \ } #define log(args...) \ { \ string s = #args; \ deque<string> deq; \ string buf = ""; \ int bal = 0; \ for (char c : s) { \ if (c == '(' || c == '[' || c == '{') { \ bal++; \ } else if (c == ')' || c == ']' || c == '}') { \ bal--; \ } else { \ if (bal == 0) { \ if (c == ',') { \ deq.pb(buf); \ buf = ""; \ } else { \ if (c != ' ') { \ buf += c; \ } \ } \ } \ } \ } \ if (!buf.empty()) { \ deq.pb(buf); \ } \ smart_io::precall_print(); \ smart_io::_print(deq, args); \ } inline int min(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; } inline int max(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; } inline long long min(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x; } inline long long max(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y; } #define print \ smart_io::precall_print(); \ cout, #define scan cin, #ifdef fast_allocator const int MAXMEM = 200 * 1000 * 1024; char _memory[MAXMEM]; size_t _ptr = 0; void *operator new(size_t _x) { _ptr += _x; assert(_ptr < MAXMEM); return _memory + _ptr - _x; } void operator delete(void *) noexcept {} #endif using namespace std; char string_in_buffer[(int)260]; void fast_scan(int &x) { scanf("%d", &x); } void fast_scan(long long &x) { scanf("%lld", &x); } void fast_scan(unsigned long long &x) { scanf("%llu", &x); } void fast_scan(double &x) { scanf("%lf", &x); } void fast_scan(long double &x) { scanf("%Lf", &x); } void fast_scan(char &x) { scanf("%c", &x); if (x == '\n') { fast_scan(x); } } void fast_scan(string &x) { scanf("%s", string_in_buffer); x = string(string_in_buffer); } template <class TFirst, class TSecond> void fast_scan(pair<TFirst, TSecond> &p) { fast_scan(p.first); fast_scan(p.second); } template <class T> void fast_scan(vector<T> &v) { for (auto &x : v) fast_scan(x); } void fast_print(const int &x) { printf("%d", x); } void fast_print(const unsigned int &x) { printf("%u", x); } void fast_print(const long long &x) { printf("%lld", x); } void fast_print(const unsigned long long &x) { printf("%llu", x); } void fast_print(const double &x) { printf("%.15lf", x); } void fast_print(const long double &x) { printf("%.15Lf", x); } void fast_print(const char &x) { printf("%c", x); }; void fast_print(const string &x) { printf("%s", x.c_str()); } void fast_print(const char v[]) { fast_print((string)v); } template <class TFirst, class TSecond> void fast_print(const pair<TFirst, TSecond> &p) { fast_print(p.first); fast_print(' '); fast_print(p.second); } template <class T> void fast_print(const vector<T> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print(' '); fast_print(v[i]); } } template <class T> void fast_print(const vector<vector<T>> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print('\n'); fast_print(v[i]); } } template <class T> void fast_print(const T &v) { for (const auto &x : v) { fast_print(x); fast_print(' '); } } using namespace std; namespace smart_io { string print_start = ""; string sep = " "; bool first_print = false; void precall_print() { fast_print(print_start); print_start = "\n"; first_print = true; } void _print(deque<string>) {} template <class T, class... Args> void _print(deque<string> names, T elem, Args... args) { if (!first_print) { fast_print("\n"); } else { first_print = false; } fast_print(names.front()); fast_print(" = "); fast_print(elem); names.pop_front(); _print(names, args...); } } // namespace smart_io template <class T> ostream &operator,(ostream &os, const T &object) { if (!smart_io::first_print) { fast_print(smart_io::sep); } else { smart_io::first_print = false; } fast_print(object); return os; } template <class T> istream &operator,(istream &is, T &object) { fast_scan(object); return is; } namespace random { using namespace std::chrono; mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch()) .count()); uniform_real_distribution<> prob_dist(0.0, 1.0); }; // namespace random namespace typedefs { typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef long double ld; } // namespace typedefs namespace numbers_operation { template <class T> T floor_mod(T a, T b) { if (a >= 0 && b >= 0) return a % b; if (a <= 0 && b <= 0) return a % b; return abs(b) - (abs(a) % abs(b)); } } // namespace numbers_operation using namespace numbers_operation; using namespace typedefs; using namespace random; const int N = 186; string v[N]; int pr[N][N]; int __sm(int x, int y, int w, int h) { int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm; } bool zero(int x, int y, int w, int h) { if (w == 0 || h == 0) return true; x++, y++; int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm == 0 || sm == w * h; } int dpL[2][187][187][187]; int dpR[2][187][187][187]; signed main(signed argc, char *argv[]) { int n, m; scan n, m; f(i, n) { string s; scan s; f(j, m) { pr[i + 1][j + 1] = (s[j] == '.'); pr[i + 1][j + 1] += pr[i][j + 1]; pr[i + 1][j + 1] += pr[i + 1][j]; pr[i + 1][j + 1] -= pr[i][j]; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = m; for (int k = i; k < n; k++) { while (!zero(i, j, k - i + 1, cur - i)) cur--; dpL[0][i][j][k] = cur; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = n; for (int k = j; k < m; k++) { while (!zero(i, j, cur - i, k - j + 1)) { cur--; } dpR[0][i][j][k] = cur; } } for (int c = 1; c < 26; c++) { if (dpL[0][0][0][n - 1] == m || dpR[0][0][0][m - 1] == n) { print c - 1; return 0; } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int ver = m - 1; for (int k = i; k < n; k++) { int sub = dpL[0][i][j][k]; if (sub < m) sub = dpL[0][i][sub][k]; dpL[1][i][j][k] = sub; if (k > i) { while (ver >= i) { int up = dpR[0][i][j][ver]; if (up <= k) up = dpR[0][up][j][ver]; if (up > k) break; ver--; } dpL[1][i][j][k] = max(dpL[1][i][j][k], ver + 1); } } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int hor = n - 1; for (int k = j; k < m; k++) { int sub = dpR[0][i][j][k]; if (sub < n) sub = dpR[0][sub][j][k]; dpR[1][i][j][k] = sub; if (k > j) { while (hor >= j) { int right = dpL[0][i][j][hor]; if (right <= k) right = dpL[0][i][right][hor]; if (right > k) break; hor--; } dpR[1][i][j][k] = max(dpR[1][i][j][k], hor + 1); } } } swap(dpL[0], dpL[1]); swap(dpR[0], dpR[1]); } }
/* `-:://:::- `//:-------:/:` .+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .o:--...```..---+/` `/y+o/---....---:+o. `...````-os+/:---:/+o/--.` `-/+++++/:. `...` :h+d+oooo+/+-` ... `/++//:::://++-`....` -.`//````````:` `..` `o+/::------://o/` `-` -. -` `..` `---.-o/:./o/::-..``..-ЗАПУСКАЕМ .. .. -` `... ``..`` `....o+:-++/:--.```..-://s. `-` .- -` `-o: .-//::::/:-` `:s+/:--....-::/+s-` .- `- -` -///:--------:/:` ./s+//:::::://oo-``..НЕЙРОННУЮ: СЕТЬ:::::::-`РАБОТЯГИ `+:--........--:/` .:ooo+++++osso-` `.:-...`/` ./::-------:/:` -` :+--..``````.--:+:...-+:-` `.-/+++++/+-.-` -. ``:so:/:--.......--:+` `-```````o+/+--..`````..--:o/-..:s+:. ```````:``.. `-` -` `+:--..`````..--/+-.../.`````..-o:--.......---/o. ` `: `:- -. .o:--..`` ``..--:o` `-` `:o+:--------:+o-` `-`-... .. .o/--...```..--:+/` `-` `oy/so/////++o/.` -/` `-` `- ``+s/o/:---...---:++. `-` .-../d://///:-.` `.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-. ```` `:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `- -++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `- `` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.- -----ss+:++/:--.```..-://s. /. `:: `-:. ./` `````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-` `-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-` `:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-` `./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:. ``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `- `.:--h.``..``` -.-`.- .- `+:--..`````..--//` `- /s-//::::::::. -` `/- .. .o:--..`` ``..--:o.```.- `//:--------://` -` .-`.-` -.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+` ..`-. `-. ``:os:o/:---...---:++. `- ``///+:-..``````.--:+-````-.` `.:///////.-` .:-..` -``-+o+/:::::/+o/. `- `:+:-..`````..--:o/:--/ys+- `-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o. `.` `++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-` `````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.` -----syo/o+/:--.```..-://s. .-` `- .- `... ``-:////:-`` .` `/s//:--....-::/+s. -. `-` .- `..` .+o+/:::--:://+s/-..` .::+y ``` .- `..` ./oo++////+oso-` `.... :y-+:::::::/` ... `.:+oooooo/-` `....-. .//:-------:/:-.` ``...`` /+:+:--.......--:+` `+:--..`````..--//` .o:--..`` ``..--:o` .+/--...```..--:+/` `-o/:---...---:++. `-+o+/:---:/+o/. `.:+oooo+/-.` `````` */ #ifdef aimbot #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #endif #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <istream> #include <limits> #include <list> #include <map> #include <ostream> #include <queue> #include <random> #include <set> #include <string> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <vector> #define random escape__from__random__aetuhoetnuhshe #define mt make_tuple #define x first #define y second #define pb push_back #define ppb pop_back #define mp make_pair #define umap unordered_map #define uset unordered_set #define elif else if #define len(v) ((int)v.size()) #define f(i, n) for (int i = 0; i < (n); i++) #define rof(i, n) for (int i = ((n)-1); i >= 0; i--) #define apply(v, act) \ for (auto &x : v) { \ act; \ } #define log(args...) \ { \ string s = #args; \ deque<string> deq; \ string buf = ""; \ int bal = 0; \ for (char c : s) { \ if (c == '(' || c == '[' || c == '{') { \ bal++; \ } else if (c == ')' || c == ']' || c == '}') { \ bal--; \ } else { \ if (bal == 0) { \ if (c == ',') { \ deq.pb(buf); \ buf = ""; \ } else { \ if (c != ' ') { \ buf += c; \ } \ } \ } \ } \ } \ if (!buf.empty()) { \ deq.pb(buf); \ } \ smart_io::precall_print(); \ smart_io::_print(deq, args); \ } inline int min(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; } inline int max(const int &x, const int &y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; } inline long long min(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ x; } inline long long max(const long long &x, const long long &y) { return (((y - x) >> (64 - 1)) & (x ^ y)) ^ y; } #define print \ smart_io::precall_print(); \ cout, #define scan cin, #ifdef fast_allocator const int MAXMEM = 200 * 1000 * 1024; char _memory[MAXMEM]; size_t _ptr = 0; void *operator new(size_t _x) { _ptr += _x; assert(_ptr < MAXMEM); return _memory + _ptr - _x; } void operator delete(void *) noexcept {} #endif using namespace std; char string_in_buffer[(int)260]; void fast_scan(int &x) { scanf("%d", &x); } void fast_scan(long long &x) { scanf("%lld", &x); } void fast_scan(unsigned long long &x) { scanf("%llu", &x); } void fast_scan(double &x) { scanf("%lf", &x); } void fast_scan(long double &x) { scanf("%Lf", &x); } void fast_scan(char &x) { scanf("%c", &x); if (x == '\n') { fast_scan(x); } } void fast_scan(string &x) { scanf("%s", string_in_buffer); x = string(string_in_buffer); } template <class TFirst, class TSecond> void fast_scan(pair<TFirst, TSecond> &p) { fast_scan(p.first); fast_scan(p.second); } template <class T> void fast_scan(vector<T> &v) { for (auto &x : v) fast_scan(x); } void fast_print(const int &x) { printf("%d", x); } void fast_print(const unsigned int &x) { printf("%u", x); } void fast_print(const long long &x) { printf("%lld", x); } void fast_print(const unsigned long long &x) { printf("%llu", x); } void fast_print(const double &x) { printf("%.15lf", x); } void fast_print(const long double &x) { printf("%.15Lf", x); } void fast_print(const char &x) { printf("%c", x); }; void fast_print(const string &x) { printf("%s", x.c_str()); } void fast_print(const char v[]) { fast_print((string)v); } template <class TFirst, class TSecond> void fast_print(const pair<TFirst, TSecond> &p) { fast_print(p.first); fast_print(' '); fast_print(p.second); } template <class T> void fast_print(const vector<T> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print(' '); fast_print(v[i]); } } template <class T> void fast_print(const vector<vector<T>> &v) { if (v.empty()) return; fast_print(v[0]); for (int i = 1; i < v.size(); i++) { fast_print('\n'); fast_print(v[i]); } } template <class T> void fast_print(const T &v) { for (const auto &x : v) { fast_print(x); fast_print(' '); } } using namespace std; namespace smart_io { string print_start = ""; string sep = " "; bool first_print = false; void precall_print() { fast_print(print_start); print_start = "\n"; first_print = true; } void _print(deque<string>) {} template <class T, class... Args> void _print(deque<string> names, T elem, Args... args) { if (!first_print) { fast_print("\n"); } else { first_print = false; } fast_print(names.front()); fast_print(" = "); fast_print(elem); names.pop_front(); _print(names, args...); } } // namespace smart_io template <class T> ostream &operator,(ostream &os, const T &object) { if (!smart_io::first_print) { fast_print(smart_io::sep); } else { smart_io::first_print = false; } fast_print(object); return os; } template <class T> istream &operator,(istream &is, T &object) { fast_scan(object); return is; } namespace random { using namespace std::chrono; mt19937 rng(duration_cast<milliseconds>(system_clock::now().time_since_epoch()) .count()); uniform_real_distribution<> prob_dist(0.0, 1.0); }; // namespace random namespace typedefs { typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef long double ld; } // namespace typedefs namespace numbers_operation { template <class T> T floor_mod(T a, T b) { if (a >= 0 && b >= 0) return a % b; if (a <= 0 && b <= 0) return a % b; return abs(b) - (abs(a) % abs(b)); } } // namespace numbers_operation using namespace numbers_operation; using namespace typedefs; using namespace random; const int N = 186; string v[N]; int pr[N][N]; int __sm(int x, int y, int w, int h) { int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm; } bool zero(int x, int y, int w, int h) { if (w == 0 || h == 0) return true; x++, y++; int sm = pr[x + w - 1][y + h - 1] - pr[x - 1][y + h - 1] - pr[x + w - 1][y - 1] + pr[x - 1][y - 1]; return sm == 0 || sm == w * h; } int dpL[2][187][187][187]; int dpR[2][187][187][187]; signed main(signed argc, char *argv[]) { int n, m; scan n, m; f(i, n) { string s; scan s; f(j, m) { pr[i + 1][j + 1] = (s[j] == '.'); pr[i + 1][j + 1] += pr[i][j + 1]; pr[i + 1][j + 1] += pr[i + 1][j]; pr[i + 1][j + 1] -= pr[i][j]; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = m; for (int k = i; k < n; k++) { while (!zero(i, j, k - i + 1, cur - j)) cur--; dpL[0][i][j][k] = cur; } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int cur = n; for (int k = j; k < m; k++) { while (!zero(i, j, cur - i, k - j + 1)) cur--; dpR[0][i][j][k] = cur; } } for (int c = 1; c < 26; c++) { if (dpL[0][0][0][n - 1] == m || dpR[0][0][0][m - 1] == n) { print c - 1; return 0; } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int ver = m - 1; for (int k = i; k < n; k++) { int sub = dpL[0][i][j][k]; if (sub < m) sub = dpL[0][i][sub][k]; dpL[1][i][j][k] = sub; if (k > i) { while (ver >= j) { int up = dpR[0][i][j][ver]; if (up <= k) up = dpR[0][up][j][ver]; if (up > k) break; ver--; } dpL[1][i][j][k] = max(dpL[1][i][j][k], ver + 1); } } } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { int hor = n - 1; for (int k = j; k < m; k++) { int sub = dpR[0][i][j][k]; if (sub < n) sub = dpR[0][sub][j][k]; dpR[1][i][j][k] = sub; if (k > j) { while (hor >= i) { int right = dpL[0][i][j][hor]; if (right <= k) right = dpL[0][i][right][hor]; if (right > k) break; hor--; } dpR[1][i][j][k] = max(dpR[1][i][j][k], hor + 1); } } } swap(dpL[0], dpL[1]); swap(dpR[0], dpR[1]); } }
[ "identifier.change", "control_flow.loop.condition.change" ]
875,541
875,540
u656721037
cpp
p03056
#include <bits/stdc++.h> using namespace std; void chmax(int &a, int b) { a = max(a, b); } int main() { int H, W; cin >> H >> W; string S[185]; for (int i = 0; i < H; i++) cin >> S[i]; int sum[186][186] = {0}; for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) sum[i][j] = (S[i - 1][j - 1] == '#'); for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) sum[i][j] += sum[i - 1][j]; for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) sum[i][j] += sum[i][j - 1]; static int dpX[2][187][187][187], dpY[2][187][187][187]; for (int x1 = 1; x1 <= H; x1++) for (int x2 = x1; x2 <= H; x2++) for (int y1 = 1; y1 <= W; y1++) { int ok = y1 - 1, ng = W + 1; while (ng - ok > 1) { int y2 = (ok + ng) / 2; int a = (x2 - x1 + 1) * (y2 - y1 + 1); int s = sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1]; ((s == 0 || s == a) ? ok : ng) = y2; } int y2 = ok; chmax(dpX[0][x1][x2][y1], y2); chmax(dpY[0][y1][y2][x1], x2); } for (int t = 0;; t++) { int p = t % 2, np = (t + 1) % 2; for (int d = H - 1; d >= 1; d--) for (int x1 = 1; x1 + d - 1 <= H; x1++) { int x2 = x1 + d - 1; for (int y1 = 1; y1 <= W; y1++) { chmax(dpX[p][x1][x2][y1], dpX[p][x1 - 1][x2][y1]); chmax(dpX[p][x1][x2][y1], dpX[p][x1][x2 + 1][y1]); chmax(dpX[p][x1][x2][y1], dpX[p][x1][x2][y1 - 1]); } } for (int d = W - 1; d >= 1; d--) for (int y1 = 1; y1 + d - 1 <= W; y1++) { int y2 = y1 + d - 1; for (int x1 = 1; x1 <= H; x1++) { chmax(dpY[p][y1][y2][x1], dpX[p][y1 - 1][y2][x1]); chmax(dpY[p][y1][y2][x1], dpX[p][y1][y2 + 1][x1]); chmax(dpY[p][y1][y2][x1], dpX[p][y1][y2][x1 - 1]); } } if (dpX[p][1][H][1] == W) { cout << t << endl; return 0; } for (int x1 = 1; x1 <= H; x1++) for (int x2 = 1; x2 <= H; x2++) for (int y1 = 1; y1 <= W; y1++) { int ym = dpX[p][x1][x2][y1] + 1; int y2 = (ym <= W ? dpX[p][x1][x2][ym] : W); chmax(dpX[np][x1][x2][y1], y2); chmax(dpY[np][y1][y2][x1], x2); } for (int y1 = 1; y1 <= W; y1++) for (int y2 = 1; y2 <= W; y2++) for (int x1 = 1; x1 <= H; x1++) { int xm = dpY[p][y1][y2][x1] + 1; int x2 = (xm <= H ? dpY[p][y1][y2][xm] : H); chmax(dpX[np][x1][x2][y1], y2); chmax(dpY[np][y1][y2][x1], x2); } } return 0; }
#include <bits/stdc++.h> using namespace std; void chmax(int &a, int b) { a = max(a, b); } int main() { int H, W; cin >> H >> W; string S[185]; for (int i = 0; i < H; i++) cin >> S[i]; int sum[186][186] = {0}; for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) sum[i][j] = (S[i - 1][j - 1] == '#'); for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) sum[i][j] += sum[i - 1][j]; for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) sum[i][j] += sum[i][j - 1]; static int dpX[2][187][187][187], dpY[2][187][187][187]; for (int x1 = 1; x1 <= H; x1++) for (int x2 = x1; x2 <= H; x2++) for (int y1 = 1; y1 <= W; y1++) { int ok = y1 - 1, ng = W + 1; while (ng - ok > 1) { int y2 = (ok + ng) / 2; int a = (x2 - x1 + 1) * (y2 - y1 + 1); int s = sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1]; ((s == 0 || s == a) ? ok : ng) = y2; } int y2 = ok; chmax(dpX[0][x1][x2][y1], y2); chmax(dpY[0][y1][y2][x1], x2); } for (int t = 0;; t++) { int p = t % 2, np = (t + 1) % 2; for (int d = H - 1; d >= 1; d--) for (int x1 = 1; x1 + d - 1 <= H; x1++) { int x2 = x1 + d - 1; for (int y1 = 1; y1 <= W; y1++) { chmax(dpX[p][x1][x2][y1], dpX[p][x1 - 1][x2][y1]); chmax(dpX[p][x1][x2][y1], dpX[p][x1][x2 + 1][y1]); chmax(dpX[p][x1][x2][y1], dpX[p][x1][x2][y1 - 1]); } } for (int d = W - 1; d >= 1; d--) for (int y1 = 1; y1 + d - 1 <= W; y1++) { int y2 = y1 + d - 1; for (int x1 = 1; x1 <= H; x1++) { chmax(dpY[p][y1][y2][x1], dpY[p][y1 - 1][y2][x1]); chmax(dpY[p][y1][y2][x1], dpY[p][y1][y2 + 1][x1]); chmax(dpY[p][y1][y2][x1], dpY[p][y1][y2][x1 - 1]); } } if (dpX[p][1][H][1] == W) { cout << t << endl; return 0; } for (int x1 = 1; x1 <= H; x1++) for (int x2 = 1; x2 <= H; x2++) for (int y1 = 1; y1 <= W; y1++) { int ym = dpX[p][x1][x2][y1] + 1; int y2 = (ym <= W ? dpX[p][x1][x2][ym] : W); chmax(dpX[np][x1][x2][y1], y2); chmax(dpY[np][y1][y2][x1], x2); } for (int y1 = 1; y1 <= W; y1++) for (int y2 = 1; y2 <= W; y2++) for (int x1 = 1; x1 <= H; x1++) { int xm = dpY[p][y1][y2][x1] + 1; int x2 = (xm <= H ? dpY[p][y1][y2][xm] : H); chmax(dpX[np][x1][x2][y1], y2); chmax(dpY[np][y1][y2][x1], x2); } } return 0; }
[ "identifier.change", "call.arguments.change" ]
875,560
875,561
u314396879
cpp
p03056
// https://atcoder.jp/contests/agc033/tasks/agc033_d /*<head>*/ // #include "lib/Template.hpp" /*</head>*/ /*<body>*/ /* #region header */ /** * @file Template.hpp * @brief 競技プログラミング用テンプレート * @author btk15049 * @date 2019/05/02 */ #include <bits/stdc++.h> using namespace std; /* #region macro */ #ifdef BTK #define DEBUG if (1) #define CIN_ONLY if (0) #else #define DEBUG if (0) #define CIN_ONLY if (1) #endif /** @def * ALLマクロ */ #define ALL(v) (v).begin(), (v).end() /** @def * 再帰ラムダをするためのマクロ */ #define REC(ret, ...) std::function<ret(__VA_ARGS__)> /* #endregion */ namespace _Template_ { /** * @brief cin高速化処理を行うための構造体 * @details CIN_ONLYマクロで動作が変わる */ struct cww { cww() { CIN_ONLY { ios::sync_with_stdio(false); cin.tie(0); } } } star; /** * @brief change min * @tparam T 型 * @param l 参照 * @param r 非参照 * @return 更新があればtrue */ template <typename T> inline bool chmin(T &l, T r) { bool a = l > r; if (a) l = r; return a; } /** * @brief chminのmax版 * @see chmin */ template <typename T> inline bool chmax(T &l, T r) { bool a = l < r; if (a) l = r; return a; } /** * @brief * vectorに直接cin流すためのやつ * @tparam T * @param is * @param v * @return istream& */ template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &it : v) is >> it; return is; } /** * @brief * rangeを逆向きに操作したいとき用 * @details * ループの範囲は[bg,ed)なので注意 * @see range */ class reverse_range { private: struct I { int x; int operator*() { return x - 1; } bool operator!=(I &lhs) { return x > lhs.x; } void operator++() { --x; } }; I i, n; public: reverse_range(int n) : i({0}), n({n}) {} reverse_range(int i, int n) : i({i}), n({n}) {} I &begin() { return n; } I &end() { return i; } }; /** * @brief * python みたいな range-based for を実現 * @details * ループの範囲は[bg,ed)なので注意 * !つけると逆向きにループが回る (reverse_range) * 空間計算量はO(1) * 使わない変数ができて警告が出がちなので,unused_varとかを使って警告消しするとよい */ class range { private: struct I { int x; int operator*() { return x; } bool operator!=(I &lhs) { return x < lhs.x; } void operator++() { ++x; } }; I i, n; public: range(int n) : i({0}), n({n}) {} range(int i, int n) : i({i}), n({n}) {} I &begin() { return i; } I &end() { return n; } reverse_range operator!() { return reverse_range(*i, *n); } }; /** * @brief * rangeで生まれる使わない変数を消す用(警告消し) */ template <typename T> inline T &unused_var(T &v) { return v; } using LL = long long; } // namespace _Template_ using namespace _Template_; /* #endregion */ /*</body>*/ int R; int C; int grid[212][212]; template <typename T> class NDArray { private: T *ptr; int sizeAll; std::vector<int> dims; std::vector<int> slices; inline int computeIndex(std::vector<int> &&indices) { int index = 0; for (int i : range(slices.size())) { index += indices[i] * slices[i]; } return index; } public: template <typename... Ts> NDArray(T *ptr, Ts &&...params) : ptr(ptr) { for (auto const &d : {params...}) { dims.push_back(d); } slices.resize(dims.size()); slices.back() = 1; for (int di : !range(1, dims.size())) { slices[di - 1] = slices[di] * dims[di]; } sizeAll = slices.front() * dims.front(); } template <typename... Ts> inline T &random_access(Ts &&...indices) { return ptr[computeIndex({indices...})]; } template <typename... Ts> inline T &operator()(Ts &&...indices) { return random_access(indices...); } inline T &operator()(int i0, int i1, int i2) { return ptr[i0 * slices[0] + i1 * slices[1] + i2 * slices[2]]; } inline void fill(T &&v) { std::fill(ptr, ptr + sizeAll, v); } const vector<int> &getDimInfo() { return dims; } }; namespace solver { int mem1[212 * 212 * 212]; int mem2[212 * 212 * 212]; void array_clear(NDArray<int> &dp) { for (int ri : range(R)) { for (int ci : range(C + 1)) { for (int rj : range(R + 1)) { dp(ri, ci, rj) = ci; } } } } void init(NDArray<int> &dp) { array_clear(dp); // ----- for (int ri : range(R)) { for (int ci : range(C)) { int cj = ci; while (cj < C && grid[ri][ci] == grid[ri][cj]) { cj++; } dp(ri, ci, ri + 1) = cj; } } for (int ri : range(R)) { for (int ci : range(C)) { for (int rj : range(ri + 2, R + 1)) { if (grid[rj - 1][ci] == grid[rj][ci]) { dp(ri, ci, rj) = min(dp(ri, ci, rj - 1), dp(rj - 1, ci, rj)); } } } } } void run() { NDArray<int> dp(mem1, R, C + 1, R + 1); NDArray<int> nx(mem2, R, C + 1, R + 1); init(dp); int ret = 0; while (dp(0, 0, R) < C) { ret++; array_clear(nx); for (int ri : range(R)) { for (int ci : range(C)) { for (int rj : range(ri + 1, R + 1)) { nx(ri, ci, rj) = dp(ri, dp(ri, ci, rj), rj); } } } for (int ri : range(R)) { for (int ci : range(C)) { int rm = ri + 1; for (int rj : range(ri + 2, R + 1)) { while (rm + 1 < rj && min(dp(ri, ci, rm), dp(rm, ci, rj)) <= min(dp(ri, ci, rm + 1), dp(rm + 1, ci, rj))) { rm++; } chmax(nx(ri, ci, rj), min(dp(ri, ci, rm), dp(rm, ci, rj))); } } } swap(dp, nx); } cout << ret << endl; } } // namespace solver int main() { cin >> R >> C; for (int ri : range(R)) { string s; cin >> s; for (int ci : range(C)) { grid[ri][ci] = (s[ci] == '#') ? 1 : 0; } } solver::run(); return 0; }
// https://atcoder.jp/contests/agc033/tasks/agc033_d /*<head>*/ // #include "lib/Template.hpp" /*</head>*/ /*<body>*/ /* #region header */ /** * @file Template.hpp * @brief 競技プログラミング用テンプレート * @author btk15049 * @date 2019/05/02 */ #include <bits/stdc++.h> using namespace std; /* #region macro */ #ifdef BTK #define DEBUG if (1) #define CIN_ONLY if (0) #else #define DEBUG if (0) #define CIN_ONLY if (1) #endif /** @def * ALLマクロ */ #define ALL(v) (v).begin(), (v).end() /** @def * 再帰ラムダをするためのマクロ */ #define REC(ret, ...) std::function<ret(__VA_ARGS__)> /* #endregion */ namespace _Template_ { /** * @brief cin高速化処理を行うための構造体 * @details CIN_ONLYマクロで動作が変わる */ struct cww { cww() { CIN_ONLY { ios::sync_with_stdio(false); cin.tie(0); } } } star; /** * @brief change min * @tparam T 型 * @param l 参照 * @param r 非参照 * @return 更新があればtrue */ template <typename T> inline bool chmin(T &l, T r) { bool a = l > r; if (a) l = r; return a; } /** * @brief chminのmax版 * @see chmin */ template <typename T> inline bool chmax(T &l, T r) { bool a = l < r; if (a) l = r; return a; } /** * @brief * vectorに直接cin流すためのやつ * @tparam T * @param is * @param v * @return istream& */ template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &it : v) is >> it; return is; } /** * @brief * rangeを逆向きに操作したいとき用 * @details * ループの範囲は[bg,ed)なので注意 * @see range */ class reverse_range { private: struct I { int x; int operator*() { return x - 1; } bool operator!=(I &lhs) { return x > lhs.x; } void operator++() { --x; } }; I i, n; public: reverse_range(int n) : i({0}), n({n}) {} reverse_range(int i, int n) : i({i}), n({n}) {} I &begin() { return n; } I &end() { return i; } }; /** * @brief * python みたいな range-based for を実現 * @details * ループの範囲は[bg,ed)なので注意 * !つけると逆向きにループが回る (reverse_range) * 空間計算量はO(1) * 使わない変数ができて警告が出がちなので,unused_varとかを使って警告消しするとよい */ class range { private: struct I { int x; int operator*() { return x; } bool operator!=(I &lhs) { return x < lhs.x; } void operator++() { ++x; } }; I i, n; public: range(int n) : i({0}), n({n}) {} range(int i, int n) : i({i}), n({n}) {} I &begin() { return i; } I &end() { return n; } reverse_range operator!() { return reverse_range(*i, *n); } }; /** * @brief * rangeで生まれる使わない変数を消す用(警告消し) */ template <typename T> inline T &unused_var(T &v) { return v; } using LL = long long; } // namespace _Template_ using namespace _Template_; /* #endregion */ /*</body>*/ int R; int C; int grid[212][212]; template <typename T> class NDArray { private: T *ptr; int sizeAll; std::vector<int> dims; std::vector<int> slices; inline int computeIndex(std::vector<int> &&indices) { int index = 0; for (int i : range(slices.size())) { index += indices[i] * slices[i]; } return index; } public: template <typename... Ts> NDArray(T *ptr, Ts &&...params) : ptr(ptr) { for (auto const &d : {params...}) { dims.push_back(d); } slices.resize(dims.size()); slices.back() = 1; for (int di : !range(1, dims.size())) { slices[di - 1] = slices[di] * dims[di]; } sizeAll = slices.front() * dims.front(); } template <typename... Ts> inline T &random_access(Ts &&...indices) { return ptr[computeIndex({indices...})]; } template <typename... Ts> inline T &operator()(Ts &&...indices) { return random_access(indices...); } inline T &operator()(int i0, int i1, int i2) { return ptr[i0 * slices[0] + i1 * slices[1] + i2 * slices[2]]; } inline void fill(T &&v) { std::fill(ptr, ptr + sizeAll, v); } const vector<int> &getDimInfo() { return dims; } }; namespace solver { int mem1[212 * 212 * 212]; int mem2[212 * 212 * 212]; void array_clear(NDArray<int> &dp) { for (int ri : range(R)) { for (int ci : range(C + 1)) { for (int rj : range(R + 1)) { dp(ri, ci, rj) = ci; } } } } void init(NDArray<int> &dp) { array_clear(dp); // ----- for (int ri : range(R)) { for (int ci : range(C)) { int cj = ci; while (cj < C && grid[ri][ci] == grid[ri][cj]) { cj++; } dp(ri, ci, ri + 1) = cj; } } for (int ri : range(R)) { for (int ci : range(C)) { for (int rj : range(ri + 2, R + 1)) { if (grid[rj - 2][ci] == grid[rj - 1][ci]) { dp(ri, ci, rj) = min(dp(ri, ci, rj - 1), dp(rj - 1, ci, rj)); } } } } } void run() { NDArray<int> dp(mem1, R, C + 1, R + 1); NDArray<int> nx(mem2, R, C + 1, R + 1); init(dp); int ret = 0; while (dp(0, 0, R) < C) { ret++; array_clear(nx); for (int ri : range(R)) { for (int ci : range(C)) { for (int rj : range(ri + 1, R + 1)) { nx(ri, ci, rj) = dp(ri, dp(ri, ci, rj), rj); } } } for (int ri : range(R)) { for (int ci : range(C)) { int rm = ri + 1; for (int rj : range(ri + 2, R + 1)) { while (rm + 1 < rj && min(dp(ri, ci, rm), dp(rm, ci, rj)) <= min(dp(ri, ci, rm + 1), dp(rm + 1, ci, rj))) { rm++; } chmax(nx(ri, ci, rj), min(dp(ri, ci, rm), dp(rm, ci, rj))); } } } swap(dp, nx); } cout << ret << endl; } } // namespace solver int main() { cin >> R >> C; for (int ri : range(R)) { string s; cin >> s; for (int ci : range(C)) { grid[ri][ci] = (s[ci] == '#') ? 1 : 0; } } solver::run(); return 0; }
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
875,562
875,563
u613658617
cpp
p03056
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします! //ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。 //今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう! // #本田未央を一番星に #本田未央を令和のシンデレラガールに // #第8回シンデレラガール総選挙 #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define pb push_back #define pf push_front typedef long long lint; typedef complex<double> P; #define mp make_pair #define fi first #define se second typedef pair<int, int> pint; #define All(s) s.begin(), s.end() #define rAll(s) s.rbegin(), s.rend() #define REP(i, a, b) for (int i = a; i < b; i++) #define rep(i, n) REP(i, 0, n) #define N 190 #define M 20 int dp[N][N][N][M]; int sum[N][N]; string ma[N]; int h, W; int num(int lx, int hx, int ly, int hy) { return sum[hx][hy] - sum[hx][ly] - sum[lx][hy] + sum[lx][ly]; } int cal(int x, int y, int z, int w) { if (dp[x][y][z][w] >= 0) return dp[x][y][z][w]; if (w == 0) { int lo = z, hi = W; if (x == 0 && y == 3 && z == 0 && w == 0) { // cout<<lo<<hi<<endl; } while (hi > lo) { int mi = (hi + lo + 1) / 2; if (num(x, y, z, mi) == 0 || num(x, y, z, mi) == (y - x) * (mi - z)) lo = mi; else hi = mi - 1; } // cout<<x<<' '<<y<<' '<<z<<' '<<w<<' '<<lo<<endl; return dp[x][y][z][w] = lo; } int ret = cal(x, y, cal(x, y, z, w - 1), w - 1), lo = x + 1, hi = y - 1; if (hi >= lo) { while (hi > lo) { int mi = (hi + lo + 1) / 2; if (cal(x, mi, z, w - 1) < cal(mi, y, z, w - 1)) hi = mi - 1; else lo = mi; } ret = max(ret, min(cal(x, lo, z, w - 1), cal(lo, y, z, w - 1))); if (lo < y - 1) ret = max(ret, min(cal(x, lo + 1, z, w - 1), cal(lo + 1, y, z, w - 1))); } // cout<<x<<' '<<y<<' '<<z<<' '<<w<<' '<<ret<<endl; return dp[x][y][z][w] = ret; } int main() { cin >> h >> W; rep(i, h) cin >> ma[i]; memset(sum, 0, sizeof(sum)); rep(i, h) rep(j, W) { sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j]; if (ma[i][j] == '#') sum[i + 1][j + 1]++; } memset(dp, -1, sizeof(dp)); // cout<<cal(0,3,0,1)<<endl; // cout<<cal(1,3,1,0)<<endl; rep(i, M) { if (cal(0, h, 0, i) >= W) { cout << i << endl; return 0; } } }
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします! //ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。 //今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう! // #本田未央を一番星に #本田未央を令和のシンデレラガールに // #第8回シンデレラガール総選挙 #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define pb push_back #define pf push_front typedef long long lint; typedef complex<double> P; #define mp make_pair #define fi first #define se second typedef pair<int, int> pint; #define All(s) s.begin(), s.end() #define rAll(s) s.rbegin(), s.rend() #define REP(i, a, b) for (int i = a; i < b; i++) #define rep(i, n) REP(i, 0, n) #define N 190 #define M 20 short dp[N][N][N][M]; int sum[N][N]; string ma[N]; int h, W; int num(int lx, int hx, int ly, int hy) { return sum[hx][hy] - sum[hx][ly] - sum[lx][hy] + sum[lx][ly]; } int cal(int x, int y, int z, int w) { if (dp[x][y][z][w] >= 0) return dp[x][y][z][w]; if (w == 0) { int lo = z, hi = W; if (x == 0 && y == 3 && z == 0 && w == 0) { // cout<<lo<<hi<<endl; } while (hi > lo) { int mi = (hi + lo + 1) / 2; if (num(x, y, z, mi) == 0 || num(x, y, z, mi) == (y - x) * (mi - z)) lo = mi; else hi = mi - 1; } // cout<<x<<' '<<y<<' '<<z<<' '<<w<<' '<<lo<<endl; return dp[x][y][z][w] = lo; } int ret = cal(x, y, cal(x, y, z, w - 1), w - 1), lo = x + 1, hi = y - 1; if (hi >= lo) { while (hi > lo) { int mi = (hi + lo + 1) / 2; if (cal(x, mi, z, w - 1) < cal(mi, y, z, w - 1)) hi = mi - 1; else lo = mi; } ret = max(ret, min(cal(x, lo, z, w - 1), cal(lo, y, z, w - 1))); if (lo < y - 1) ret = max(ret, min(cal(x, lo + 1, z, w - 1), cal(lo + 1, y, z, w - 1))); } // cout<<x<<' '<<y<<' '<<z<<' '<<w<<' '<<ret<<endl; return dp[x][y][z][w] = ret; } int main() { cin >> h >> W; rep(i, h) cin >> ma[i]; memset(sum, 0, sizeof(sum)); rep(i, h) rep(j, W) { sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j]; if (ma[i][j] == '#') sum[i + 1][j + 1]++; } memset(dp, -1, sizeof(dp)); // cout<<cal(0,3,0,1)<<endl; // cout<<cal(1,3,1,0)<<endl; rep(i, M) { if (cal(0, h, 0, i) >= W) { cout << i << endl; return 0; } } }
[ "variable_declaration.type.primitive.change" ]
875,566
875,567
u162364634
cpp
p03062
#include <algorithm> #include <cmath> #include <functional> #include <iostream> using namespace std; long long mod = 1000000007; long long A[100000]; int main() { int N, count = 0; long long sum = 0; long long min = 100000000; cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; if (A[i] < 0) { count++; } if (abs(A[i]) < min) { min = abs(A[i]); } sum += abs(A[i]); } if (count % 2 == 0) { cout << sum << endl; } else { cout << sum - min << endl; } }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> using namespace std; long long mod = 1000000007; long long A[100000]; int main() { int N, count = 0; long long sum = 0; long long min = 100000000; cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; if (A[i] < 0) { count++; } if (abs(A[i]) < min) { min = abs(A[i]); } sum += abs(A[i]); } if (count % 2 == 0) { cout << sum << endl; } else { cout << sum - 2 * min << endl; } }
[ "expression.operation.binary.add" ]
875,570
875,571
u475843109
cpp
p03062
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <utility> #include <vector> #define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i)) using namespace std; using ll = long long; using P = pair<ll, ll>; const ll MOD = 1e9 + 7; const ll INF = (1ll << 60); int main(void) { int n; ll ans = 0; cin >> n; vector<ll> a(n); ll x = INF, xi = 0; ll res = 0; for (int i = 0; i < n; i++) { cin >> a[i]; res += a[i]; x = min(x, abs(a[i])); } for (int i = 0; i < n - 1; i++) { if (a[i] < 0) { a[i] *= -1; a[i + 1] *= -1; } } for (int i = 0; i < n; i++) { ans += a[i]; } cout << max(ans, res - x) << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <utility> #include <vector> #define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i)) using namespace std; using ll = long long; using P = pair<ll, ll>; const ll MOD = 1e9 + 7; const ll INF = (1ll << 60); int main(void) { int n; ll ans = 0; cin >> n; vector<ll> a(n); ll x = INF, xi = 0; ll res = 0; for (int i = 0; i < n; i++) { cin >> a[i]; res += abs(a[i]); x = min(x, abs(a[i])); } for (int i = 0; i < n - 1; i++) { if (a[i] < 0) { a[i] *= -1; a[i + 1] *= -1; } } for (int i = 0; i < n; i++) { ans += a[i]; } cout << max(ans, res - x * 2) << endl; }
[ "call.add", "call.arguments.change", "expression.operation.binary.add" ]
875,600
875,601
u880221923
cpp
p03062
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL << 62 #define inf 1000000007 int main() { ll n, cnt = 0, MIN = INF, ans = 0; cin >> n; for (int i = 0; i < n; i++) { ll z; cin >> z; if (z < 0) { cnt++; } z = abs(z); MIN = min(MIN, z); ans += z; } if (cnt % 2 == 1) { ans -= MIN; } cout << ans; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL << 62 #define inf 1000000007 int main() { ll n, cnt = 0, MIN = INF, ans = 0; cin >> n; for (int i = 0; i < n; i++) { ll z; cin >> z; if (z < 0) { cnt++; } z = abs(z); MIN = min(MIN, z); ans += z; } if (cnt % 2 == 1) { ans -= 2 * MIN; } cout << ans; }
[ "assignment.change" ]
875,602
875,603
u166378830
cpp
p03062
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long ans = 0; int cnt = 0; long long mn = 2000000000; for (int i = 0; i < n; ++i) { long long k; cin >> k; if (k < 0) cnt++; k = abs(k); mn = min(mn, k); ans += k; } if (cnt % 2) ans -= mn; cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long ans = 0; int cnt = 0; long long mn = 2000000000; for (int i = 0; i < n; ++i) { long long k; cin >> k; if (k < 0) cnt++; k = abs(k); mn = min(mn, k); ans += k; } if (cnt % 2) ans -= mn * 2; cout << ans << endl; }
[ "assignment.change" ]
875,604
875,605
u412837450
cpp
p03062
#include <iostream> #include <vector> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define ill long long using namespace std; int main() { ill n, s = 0, z = 1, mi = 0; cin >> n; vector<ill> v(n); rep(i, 0, n) { cin >> v[i]; if (v[i] < 0) { s -= v[i]; mi++; } else { s += v[i]; } if (v[i] == 0) { z = 0; } } if (z == 0) { cout << s; } else { if (mi % 2 == 0) { cout << s; } else { ill m = 10000000000; rep(i, 0, n) { if (v[i] > 0 && m > v[i]) { m = v[i]; } else if (v[i] < 0 && m > -v[i]) { m = -v[i]; } } cout << s - m; } } }
#include <iostream> #include <vector> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define ill long long using namespace std; int main() { ill n, s = 0, z = 1, mi = 0; cin >> n; vector<ill> v(n); rep(i, 0, n) { cin >> v[i]; if (v[i] < 0) { s -= v[i]; mi++; } else { s += v[i]; } if (v[i] == 0) { z = 0; } } if (z == 0) { cout << s; } else { if (mi % 2 == 0) { cout << s; } else { ill m = 10000000000; rep(i, 0, n) { if (v[i] > 0 && m > v[i]) { m = v[i]; } if (v[i] < 0 && m > -v[i]) { m = -v[i]; } } cout << s - m * 2; } } }
[ "control_flow.branch.if.replace.add", "control_flow.branch.else_if.replace.remove" ]
875,613
875,614
u841702632
cpp
p03062
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() #define dunk(a) cout << (a) << endl #define rall(a) (a).rbegin(), (a).rend() const int INF = 2e9; using namespace std; using Graph = vector<vector<int>>; typedef pair<int, int> P; typedef long long ll; int main() { ll n; cin >> n; vector<ll> a(n); vector<ll> b(n); ll cntm = 0; ll cntz = 0; ll ans = 0; rep(i, n) { cin >> a[i]; b[i] = abs(a[i]); if (a[i] < 0) cntm++; if (a[i] == 0) cntz++; ans += b[i]; } sort(all(b)); if (cntz >= 1 || cntm % 2 == 0) { cout << ans << endl; return 0; } cout << ans - b[0] << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() #define dunk(a) cout << (a) << endl #define rall(a) (a).rbegin(), (a).rend() const int INF = 2e9; using namespace std; using Graph = vector<vector<int>>; typedef pair<int, int> P; typedef long long ll; int main() { ll n; cin >> n; vector<ll> a(n); vector<ll> b(n); ll cntm = 0; ll cntz = 0; ll ans = 0; rep(i, n) { cin >> a[i]; b[i] = abs(a[i]); if (a[i] < 0) cntm++; if (a[i] == 0) cntz++; ans += b[i]; } sort(all(b)); if (cntz >= 1 || cntm % 2 == 0) { cout << ans << endl; return 0; } cout << ans - b[0] * 2 << endl; }
[ "expression.operation.binary.add" ]
875,615
875,616
u454081619
cpp
p03062
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { ll n; cin >> n; ll num[n + 1]; ll mind = 0; ll minz = 100000000000; ll msum = 0; ll les0 = 0; bool ex0 = false; for (int i = 1; i <= n; i++) { cin >> num[i]; if (num[i] < 0) { les0++; } if (minz > num[i]) { minz = abs(num[i]); mind = i; } msum += abs(num[i]); if (num[i] == 0) { ex0 = true; } } if (les0 % 2 == 1 && !ex0) { cout << msum - 2 * minz << endl; } else { cout << msum << endl; } }
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { ll n; cin >> n; ll num[n + 1]; ll mind = 0; ll minz = 100000000000; ll msum = 0; ll les0 = 0; bool ex0 = false; for (ll i = 1; i <= n; i++) { cin >> num[i]; if (num[i] < 0) { les0++; } if (minz > abs(num[i])) { minz = abs(num[i]); mind = i; } msum += abs(num[i]); if (num[i] == 0) { ex0 = true; } } if (les0 % 2 == 1 && !ex0) { cout << msum - 2 * minz << endl; } else { cout << msum << endl; } }
[ "control_flow.loop.for.initializer.change", "variable_declaration.type.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "call.add" ]
875,623
875,624
u233626335
cpp
p03062
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int count = 0; long long ans = 0; long long mn = 1e9; for (int i = 0; i < n; i++) { long long x; cin >> x; if (x < 0) count++; ans += abs(x); mn = min(mn, abs(x)); // cout<<ans<<endl; } if (count % 2 == 0) cout << ans; else cout << ans - (mn); // cout<<mn; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int count = 0; long long ans = 0; long long mn = 1e9; for (int i = 0; i < n; i++) { long long x; cin >> x; if (x < 0) count++; ans += abs(x); mn = min(mn, abs(x)); // cout<<ans<<endl; } if (count % 2 == 0) cout << ans; else cout << ans - (2 * mn); // cout<<mn; return 0; }
[ "expression.operation.binary.add" ]
875,640
875,641
u563422568
cpp
p03062
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; vector<long long> a(N); long long mina = 1000000000; long long minuscount = 0; long long zerocount = 0; long long sum = 0; for (int i = 0; i < N; i++) { cin >> a[i]; if (abs(a[i] < mina)) { mina = abs(a[i]); } if (a[i] < 0) { minuscount++; } if (a[i] == 0) { zerocount++; } sum = sum + abs(a[i]); } if ((minuscount % 2 == 0) || (zerocount > 0)) { cout << setprecision(18) << sum << endl; return 0; } cout << setprecision(18) << sum - 2 * mina << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; vector<long long> a(N); long long mina = 1000000000; long long minuscount = 0; long long zerocount = 0; long long sum = 0; for (long long i = 0; i < N; i++) { cin >> a[i]; if (abs(a[i]) < mina) { mina = abs(a[i]); } if (a[i] < 0) { minuscount++; } if (a[i] == 0) { zerocount++; } sum = sum + abs(a[i]); } if ((minuscount % 2 == 0) || (zerocount > 0)) { cout << setprecision(18) << sum << endl; return 0; } cout << setprecision(18) << sum - 2 * mina << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change", "control_flow.branch.if.condition.change" ]
875,642
875,643
u469315559
cpp
p03062
#include <bits/stdc++.h> using namespace std; #define lli long long int #define uli unsigned long long int #define INF 999999999999999999 #define rep(i, m, n) for (lli i = m; i < n; i++) #define rrep(i, m, n) for (lli i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(25) << S << endl #define Vec(K, L, N, S) vector<L> K(N, S) #define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S)) #define TV(K, L, N, M, R, S) \ vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S))) #define pint pair<lli, lli> #define paf(L, R) pair<L, R> #define mod 1000000007 #define MAX 510000 #define ALL(a) a.begin(), a.end() #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) lli gcd(lli num1, lli num2) { return num2 != 0 ? gcd(num2, num1 % num2) : num1; } lli lcm(lli num1, lli num2) { return num1 / gcd(num1, num2) * num2; } lli repow(lli n, lli k, lli m) { if (k == 0) return 1; else if (k % 2 == 1) return repow(n, k - 1, m) * n % m; else { lli temp = repow(n, k / 2, m); return temp * temp % m; } } int main() { ios::sync_with_stdio(false); cin.tie(0); lli A, B, C, D, E, F, N, M, K, L, X, Y, Z, H, W, sum = 0, num = 0, flag = 0; string S, T; cin >> N; Vec(P, lli, N, 0); rep(i, 0, N) { cin >> P[i]; if (P[i] < 0) { num++; P[i] *= -1; } sum += P[i]; } Sort(P); if (num & 1) Out(sum - P[0]); else Out(sum); }
#include <bits/stdc++.h> using namespace std; #define lli long long int #define uli unsigned long long int #define INF 999999999999999999 #define rep(i, m, n) for (lli i = m; i < n; i++) #define rrep(i, m, n) for (lli i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(25) << S << endl #define Vec(K, L, N, S) vector<L> K(N, S) #define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S)) #define TV(K, L, N, M, R, S) \ vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S))) #define pint pair<lli, lli> #define paf(L, R) pair<L, R> #define mod 1000000007 #define MAX 510000 #define ALL(a) a.begin(), a.end() #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) lli gcd(lli num1, lli num2) { return num2 != 0 ? gcd(num2, num1 % num2) : num1; } lli lcm(lli num1, lli num2) { return num1 / gcd(num1, num2) * num2; } lli repow(lli n, lli k, lli m) { if (k == 0) return 1; else if (k % 2 == 1) return repow(n, k - 1, m) * n % m; else { lli temp = repow(n, k / 2, m); return temp * temp % m; } } int main() { ios::sync_with_stdio(false); cin.tie(0); lli A, B, C, D, E, F, N, M, K, L, X, Y, Z, H, W, sum = 0, num = 0, flag = 0; string S, T; cin >> N; Vec(P, lli, N, 0); rep(i, 0, N) { cin >> P[i]; if (P[i] < 0) { num++; P[i] *= -1; } sum += P[i]; } Sort(P); if (num & 1) Out(sum - 2 * P[0]); else Out(sum); }
[ "expression.operation.binary.add" ]
875,644
875,645
u618604643
cpp
p03062
#include <bits/stdc++.h> using namespace std; #define lli long long int #define uli unsigned long long int #define INF 999999999999999999 #define rep(i, m, n) for (lli i = m; i < n; i++) #define rrep(i, m, n) for (lli i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(25) << S << endl #define Vec(K, L, N, S) vector<L> K(N, S) #define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S)) #define TV(K, L, N, M, R, S) \ vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S))) #define pint pair<lli, lli> #define paf(L, R) pair<L, R> #define mod 1000000007 #define MAX 510000 #define ALL(a) a.begin(), a.end() #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) lli gcd(lli num1, lli num2) { return num2 != 0 ? gcd(num2, num1 % num2) : num1; } lli lcm(lli num1, lli num2) { return num1 / gcd(num1, num2) * num2; } lli repow(lli n, lli k, lli m) { if (k == 0) return 1; else if (k % 2 == 1) return repow(n, k - 1, m) * n % m; else { lli temp = repow(n, k / 2, m); return temp * temp % m; } } int main() { ios::sync_with_stdio(false); cin.tie(0); lli A, B, C, D, E, F, N, M, K, L, X, Y, Z, H, W, sum = 0, num = 0, flag = 0; string S, T; cin >> N; Vec(P, lli, N, 0); rep(i, 0, N) { cin >> P[i]; if (P[i] < 0) { num++; P[i] *= 1; } sum += P[i]; } Sort(P); if (num & 1) Out(sum - P[0]); else Out(sum); }
#include <bits/stdc++.h> using namespace std; #define lli long long int #define uli unsigned long long int #define INF 999999999999999999 #define rep(i, m, n) for (lli i = m; i < n; i++) #define rrep(i, m, n) for (lli i = m - 1; i >= n; i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(), n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(25) << S << endl #define Vec(K, L, N, S) vector<L> K(N, S) #define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S)) #define TV(K, L, N, M, R, S) \ vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S))) #define pint pair<lli, lli> #define paf(L, R) pair<L, R> #define mod 1000000007 #define MAX 510000 #define ALL(a) a.begin(), a.end() #define chmax(a, b) a = (((a) < (b)) ? (b) : (a)) #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) lli gcd(lli num1, lli num2) { return num2 != 0 ? gcd(num2, num1 % num2) : num1; } lli lcm(lli num1, lli num2) { return num1 / gcd(num1, num2) * num2; } lli repow(lli n, lli k, lli m) { if (k == 0) return 1; else if (k % 2 == 1) return repow(n, k - 1, m) * n % m; else { lli temp = repow(n, k / 2, m); return temp * temp % m; } } int main() { ios::sync_with_stdio(false); cin.tie(0); lli A, B, C, D, E, F, N, M, K, L, X, Y, Z, H, W, sum = 0, num = 0, flag = 0; string S, T; cin >> N; Vec(P, lli, N, 0); rep(i, 0, N) { cin >> P[i]; if (P[i] < 0) { num++; P[i] *= -1; } sum += P[i]; } Sort(P); if (num & 1) Out(sum - 2 * P[0]); else Out(sum); }
[ "expression.operation.unary.arithmetic.add" ]
875,646
875,645
u618604643
cpp
p03062
#include <bits/stdc++.h> using namespace std; int main() { int N, cut = 0, ans = 0; cin >> N; vector<int> num(N); for (int i = 0; i < N; i++) { cin >> num[i]; if (num[i] < 0) { cut++; num[i] *= -1; } ans += num[i]; } sort(num.begin(), num.end()); if (cut % 2 == 1) { ans -= 2 * num[0]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int N, cut = 0, ans = 0; cin >> N; vector<long long int> num(N); for (int i = 0; i < N; i++) { cin >> num[i]; if (num[i] < 0) { cut++; num[i] *= -1; } ans += num[i]; } sort(num.begin(), num.end()); if (cut % 2 == 1) { ans -= 2 * num[0]; } cout << ans << endl; }
[ "variable_declaration.type.widen.change" ]
875,647
875,648
u618604643
cpp
p03062
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define uni(x) x.erase(unique(rng(x)), x.end()) #define snuke srand((unsigned)clock() + (unsigned)time(NULL)); #define show(x) cout << #x << " = " << x << endl; #define PQ(T) priority_queue<T, v(T), greater<T>> #define bn(x) ((1 << x) - 1) #define dup(x, y) (((x) + (y)-1) / (y)) #define newline puts("") #define v(T) vector<T> #define vv(T) v(v(T)) using namespace std; typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; inline int in() { int x; scanf("%d", &x); return x; } template <typename T> inline istream &operator>>(istream &i, v(T) & v) { rep(j, sz(v)) i >> v[j]; return i; } template <typename T> string join(const v(T) & v) { stringstream s; rep(i, sz(v)) s << ' ' << v[i]; return s.str().substr(1); } template <typename T> inline ostream &operator<<(ostream &o, const v(T) & v) { if (sz(v)) o << join(v); return o; } template <typename T1, typename T2> inline istream &operator>>(istream &i, pair<T1, T2> &v) { return i >> v.fi >> v.se; } template <typename T1, typename T2> inline ostream &operator<<(ostream &o, const pair<T1, T2> &v) { return o << v.fi << "," << v.se; } template <typename T> inline ll suma(const v(T) & a) { ll res(0); for (auto &&x : a) res += x; return res; } const double eps = 1e-10; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; #define dame \ { \ puts("-1"); \ return 0; \ } #define yn \ { puts("Yes"); } \ else { \ puts("No"); \ } const int MX = 200005; #define RET(ans) \ { \ cout << ans << endl; \ return 0; \ } // 二次元ベクターの基本 /* vector<vector<int>> dp; // 宣言 dp.resize(n); // 1次元めの要素数決定 dp[i].push_back(int); // プッシュバック rep(i,n){ sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート } */ // 整数スキャン(複数) /* int x,y,z; scanf("%d%d%d",&x,&y,&z); // n個の整数のスキャン /* ll a[n] = {}; rep(i,n){ scanf("%lld",&a[i]); } */ // 文字列スキャン /* string s; cin >> s; */ // n個の文字列スキャン /* vector<string> slist; rep(i,n){ string s; cin >> s; slist.push_back(s); } */ int main() { int n; cin >> n; ll ans = 0; int count = 0; ll mi = 99999999999; rep(i, n) { ll x; cin >> x; if (x < 0) { count++; } ans += abs(x); if (abs(x) < mi) { mi = abs(x); } } if (count % 2 == 1) { ans -= mi; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define uni(x) x.erase(unique(rng(x)), x.end()) #define snuke srand((unsigned)clock() + (unsigned)time(NULL)); #define show(x) cout << #x << " = " << x << endl; #define PQ(T) priority_queue<T, v(T), greater<T>> #define bn(x) ((1 << x) - 1) #define dup(x, y) (((x) + (y)-1) / (y)) #define newline puts("") #define v(T) vector<T> #define vv(T) v(v(T)) using namespace std; typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; inline int in() { int x; scanf("%d", &x); return x; } template <typename T> inline istream &operator>>(istream &i, v(T) & v) { rep(j, sz(v)) i >> v[j]; return i; } template <typename T> string join(const v(T) & v) { stringstream s; rep(i, sz(v)) s << ' ' << v[i]; return s.str().substr(1); } template <typename T> inline ostream &operator<<(ostream &o, const v(T) & v) { if (sz(v)) o << join(v); return o; } template <typename T1, typename T2> inline istream &operator>>(istream &i, pair<T1, T2> &v) { return i >> v.fi >> v.se; } template <typename T1, typename T2> inline ostream &operator<<(ostream &o, const pair<T1, T2> &v) { return o << v.fi << "," << v.se; } template <typename T> inline ll suma(const v(T) & a) { ll res(0); for (auto &&x : a) res += x; return res; } const double eps = 1e-10; const ll LINF = 1001002003004005006ll; const int INF = 1001001001; #define dame \ { \ puts("-1"); \ return 0; \ } #define yn \ { puts("Yes"); } \ else { \ puts("No"); \ } const int MX = 200005; #define RET(ans) \ { \ cout << ans << endl; \ return 0; \ } // 二次元ベクターの基本 /* vector<vector<int>> dp; // 宣言 dp.resize(n); // 1次元めの要素数決定 dp[i].push_back(int); // プッシュバック rep(i,n){ sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート } */ // 整数スキャン(複数) /* int x,y,z; scanf("%d%d%d",&x,&y,&z); // n個の整数のスキャン /* ll a[n] = {}; rep(i,n){ scanf("%lld",&a[i]); } */ // 文字列スキャン /* string s; cin >> s; */ // n個の文字列スキャン /* vector<string> slist; rep(i,n){ string s; cin >> s; slist.push_back(s); } */ int main() { int n; cin >> n; ll ans = 0; int count = 0; ll mi = 99999999999; rep(i, n) { ll x; cin >> x; if (x < 0) { count++; } ans += abs(x); if (abs(x) < mi) { mi = abs(x); } } // cout << count; if (count % 2 == 1) { ans -= mi * 2; } cout << ans << endl; return 0; }
[ "assignment.change" ]
875,651
875,652
u791593901
cpp