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
p03062
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; int a[n + 10]; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 0, nummi = 0, mina; if (a[0] < 0) { mina = -a[0]; } else { mina = a[0]; } for (int i = 0; i < n; i++) { if (a[i] < 0) { mina = min(mina, -a[i]); ans = ans - a[i]; nummi += 1; } else { mina = min(a[i], mina); ans += a[i]; } } if ((nummi % 2) == 0) { cout << ans; } else { cout << ans - 2 * mina; } }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { long long int n; cin >> n; long long int a[n + 10]; for (int i = 0; i < n; i++) cin >> a[i]; long long int ans = 0, nummi = 0, mina; if (a[0] < 0) { mina = -a[0]; } else { mina = a[0]; } for (int i = 0; i < n; i++) { if (a[i] < 0) { mina = min(mina, -a[i]); ans = ans - a[i]; nummi += 1; } else { mina = min(a[i], mina); ans += a[i]; } } if ((nummi % 2) == 0) { cout << ans; } else { cout << ans - 2 * mina; } }
[ "variable_declaration.type.widen.change" ]
876,942
876,943
u337054478
cpp
p03062
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; #define double long double #define vec vector #define pb push_back #define unset unordered_set #define ii pair<int, int> #define X first #define Y second #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define FORE(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) #define bitcount(n) __builtin_popcountll(n) typedef vector<int> vi; template <typename T, typename U> std::pair<T, U> operator+(const std::pair<T, U> &l, const std::pair<T, U> &r) { return {l.first + r.first, l.second + r.second}; } typedef void (*callback_function)(void); // type for conciseness const long long ZERO = 0LL; const long long INF64 = 1e18; const int INF32 = 1e9; const int MOD = 1e6 + 3; const double EPS = static_cast<double>(1e-9); #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) //************************************ //#undef int int main() { //#define int long long ios_base::sync_with_stdio(false); cin.tie(); // auto beginProgram = chrono::steady_clock::now(); // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); int n; cin >> n; ll sum = 0, minV = LLONG_MAX, cnt = 0; FOR(i, 0, n) { ll a; cin >> a; if (a < 0) { cnt++; a = -a; } sum += a; minV = min(minV, a); // cout << a << ", " << sum << ", " << minV << ", " << cnt << endl; } if (cnt % 2 == 0) cout << sum << endl; else cout << sum - minV << endl; // auto endProgram = chrono::steady_clock::now(); return 0; }
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; #define double long double #define vec vector #define pb push_back #define unset unordered_set #define ii pair<int, int> #define X first #define Y second #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define FORE(i, a, b) for (int i = (a); i <= (b); i++) #define FORD(i, a, b) for (int i = (a); i >= (b); i--) #define bitcount(n) __builtin_popcountll(n) typedef vector<int> vi; template <typename T, typename U> std::pair<T, U> operator+(const std::pair<T, U> &l, const std::pair<T, U> &r) { return {l.first + r.first, l.second + r.second}; } typedef void (*callback_function)(void); // type for conciseness const long long ZERO = 0LL; const long long INF64 = 1e18; const int INF32 = 1e9; const int MOD = 1e6 + 3; const double EPS = static_cast<double>(1e-9); #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) //************************************ //#undef int int main() { //#define int long long ios_base::sync_with_stdio(false); cin.tie(); // auto beginProgram = chrono::steady_clock::now(); // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); int n; cin >> n; ll sum = 0, minV = LLONG_MAX, cnt = 0; FOR(i, 0, n) { ll a; cin >> a; if (a < 0) { cnt++; a = -a; } sum += a; minV = min(minV, a); // cout << a << ", " << sum << ", " << minV << ", " << cnt << endl; } if (cnt % 2 == 0) cout << sum << endl; else cout << sum - 2 * minV << endl; // auto endProgram = chrono::steady_clock::now(); return 0; }
[ "expression.operation.binary.add" ]
876,950
876,951
u210484769
cpp
p03062
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; const int INF = 999999999; int main() { ll N; cin >> N; vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); int cnt = 0; for (ll i = 0; i < N; i++) { if (A[i] >= 0) break; cnt++; } for (ll i = 0; i < N; i++) A[i] = abs(A[i]); sort(A.begin(), A.end()); int ans = 0; for (ll i = 0; i < N; i++) ans += A[i]; if (cnt % 2 != 0) ans -= (A[0] * 2); cout << ans << endl; }
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; const int INF = 999999999; int main() { ll N; cin >> N; vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); ll cnt = 0; for (ll i = 0; i < N; i++) { if (A[i] >= 0) break; cnt++; } for (ll i = 0; i < N; i++) A[i] = abs(A[i]); sort(A.begin(), A.end()); ll ans = 0; for (ll i = 0; i < N; i++) ans += A[i]; if (cnt % 2 != 0) ans -= (A[0] * 2); cout << ans << endl; }
[ "variable_declaration.type.change" ]
876,957
876,958
u239023686
cpp
p03062
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; const int INF = 999999999; int main() { ll N; cin >> N; vector<int> A(N); for (ll i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); int cnt = 0; for (ll i = 0; i < N; i++) { if (A[i] >= 0) break; cnt++; } for (ll i = 0; i < N; i++) A[i] = abs(A[i]); sort(A.begin(), A.end()); int ans = 0; for (ll i = 0; i < N; i++) ans += A[i]; if (cnt % 2 != 0) ans -= (A[0] * 2); cout << ans << endl; }
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; const int INF = 999999999; int main() { ll N; cin >> N; vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); ll cnt = 0; for (ll i = 0; i < N; i++) { if (A[i] >= 0) break; cnt++; } for (ll i = 0; i < N; i++) A[i] = abs(A[i]); sort(A.begin(), A.end()); ll ans = 0; for (ll i = 0; i < N; i++) ans += A[i]; if (cnt % 2 != 0) ans -= (A[0] * 2); cout << ans << endl; }
[ "variable_declaration.type.change" ]
876,959
876,958
u239023686
cpp
p03063
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF 10000000 #define MOD 998244353 #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() int main() { int N; string s; cin >> N >> s; vector<int> black(N + 1, 0); vector<int> white(N + 1, 0); for (int i = 0; i < N; i++) { if (s[i] == '#') black[i + 1]++; else white[i + 1]++; } for (int i = 0; i < N; i++) black[i + 1] += black[i]; for (int i = 0; i < N; i++) white[i + 1] += white[i]; int ans = INF; for (int i = 0; i < N; i++) { ans = min(ans, black[i] - black[0] + white[N] - white[i]); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF 10000000 #define MOD 998244353 #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() int main() { int N; string s; cin >> N >> s; vector<int> black(N + 1, 0); vector<int> white(N + 1, 0); for (int i = 0; i < N; i++) { if (s[i] == '#') black[i + 1]++; else white[i + 1]++; } for (int i = 0; i < N; i++) black[i + 1] += black[i]; for (int i = 0; i < N; i++) white[i + 1] += white[i]; int ans = INF; for (int i = 0; i <= N; i++) { ans = min(ans, black[i] - black[0] + white[N] - white[i]); } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
876,982
876,983
u864171425
cpp
p03063
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define int long long #define double long double #define mod 1000000007 #define F first #define S second #define P pair<long long, long long> #define all(a) a.begin(), a.end() #define INF 1000000000000000 #define endl '\n' 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; } using namespace std; signed main() { int n; cin >> n; string s; cin >> s; vector<int> b(n, 0), w(n, 0); int B = 0, W = 0; rep(i, n) { if (s.at(i) == '.') W++; w.at(i) = W; } for (int i = n - 1; i >= 0; i--) { if (s.at(i) == '#') B++; b.at(i) = B; } int ans = INF; chmin(ans, w.back()); chmin(ans, b.front()); rep(i, n - 1) { chmin(ans, w.at(i) + b.at(i + 1)); } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define int long long #define double long double #define mod 1000000007 #define F first #define S second #define P pair<long long, long long> #define all(a) a.begin(), a.end() #define INF 1000000000000000 #define endl '\n' 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; } using namespace std; signed main() { int n; cin >> n; string s; cin >> s; vector<int> b(n, 0), w(n, 0); int B = 0, W = 0; rep(i, n) { if (s.at(i) == '#') W++; w.at(i) = W; } for (int i = n - 1; i >= 0; i--) { if (s.at(i) == '.') B++; b.at(i) = B; } int ans = INF; chmin(ans, w.back()); chmin(ans, b.front()); rep(i, n - 1) { chmin(ans, w.at(i) + b.at(i + 1)); } cout << ans << endl; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
876,992
876,993
u807998890
cpp
p03063
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> #define M_PI 3.14159265358979323846 using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define MT make_tuple #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define FILL(a, x) memset(a, x, sizeof(a)) // repetition //------------------------------------------ #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) const LL MOD = 998244353; int sb[200005], sw[200005]; int main() { int n; string s; cin >> n >> s; REP(i, n) sb[i + 1] = sb[i] + (s[i] == '#'); REP(i, n) sw[i + 1] = sw[i] + (s[i] == '.'); int ret = n + 5; REP(i, n) { ret = min(ret, sb[i] - sb[0] + sw[n] - sw[i]); } cout << ret << endl; return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> #define M_PI 3.14159265358979323846 using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define MT make_tuple #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define FILL(a, x) memset(a, x, sizeof(a)) // repetition //------------------------------------------ #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) const LL MOD = 998244353; int sb[200005], sw[200005]; int main() { int n; string s; cin >> n >> s; REP(i, n) sb[i + 1] = sb[i] + (s[i] == '#'); REP(i, n) sw[i + 1] = sw[i] + (s[i] == '.'); int ret = n + 5; REP(i, n + 1) { ret = min(ret, sb[i] - sb[0] + sw[n] - sw[i]); } cout << ret << endl; return 0; }
[ "expression.operation.binary.add" ]
877,003
877,004
u614497125
cpp
p03063
#include "bits/stdc++.h" using namespace std; #define Rep(i, n) for (int i = 0; i < n; i++) #define For(i, n1, n2) for (int i = n1; i < n2; i++) #define REP(i, n) for (ll i = 0; i < n; i++) #define RREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, n1, n2) for (ll i = n1; i < n2; i++) #define put(a) cout << a << "\n" #define all(a) (a).begin(), (a).end() #define SORT(a) sort((a).begin(), (a).end()) #define oorret 0 #define oor(x) \ [&]() { \ try { \ x; \ } catch (const out_of_range &oor) { \ return oorret; \ } \ return x; \ }() typedef long long ll; typedef pair<int, int> P; template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; } int n; int main() { cin >> n; string s; cin >> s; int l = n; vector<int> b(n, 0); vector<int> w(n, 0); vector<int> sb(n + 1, 0); vector<int> sw(n + 1, 0); vector<int> bp; REP(i, n) { if (s[i] == '.') { w[i] = 1; } else { bp.push_back(i); b[i] = 1; } } REP(i, n + 1) { sw[i + 1] = sw[i] + w[i]; sb[i + 1] = sb[i] + b[i]; } /*REP(i,n){ if(b[i]==1){ int temp = sb[i]-sb[0] + sw[n]- sw[i]; chmin(res,temp); } }*/ int res = bp.size(); REP(i, bp.size()) { int temp = i + sw[n] - sw[bp[i]]; chmin(res, temp); } put(res); return 0; }
#include "bits/stdc++.h" using namespace std; #define Rep(i, n) for (int i = 0; i < n; i++) #define For(i, n1, n2) for (int i = n1; i < n2; i++) #define REP(i, n) for (ll i = 0; i < n; i++) #define RREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, n1, n2) for (ll i = n1; i < n2; i++) #define put(a) cout << a << "\n" #define all(a) (a).begin(), (a).end() #define SORT(a) sort((a).begin(), (a).end()) #define oorret 0 #define oor(x) \ [&]() { \ try { \ x; \ } catch (const out_of_range &oor) { \ return oorret; \ } \ return x; \ }() typedef long long ll; typedef pair<int, int> P; template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; } int n; int main() { cin >> n; string s; cin >> s; int l = n; vector<int> b(n, 0); vector<int> w(n, 0); vector<int> sb(n + 1, 0); vector<int> sw(n + 1, 0); vector<int> bp; REP(i, n) { if (s[i] == '.') { w[i] = 1; } else { bp.push_back(i); b[i] = 1; } } REP(i, n) { sw[i + 1] = sw[i] + w[i]; sb[i + 1] = sb[i] + b[i]; } /*REP(i,n){ if(b[i]==1){ int temp = sb[i]-sb[0] + sw[n]- sw[i]; chmin(res,temp); } }*/ int res = bp.size(); REP(i, bp.size()) { int temp = i + sw[n] - sw[bp[i]]; chmin(res, temp); } put(res); return 0; }
[ "expression.operation.binary.remove" ]
877,018
877,019
u030685402
cpp
p03063
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) typedef long long ll; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; } return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c % mod; } a = a * a % mod; b >>= 1LL; } return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i % mod; } for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod) * inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; } for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } vector<vector<pair<int, int>>> Edge; vector<int> node; bool bellman_ford(int n, int s) { node = vector<int>(n, INF); node[s] = 0; REP(i, n) { REP(j, Edge.size()) { REP(k, Edge[j].size()) { int from = j, to = Edge[j][k].F; int cost = Edge[j][k].S; if (node[from] != INF && node[to] > node[from] + cost) { node[to] = node[from] + cost; if (i == n - 1 && to == n - 1) return true; } } } } return false; } signed main() { int n; cin >> n; string s; cin >> s; int bn = 0; REP(i, n) { if (s[i] == '#') bn++; } int spos = 0; if (bn == 0) { cout << 0 << endl; return 0; } int koremade = 0; int ans = INF; REP(i, n) { if (s[i] == '#') { ans = min(ans, n - i - bn + koremade); koremade++; } } cout << min(ans, bn) << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(), (c).end()) typedef long long ll; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1}; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; } return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c % mod; } a = a * a % mod; b >>= 1LL; } return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i % mod; } for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod) * inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; } for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } vector<vector<pair<int, int>>> Edge; vector<int> node; bool bellman_ford(int n, int s) { node = vector<int>(n, INF); node[s] = 0; REP(i, n) { REP(j, Edge.size()) { REP(k, Edge[j].size()) { int from = j, to = Edge[j][k].F; int cost = Edge[j][k].S; if (node[from] != INF && node[to] > node[from] + cost) { node[to] = node[from] + cost; if (i == n - 1 && to == n - 1) return true; } } } } return false; } signed main() { int n; cin >> n; string s; cin >> s; int bn = 0; REP(i, n) { if (s[i] == '#') bn++; } int spos = 0; if (bn == 0) { cout << 0 << endl; return 0; } int koremade = 0; int ans = INF; REP(i, n) { if (s[i] == '#') { ans = min(ans, n - i - bn + 2 * koremade); koremade++; } } cout << min(ans, bn) << endl; }
[ "assignment.change" ]
877,034
877,035
u764234894
cpp
p03063
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 2e5 + 5; string s; int preB[N], sufW[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> s; // ....### int len = s.length(); for (int i = 0; s[i]; i++) { if (i == 0) preB[i] = (s[i] == '#'); else preB[i] = preB[i - 1] + (s[i] == '#'); } for (int i = len - 1; i >= 0; i--) sufW[i] = sufW[i + 1] + (s[i] == '.'); int res = 1e9; for (int i = 0; i < len; i++) res = min(res, preB[i] + sufW[i + 1]); res = min(res, sufW[0]); cout << res << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 2e5 + 5; string s; int n, preB[N], sufW[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> s; // ....### int len = s.length(); for (int i = 0; s[i]; i++) { if (i == 0) preB[i] = (s[i] == '#'); else preB[i] = preB[i - 1] + (s[i] == '#'); } for (int i = len - 1; i >= 0; i--) sufW[i] = sufW[i + 1] + (s[i] == '.'); int res = 1e9; for (int i = 0; i < len; i++) res = min(res, preB[i] + sufW[i + 1]); res = min(res, sufW[0]); cout << res << '\n'; return 0; }
[ "variable_declaration.add" ]
877,055
877,056
u029340806
cpp
p03063
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define REP(i, n) for (auto i = 0; i < n; ++i) #define REPR(i, n) for (auto i = n; i >= 0; --i) #define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr) #define FOR(i, a, b) for (auto i = a; i < b; ++i) #define SORT(v, n) sort(v, v + n) #define SORTV(v) sort(v.begin(), v.end()) #define ALL(v) v.begin(), v.end() #define llong long long #define ll long long #define INF 999999999 #define MOD 1000000007 #define pb push_back #define pf push_front #define MP make_pair #define SV(n, v) \ { \ int tmp; \ for (int i = 0; i < n; ++i) { \ scanf("%d", &tmp); \ v.push_back(tmp); \ } \ } int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; using namespace std; typedef pair<int, int> pii; int main() { int n; string s; cin >> n >> s; int sum_w, sum_b; REP(i, n) { if (s[i] == '#') { sum_b++; } else { sum_w++; } } int ans = min(sum_w, sum_b); int w = 0, b = 0; REP(i, n - 1) { if (s[i] == '#') { b++; } else { w++; } ans = min(ans, b + sum_w - w); } cout << ans << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define REP(i, n) for (auto i = 0; i < n; ++i) #define REPR(i, n) for (auto i = n; i >= 0; --i) #define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr) #define FOR(i, a, b) for (auto i = a; i < b; ++i) #define SORT(v, n) sort(v, v + n) #define SORTV(v) sort(v.begin(), v.end()) #define ALL(v) v.begin(), v.end() #define llong long long #define ll long long #define INF 999999999 #define MOD 1000000007 #define pb push_back #define pf push_front #define MP make_pair #define SV(n, v) \ { \ int tmp; \ for (int i = 0; i < n; ++i) { \ scanf("%d", &tmp); \ v.push_back(tmp); \ } \ } int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; using namespace std; typedef pair<int, int> pii; int main() { int n; string s; cin >> n >> s; int sum_w = 0, sum_b = 0; REP(i, n) { if (s[i] == '#') { sum_b++; } else { sum_w++; } } int ans = min(sum_w, sum_b); int w = 0, b = 0; REP(i, n - 1) { if (s[i] == '#') { b++; } else { w++; } ans = min(ans, b + sum_w - w); } cout << ans << endl; return 0; }
[ "variable_declaration.value.change" ]
877,061
877,062
u479953984
cpp
p03063
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <utility> #include <vector> using namespace std; #define endl "\n" #define X first #define Y second #define Z third #define mp make_pair #define mt make_triple typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ld PI = 3.141592653589793; const ld E = 2.71828182845904523; const ll LLINF = 4000000009000000099; const ll INF = 1009000099; const ll MOD7 = 1000000007; const ll MOD9 = 1000000009; template <class A, class B, class C> struct triple { A first; B second; C third; triple(A, B, C); triple(); }; template <class A, class B, class C> triple<A, B, C>::triple(A a, B b, C c) { first = a; second = b; third = c; } template <class A, class B, class C> triple<A, B, C>::triple() {} template <class A, class B, class C> triple<A, B, C> make_triple(A a, B b, C c) { triple<A, B, C> t(a, b, c); return t; } template <class A, class B, class C> bool operator<(triple<A, B, C> a, triple<A, B, C> b) { if (a.first != b.first) return a.first < b.first; if (a.second != b.second) return a.second < b.second; if (a.third != b.third) return a.third < b.third; } template <class T> T inline sqr(T a) { return a * a; } ll bpow(ll a, ll d, ll mod) { if (d == 0) return 1; ll t = bpow(a, d / 2, mod); t = (t * t) % mod; if (d & 1) t = (t * a) % mod; return t; } ll bpow(ll a, ll d) { if (d == 0) return 1; ll t = bpow(a, d / 2); t = (t * t); if (d & 1) t = (t * a); return t; } ll gcd(ll a, ll b) { while (a && b) if (a > b) a %= b; else b %= a; return a + b; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll C(ll n, ll k) { ll res = 1; for (int i = 1; i <= k; ++i) res = res * (n - k + i) / i; return res; } ll C(ll n, ll k, ll mod) { ll u = 1, d = 1; for (int i = 2; i <= n; ++i) u = (u * i) % mod; int x = max(k, n - k), z = min(k, n - k); for (int i = 2; i <= x; ++i) { d = (d * i) % mod; if (i <= z) d = (d * i) % mod; } d = bpow(d, mod - 2, mod); ll res = (u * d) % mod; return res; } using namespace std; vector<ll> fact; vector<ll> invf; ll n_path(ll x, ll y) { return fact[x + y] * invf[x] % MOD7 * invf[y] % MOD7; } void solve() { int n; cin >> n; string s; cin >> s; vector<int> prefs(n); vector<int> sufd(n); prefs[0] = s[0] == '#'; sufd.back() = s.back() == '.'; for (int i = 1; i < n; ++i) { prefs[i] = prefs[i - 1] + (s[i] == '#'); sufd[n - i - 1] = sufd[n - i] + (s[n - i - 1] == '.'); } int ans = n + 1; for (int i = 0; i < n; ++i) if (s[i] == '#') ans = min(ans, prefs[i] - 1 + sufd[i]); cout << ans; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); #ifdef _DEBUG freopen("in.txt", "r", stdin); #else #endif solve(); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <utility> #include <vector> using namespace std; #define endl "\n" #define X first #define Y second #define Z third #define mp make_pair #define mt make_triple typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ld PI = 3.141592653589793; const ld E = 2.71828182845904523; const ll LLINF = 4000000009000000099; const ll INF = 1009000099; const ll MOD7 = 1000000007; const ll MOD9 = 1000000009; template <class A, class B, class C> struct triple { A first; B second; C third; triple(A, B, C); triple(); }; template <class A, class B, class C> triple<A, B, C>::triple(A a, B b, C c) { first = a; second = b; third = c; } template <class A, class B, class C> triple<A, B, C>::triple() {} template <class A, class B, class C> triple<A, B, C> make_triple(A a, B b, C c) { triple<A, B, C> t(a, b, c); return t; } template <class A, class B, class C> bool operator<(triple<A, B, C> a, triple<A, B, C> b) { if (a.first != b.first) return a.first < b.first; if (a.second != b.second) return a.second < b.second; if (a.third != b.third) return a.third < b.third; } template <class T> T inline sqr(T a) { return a * a; } ll bpow(ll a, ll d, ll mod) { if (d == 0) return 1; ll t = bpow(a, d / 2, mod); t = (t * t) % mod; if (d & 1) t = (t * a) % mod; return t; } ll bpow(ll a, ll d) { if (d == 0) return 1; ll t = bpow(a, d / 2); t = (t * t); if (d & 1) t = (t * a); return t; } ll gcd(ll a, ll b) { while (a && b) if (a > b) a %= b; else b %= a; return a + b; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll C(ll n, ll k) { ll res = 1; for (int i = 1; i <= k; ++i) res = res * (n - k + i) / i; return res; } ll C(ll n, ll k, ll mod) { ll u = 1, d = 1; for (int i = 2; i <= n; ++i) u = (u * i) % mod; int x = max(k, n - k), z = min(k, n - k); for (int i = 2; i <= x; ++i) { d = (d * i) % mod; if (i <= z) d = (d * i) % mod; } d = bpow(d, mod - 2, mod); ll res = (u * d) % mod; return res; } using namespace std; vector<ll> fact; vector<ll> invf; ll n_path(ll x, ll y) { return fact[x + y] * invf[x] % MOD7 * invf[y] % MOD7; } void solve() { int n; cin >> n; string s; cin >> s; vector<int> prefs(n); vector<int> sufd(n); prefs[0] = s[0] == '#'; sufd.back() = s.back() == '.'; for (int i = 1; i < n; ++i) { prefs[i] = prefs[i - 1] + (s[i] == '#'); sufd[n - i - 1] = sufd[n - i] + (s[n - i - 1] == '.'); } int ans = prefs.back(); for (int i = 0; i < n; ++i) if (s[i] == '#') ans = min(ans, prefs[i] - 1 + sufd[i]); cout << ans; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); #ifdef _DEBUG freopen("in.txt", "r", stdin); #else #endif solve(); return 0; }
[ "call.add" ]
877,069
877,070
u568370190
cpp
p03063
#include <bits/stdc++.h> using namespace std; #define ll long long inline ll read() { ll x = 0, f = 1; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -f; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return x * f; } inline void chkmin(int &a, int b) { if (a > b) a = b; } inline void chkmax(int &a, int b) { if (a < b) a = b; } #define _ read() int sum1[200005], sum2[200005]; int main() { int n = _, ans; string s; cin >> s; for (int i = 0; i < n; i++) { sum1[i + 1] = sum1[i]; sum2[i + 1] = sum2[i]; if (s[i] == '#') sum1[i + 1]++; else sum2[i + 1]++; } for (int i = 0; i <= n; i++) ans = min(ans, sum1[i] + sum2[n] - sum2[i]); cout << ans; }
#include <bits/stdc++.h> using namespace std; #define ll long long inline ll read() { ll x = 0, f = 1; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -f; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return x * f; } inline void chkmin(int &a, int b) { if (a > b) a = b; } inline void chkmax(int &a, int b) { if (a < b) a = b; } #define _ read() int sum1[200005], sum2[200005]; int main() { int n = _, ans = 2e9; string s; cin >> s; for (int i = 0; i < n; i++) { sum1[i + 1] = sum1[i]; sum2[i + 1] = sum2[i]; if (s[i] == '#') sum1[i + 1]++; //黑色 else sum2[i + 1]++; //白色 } for (int i = 0; i <= n; i++) ans = min(ans, sum1[i] + sum2[n] - sum2[i]); // 1~i为白色,i+1~n为黑色 cout << ans; }
[ "variable_declaration.value.change" ]
877,078
877,079
u900306103
cpp
p03063
#include <bits/stdc++.h> using namespace std; #define ll long long inline ll read() { ll x = 0, f = 1; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -f; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return x * f; } inline void chkmin(int &a, int b) { if (a > b) a = b; } inline void chkmax(int &a, int b) { if (a < b) a = b; } #define _ read() int sum1[100005], sum2[100005]; int main() { int n = _, ans; string s; cin >> s; for (int i = 0; i < n; i++) { sum1[i + 1] = sum1[i]; sum2[i + 1] = sum2[i]; if (s[i] == '#') sum1[i + 1]++; else sum2[i + 1]++; } for (int i = 0; i <= n; i++) ans = min(ans, sum1[i] + sum2[n] - sum2[i]); cout << ans; }
#include <bits/stdc++.h> using namespace std; #define ll long long inline ll read() { ll x = 0, f = 1; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -f; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return x * f; } inline void chkmin(int &a, int b) { if (a > b) a = b; } inline void chkmax(int &a, int b) { if (a < b) a = b; } #define _ read() int sum1[200005], sum2[200005]; int main() { int n = _, ans = 2e9; string s; cin >> s; for (int i = 0; i < n; i++) { sum1[i + 1] = sum1[i]; sum2[i + 1] = sum2[i]; if (s[i] == '#') sum1[i + 1]++; //黑色 else sum2[i + 1]++; //白色 } for (int i = 0; i <= n; i++) ans = min(ans, sum1[i] + sum2[n] - sum2[i]); // 1~i为白色,i+1~n为黑色 cout << ans; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "variable_declaration.value.change" ]
877,080
877,079
u900306103
cpp
p03063
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define pie 3.141592653589793238462643383279 #define mod 1000000007 #define inf 10000000000000007 #define all(vec) vec.begin(), vec.end() #define ggr \ getchar(); \ getchar(); \ return 0; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } bool prime(int x) { for (int i = 2; i <= sqrt(x); i++) { if (x % i == 0) return false; } return true; } int kai(int x) { if (x == 1) return 1; return kai(x - 1) * x; } int mod_pow(int x, int y, int moder) { int res = 1; while (y > 0) { if (y & 1) res = res * x % moder; x = x * x % moder; y >>= 1; } return res; } int n; string s; int ans = inf; int ta, mu; int rin, wa; signed main() { cin >> n >> s; rep(i, s.size()) { if (s[i] == '.') mu++; } rep(i, s.size()) { ans = min(ans, ta + mu); if (s[i] == '#') rin++; else mu--; } ans = min(ans, ta + mu); cout << ans << endl; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define pie 3.141592653589793238462643383279 #define mod 1000000007 #define inf 10000000000000007 #define all(vec) vec.begin(), vec.end() #define ggr \ getchar(); \ getchar(); \ return 0; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } bool prime(int x) { for (int i = 2; i <= sqrt(x); i++) { if (x % i == 0) return false; } return true; } int kai(int x) { if (x == 1) return 1; return kai(x - 1) * x; } int mod_pow(int x, int y, int moder) { int res = 1; while (y > 0) { if (y & 1) res = res * x % moder; x = x * x % moder; y >>= 1; } return res; } int n; string s; int ans = inf; int ta, mu; signed main() { cin >> n >> s; rep(i, s.size()) { if (s[i] == '.') mu++; } rep(i, s.size()) { ans = min(ans, ta + mu); if (s[i] == '#') ta++; else mu--; } ans = min(ans, ta + mu); cout << ans << endl; }
[ "variable_declaration.remove", "identifier.change" ]
877,085
877,086
u277153875
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b > a) return gcd(b, a); else if (b == 0) return a; return gcd(b, a % b); } int main() { int N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); long long res = 1; vector<long long> L(N + 1); vector<long long> R(N + 1); L[0] = 0; R[N] = 0; for (int i = 1; i < N + 1; i++) { L[i] = __gcd(L[i - 1], A[i - 1]); } for (int i = N - 1; i >= 0; i--) { R[i] = __gcd(R[i + 1], A[i]); } for (int i = 0; i < N - 1; i++) { res = max(res, __gcd(L[i], R[i + 1])); } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b > a) return gcd(b, a); else if (b == 0) return a; return gcd(b, a % b); } int main() { int N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); long long res = 1; vector<long long> L(N + 1); vector<long long> R(N + 1); L[0] = 0; R[N] = 0; for (int i = 1; i < N + 1; i++) { L[i] = __gcd(L[i - 1], A[i - 1]); } for (int i = N - 1; i >= 0; i--) { R[i] = __gcd(R[i + 1], A[i]); } for (int i = 0; i < N; i++) { res = max(res, __gcd(L[i], R[i + 1])); } cout << res << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
877,121
877,122
u074014027
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd1[100000]; int gcd2[100000]; int gcd(int a, int b) { if (a < b) { swap(a, b); } if (a % b == 0) { return b; } else { return gcd(b, a % b); } } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } gcd1[0] = a[0]; for (int i = 1; i < n; i++) { gcd1[i] = gcd(gcd1[i - i], a[i]); } gcd2[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { gcd2[i] = gcd(gcd2[i + 1], a[i]); } int ans = 0; for (int i = 0; i < n; i++) { if (i == 0) { ans = max(ans, gcd2[1]); } else if (i == n - 1) { ans = max(ans, gcd1[n - 2]); } else { ans = max(ans, gcd(gcd1[i - 1], gcd2[i + 1])); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd1[100000]; int gcd2[100000]; int gcd(int a, int b) { if (a < b) { swap(a, b); } if (a % b == 0) { return b; } else { return gcd(b, a % b); } } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } 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]); } int ans = 0; for (int i = 0; i < n; i++) { if (i == 0) { ans = max(ans, gcd2[1]); } else if (i == n - 1) { ans = max(ans, gcd1[n - 2]); } else { ans = max(ans, gcd(gcd1[i - 1], gcd2[i + 1])); } } cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
877,123
877,124
u115086397
cpp
p03061
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ int GCD(int a, int b) { if (a < b) GCD(b, a); int r; while ((r = a % b)) { a = b; b = r; } return b; } void _main() { int N; cin >> N; vector<int> A(N); rep(i, 0, N) cin >> A[i]; vector<int> a(N); vector<int> b(N); a[0] = A[0]; b[N - 1] = A[N - 1]; rep(i, 0, N - 1) { a[i + 1] = GCD(A[i], A[i + 1]); } rrep(i, N - 1, 1) { b[i - 1] = GCD(A[i - 1], A[i]); } int ans = 0; rep(i, 0, N) { if (i == 0) { chmax(ans, b[i + 1]); } else if (i == N - 1) { chmax(ans, a[i - 1]); } else { chmax(ans, GCD(a[i - 1], b[i + 1])); } } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ int GCD(int a, int b) { if (a < b) GCD(b, a); int r; while ((r = a % b)) { a = b; b = r; } return b; } void _main() { int N; cin >> N; vector<int> A(N); rep(i, 0, N) cin >> A[i]; vector<int> a(N); vector<int> b(N); a[0] = A[0]; b[N - 1] = A[N - 1]; rep(i, 0, N - 1) { a[i + 1] = GCD(a[i], A[i + 1]); } rrep(i, N - 1, 1) { b[i - 1] = GCD(A[i - 1], b[i]); } /* rep(i, 0, N) { cout << a[i] << " "; } cout << endl; rep(i, 0, N) { cout << b[i] << " "; } cout << endl; */ int ans = 0; rep(i, 0, N) { if (i == 0) { chmax(ans, b[i + 1]); } else if (i == N - 1) { chmax(ans, a[i - 1]); } else { chmax(ans, GCD(a[i - 1], b[i + 1])); } } cout << ans << endl; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
877,132
877,133
u532065884
cpp
p03061
#include <bits/stdc++.h> using namespace std; int main(void) { long long n; vector<long long> a; cin >> n; for (int i = 0; i < n; ++i) { long long tmp; cin >> tmp; a.push_back(tmp); } long long l[100010], r[100010]; l[0] = r[n] = 0; for (int i = 1; i <= n; ++i) { l[i] = __gcd(l[i - 1], a[i - 1]); r[n - i] = __gcd(r[n - i + 1], a[n - i]); } long long ans; ans = 0; for (int i = 1; i < n; ++i) { ans = max(ans, __gcd(l[i], r[i + 1])); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { long long n; vector<long long> a; cin >> n; for (int i = 0; i < n; ++i) { long long tmp; cin >> tmp; a.push_back(tmp); } long long l[100010], r[100010]; l[0] = r[n] = 0; for (int i = 1; i <= n; ++i) { l[i] = __gcd(l[i - 1], a[i - 1]); r[n - i] = __gcd(r[n - i + 1], a[n - i]); } long long ans; ans = 0; for (int i = 0; i < n; ++i) { ans = max(ans, __gcd(l[i], r[i + 1])); } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
877,136
877,137
u464540027
cpp
p03061
#include <algorithm> #include <iostream> #include <string> using namespace std; int gcd(int m, int n); int a[100010]; int l[100010]; int r[100010]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < n; j++) { if (j == 0) l[j] = a[0]; else { l[j] = gcd(l[j - 1], a[j]); } if (j == 0) r[j] = a[n - 1]; else { r[j] = gcd(r[j - 1], a[n - 1 - j]); } } int ans = max(l[n - 2], r[n - 2]); int tmp; for (int k = 1; k < n - 1; k++) { tmp = gcd(l[k - 1], r[n - 2 - k]); if (tmp > ans) ans = tmp; } cout << ans << endl; cin >> n; return 0; } int gcd(int m, int n) //ユークリッドの互除法 { if ((0 == m) || (0 == n)) return 0; while ((m != n) && ((0 != m) && (0 != n))) { if (m > n) m = m % n; else n = n % m; } return m; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int gcd(int m, int n); int a[100010]; int l[100010]; int r[100010]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < n; j++) { if (j == 0) l[j] = a[0]; else { l[j] = gcd(l[j - 1], a[j]); } if (j == 0) r[j] = a[n - 1]; else { r[j] = gcd(r[j - 1], a[n - 1 - j]); } } int ans = max(l[n - 2], r[n - 2]); int tmp; for (int k = 1; k < n - 1; k++) { tmp = gcd(l[k - 1], r[n - 2 - k]); if (tmp > ans) ans = tmp; } cout << ans << endl; cin >> n; return 0; } int gcd(int m, int n) //ユークリッドの互除法 { if ((0 == m) || (0 == n)) return 0; while ((m != n) && ((0 != m) && (0 != n))) { if (m > n) m = m % n; else n = n % m; } return max(m, n); }
[ "call.add", "call.arguments.add" ]
877,138
877,139
u125468789
cpp
p03061
#include <iostream> #include <vector> using namespace std; using ull = unsigned long long; ull gcd(ull u, ull v) { ull shift; if (u == 0) return v; if (v == 0) return u; shift = __builtin_ctzll(u | v); u >>= __builtin_ctzll(u); do { v >>= __builtin_ctzll(v); if (u > v) { ull t = v; v = u; u = t; } v = v - u; } while (v != 0); return u << shift; } int main() { size_t n; cin >> n; std::vector<ull> vec(n); std::vector<ull> left(n); std::vector<ull> right(n); for (size_t i = 0; i < n; i++) { cin >> vec[i]; } ull p1 = 0, p2 = 0; for (size_t i = 0, j = n - 1; i < n; i++) { p1 = gcd(vec[i], p1); p2 = gcd(vec[j], p2); left[i] = p1; right[j] = p2; j--; } ull mval = max(left[1], right[n - 2]); mval = max(p1, mval); auto m = n - 1; for (size_t i = 1; i < m; i++) { mval = max(mval, gcd(left[i - 1], right[i + 1])); } cout << mval << endl; return 0; }
#include <iostream> #include <vector> using namespace std; using ull = unsigned long long; ull gcd(ull u, ull v) { ull shift; if (u == 0) return v; if (v == 0) return u; shift = __builtin_ctzll(u | v); u >>= __builtin_ctzll(u); do { v >>= __builtin_ctzll(v); if (u > v) { ull t = v; v = u; u = t; } v = v - u; } while (v != 0); return u << shift; } int main() { size_t n; cin >> n; std::vector<ull> vec(n); std::vector<ull> left(n); std::vector<ull> right(n); for (size_t i = 0; i < n; i++) { cin >> vec[i]; } ull p1 = 0, p2 = 0; for (size_t i = 0, j = n - 1; i < n; i++) { p1 = gcd(vec[i], p1); p2 = gcd(vec[j], p2); left[i] = p1; right[j] = p2; j--; } ull mval = max(right[1], left[n - 2]); mval = max(p1, mval); auto m = n - 1; for (size_t i = 1; i < m; i++) { mval = max(mval, gcd(left[i - 1], right[i + 1])); } cout << mval << endl; return 0; }
[ "identifier.change", "call.arguments.change" ]
877,153
877,154
u977980482
cpp
p03061
#include <algorithm> #include <iostream> #include <vector> long long gcd(long long a, long long b) { long long temp; if (a < b) { temp = b; b = a; a = temp; } if (b == 0) return a; while (a % b != 0) { temp = a % b; a = b; b = temp; } return b; } using namespace std; int main() { int n; cin >> n; vector<long long> vec(n, 0), Lvec(n + 1, 0), Rvec(n + 1, 0), ans(n + 1, 0); for (int i = 0; i < n; i++) cin >> vec[i]; for (int i = 1; i < n - 1; i++) { Lvec[i] = gcd(Lvec[i - 1], vec[i]); Rvec[n - i - 1] = gcd(Rvec[n - i], vec[n - i]); } for (int i = 0; i < n; i++) ans[i] = gcd(Lvec[i], Rvec[i]); sort(ans.rbegin(), ans.rend()); cout << ans[0]; }
#include <algorithm> #include <iostream> #include <vector> long long gcd(long long a, long long b) { long long temp; if (a < b) { temp = b; b = a; a = temp; } if (b == 0) return a; while (a % b != 0) { temp = a % b; a = b; b = temp; } return b; } using namespace std; int main() { int n; cin >> n; vector<long long> vec(n, 0), Lvec(n + 2, 0), Rvec(n + 2, 0), ans(n + 1, 0); for (int i = 0; i < n; i++) cin >> vec[i]; for (int i = 1; i < n; i++) { Lvec[i] = gcd(Lvec[i - 1], vec[i - 1]); Rvec[n - i - 1] = gcd(Rvec[n - i], vec[n - i]); } for (int i = 0; i < n; i++) ans[i] = gcd(Lvec[i], Rvec[i]); sort(ans.rbegin(), ans.rend()); cout << ans[0]; }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "assignment.change" ]
877,158
877,159
u950603962
cpp
p03061
using namespace std; #include <algorithm> #include <iostream> #include <string> #include <vector> #define ll long long #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) int main() { int N; cin >> N; int A[N]; rep(i, N) cin >> A[i]; int ans; if (N > 2) { int gcd_l[N]; gcd_l[0] = 0; for (int i = 1; i < N; i++) { gcd_l[i] = __gcd(gcd_l[i - 1], A[i]); } int gcd_r[N]; gcd_r[N - 1] = 0; for (int i = N - 2; i >= 0; i--) { gcd_r[i] = __gcd(gcd_r[i + 1], A[i]); } ans = 1; for (int i = 0; i < N; i++) { int tmp0 = gcd_r[i]; int tmp1 = gcd_l[i]; int tmp = __gcd(tmp0, tmp1); ans = max(tmp, ans); } } else { ans = max(A[0], A[1]); } cout << ans << endl; return 0; }
using namespace std; #include <algorithm> #include <iostream> #include <string> #include <vector> #define ll long long #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) int main() { int N; cin >> N; int A[N]; rep(i, N) cin >> A[i]; int ans; if (N > 2) { int gcd_l[N]; gcd_l[0] = 0; for (int i = 1; i < N; i++) { gcd_l[i] = __gcd(gcd_l[i - 1], A[i - 1]); } int gcd_r[N]; gcd_r[N - 1] = 0; for (int i = N - 2; i >= 0; i--) { gcd_r[i] = __gcd(gcd_r[i + 1], A[i + 1]); } ans = 1; for (int i = 0; i < N; i++) { int tmp0 = gcd_r[i]; int tmp1 = gcd_l[i]; int tmp = __gcd(tmp0, tmp1); ans = max(tmp, ans); } } else { ans = max(A[0], A[1]); } cout << ans << endl; return 0; }
[ "assignment.change" ]
877,160
877,161
u981068718
cpp
p03061
#include <bits/stdc++.h> typedef long long ll; using namespace std; int arr[100005], seg[4 * 100005]; int gcd(int a, int b) { if (a * b == 0) return a ? a : b; while (a % b != 0) { a = a % b; swap(a, b); } return b; } void build(int index, int left, int right) { if (left == right) { seg[index] = arr[left]; return; } int mid = (left + right) / 2; build(2 * index, left, mid); build(2 * index + 1, mid + 1, right); seg[index] = gcd(seg[2 * index], seg[2 * index] + 1); } int query(int index, int left, int right, int lo, int hi) { if (lo > hi) return 0; if (lo <= left && right <= hi) return seg[index]; int mid = (left + right) / 2; if (hi <= mid) return query(2 * index, left, mid, lo, hi); if (lo > mid) return query(2 * index + 1, mid + 1, right, lo, hi); return gcd(query(2 * index, left, mid, lo, hi), query(2 * index + 1, mid + 1, right, lo, hi)); } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> arr[i]; build(1, 1, n); int ans = 1; for (int i = 1; i <= n; ++i) ans = max(ans, gcd(query(1, 1, n, 1, i - 1), query(1, 1, n, i + 1, n))); cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; int arr[100005], seg[4 * 100005]; int gcd(int a, int b) { if (a * b == 0) return a ? a : b; while (a % b != 0) { a = a % b; swap(a, b); } return b; } void build(int index, int left, int right) { if (left == right) { seg[index] = arr[left]; return; } int mid = (left + right) / 2; build(2 * index, left, mid); build(2 * index + 1, mid + 1, right); seg[index] = gcd(seg[2 * index], seg[2 * index + 1]); } int query(int index, int left, int right, int lo, int hi) { if (lo > hi) return 0; if (lo <= left && right <= hi) return seg[index]; int mid = (left + right) / 2; if (hi <= mid) return query(2 * index, left, mid, lo, hi); if (lo > mid) return query(2 * index + 1, mid + 1, right, lo, hi); return gcd(query(2 * index, left, mid, lo, hi), query(2 * index + 1, mid + 1, right, lo, hi)); } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> arr[i]; build(1, 1, n); int ans = 1; for (int i = 1; i <= n; ++i) ans = max(ans, gcd(query(1, 1, n, 1, i - 1), query(1, 1, n, i + 1, n))); cout << ans << '\n'; return 0; }
[ "call.arguments.change" ]
877,165
877,166
u023397458
cpp
p03061
#include <algorithm> #include <iostream> using namespace std; const int N = 1e5 + 9; int s[N], l[N], r[N]; int main(void) { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> s[i]; l[0] = 0; l[1] = s[1]; for (int i = 2; i < n; ++i) l[i] = __gcd(s[i], s[i - 1]); r[n + 1] = 0; r[n] = s[n]; for (int i = n - 1; i >= 0; --i) r[i] = __gcd(s[i], s[i + 1]); int ans = 0; for (int i = 1; i <= n; ++i) { ans = max(__gcd(l[i - 1], r[i + 1]), ans); } cout << ans << '\n'; return 0; }
#include <algorithm> #include <iostream> using namespace std; const int N = 1e5 + 9; int s[N], l[N], r[N]; int main(void) { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> s[i]; l[0] = 0; l[1] = s[1]; for (int i = 2; i < n; ++i) l[i] = __gcd(s[i], l[i - 1]); r[n + 1] = 0; r[n] = s[n]; for (int i = n - 1; i >= 0; --i) r[i] = __gcd(s[i], r[i + 1]); int ans = 0; for (int i = 1; i <= n; ++i) { ans = max(__gcd(l[i - 1], r[i + 1]), ans); } cout << ans << '\n'; return 0; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
877,175
877,176
u777148280
cpp
p03061
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int gcd(int A, int B) { if (A == 0) return B; if (B == 0) return A; int tmp; if (B > A) { tmp = B; B = A; A = tmp; } int r; while (1) { r = A % B; A = B; if (r == 0) { return B; } B = r; } } int main(void) { int N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector<vector<long>> ans_vec(N + 2, vector<long>(2)); ans_vec[1][0] = A[0]; ans_vec[N][1] = A[N - 1]; ans_vec[0][0] = 0; ans_vec[N + 1][1] = 0; for (int i = 1; i < N; i++) { ans_vec[i][0] = gcd(A[i - 1], ans_vec[i - 1][0]); ans_vec[N - i + 1][1] = gcd(A[N - i], ans_vec[N - i + 2][1]); } long long ans = 0; for (int i = 0; i < N - 1; i++) { long long gcd_i = gcd(ans_vec[i][0], ans_vec[i + 2][1]); if (ans < gcd_i) ans = gcd_i; } cout << ans << endl; // cout << gcd(12,18) << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int gcd(int A, int B) { if (A == 0) return B; if (B == 0) return A; int tmp; if (B > A) { tmp = B; B = A; A = tmp; } int r; while (1) { r = A % B; A = B; if (r == 0) { return B; } B = r; } } int main(void) { int N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector<vector<long>> ans_vec(N + 2, vector<long>(2)); ans_vec[1][0] = A[0]; ans_vec[N][1] = A[N - 1]; ans_vec[0][0] = 0; ans_vec[N + 1][1] = 0; for (int i = 1; i < N; i++) { ans_vec[i][0] = gcd(A[i - 1], ans_vec[i - 1][0]); ans_vec[N - i + 1][1] = gcd(A[N - i], ans_vec[N - i + 2][1]); } long long ans = 0; for (int i = 0; i < N; i++) { long long gcd_i = gcd(ans_vec[i][0], ans_vec[i + 2][1]); if (ans < gcd_i) ans = gcd_i; } cout << ans << endl; // cout << gcd(12,18) << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
877,179
877,180
u761510695
cpp
p03061
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> //#include<bits/stdc++.h> using namespace std; #define ok1 printf("ok1\n"); #define ok2 printf("ok2\n"); #define M 1000000000000000000LL #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, s, n) for (int i = (s); i < (n); ++i) #define repr(i, n) for (int i = n - 1; i >= 0; --i) #define REPR(i, s, n) for (int i = (s); i >= (n); --(i)) #define all(a) (a).begin(), (a).end() #define reall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front #define MIN(a, b) a = min((a), (b)) #define MAX(a, b) a = max((a), (b)) #define SIZE(v) (int)v.size() const double pi = acos(-1.0); typedef vector<int> vi; typedef vector<string> vs; typedef long long ll; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<double> vd; typedef vector<bool> vb; typedef deque<ll> dll; typedef pair<ll, ll> P; typedef vector<P> vP; using Edge = pair<int, ll>; using Graph = vector<vector<Edge>>; const ll mod = 1e9 + 7; ll dx[4] = {1, 0, -1, 0}; ll dy[4] = {0, 1, 0, -1}; void printvll(vll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) cout << v[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void printvvll(vvll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) { rep(j, v[i].size()) { cout << v[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void prints(string s) { cout << "------------------------------------------------\n"; rep(i, s.size()) cout << s[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void printvs(vs s) { cout << "------------------------------------------------\n"; rep(i, s.size()) { rep(j, s[i].size()) { cout << s[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void Yes(bool x) { if (x) cout << "Yes\n"; else cout << "No\n"; } void YES(bool x) { if (x) cout << "YES\n"; else cout << "NO\n"; } void yes(bool x) { if (x) cout << "yes\n"; else cout << "no\n"; } void Yay(bool x) { if (x) cout << "Yay!\n"; else cout << ":(\n"; } ll gcd(ll x, ll y) { ll r; while ((r = x % y) != 0) { x = y; y = r; } return y; } ll lcm(ll x, ll y) { x /= gcd(x, y); y /= gcd(x, y); return (x * y); } ll d, n, r, l, k, ans = 0, ret = M; bool flag = false, flag2 = false, flag3 = false; string s, t; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vll v(n); rep(i, n) cin >> v[i]; vll a(n + 1, 0), b(n + 1, 0); REP(i, 1, n + 1) { a[i] = gcd(a[i - 1], v[i - 1]); b[i] = gcd(b[i - 1], v[n - i]); } // printvll(a); // printvll(b); ans = max(a[n], b[n]); REP(i, 1, n - 1) ans = max(ans, gcd(a[i], b[n - i - 1])); cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> //#include<bits/stdc++.h> using namespace std; #define ok1 printf("ok1\n"); #define ok2 printf("ok2\n"); #define M 1000000000000000000LL #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, s, n) for (int i = (s); i < (n); ++i) #define repr(i, n) for (int i = n - 1; i >= 0; --i) #define REPR(i, s, n) for (int i = (s); i >= (n); --(i)) #define all(a) (a).begin(), (a).end() #define reall(a) (a).rbegin(), (a).rend() #define pb push_back #define pf push_front #define MIN(a, b) a = min((a), (b)) #define MAX(a, b) a = max((a), (b)) #define SIZE(v) (int)v.size() const double pi = acos(-1.0); typedef vector<int> vi; typedef vector<string> vs; typedef long long ll; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<double> vd; typedef vector<bool> vb; typedef deque<ll> dll; typedef pair<ll, ll> P; typedef vector<P> vP; using Edge = pair<int, ll>; using Graph = vector<vector<Edge>>; const ll mod = 1e9 + 7; ll dx[4] = {1, 0, -1, 0}; ll dy[4] = {0, 1, 0, -1}; void printvll(vll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) cout << v[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void printvvll(vvll v) { cout << "------------------------------------------------\n"; rep(i, v.size()) { rep(j, v[i].size()) { cout << v[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void prints(string s) { cout << "------------------------------------------------\n"; rep(i, s.size()) cout << s[i] << " "; cout << endl; cout << "------------------------------------------------\n"; } void printvs(vs s) { cout << "------------------------------------------------\n"; rep(i, s.size()) { rep(j, s[i].size()) { cout << s[i][j] << " "; } cout << endl; } cout << "------------------------------------------------\n"; } void Yes(bool x) { if (x) cout << "Yes\n"; else cout << "No\n"; } void YES(bool x) { if (x) cout << "YES\n"; else cout << "NO\n"; } void yes(bool x) { if (x) cout << "yes\n"; else cout << "no\n"; } void Yay(bool x) { if (x) cout << "Yay!\n"; else cout << ":(\n"; } ll gcd(ll x, ll y) { ll r; while ((r = x % y) != 0) { x = y; y = r; } return y; } ll lcm(ll x, ll y) { x /= gcd(x, y); y /= gcd(x, y); return (x * y); } ll d, n, r, l, k, ans = 0, ret = M; bool flag = false, flag2 = false, flag3 = false; string s, t; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vll v(n); rep(i, n) cin >> v[i]; vll a(n + 1, 0), b(n + 1, 0); REP(i, 1, n + 1) { a[i] = gcd(a[i - 1], v[i - 1]); b[i] = gcd(b[i - 1], v[n - i]); } // printvll(a); // printvll(b); ans = max(a[n - 1], b[n - 1]); REP(i, 1, n - 1) ans = max(ans, gcd(a[i], b[n - i - 1])); cout << ans << endl; return 0; }
[ "assignment.change" ]
877,208
877,209
u373958718
cpp
p03061
#include <iostream> using namespace std; void swap(int &a, int &b) { int t = a; a = b; b = t; } int gcd(int a, int b) { if (a < b) swap(a, b); while (b) { a = a % b; swap(a, b); } return a; } int main() { int A[100005]; int N; cin >> N; for (int i = 1; i <= N; i++) cin >> A[i]; int L[100005]; int R[100004]; L[N + 1] = 0; R[0] = 0; for (int i = 1; i <= N; i++) { L[i] = gcd(L[i - 1], A[i]); } for (int j = N; j > 0; j--) { R[j] = gcd(R[j + 1], A[j]); } int ans = 1000000001; for (int i = 1; i <= N; i++) { int k = gcd(L[i - 1], R[i + 1]); if (ans > k) ans = k; } cout << ans << endl; // cout << gcd(39, 13) << endl; }
#include <iostream> using namespace std; void swap(int &a, int &b) { int t = a; a = b; b = t; } int gcd(int a, int b) { if (a < b) swap(a, b); while (b) { a = a % b; swap(a, b); } return a; } int main() { int A[100005]; int N; cin >> N; for (int i = 1; i <= N; i++) cin >> A[i]; int L[100005]; int R[100004]; L[N + 1] = 0; R[0] = 0; for (int i = 1; i <= N; i++) { L[i] = gcd(L[i - 1], A[i]); } for (int j = N; j > 0; j--) { R[j] = gcd(R[j + 1], A[j]); } int ans = 0; for (int i = 1; i <= N; i++) { int k = gcd(L[i - 1], R[i + 1]); if (ans < k) ans = k; } cout << ans << endl; // cout << gcd(39, 13) << endl; }
[ "literal.number.change", "variable_declaration.value.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
877,210
877,211
u058186113
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0) { return b; } if (b == 0) { return a; } if (a < b) gcd(b, a); int r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { int N; cin >> N; vector<int> A; int tmp; for (int i = 0; i < N; i++) { cin >> tmp; A.push_back(tmp); } vector<int> L, R; L.push_back(0); R.push_back(0); for (int i = 0; i < N; i++) { L.push_back(gcd(L[i], A[i])); R.push_back(gcd(R[i], A[N - 1 - i])); } reverse(R.begin(), R.end()); vector<int> M; for (int i = 0; i < N - 1; i++) { M.push_back(gcd(L[i], R[i + 1])); } sort(M.begin(), M.end()); cout << M.back() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0) { return b; } if (b == 0) { return a; } if (a < b) gcd(b, a); int r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { int N; cin >> N; vector<int> A; int tmp; for (int i = 0; i < N; i++) { cin >> tmp; A.push_back(tmp); } vector<int> L, R; L.push_back(0); R.push_back(0); for (int i = 0; i < N; i++) { L.push_back(gcd(L[i], A[i])); R.push_back(gcd(R[i], A[N - 1 - i])); } reverse(R.begin(), R.end()); // cout << "L : "; // for (int i=0; i<=N; i++) { // cout << L[i] << " "; // } // cout << endl; // cout << "R : "; // for (int i=0; i<=N; i++) { // cout << R[i] << " "; // } // cout << endl; vector<int> M; for (int i = 0; i < N; i++) { // cout << "L : " << L[i] << " R : " << R[i+1]; M.push_back(gcd(L[i], R[i + 1])); // cout << " M : " << M.back() << endl; } sort(M.begin(), M.end()); cout << M.back() << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
877,212
877,213
u269804060
cpp
p03061
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define llong long long #define pb(a) push_back(a) #define INF 999999999999 #define MOD 1000000007 using namespace std; typedef pair<int, int> P; typedef pair<llong, llong> LP; typedef pair<int, P> PP; typedef pair<llong, LP> LPP; typedef vector<llong> LV; int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; llong gcd(llong a, llong b) { if (a < b) gcd(b, a); llong r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { llong N; cin >> N; llong ans = 1; LV A(N); LV before_r(N), after_r(N), before_l(N), after_l(N); REP(i, N) { cin >> A[i]; } after_r[N - 1] = before_r[N - 1] = A[N - 1]; REPR(i, N - 2) { before_r[i] = after_r[i + 1]; after_r[i] = gcd(A[i], before_r[i]); } before_l[0] = after_l[0] = A[0]; FOR(i, 1, N) { before_l[i] = after_l[i - 1]; after_l[i] = gcd(before_l[i], A[i]); } llong ngcd = after_r[0]; llong min_notg = INF; // REP(i,N){ // cout << before_l[i] << " "; // } // cout << "e" << endl; // REP(i,N){ // cout << before_r[i] << " "; // } LV notme(N); FOR(i, 1, N - 1) { notme[i] = gcd(before_l[i], before_r[i]); } notme[0] = before_r[0]; notme[N - 1] = before_l[N - 1]; sort(notme.begin(), notme.end()); ans = notme[0]; REP(i, N) { if (notme[i] != ans) { ans = notme[i]; break; } } cout << ans << endl; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for (int i = m; i >= n; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define llong long long #define pb(a) push_back(a) #define INF 999999999999 #define MOD 1000000007 using namespace std; typedef pair<int, int> P; typedef pair<llong, llong> LP; typedef pair<int, P> PP; typedef pair<llong, LP> LPP; typedef vector<llong> LV; int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; llong gcd(llong a, llong b) { if (a < b) gcd(b, a); llong r; while ((r = a % b)) { a = b; b = r; } return b; } int main() { llong N; cin >> N; llong ans = 1; LV A(N); LV before_r(N), after_r(N), before_l(N), after_l(N); REP(i, N) { cin >> A[i]; } after_r[N - 1] = before_r[N - 1] = A[N - 1]; REPR(i, N - 2) { before_r[i] = after_r[i + 1]; after_r[i] = gcd(A[i], before_r[i]); } before_l[0] = after_l[0] = A[0]; FOR(i, 1, N) { before_l[i] = after_l[i - 1]; after_l[i] = gcd(before_l[i], A[i]); } llong ngcd = after_r[0]; llong min_notg = INF; // REP(i,N){ // cout << before_l[i] << " "; // } // cout << "e" << endl; // REP(i,N){ // cout << before_r[i] << " "; // } LV notme(N); FOR(i, 1, N - 1) { notme[i] = gcd(before_l[i], before_r[i]); } notme[0] = before_r[0]; notme[N - 1] = before_l[N - 1]; sort(notme.begin(), notme.end()); ans = notme[0]; REPR(i, N - 1) { if (notme[i] != ans) { ans = notme[i]; break; } } cout << ans << endl; }
[ "expression.operation.binary.add" ]
877,214
877,215
u186359321
cpp
p03061
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; // const ll MOD = 1000000007; // const int INF = 2000000000; int gcd(int a, int b) { if (a < b) { return gcd(b, a); } while (a % b != 0) { int tmp = b; b = a % b; a = tmp; } return b; } int N; vector<int> A; vector<int> cum_A; vector<int> cum_rev_A; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; A.resize(N); for (int i = 0; i < N; i++) { cin >> A[i]; } cum_A.resize(N, 0); cum_A[0] = A[0]; for (int i = 1; i < N; i++) { cum_A[i] = gcd(cum_A[i - 1], A[i]); } cum_rev_A.resize(N, 0); cum_rev_A[0] = A[N - 1]; for (int i = 1; i < N; i++) { cum_rev_A[i] = gcd(cum_rev_A[i - 1], A[N - i - 1]); } int ans = 0; for (int i = 0; i < N; i++) { if (i == 0) { ans = max(ans, cum_rev_A[N - 2]); } else if (i == N - 1) { ans = max(ans, cum_A[N - 2]); } else { ans = max(ans, gcd(cum_A[i - 1], cum_rev_A[i - 1])); } } cout << ans << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; // const ll MOD = 1000000007; // const int INF = 2000000000; int gcd(int a, int b) { if (a < b) { return gcd(b, a); } while (a % b != 0) { int tmp = b; b = a % b; a = tmp; } return b; } int N; vector<int> A; vector<int> cum_A; vector<int> cum_rev_A; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; A.resize(N); for (int i = 0; i < N; i++) { cin >> A[i]; } cum_A.resize(N, 0); cum_A[0] = A[0]; for (int i = 1; i < N; i++) { cum_A[i] = gcd(cum_A[i - 1], A[i]); } cum_rev_A.resize(N, 0); cum_rev_A[0] = A[N - 1]; for (int i = 1; i < N; i++) { cum_rev_A[i] = gcd(cum_rev_A[i - 1], A[N - i - 1]); } int ans = 0; for (int i = 0; i < N; i++) { if (i == 0) { ans = max(ans, cum_rev_A[N - 2]); } else if (i == N - 1) { ans = max(ans, cum_A[N - 2]); } else { ans = max(ans, gcd(cum_A[i - 1], cum_rev_A[N - i - 2])); } } cout << ans << endl; return 0; }
[ "assignment.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
877,218
877,219
u751964641
cpp
p03061
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); int cnt; for (int i = a[0]; i > 0; i--) { cnt = 0; for (int j = 0; j < n; j++) { if (a[j] % i != 0) ++cnt; if (cnt == 2) { break; } } if (cnt == 0 || cnt == 1) { cout << i << endl; break; } if (i == 1) { cout << 1 << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); int cnt; for (int i = a[1]; i > 0; i--) { cnt = 0; for (int j = 0; j < n; j++) { if (a[j] % i != 0) ++cnt; if (cnt == 2) { break; } } if (cnt == 0 || cnt == 1) { cout << i << endl; break; } if (i == 1) { cout << 1 << endl; } } }
[ "literal.number.change", "variable_access.subscript.index.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
877,220
877,221
u280114218
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PII; // chmax, chmin 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; } template <typename T> function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); }; template <typename T> function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); }; template <typename T> function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; }; namespace detail { template <typename T, std::size_t NDIMS> struct vector_builder { using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>; static type make(std::vector<std::size_t> dims, const T &v = {}) { const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v); if (!dims.empty()) dims.pop_back(); return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec); } }; template <typename T> struct vector_builder<T, 1> { using type = std::vector<T>; static type make(std::vector<std::size_t> dims, const T &v = {}) { return type(dims.empty() ? 0 : dims.back(), v); } }; } // namespace detail template <typename T, typename... SIZE_T> auto exvector(const T &v, SIZE_T... dims) { static_assert(sizeof...(dims) != 0, "invalid dimension"); std::vector<std::size_t> vec_dims{dims...}; return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v); } using namespace std; //******************** dumps ************************// template <typename T> void dump(const T &data, vector<int> &iter) { cout << data << " "; } template <typename T> void dump(const vector<T> &data, vector<int> &iter) { for (auto elem : data) dump(elem, iter); cout << endl; } template <typename T> void dump(const vector<vector<T>> &data, vector<int> &iter) { for (auto elem : iter) { cout << "[" << elem << "]"; } cout << endl; for (int i = 0; i < data.size(); i++) { iter.push_back(i); dump(data[i], iter); iter.pop_back(); } cout << endl; } template <typename T> void dump(const vector<T> &data, int dummy) { for (int i = 0; i < data.size(); i++) { cout << "[" << i << "] " << data[i] << endl; } } template <typename T> void dump(const T &data) { // T : data, U = base type val. vector<int> iter; dump(data, iter); } /////////////////////////////////////////////// function<LL(LL, LL)> gcdlambda = [](LL n, LL m) { return __gcd(n, m); }; void solve(long long N, std::vector<long long> A) { vector<LL> front = {0}; partial_sum(A.begin(), A.end(), back_inserter(front), gcdlambda); reverse(A.begin(), A.end()); vector<LL> back = {0}; partial_sum(A.begin(), A.end(), back_inserter(back), gcdlambda); LL maxim = 0; for (int i = 0; i < N - 1; i++) { maxim = max(maxim, gcdlambda(front[i], back[N - i - 1])); } cout << maxim << endl; } int main() { cout << setprecision(10); long long N; scanf("%lld", &N); std::vector<long long> A(N); for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); } solve(N, std::move(A)); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PII; // chmax, chmin 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; } template <typename T> function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); }; template <typename T> function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); }; template <typename T> function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; }; namespace detail { template <typename T, std::size_t NDIMS> struct vector_builder { using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>; static type make(std::vector<std::size_t> dims, const T &v = {}) { const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v); if (!dims.empty()) dims.pop_back(); return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec); } }; template <typename T> struct vector_builder<T, 1> { using type = std::vector<T>; static type make(std::vector<std::size_t> dims, const T &v = {}) { return type(dims.empty() ? 0 : dims.back(), v); } }; } // namespace detail template <typename T, typename... SIZE_T> auto exvector(const T &v, SIZE_T... dims) { static_assert(sizeof...(dims) != 0, "invalid dimension"); std::vector<std::size_t> vec_dims{dims...}; return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v); } using namespace std; //******************** dumps ************************// template <typename T> void dump(const T &data, vector<int> &iter) { cout << data << " "; } template <typename T> void dump(const vector<T> &data, vector<int> &iter) { for (auto elem : data) dump(elem, iter); cout << endl; } template <typename T> void dump(const vector<vector<T>> &data, vector<int> &iter) { for (auto elem : iter) { cout << "[" << elem << "]"; } cout << endl; for (int i = 0; i < data.size(); i++) { iter.push_back(i); dump(data[i], iter); iter.pop_back(); } cout << endl; } template <typename T> void dump(const vector<T> &data, int dummy) { for (int i = 0; i < data.size(); i++) { cout << "[" << i << "] " << data[i] << endl; } } template <typename T> void dump(const T &data) { // T : data, U = base type val. vector<int> iter; dump(data, iter); } /////////////////////////////////////////////// function<LL(LL, LL)> gcdlambda = [](LL n, LL m) { return __gcd(n, m); }; void solve(long long N, std::vector<long long> A) { vector<LL> front = {0}; partial_sum(A.begin(), A.end(), back_inserter(front), gcdlambda); reverse(A.begin(), A.end()); vector<LL> back = {0}; partial_sum(A.begin(), A.end(), back_inserter(back), gcdlambda); LL maxim = 0; for (int i = 0; i < N; i++) { maxim = max(maxim, gcdlambda(front[i], back[N - i - 1])); } cout << maxim << endl; } int main() { cout << setprecision(10); long long N; scanf("%lld", &N); std::vector<long long> A(N); for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); } solve(N, std::move(A)); return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
877,230
877,231
u806201407
cpp
p03061
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define inf 1000000007 typedef pair<int, int> P; bool prime(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } signed main() { int n, ans = 0; cin >> n; int a[114514], f[114514], e[114514]; rep(i, n) cin >> a[i]; f[0] = a[0], e[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--) { e[i] = gcd(e[i + 1], a[i]); } ans = max(e[1], ans); for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(e[i + 1], f[i - 1])); } ans = max(f[n - 1], ans); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define inf 1000000007 typedef pair<int, int> P; bool prime(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } signed main() { int n, ans = 0; cin >> n; int a[114514], f[114514], e[114514]; rep(i, n) cin >> a[i]; f[0] = a[0], e[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--) { e[i] = gcd(e[i + 1], a[i]); } ans = max(e[1], ans); for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(e[i + 1], f[i - 1])); } ans = max(f[n - 2], ans); cout << ans << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
877,247
877,248
u452009494
cpp
p03061
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define inf 1000000007 typedef pair<int, int> P; bool prime(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } signed main() { int n, ans = 0; cin >> n; int a[114514], f[114514], e[114514]; rep(i, n) cin >> a[i]; f[0] = a[0], e[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--) { e[i] = gcd(e[i - 1], a[i]); } ans = max(e[1], ans); for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(e[i + 1], f[i - 1])); } ans = max(f[n - 1], ans); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define inf 1000000007 typedef pair<int, int> P; bool prime(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } signed main() { int n, ans = 0; cin >> n; int a[114514], f[114514], e[114514]; rep(i, n) cin >> a[i]; f[0] = a[0], e[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--) { e[i] = gcd(e[i + 1], a[i]); } ans = max(e[1], ans); for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(e[i + 1], f[i - 1])); } ans = max(f[n - 2], ans); cout << ans << endl; return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "literal.number.change" ]
877,249
877,248
u452009494
cpp
p03061
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <numeric> #include <vector> #define _for(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; using namespace std; template <typename T> vector<size_t> sort_indexes(const vector<T> &v) { vector<size_t> idx(v.size()); iota(idx.begin(), idx.end(), 0); sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] < v[i2]; }); return idx; } ll gcd(ll a, ll b) { ll gmax = 1; ll aa = (a < b) ? a : b; ll bb = (a < b) ? b : a; for (ll i = 1; i * i <= aa; i++) { if (aa % i == 0) { if (bb % (aa / i) == 0) { gmax = a / i; break; } if (bb % i == 0) { gmax = i; } } } return gmax; } int main() { ll n; cin >> n; ll a[n]; _for(i, n) cin >> a[i]; ll gcd_max = 1; ll gcd_arr[n]; ll gcd_arr2[n]; ll cgcd; gcd_arr[0] = a[0]; gcd_arr2[n - 1] = a[n - 1]; for (ll i = 1; i < n; i++) gcd_arr[i] = gcd(a[i], gcd_arr[i - 1]); for (ll i = 1; i < n; i++) gcd_arr2[n - i - 1] = gcd(a[n - i - 1], gcd_arr2[n - i]); _for(i, n) { if (i == 0) cgcd = gcd_arr2[1]; else if (i == n - 1) cgcd = gcd_arr[n - 2]; else cgcd = gcd(gcd_arr[i - 1], gcd_arr2[i + 1]); gcd_max = max(gcd_max, cgcd); } cout << gcd_max << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <numeric> #include <vector> #define _for(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; using namespace std; template <typename T> vector<size_t> sort_indexes(const vector<T> &v) { vector<size_t> idx(v.size()); iota(idx.begin(), idx.end(), 0); sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] < v[i2]; }); return idx; } ll gcd(ll a, ll b) { ll gmax = 1; ll aa = (a < b) ? a : b; ll bb = (a < b) ? b : a; for (ll i = 1; i * i <= aa; i++) { if (aa % i == 0) { if (bb % (aa / i) == 0) { gmax = aa / i; break; } if (bb % i == 0) { gmax = i; } } } return gmax; } int main() { ll n; cin >> n; ll a[n]; _for(i, n) cin >> a[i]; ll gcd_max = 1; ll gcd_arr[n]; ll gcd_arr2[n]; ll cgcd; gcd_arr[0] = a[0]; gcd_arr2[n - 1] = a[n - 1]; for (ll i = 1; i < n; i++) gcd_arr[i] = gcd(a[i], gcd_arr[i - 1]); for (ll i = 1; i < n; i++) gcd_arr2[n - i - 1] = gcd(a[n - i - 1], gcd_arr2[n - i]); _for(i, n) { if (i == 0) cgcd = gcd_arr2[1]; else if (i == n - 1) cgcd = gcd_arr[n - 2]; else cgcd = gcd(gcd_arr[i - 1], gcd_arr2[i + 1]); gcd_max = max(gcd_max, cgcd); } cout << gcd_max << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
877,250
877,251
u128456980
cpp
p03061
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <numeric> #include <vector> #define _for(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; using namespace std; template <typename T> vector<size_t> sort_indexes(const vector<T> &v) { vector<size_t> idx(v.size()); iota(idx.begin(), idx.end(), 0); sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] < v[i2]; }); return idx; } ll gcd(ll a, ll b) { ll gmax = 1; ll aa = (a < b) ? a : b; ll bb = (a < b) ? b : a; for (ll i = 1; i * i <= aa; i++) { if (aa % i == 0) { if (bb % (a / i) == 0) { gmax = a / i; break; } if (bb % i == 0) { gmax = i; } } } return gmax; } int main() { ll n; cin >> n; ll a[n]; _for(i, n) cin >> a[i]; ll gcd_max = 1; ll gcd_arr[n]; ll gcd_arr2[n]; ll cgcd; gcd_arr[0] = a[0]; gcd_arr2[n - 1] = a[n - 1]; for (ll i = 1; i < n; i++) gcd_arr[i] = gcd(a[i], gcd_arr[i - 1]); for (ll i = 1; i < n; i++) gcd_arr2[n - i - 1] = gcd(a[n - i - 1], gcd_arr2[n - i]); _for(i, n) { if (i == 0) cgcd = gcd_arr2[1]; else if (i == n - 1) cgcd = gcd_arr[n - 2]; else cgcd = gcd(gcd_arr[i - 1], gcd_arr2[i + 1]); gcd_max = max(gcd_max, cgcd); } cout << gcd_max << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <numeric> #include <vector> #define _for(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; using namespace std; template <typename T> vector<size_t> sort_indexes(const vector<T> &v) { vector<size_t> idx(v.size()); iota(idx.begin(), idx.end(), 0); sort(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) { return v[i1] < v[i2]; }); return idx; } ll gcd(ll a, ll b) { ll gmax = 1; ll aa = (a < b) ? a : b; ll bb = (a < b) ? b : a; for (ll i = 1; i * i <= aa; i++) { if (aa % i == 0) { if (bb % (aa / i) == 0) { gmax = aa / i; break; } if (bb % i == 0) { gmax = i; } } } return gmax; } int main() { ll n; cin >> n; ll a[n]; _for(i, n) cin >> a[i]; ll gcd_max = 1; ll gcd_arr[n]; ll gcd_arr2[n]; ll cgcd; gcd_arr[0] = a[0]; gcd_arr2[n - 1] = a[n - 1]; for (ll i = 1; i < n; i++) gcd_arr[i] = gcd(a[i], gcd_arr[i - 1]); for (ll i = 1; i < n; i++) gcd_arr2[n - i - 1] = gcd(a[n - i - 1], gcd_arr2[n - i]); _for(i, n) { if (i == 0) cgcd = gcd_arr2[1]; else if (i == n - 1) cgcd = gcd_arr[n - 2]; else cgcd = gcd(gcd_arr[i - 1], gcd_arr2[i + 1]); gcd_max = max(gcd_max, cgcd); } cout << gcd_max << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change", "assignment.value.change", "expression.operation.binary.change" ]
877,252
877,251
u128456980
cpp
p03061
#include <bits/stdc++.h> using namespace std; int ucrid(int x, int y) { int a; int b; a = max(x, y); b = min(x, y); while (true) { if (a / b == 0) { return b; } else { x = b; y = a / b; a = x; b = y; } } } int main() { int n; cin >> n; vector<int> a(n); vector<int> ml(n); vector<int> mr(n); vector<int> m(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ml[0] = a[0]; mr[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { ml[i] = ucrid(a[i], ml[i - 1]); mr[n - i - 1] = ucrid(a[n - i - 1], mr[n - i]); } for (int i = 1; i < n - 1; i++) { m[i] = ucrid(ml[i - 1], mr[i + 1]); } m[0] = mr[1]; m[n - 1] = ml[n - 2]; int answer; answer = m[0]; for (int i = 1; i < n; i++) { answer = max(answer, m[i]); } cout << answer << endl; }
#include <bits/stdc++.h> using namespace std; int ucrid(int x, int y) { int a; int b; a = max(x, y); b = min(x, y); while (true) { if (a % b == 0) { return b; } else { x = b; y = a % b; a = x; b = y; } } } int main() { int n; cin >> n; vector<int> a(n); vector<int> ml(n); vector<int> mr(n); vector<int> m(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ml[0] = a[0]; mr[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { ml[i] = ucrid(a[i], ml[i - 1]); mr[n - i - 1] = ucrid(a[n - i - 1], mr[n - i]); } for (int i = 1; i < n - 1; i++) { m[i] = ucrid(ml[i - 1], mr[i + 1]); } m[0] = mr[1]; m[n - 1] = ml[n - 2]; int answer; answer = m[0]; for (int i = 1; i < n; i++) { answer = max(answer, m[i]); } cout << answer << endl; }
[ "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change", "assignment.value.change", "expression.operation.binary.change" ]
877,257
877,258
u544165468
cpp
p03061
#include <bits/stdc++.h> using namespace std; int ucrid(int x, int y) { int a; int b; a = max(x, y); b = min(x, y); while (true) { if (a / b == 0) { return b; } else { x = b; y = a / b; a = x; b = y; } } } int main() { int n; cin >> n; vector<int> a(n); vector<int> ml(n); vector<int> mr(n); vector<int> m(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ml[0] = a[0]; mr[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { ml[i] = ucrid(a[i], ml[i - 1]); mr[n - i - 1] = ucrid(a[n - i - 1], mr[n - i]); } for (int i = 0; i < n - 1; i++) { m[i] = ucrid(ml[i - 1], mr[i + 1]); } m[0] = mr[1]; m[n - 1] = ml[n - 2]; int answer; answer = m[0]; for (int i = 1; i < n; i++) { answer = max(answer, m[i]); } cout << answer << endl; }
#include <bits/stdc++.h> using namespace std; int ucrid(int x, int y) { int a; int b; a = max(x, y); b = min(x, y); while (true) { if (a % b == 0) { return b; } else { x = b; y = a % b; a = x; b = y; } } } int main() { int n; cin >> n; vector<int> a(n); vector<int> ml(n); vector<int> mr(n); vector<int> m(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ml[0] = a[0]; mr[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { ml[i] = ucrid(a[i], ml[i - 1]); mr[n - i - 1] = ucrid(a[n - i - 1], mr[n - i]); } for (int i = 1; i < n - 1; i++) { m[i] = ucrid(ml[i - 1], mr[i + 1]); } m[0] = mr[1]; m[n - 1] = ml[n - 2]; int answer; answer = m[0]; for (int i = 1; i < n; i++) { answer = max(answer, m[i]); } cout << answer << endl; }
[ "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change", "assignment.value.change", "expression.operation.binary.change", "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
877,259
877,258
u544165468
cpp
p03061
/** * @Author: G_bg * @DateTime: 2019-04-27 21:56:38 * @Description: */ #include <bits/stdc++.h> using namespace std; typedef long long LL; const double PI = 3.1415926535898; const double E = 2.718281828459; const int INF = 0x7fffffff; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; int a[maxn], q[maxn], h[maxn]; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main(int argc, char const *argv[]) { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; q[0] = a[0]; for (int i = 1; i < n; i++) q[i] = gcd(a[i], q[i - 1]); h[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) q[i] = gcd(a[i], h[i + 1]); int ans = 0; for (int i = 0; i < n; i++) { if (i == 0) ans = max(ans, h[i + 1]); else if (i == n - 1) ans = max(ans, q[i - 1]); else ans = max(ans, gcd(q[i - 1], h[i + 1])); } cout << ans << endl; // system("pause"); return 0; }
/** * @Author: G_bg * @DateTime: 2019-04-27 21:56:38 * @Description: */ #include <bits/stdc++.h> using namespace std; typedef long long LL; const double PI = 3.1415926535898; const double E = 2.718281828459; const int INF = 0x7fffffff; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; int a[maxn], q[maxn], h[maxn]; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main(int argc, char const *argv[]) { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; q[0] = a[0]; for (int i = 1; i < n; i++) q[i] = gcd(a[i], q[i - 1]); h[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) h[i] = gcd(a[i], h[i + 1]); int ans = 0; for (int i = 0; i < n; i++) { if (i == 0) ans = max(ans, h[i + 1]); else if (i == n - 1) ans = max(ans, q[i - 1]); else ans = max(ans, gcd(q[i - 1], h[i + 1])); } cout << ans << endl; // system("pause"); return 0; }
[ "assignment.variable.change", "identifier.change" ]
877,265
877,266
u838609976
cpp
p03061
#include <cstdio> #define SWAP(a, b) (a += b, b = a - b, a -= b) int gcd(int a, int b) { if (b < a) SWAP(a, b); int tmp; while (a != 0) { tmp = b % a; b = a; a = tmp; } return b; } int main(void) { int i, n; int a[100000]; int gcd_array[100000]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", a + i); } gcd_array[0] = 0; int tmp = 0; for (i = 1; i < n; i++) { tmp = gcd(tmp, a[i - 1]); gcd_array[i] = tmp; } tmp = 0; for (i = n - 2; i >= 0; i--) { tmp = gcd(tmp, a[i + 1]); gcd_array[i] = gcd(tmp, gcd_array[i]); } int min = gcd_array[0]; for (i = 1; i < n; i++) { if (gcd_array[i] < min) min = gcd_array[i]; } printf("%d\n", min); return 0; }
#include <cstdio> #define SWAP(a, b) (a += b, b = a - b, a -= b) int gcd(int a, int b) { if (b < a) SWAP(a, b); int tmp; while (a != 0) { tmp = b % a; b = a; a = tmp; } return b; } int main(void) { int i, n; int a[100000]; int gcd_array[100000]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", a + i); } gcd_array[0] = 0; int tmp = 0; for (i = 1; i < n; i++) { tmp = gcd(tmp, a[i - 1]); gcd_array[i] = tmp; } tmp = 0; for (i = n - 2; i >= 0; i--) { tmp = gcd(tmp, a[i + 1]); gcd_array[i] = gcd(tmp, gcd_array[i]); } int max = gcd_array[0]; for (i = 1; i < n; i++) { if (gcd_array[i] > max) max = gcd_array[i]; } printf("%d\n", max); return 0; }
[ "misc.opposites", "variable_declaration.name.change", "identifier.change", "control_flow.loop.for.condition.change", "assignment.variable.change", "call.arguments.change", "io.output.change" ]
877,271
877,272
u651808137
cpp
p03061
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template <class T, class V> typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) { t = v; } template <class T, class V> typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) { for (auto &e : t) fill(e, v); } #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template <class T1, class T2> ostream &operator<<(ostream &s, pair<T1, T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template <class T> ostream &operator<<(ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template <class T> ostream &operator<<(ostream &s, vector<vector<T>> P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) template <class T> ostream &operator<<(ostream &s, set<T> P) { EACH(it, P) { s << "<" << *it << "> "; } return s << endl; } template <class T1, class T2> ostream &operator<<(ostream &s, map<T1, T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } template <class Monoid> struct SegTree { using Func = function<Monoid(Monoid, Monoid)>; const Func F; const Monoid UNITY; int SIZE_R; vector<Monoid> dat; SegTree(int n, const Func f, const Monoid &unity) : F(f), UNITY(unity) { init(n); } void init(int n) { SIZE_R = 1; while (SIZE_R < n) SIZE_R *= 2; dat.assign(SIZE_R * 2, UNITY); } /* set, a is 0-indexed */ void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; } void build() { for (int k = SIZE_R - 1; k > 0; --k) dat[k] = F(dat[k * 2], dat[k * 2 + 1]); } /* update a, a is 0-indexed */ void update(int a, const Monoid &v) { int k = a + SIZE_R; dat[k] = v; while (k >>= 1) dat[k] = F(dat[k * 2], dat[k * 2 + 1]); } /* get [a, b), a and b are 0-indexed */ Monoid get(int a, int b) { Monoid vleft = UNITY, vright = UNITY; for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) { if (left & 1) vleft = F(vleft, dat[left++]); if (right & 1) vright = F(dat[--right], vright); } return F(vleft, vright); } inline Monoid operator[](int a) { return dat[a + SIZE_R]; } /* debug */ void print() { for (int i = 0; i < SIZE_R; ++i) { cout << (*this)[i]; if (i != SIZE_R - 1) cout << ","; } cout << endl; } }; long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; } int main() { int N; while (cin >> N) { SegTree<long long> seg( N, [](long long a, long long b) { return GCD(a, b); }, 0); vector<long long> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; seg.set(i, A[i]); } long long res = 0; for (int i = 0; i < N; ++i) { long long left = seg.get(0, i); long long right = seg.get(i + 1, N); chmax(res, GCD(left, right)); } cout << res << endl; } }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } template <class T, class V> typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) { t = v; } template <class T, class V> typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) { for (auto &e : t) fill(e, v); } #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template <class T1, class T2> ostream &operator<<(ostream &s, pair<T1, T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template <class T> ostream &operator<<(ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template <class T> ostream &operator<<(ostream &s, vector<vector<T>> P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) template <class T> ostream &operator<<(ostream &s, set<T> P) { EACH(it, P) { s << "<" << *it << "> "; } return s << endl; } template <class T1, class T2> ostream &operator<<(ostream &s, map<T1, T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } template <class Monoid> struct SegTree { using Func = function<Monoid(Monoid, Monoid)>; const Func F; const Monoid UNITY; int SIZE_R; vector<Monoid> dat; SegTree(int n, const Func f, const Monoid &unity) : F(f), UNITY(unity) { init(n); } void init(int n) { SIZE_R = 1; while (SIZE_R < n) SIZE_R *= 2; dat.assign(SIZE_R * 2, UNITY); } /* set, a is 0-indexed */ void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; } void build() { for (int k = SIZE_R - 1; k > 0; --k) dat[k] = F(dat[k * 2], dat[k * 2 + 1]); } /* update a, a is 0-indexed */ void update(int a, const Monoid &v) { int k = a + SIZE_R; dat[k] = v; while (k >>= 1) dat[k] = F(dat[k * 2], dat[k * 2 + 1]); } /* get [a, b), a and b are 0-indexed */ Monoid get(int a, int b) { Monoid vleft = UNITY, vright = UNITY; for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) { if (left & 1) vleft = F(vleft, dat[left++]); if (right & 1) vright = F(dat[--right], vright); } return F(vleft, vright); } inline Monoid operator[](int a) { return dat[a + SIZE_R]; } /* debug */ void print() { for (int i = 0; i < SIZE_R; ++i) { cout << (*this)[i]; if (i != SIZE_R - 1) cout << ","; } cout << endl; } }; long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; } int main() { int N; while (cin >> N) { SegTree<long long> seg( N, [](long long a, long long b) { return GCD(a, b); }, 0); vector<long long> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; seg.set(i, A[i]); } seg.build(); long long res = 0; for (int i = 0; i < N; ++i) { long long left = seg.get(0, i); long long right = seg.get(i + 1, N); chmax(res, GCD(left, right)); } cout << res << endl; } }
[ "call.add" ]
877,275
877,276
u692336506
cpp
p03061
#include <algorithm> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <sys/timeb.h> #include <vector> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define reprev(i, n) reprrev(i, 0, n) #define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define mp make_pair #define mt make_tuple #define INF 1050000000 #define INFL 1100000000000000000LL #define EPS (1e-10) #define MOD 1000000007 #define PI 3.1415926536 #define RMAX 4294967295 typedef long long ll; typedef pair<int, int> Pi; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<string> vs; typedef vector<double> vd; typedef vector<Pi> vPi; typedef vector<vector<int>> vvi; typedef vector<vector<bool>> vvb; typedef vector<vector<ll>> vvll; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; typedef vector<vector<double>> vvd; typedef vector<vector<Pi>> vvPi; typedef priority_queue<int, vector<int>, greater<int>> pqli; typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll; typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP; struct Edge { int from, to, cost; bool operator<(Edge e) { return cost < e.cost; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; template <class T> using vec = vector<T>; template <class T> using pql = priority_queue<T, vector<T>, greater<T>>; string debug_show(Pi a) { return "(" + to_string(a.first) + "," + to_string(a.second) + ")"; } template <class T> struct augEdge { T from, to; int cost; bool operator<(augEdge e) { return cost < e.cost; } bool operator>(augEdge e) { return cost > e.cost; } }; template <class T> using augGraph = vector<augEdge<T>>; bool pairCompare(const Pi &firstElof, const Pi &secondElof) { return firstElof.second > secondElof.second; } ll gcd(ll a, ll b) { ll temp; while (a % b != 0) { temp = b; b = a % b; a = temp; } return b; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vll a(n); ll maxa = 0; rep(i, n) { cin >> a[i]; maxa = max(maxa, a[i]); } ll ans = 0; vll beforegcd(n); vll aftergcd(n); beforegcd[0] = a[0]; aftergcd[n - 1] = a[n - 1]; repr(i, 1, n) { beforegcd[i] = gcd(a[i], beforegcd[i - 1]); } for (int i = n - 2; i >= 0; i--) { aftergcd[i] = gcd(aftergcd[i + 1], a[i]); } rep(i, n) { // cout << beforegcd[i] << " " << aftergcd[i] << endl; } rep(i, n) { if (i == 0) { // cout <<beforegcd[n - 1 - 1] << endl;; ans = max(ans, aftergcd[n - 1 - 1]); } else if (i == n - 1) { // cout << aftergcd[1] << endl; ans = max(ans, beforegcd[n - 2]); } else { // cout << beforegcd[i - 1] << " " << aftergcd[n - 1-i] << endl; ans = max(ans, gcd(beforegcd[i - 1], aftergcd[i + 1])); } // cout << beforegcd[i] << " " << aftergcd[i] << endl; } cout << ans << endl; return 0; }
#include <algorithm> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <sys/timeb.h> #include <vector> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--) #define reprev(i, n) reprrev(i, 0, n) #define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define mp make_pair #define mt make_tuple #define INF 1050000000 #define INFL 1100000000000000000LL #define EPS (1e-10) #define MOD 1000000007 #define PI 3.1415926536 #define RMAX 4294967295 typedef long long ll; typedef pair<int, int> Pi; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<string> vs; typedef vector<double> vd; typedef vector<Pi> vPi; typedef vector<vector<int>> vvi; typedef vector<vector<bool>> vvb; typedef vector<vector<ll>> vvll; typedef vector<vector<char>> vvc; typedef vector<vector<string>> vvs; typedef vector<vector<double>> vvd; typedef vector<vector<Pi>> vvPi; typedef priority_queue<int, vector<int>, greater<int>> pqli; typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll; typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP; struct Edge { int from, to, cost; bool operator<(Edge e) { return cost < e.cost; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; template <class T> using vec = vector<T>; template <class T> using pql = priority_queue<T, vector<T>, greater<T>>; string debug_show(Pi a) { return "(" + to_string(a.first) + "," + to_string(a.second) + ")"; } template <class T> struct augEdge { T from, to; int cost; bool operator<(augEdge e) { return cost < e.cost; } bool operator>(augEdge e) { return cost > e.cost; } }; template <class T> using augGraph = vector<augEdge<T>>; bool pairCompare(const Pi &firstElof, const Pi &secondElof) { return firstElof.second > secondElof.second; } ll gcd(ll a, ll b) { ll temp; while (a % b != 0) { temp = b; b = a % b; a = temp; } return b; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vll a(n); ll maxa = 0; rep(i, n) { cin >> a[i]; maxa = max(maxa, a[i]); } ll ans = 0; vll beforegcd(n); vll aftergcd(n); beforegcd[0] = a[0]; aftergcd[n - 1] = a[n - 1]; repr(i, 1, n) { beforegcd[i] = gcd(a[i], beforegcd[i - 1]); } for (int i = n - 2; i >= 0; i--) { aftergcd[i] = gcd(aftergcd[i + 1], a[i]); } rep(i, n) { // cout << beforegcd[i] << " " << aftergcd[i] << endl; } rep(i, n) { if (i == 0) { // cout <<beforegcd[n - 1 - 1] << endl;; ans = max(ans, aftergcd[1]); } else if (i == n - 1) { // cout << aftergcd[1] << endl; ans = max(ans, beforegcd[n - 2]); } else { // cout << beforegcd[i - 1] << " " << aftergcd[n - 1-i] << endl; ans = max(ans, gcd(beforegcd[i - 1], aftergcd[i + 1])); } // cout << beforegcd[i] << " " << aftergcd[i] << endl; } cout << ans << endl; return 0; }
[ "expression.operation.binary.remove" ]
877,277
877,278
u702133921
cpp
p03061
#include <iostream> using namespace std; int gcd(long long int a, long long int b) { long long int temp; if (a < b) { temp = a; a = b; b = temp; } while (a % b) { temp = a % b; a = b; b = temp; } return b; } int main() { int N; long long int A[100000]; long long int fromleft[100000]; long long int fromright[100000]; long long int now_gcd, max; cin >> N; now_gcd = 0; for (int i = 0; i < N; i++) { cin >> A[i]; if (i == 0) { now_gcd = A[i]; } else { now_gcd = gcd(now_gcd, A[i]); } fromleft[i] = now_gcd; } for (int i = 0; i < N; i++) { if (i == 0) { now_gcd = A[N - 1 - i]; } else { now_gcd = gcd(A[N - 1 - i], now_gcd); } fromright[i] = now_gcd; } max = 1; for (int i = 0; i < N; i++) { if (i == 0) { now_gcd = fromright[N - 1 - 1]; } if (i == N - 1) { now_gcd = fromleft[N - 1 - 1]; } else { now_gcd = gcd(fromleft[i - 1], fromright[N - 1 - 1 - i]); } if (max < now_gcd) { max = now_gcd; } } cout << max << endl; return 0; }
#include <iostream> using namespace std; int gcd(long long int a, long long int b) { long long int temp; if (a < b) { temp = a; a = b; b = temp; } while (b) { temp = a % b; a = b; b = temp; } return a; } int main() { int N; long long int A[100000]; long long int fromleft[100000]; long long int fromright[100000]; long long int now_gcd, max; cin >> N; now_gcd = 0; for (int i = 0; i < N; i++) { cin >> A[i]; if (i == 0) { now_gcd = A[i]; } else { now_gcd = gcd(now_gcd, A[i]); } fromleft[i] = now_gcd; } for (int i = 0; i < N; i++) { if (i == 0) { now_gcd = A[N - 1 - i]; } else { now_gcd = gcd(A[N - 1 - i], now_gcd); } fromright[i] = now_gcd; } max = 1; for (int i = 0; i < N; i++) { if (i == 0) { now_gcd = fromright[N - 1 - 1]; } if (i == N - 1) { now_gcd = fromleft[N - 1 - 1]; } else { now_gcd = gcd(fromleft[i - 1], fromright[N - 1 - 1 - i]); } if (max < now_gcd) { max = now_gcd; } } cout << max << endl; return 0; }
[ "expression.operation.binary.remove", "identifier.change", "function.return_value.change" ]
877,293
877,294
u448406471
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef int64_t Int; #define dump(x) cout << (x) << '\n' Int mod = 1e9 + 7; Int gcd(Int n, Int m) { Int x = max(n, m); Int y = min(n, m); return x % y == 0 ? y : gcd(y, x % y); } int main() { Int n; cin >> n; vector<Int> c(n); for (Int i = 0; i < n; i++) cin >> c[i]; vector<Int> d = c; for (Int i = 0; i < n - 1; i++) { c[i + 1] = gcd(c[i], c[i + 1]); } for (Int i = n - 1; i > 0; i--) { d[i - 1] = gcd(d[i], d[i - 1]); } // for (Int i =0; i < n; i++) cout << c[i] << " "; cout << endl; // for (Int i =0; i < n; i++) cout << d[i] << " "; cout << endl; Int res = 1; for (Int i = 0; i < n; i++) { if (i == 0) { res = max(res, d[i]); } else if (i == n - 1) { res = max(res, c[i]); } else { res = max(res, gcd(c[i - 1], d[i + 1])); } } dump(res); return 0; }
#include <bits/stdc++.h> using namespace std; typedef int64_t Int; #define dump(x) cout << (x) << '\n' Int mod = 1e9 + 7; Int gcd(Int n, Int m) { Int x = max(n, m); Int y = min(n, m); return x % y == 0 ? y : gcd(y, x % y); } int main() { Int n; cin >> n; vector<Int> c(n); for (Int i = 0; i < n; i++) cin >> c[i]; vector<Int> d = c; for (Int i = 0; i < n - 1; i++) { c[i + 1] = gcd(c[i], c[i + 1]); } for (Int i = n - 1; i > 0; i--) { d[i - 1] = gcd(d[i], d[i - 1]); } // for (Int i =0; i < n; i++) cout << c[i] << " "; cout << endl; // for (Int i =0; i < n; i++) cout << d[i] << " "; cout << endl; Int res = 1; for (Int i = 0; i < n; i++) { if (i == 0) { res = max(res, d[i + 1]); } else if (i == n - 1) { res = max(res, c[i - 1]); } else { res = max(res, gcd(c[i - 1], d[i + 1])); } } dump(res); return 0; }
[ "assignment.change" ]
877,297
877,298
u572665222
cpp
p03061
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <sstream> #include <string> #include <vector> using namespace std; long long int mod = 1e9; int func(vector<int> a, int p) { int n = a.size(); int x = a[0]; if (p == 0) x = a[1]; for (int i = 0; i < n; i++) { if (i == p) continue; x = __gcd(x, a[i]); } return x; } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> l(n + 1, 0); vector<int> r(n + 1, 0); int x = a[0]; for (int i = 0; i < n; i++) { x = __gcd(x, a[i]); l[i] = x; } int y = a[n - 1]; for (int i = n - 1; i >= 0; i--) { y = __gcd(y, a[i]); r[i] = y; } int ans = 1; for (int i = 1; i < n - 1; i++) { ans = max(ans, __gcd(l[i - 1], r[i + 1])); } ans = max({ans, l[n - 1], r[1]}); cout << ans << endl; return 0; } // EOF
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <sstream> #include <string> #include <vector> using namespace std; long long int mod = 1e9; int func(vector<int> a, int p) { int n = a.size(); int x = a[0]; if (p == 0) x = a[1]; for (int i = 0; i < n; i++) { if (i == p) continue; x = __gcd(x, a[i]); } return x; } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> l(n + 1, 0); vector<int> r(n + 1, 0); int x = a[0]; for (int i = 0; i < n; i++) { x = __gcd(x, a[i]); l[i] = x; } int y = a[n - 1]; for (int i = n - 1; i >= 0; i--) { y = __gcd(y, a[i]); r[i] = y; } int ans = 1; for (int i = 1; i < n - 1; i++) { ans = max(ans, __gcd(l[i - 1], r[i + 1])); } ans = max({ans, l[n - 2], r[1]}); cout << ans << endl; return 0; } // EOF
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
877,299
877,300
u543657872
cpp
p03061
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; // BEGIN CUT HERE template <typename T, typename E> struct SegmentTree { typedef function<T(T, T)> F; typedef function<T(T, E)> G; int n; F f; G g; T d1; E d0; vector<T> dat; SegmentTree(){}; SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>()) : f(f), g(g), d1(d1) { init(n_); if (n_ == (int)v.size()) build(n_, v); } void init(int n_) { n = 1; while (n < n_) n *= 2; dat.clear(); dat.resize(2 * n - 1, d1); } void build(int n_, vector<T> v) { for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]); } void update(int k, E a) { k += n - 1; dat[k] = g(dat[k], a); while (k > 0) { k = (k - 1) / 2; dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]); } } inline T query(int a, int b) { T vl = d1, vr = d1; for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if (l & 1) vl = f(vl, dat[(l++) - 1]); if (r & 1) vr = f(dat[(--r) - 1], vr); } return f(vl, vr); } }; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // END CUT HERE signed main() { int N; cin >> N; vector<int> V(N); rep(i, 0, N) cin >> V[i]; SegmentTree<ll, ll> rmq( N, [](ll a, ll b) { return gcd(a, b); }, [](ll a, ll b) { return b; }, 0); rep(i, 0, N) { rmq.update(i, V[i]); } ll ans = 0; rep(i, 0, N) { ll left = rmq.query(0, max(0, i)); ll right = rmq.query(min(i + 1, N - 1), N); // cout << gcd(left, right) << endl; ans = max(ans, gcd(left, right)); } if (N == 2) ans = max(V[0], V[1]); cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) using namespace std; typedef long long ll; int INF = (1LL << 30) - 1; int MOD = 1e9 + 7; // BEGIN CUT HERE template <typename T, typename E> struct SegmentTree { typedef function<T(T, T)> F; typedef function<T(T, E)> G; int n; F f; G g; T d1; E d0; vector<T> dat; SegmentTree(){}; SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>()) : f(f), g(g), d1(d1) { init(n_); if (n_ == (int)v.size()) build(n_, v); } void init(int n_) { n = 1; while (n < n_) n *= 2; dat.clear(); dat.resize(2 * n - 1, d1); } void build(int n_, vector<T> v) { for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]); } void update(int k, E a) { k += n - 1; dat[k] = g(dat[k], a); while (k > 0) { k = (k - 1) / 2; dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]); } } inline T query(int a, int b) { T vl = d1, vr = d1; for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) { if (l & 1) vl = f(vl, dat[(l++) - 1]); if (r & 1) vr = f(dat[(--r) - 1], vr); } return f(vl, vr); } }; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // END CUT HERE signed main() { int N; cin >> N; vector<int> V(N); rep(i, 0, N) cin >> V[i]; SegmentTree<ll, ll> rmq( N, [](ll a, ll b) { return gcd(a, b); }, [](ll a, ll b) { return b; }, 0); rep(i, 0, N) { rmq.update(i, V[i]); } ll ans = 0; rep(i, 0, N) { ll left = rmq.query(0, max(0, i)); ll right = rmq.query(min(i + 1, N), N); // cout << gcd(left, right) << endl; ans = max(ans, gcd(left, right)); } if (N == 2) ans = max(V[0], V[1]); cout << ans << endl; }
[ "expression.operation.binary.remove" ]
877,301
877,302
u157322125
cpp
p03061
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <sstream> #include <string> #include <vector> #define rep(i, n) for (ll i = 0; i < n; i++) #define rrep(i, n) for (ll i = n - 1; i >= 0; i--) #define range(i, n, m) for (ll i = n; i < m; i++) #define rrange(i, n, m) for (ll i = n - 1; i = > m; i--) #define MOD 1000000007 //#define MOD 998244353 typedef long long int ll; typedef unsigned long long int ull; using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } long long gcd(long long a, long long b) { if (b == 0) { return a; } if (a == 0) { return b; } return gcd(b, a % b); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N; vector<ll> A(N); rep(i, N) { cin >> A[i]; } vector<ll> L(N + 1), R(N + 1); rep(i, N) { L[i + 1] = gcd(L[i], A[i]); R[N - i - 1] = gcd(R[N - i], A[N - i - 1]); } ll ret = 0; rep(i, N) { ret = max(ret, gcd(L[i], R[i])); } cout << ret << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <sstream> #include <string> #include <vector> #define rep(i, n) for (ll i = 0; i < n; i++) #define rrep(i, n) for (ll i = n - 1; i >= 0; i--) #define range(i, n, m) for (ll i = n; i < m; i++) #define rrange(i, n, m) for (ll i = n - 1; i = > m; i--) #define MOD 1000000007 //#define MOD 998244353 typedef long long int ll; typedef unsigned long long int ull; using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } long long gcd(long long a, long long b) { if (b == 0) { return a; } if (a == 0) { return b; } return gcd(b, a % b); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N; vector<ll> A(N); rep(i, N) { cin >> A[i]; } vector<ll> L(N + 1), R(N + 1); rep(i, N) { L[i + 1] = gcd(L[i], A[i]); R[N - i - 1] = gcd(R[N - i], A[N - i - 1]); } ll ret = 0; rep(i, N) { ret = max(ret, gcd(L[i], R[i + 1])); } cout << ret << endl; return 0; }
[ "assignment.change" ]
877,303
877,304
u991974907
cpp
p03067
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if ((a <= c && c <= b) && (b <= c && c <= a)) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if ((a <= c && c <= b) || (b <= c && c <= a)) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
877,311
877,312
u286623856
cpp
p03067
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef long double ld; typedef pair<ld, ld> LDP; typedef vector<vector<ll>> mat; typedef vector<ll> vec; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) #define all(v) (v).begin(), (v).end() const ll mod = 1000000007; const ll INF = mod * mod; const ld eps = 1e-12; const ld pi = acos(-1.0); // int qp(int a,ll b){int // ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;} ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; } 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; } // 最小公倍数 int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); } template <typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); } template <typename T> bool chmax(T &m, const T q) { if (m < q) { m = q; return true; } else return false; } template <typename T> bool chmin(T &m, const T q) { if (q < m) { m = q; return true; } else return false; } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } template <typename T1, typename T2> pair<T1, T2> operator<(const pair<T1, T2> l, const pair<T1, T2> r) { return (l.first < r.first); } template <typename T1, typename T2> pair<T1, T2> operator>(const pair<T1, T2> l, const pair<T1, T2> r) { return (l.first > r.first); } void solve() { ll a, b, c; cin >> a >> b >> c; if (a < c && c < b) cout << "Yes" << endl; if (a > c && c > b) cout << "Yes" << endl; else cout << "No" << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); std::cout << fixed << setprecision(10); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef long double ld; typedef pair<ld, ld> LDP; typedef vector<vector<ll>> mat; typedef vector<ll> vec; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) #define all(v) (v).begin(), (v).end() const ll mod = 1000000007; const ll INF = mod * mod; const ld eps = 1e-12; const ld pi = acos(-1.0); // int qp(int a,ll b){int // ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;} ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; } 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; } // 最小公倍数 int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; } template <typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); } template <typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); } template <typename T> bool chmax(T &m, const T q) { if (m < q) { m = q; return true; } else return false; } template <typename T> bool chmin(T &m, const T q) { if (q < m) { m = q; return true; } else return false; } template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } template <typename T1, typename T2> pair<T1, T2> operator<(const pair<T1, T2> l, const pair<T1, T2> r) { return (l.first < r.first); } template <typename T1, typename T2> pair<T1, T2> operator>(const pair<T1, T2> l, const pair<T1, T2> r) { return (l.first > r.first); } void solve() { ll a, b, c; cin >> a >> b >> c; if (a < c && c < b) cout << "Yes" << endl; else if (a > c && c > b) cout << "Yes" << endl; else cout << "No" << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); std::cout << fixed << setprecision(10); solve(); return 0; }
[ "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove" ]
877,321
877,322
u114137758
cpp
p03067
#include <bits/stdc++.h> using namespace std; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } #ifdef __LOCAL #define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl #define debugArray(x, n) \ cerr << __LINE__ << ": " << #x << " = {"; \ for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \ cerr << ((hoge) ? "," : "") << x[hoge]; \ cerr << "}" << endl #else #define debug(x) (void(0)) #define debugArray(x, n) (void(0)) #endif signed main() { cin.tie(0); ios::sync_with_stdio(false); int A, B, C; cin >> A >> B >> C; cout << (min(A, B) <= C && C <= max(A, B) ? "No" : "Yes") << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } #ifdef __LOCAL #define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl #define debugArray(x, n) \ cerr << __LINE__ << ": " << #x << " = {"; \ for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \ cerr << ((hoge) ? "," : "") << x[hoge]; \ cerr << "}" << endl #else #define debug(x) (void(0)) #define debugArray(x, n) (void(0)) #endif signed main() { cin.tie(0); ios::sync_with_stdio(false); int A, B, C; cin >> A >> B >> C; cout << (min(A, B) <= C && C <= max(A, B) ? "Yes" : "No") << '\n'; return 0; }
[ "literal.string.change", "io.output.change" ]
877,327
877,328
u120143737
cpp
p03067
#include <bits/stdc++.h> using namespace std; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } #ifdef __LOCAL #define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl #define debugArray(x, n) \ cerr << __LINE__ << ": " << #x << " = {"; \ for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \ cerr << ((hoge) ? "," : "") << x[hoge]; \ cerr << "}" << endl #else #define debug(x) (void(0)) #define debugArray(x, n) (void(0)) #endif signed main() { cin.tie(0); ios::sync_with_stdio(false); int A, B, C; cin >> A >> B >> C; cout << (min(A, C) <= B && B <= max(A, C) ? "No" : "Yes") << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } #ifdef __LOCAL #define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl #define debugArray(x, n) \ cerr << __LINE__ << ": " << #x << " = {"; \ for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \ cerr << ((hoge) ? "," : "") << x[hoge]; \ cerr << "}" << endl #else #define debug(x) (void(0)) #define debugArray(x, n) (void(0)) #endif signed main() { cin.tie(0); ios::sync_with_stdio(false); int A, B, C; cin >> A >> B >> C; cout << (min(A, B) <= C && C <= max(A, B) ? "Yes" : "No") << '\n'; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "io.output.change", "literal.string.change" ]
877,329
877,328
u120143737
cpp
p03067
#include <bits/stdc++.h> #include <regex> using namespace std; // type typedef long long int ll; typedef pair<int, int> P; //定数 #define INF 1000000000000 // 10^12:∞ #define MOD 1000000007 // 10^9+7:合同式の法 #define MAXR 100000 // 10^5:配列の最大のrange #define PI 3.14159265358979323846264338327950L //略記 #define PB push_back //挿入 #define MP make_pair // pairのコンストラクタ #define F first // pairの一つ目の要素 #define S second // pairの二つ目の要素 #define Z class // input #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define VAR(type, ...) \ type __VA_ARGS__; \ MACRO_VAR_Scan(__VA_ARGS__); template <typename T> void MACRO_VAR_Scan(T &t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First &first, Rest &...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...) \ std::vector<type> __VA_ARGS__; \ MACRO_VEC_ROW_Init(n, __VA_ARGS__); \ for (int w_ = 0; w_ < n; ++w_) { \ MACRO_VEC_ROW_Scan(w_, __VA_ARGS__); \ } template <typename T> void MACRO_VEC_ROW_Init(int n, T &t) { t.resize(n); } template <typename First, typename... Rest> void MACRO_VEC_ROW_Init(int n, First &first, Rest &...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template <typename T> void MACRO_VEC_ROW_Scan(int p, T &t) { std::cin >> t[p]; } template <typename First, typename... Rest> void MACRO_VEC_ROW_Scan(int p, First &first, Rest &...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define VEC(type, c, n) \ std::vector<type> c(n); \ for (auto &i : c) \ std::cin >> i; // 2d vector: MAT(type, v, size, size); #define MAT(type, c, m, n) \ std::vector<std::vector<type>> c(m, std::vector<type>(n)); \ for (auto &R : c) \ for (auto &w : R) \ std::cin >> w; // output template <typename T> void MACRO_OUT(const T t) { std::cout << t; } #define OUT(...) MACRO_OUT(__VA_ARGS__); #define SP std::cout << " "; #define TAB std::cout << "\t"; #define BR std::cout << "\n"; #define ENDL std::cout << std::endl; #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("%s\n", (x) ? "YES" : "NO") #define Yes() printf("Yes\n") #define No() printf("No\n") #define yes() printf("yes\n") #define no() printf("no\n") #define ln cout << '\n' template <Z A> void pr(A a) { cout << a; ln; } template <Z A, Z B> void pr(A a, B b) { cout << a << ' ' << b << endl; } // OTHER // xの二乗を返す (関数テンプレート版) template <typename T> T square(T x) { return x * x; } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } #define chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) // loop #define rep(i, n) for (ll i = 0; i < (n); i++) #define repe(i, n) for (ll i = 0; i <= (n); i++) #define repd(i, n) for (ll i = n; i > 0; i--) #define repde(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < (b); i++) #define FORE(i, a, b) for (ll i = a; i <= (b); i++) #define FORD(i, a, b) for (ll i = a; i >= (b); i--) #define FORA(i, I) for (const auto &i : I) // vector #define ALL(x) x.begin(), x.end() #define ALLR(x) x.end(), x.begin() typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vi> vvi; typedef vector<ll> vl; #define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements #define sz(x) (int)(x).size() bool yes = 0; bool boo = 0; double mx = -100000; int mn = 1001001001; int sum = 0; ll ans = 0; int co = 0; int abc[26]; bool OK = false; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * cout << (conditon ? (result: == 1 ): (==0)) << endl; <- output // result of if long long 型が表せる値の上限はおよそ 9 × 10^18 です. // vector // sum: accumulate(ALl(x),0) // return last element: v.back(); // i & 1 は偶数なら 0に 奇数なら1に // sort (descending order) : sort(arr, arr+n, greater<int>()); // sort indescending order: sort(ALL())-> reverse(ALL()) // (string): sort(all(t),greater<char>()); (string t ) // string // strncmp: ompare characters of two string *長さ指定 strcmp(s1,s2,length) // <0:s1<s2 (s1が辞書早い) | 0:s1==s2 | >0:s1>s2 // 三角形 ABC について,a^2 = b^2+c^2−2bc cos ∠A int main() { VAR(int, a, b, c); int x = min(a, c); int y = max(a, c); if (x <= b && b <= y) Yes(); else No(); }
#include <bits/stdc++.h> #include <regex> using namespace std; // type typedef long long int ll; typedef pair<int, int> P; //定数 #define INF 1000000000000 // 10^12:∞ #define MOD 1000000007 // 10^9+7:合同式の法 #define MAXR 100000 // 10^5:配列の最大のrange #define PI 3.14159265358979323846264338327950L //略記 #define PB push_back //挿入 #define MP make_pair // pairのコンストラクタ #define F first // pairの一つ目の要素 #define S second // pairの二つ目の要素 #define Z class // input #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define VAR(type, ...) \ type __VA_ARGS__; \ MACRO_VAR_Scan(__VA_ARGS__); template <typename T> void MACRO_VAR_Scan(T &t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First &first, Rest &...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...) \ std::vector<type> __VA_ARGS__; \ MACRO_VEC_ROW_Init(n, __VA_ARGS__); \ for (int w_ = 0; w_ < n; ++w_) { \ MACRO_VEC_ROW_Scan(w_, __VA_ARGS__); \ } template <typename T> void MACRO_VEC_ROW_Init(int n, T &t) { t.resize(n); } template <typename First, typename... Rest> void MACRO_VEC_ROW_Init(int n, First &first, Rest &...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template <typename T> void MACRO_VEC_ROW_Scan(int p, T &t) { std::cin >> t[p]; } template <typename First, typename... Rest> void MACRO_VEC_ROW_Scan(int p, First &first, Rest &...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define VEC(type, c, n) \ std::vector<type> c(n); \ for (auto &i : c) \ std::cin >> i; // 2d vector: MAT(type, v, size, size); #define MAT(type, c, m, n) \ std::vector<std::vector<type>> c(m, std::vector<type>(n)); \ for (auto &R : c) \ for (auto &w : R) \ std::cin >> w; // output template <typename T> void MACRO_OUT(const T t) { std::cout << t; } #define OUT(...) MACRO_OUT(__VA_ARGS__); #define SP std::cout << " "; #define TAB std::cout << "\t"; #define BR std::cout << "\n"; #define ENDL std::cout << std::endl; #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("%s\n", (x) ? "YES" : "NO") #define Yes() printf("Yes\n") #define No() printf("No\n") #define yes() printf("yes\n") #define no() printf("no\n") #define ln cout << '\n' template <Z A> void pr(A a) { cout << a; ln; } template <Z A, Z B> void pr(A a, B b) { cout << a << ' ' << b << endl; } // OTHER // xの二乗を返す (関数テンプレート版) template <typename T> T square(T x) { return x * x; } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } #define chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) // loop #define rep(i, n) for (ll i = 0; i < (n); i++) #define repe(i, n) for (ll i = 0; i <= (n); i++) #define repd(i, n) for (ll i = n; i > 0; i--) #define repde(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < (b); i++) #define FORE(i, a, b) for (ll i = a; i <= (b); i++) #define FORD(i, a, b) for (ll i = a; i >= (b); i--) #define FORA(i, I) for (const auto &i : I) // vector #define ALL(x) x.begin(), x.end() #define ALLR(x) x.end(), x.begin() typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vi> vvi; typedef vector<ll> vl; #define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements #define sz(x) (int)(x).size() bool yes = 0; bool boo = 0; double mx = -100000; int mn = 1001001001; int sum = 0; ll ans = 0; int co = 0; int abc[26]; bool OK = false; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * cout << (conditon ? (result: == 1 ): (==0)) << endl; <- output // result of if long long 型が表せる値の上限はおよそ 9 × 10^18 です. // vector // sum: accumulate(ALl(x),0) // return last element: v.back(); // i & 1 は偶数なら 0に 奇数なら1に // sort (descending order) : sort(arr, arr+n, greater<int>()); // sort indescending order: sort(ALL())-> reverse(ALL()) // (string): sort(all(t),greater<char>()); (string t ) // string // strncmp: ompare characters of two string *長さ指定 strcmp(s1,s2,length) // <0:s1<s2 (s1が辞書早い) | 0:s1==s2 | >0:s1>s2 // 三角形 ABC について,a^2 = b^2+c^2−2bc cos ∠A int main() { VAR(int, a, c, b); int x = min(a, c); int y = max(a, c); if (x <= b && b <= y) Yes(); else No(); }
[]
877,332
877,333
u506464494
cpp
p03067
#include <bits/stdc++.h> #include <regex> using namespace std; // type typedef long long int ll; typedef pair<int, int> P; //定数 #define INF 1000000000000 // 10^12:∞ #define MOD 1000000007 // 10^9+7:合同式の法 #define MAXR 100000 // 10^5:配列の最大のrange #define PI 3.14159265358979323846264338327950L //略記 #define PB push_back //挿入 #define MP make_pair // pairのコンストラクタ #define F first // pairの一つ目の要素 #define S second // pairの二つ目の要素 #define Z class // input #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define VAR(type, ...) \ type __VA_ARGS__; \ MACRO_VAR_Scan(__VA_ARGS__); template <typename T> void MACRO_VAR_Scan(T &t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First &first, Rest &...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...) \ std::vector<type> __VA_ARGS__; \ MACRO_VEC_ROW_Init(n, __VA_ARGS__); \ for (int w_ = 0; w_ < n; ++w_) { \ MACRO_VEC_ROW_Scan(w_, __VA_ARGS__); \ } template <typename T> void MACRO_VEC_ROW_Init(int n, T &t) { t.resize(n); } template <typename First, typename... Rest> void MACRO_VEC_ROW_Init(int n, First &first, Rest &...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template <typename T> void MACRO_VEC_ROW_Scan(int p, T &t) { std::cin >> t[p]; } template <typename First, typename... Rest> void MACRO_VEC_ROW_Scan(int p, First &first, Rest &...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define VEC(type, c, n) \ std::vector<type> c(n); \ for (auto &i : c) \ std::cin >> i; // 2d vector: MAT(type, v, size, size); #define MAT(type, c, m, n) \ std::vector<std::vector<type>> c(m, std::vector<type>(n)); \ for (auto &R : c) \ for (auto &w : R) \ std::cin >> w; // output template <typename T> void MACRO_OUT(const T t) { std::cout << t; } #define OUT(...) MACRO_OUT(__VA_ARGS__); #define SP std::cout << " "; #define TAB std::cout << "\t"; #define BR std::cout << "\n"; #define ENDL std::cout << std::endl; #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("%s\n", (x) ? "YES" : "NO") #define Yes() printf("Yes\n") #define No() printf("No\n") #define yes() printf("yes\n") #define no() printf("no\n") #define ln cout << '\n' template <Z A> void pr(A a) { cout << a; ln; } template <Z A, Z B> void pr(A a, B b) { cout << a << ' ' << b << endl; } // OTHER // xの二乗を返す (関数テンプレート版) template <typename T> T square(T x) { return x * x; } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } #define chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) // loop #define rep(i, n) for (ll i = 0; i < (n); i++) #define repe(i, n) for (ll i = 0; i <= (n); i++) #define repd(i, n) for (ll i = n; i > 0; i--) #define repde(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < (b); i++) #define FORE(i, a, b) for (ll i = a; i <= (b); i++) #define FORD(i, a, b) for (ll i = a; i >= (b); i--) #define FORA(i, I) for (const auto &i : I) // vector #define ALL(x) x.begin(), x.end() #define ALLR(x) x.end(), x.begin() typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vi> vvi; typedef vector<ll> vl; #define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements #define sz(x) (int)(x).size() bool yes = 0; bool boo = 0; double mx = -100000; int mn = 1001001001; int sum = 0; ll ans = 0; int co = 0; int abc[26]; bool OK = false; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * cout << (conditon ? (result: == 1 ): (==0)) << endl; <- output // result of if long long 型が表せる値の上限はおよそ 9 × 10^18 です. // vector // sum: accumulate(ALl(x),0) // return last element: v.back(); // i & 1 は偶数なら 0に 奇数なら1に // sort (descending order) : sort(arr, arr+n, greater<int>()); // sort indescending order: sort(ALL())-> reverse(ALL()) // (string): sort(all(t),greater<char>()); (string t ) // string // strncmp: ompare characters of two string *長さ指定 strcmp(s1,s2,length) // <0:s1<s2 (s1が辞書早い) | 0:s1==s2 | >0:s1>s2 // 三角形 ABC について,a^2 = b^2+c^2−2bc cos ∠A int main() { VAR(int, a, b, c); int x = min(a, c); int y = max(a, c); if (x <= b || b <= y) Yes(); else No(); }
#include <bits/stdc++.h> #include <regex> using namespace std; // type typedef long long int ll; typedef pair<int, int> P; //定数 #define INF 1000000000000 // 10^12:∞ #define MOD 1000000007 // 10^9+7:合同式の法 #define MAXR 100000 // 10^5:配列の最大のrange #define PI 3.14159265358979323846264338327950L //略記 #define PB push_back //挿入 #define MP make_pair // pairのコンストラクタ #define F first // pairの一つ目の要素 #define S second // pairの二つ目の要素 #define Z class // input #define INIT \ std::ios::sync_with_stdio(false); \ std::cin.tie(0); #define VAR(type, ...) \ type __VA_ARGS__; \ MACRO_VAR_Scan(__VA_ARGS__); template <typename T> void MACRO_VAR_Scan(T &t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First &first, Rest &...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...) \ std::vector<type> __VA_ARGS__; \ MACRO_VEC_ROW_Init(n, __VA_ARGS__); \ for (int w_ = 0; w_ < n; ++w_) { \ MACRO_VEC_ROW_Scan(w_, __VA_ARGS__); \ } template <typename T> void MACRO_VEC_ROW_Init(int n, T &t) { t.resize(n); } template <typename First, typename... Rest> void MACRO_VEC_ROW_Init(int n, First &first, Rest &...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template <typename T> void MACRO_VEC_ROW_Scan(int p, T &t) { std::cin >> t[p]; } template <typename First, typename... Rest> void MACRO_VEC_ROW_Scan(int p, First &first, Rest &...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define VEC(type, c, n) \ std::vector<type> c(n); \ for (auto &i : c) \ std::cin >> i; // 2d vector: MAT(type, v, size, size); #define MAT(type, c, m, n) \ std::vector<std::vector<type>> c(m, std::vector<type>(n)); \ for (auto &R : c) \ for (auto &w : R) \ std::cin >> w; // output template <typename T> void MACRO_OUT(const T t) { std::cout << t; } #define OUT(...) MACRO_OUT(__VA_ARGS__); #define SP std::cout << " "; #define TAB std::cout << "\t"; #define BR std::cout << "\n"; #define ENDL std::cout << std::endl; #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("%s\n", (x) ? "YES" : "NO") #define Yes() printf("Yes\n") #define No() printf("No\n") #define yes() printf("yes\n") #define no() printf("no\n") #define ln cout << '\n' template <Z A> void pr(A a) { cout << a; ln; } template <Z A, Z B> void pr(A a, B b) { cout << a << ' ' << b << endl; } // OTHER // xの二乗を返す (関数テンプレート版) template <typename T> T square(T x) { return x * x; } ll gcd(ll a, ll b) { while (b) { ll c = b; b = a % b; a = c; } return a; } ll lcm(ll a, ll b) { if (!a || !b) return 0; return a * b / gcd(a, b); } #define chmax(x, y) (x = max(x, y)) #define chmin(x, y) (x = min(x, y)) // loop #define rep(i, n) for (ll i = 0; i < (n); i++) #define repe(i, n) for (ll i = 0; i <= (n); i++) #define repd(i, n) for (ll i = n; i > 0; i--) #define repde(i, n) for (ll i = n; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < (b); i++) #define FORE(i, a, b) for (ll i = a; i <= (b); i++) #define FORD(i, a, b) for (ll i = a; i >= (b); i--) #define FORA(i, I) for (const auto &i : I) // vector #define ALL(x) x.begin(), x.end() #define ALLR(x) x.end(), x.begin() typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vi> vvi; typedef vector<ll> vl; #define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements #define sz(x) (int)(x).size() bool yes = 0; bool boo = 0; double mx = -100000; int mn = 1001001001; int sum = 0; ll ans = 0; int co = 0; int abc[26]; bool OK = false; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * * * * * * cout << (conditon ? (result: == 1 ): (==0)) << endl; <- output // result of if long long 型が表せる値の上限はおよそ 9 × 10^18 です. // vector // sum: accumulate(ALl(x),0) // return last element: v.back(); // i & 1 は偶数なら 0に 奇数なら1に // sort (descending order) : sort(arr, arr+n, greater<int>()); // sort indescending order: sort(ALL())-> reverse(ALL()) // (string): sort(all(t),greater<char>()); (string t ) // string // strncmp: ompare characters of two string *長さ指定 strcmp(s1,s2,length) // <0:s1<s2 (s1が辞書早い) | 0:s1==s2 | >0:s1>s2 // 三角形 ABC について,a^2 = b^2+c^2−2bc cos ∠A int main() { VAR(int, a, c, b); int x = min(a, c); int y = max(a, c); if (x <= b && b <= y) Yes(); else No(); }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
877,334
877,333
u506464494
cpp
p03067
using namespace std; #include <iostream> #include <vector> int A, B, C; int main() { cin >> A >> B >> C; string ans = (A < C) ^ (B > C) ? "Yes" : "No"; cout << ans << endl; return 0; }
using namespace std; #include <iostream> #include <vector> int A, B, C; int main() { cin >> A >> B >> C; string ans = (A < C) ^ (B < C) ? "Yes" : "No"; cout << ans << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
877,345
877,346
u288087195
cpp
p03067
using namespace std; #include <iostream> #include <vector> int A, B, C; int main() { cin >> A >> B >> C; string ans = A < C && B > C ? "Yes" : "No"; cout << ans << endl; return 0; }
using namespace std; #include <iostream> #include <vector> int A, B, C; int main() { cin >> A >> B >> C; string ans = (A < C) ^ (B < C) ? "Yes" : "No"; cout << ans << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.change", "misc.opposites", "expression.operator.compare.change" ]
877,347
877,346
u288087195
cpp
p03067
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(); \ cout.tie(); #define MAXX 100005 #define PI 3.14159265358979323846264338327950 #define F first #define S second #define ll long long int #define mod 1000000007 map<string, int> m; int main() { FAST; ll a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); if (c > a && b < c) { cout << "Yes"; return 0; } cout << "No"; return 0; }
#include <bits/stdc++.h> using namespace std; #define FAST \ ios_base::sync_with_stdio(0); \ cin.tie(); \ cout.tie(); #define MAXX 100005 #define PI 3.14159265358979323846264338327950 #define F first #define S second #define ll long long int #define mod 1000000007 map<string, int> m; int main() { FAST; ll a, b, c; cin >> a >> b >> c; if (a > b) { swap(a, b); } if (c > a && b > c) { cout << "Yes"; return 0; } cout << "No"; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
877,350
877,351
u102842945
cpp
p03067
// ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(), a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second +1 << endl; } } */ // ABC_058_Cのように // s.at(j) == a のとき // cout << s.at(j)-'0' - 49 << endl; //とすると、「0」を出力してくれる。 →もっといいほかの方法はないの? //全bit探索を入れよう!! /*ABC_167_C skill up などを参考に… //https://qiita.com/hareku/items/3d08511eab56a481c7db int main() { int n = 3; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 0; bit < (1<<n); ++bit) { vector<int> S; for (int i = 0; i < n; ++i) { if (bit & (1<<i)) { // 列挙に i が含まれるか S.push_back(i); } } cout << bit << ": {"; for (int i = 0; i < (int)S.size(); ++i) { cout << S[i] << " "; } cout << "}" << endl; } } */ // next_permutation(順列列挙) /*https://note.com/memenekokaburi/n/nf0201d6002cd ABC_150_Cなど。 int main() { int n; cin >> n ; vector<int>array = {}; for(int i=0;i<n;i++){ array.push_back(i); } do{ for(int i=0; i<n; i++){ cout << array.at(i); if(i!=n-1)cout<<" "; } cout<<endl; }while(next_permutation(array.begin(),array.end())); return 0; } */ // ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble // kan_halfのようにかく /* //ABC_041_C// pair型 int main() { int n; cin >> n; vector<pair<int,int>>a(n); for(int i=0;i<n;i++){ int num; cin >> num; a.at(i).first = num; a.at(i).second = i; } sort(a.begin(), a.end()); reverse(a.begin(),a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second + 1<< endl; } } */ /*ABC_068_C //boolの配列を使って bool s[200050] = {}; bool t[200050] = {}; int main() { ll n, m; cin >> n >> m; for (int i = 0; i < m; i++){ ll a, b; cin >> a >> b; if (a == 1) { t[b] = true; } if (b == n) { s[a] = true; } } for (int i = 0; i < 200050; i++){ if (s[i] && t[i]) { cout << "POSSIBLE" << endl; return 0; } } cout << "IMPOSSIBLE" << endl; return 0; } */ // int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = // 2*10^9 再帰関数 ABC_029_C /* void f(int rest , string s){ if(rest == 0){ cout << s << endl; } else{ for(char moji = 'a' ;moji <='c' ; moji++){ f(rest-1,s+moji); } } } int main() { int n; cin >> n; f(n, ""); } */ //連想配列 ARC_081_Cの解答 //ABC073でも復習できます。 /* int main() { ll n; cin >> n; vector<ll>a(n); rep(i,n) cin>>a.at(i); map<ll,ll>mp; rep(i,n){ mp[a.at(i)]++; } ll one = 0; ll two = 0; for(auto p:mp){ // cout << p.first << " " << p.second << endl; if(p.second >= 2){ if(one <= p.first){ two = one; one = p.first; } } if(p.second >= 4){ if(one <= p.first){ two = p.first; one = p.first; } } } // cout << one << endl; // cout << two << endl; // cout << endl; cout << one * two << endl; } */ //#define pi 3.14159265359 //桁数を指定して出力する方法 //#include <iomanip>//これをincludeしておかないといけない // cout << fixed << setprecision(20)<< ans << endl; // s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま // s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま // getline(cin, s); //空白文字を含むものをまとめて入力できる。 // s配列に格納した単語を、辞書順にソートする // sort(s.begin(), s.end()); // string t = "keyence";//で文字列を格納できる // s.empty() //emptyなら1を出力 入っていれば0を出力 /*//ABC018-B 部分的にreverseをかける解法 int main() { string s; cin >> s; int n; cin >> n; vector<int>a(n); vector<int>b(n); rep(i,n) cin>>a.at(i)>>b.at(i); rep(i,n)a.at(i)--; rep(i,n)b.at(i)--; string t; rep(i,n){ t = s; for(int k=0;k<=b.at(i)-a.at(i);k++){ t.at(a.at(i)+k) = s.at(b.at(i)-k); } s = t; } cout << s << endl; } *///ABC018-B // cout << char(i+48) << // endl;//なぜかaは47と得る時がある。+48で出力もaにできる。 cout << char(97) << // endl;//アスキーコードでaを出力 // sort(b.begin(), b.end());//bという配列を小さい方からソート // reverse(b.begin(), b.end());//bという配列をリターン /*01 02 03 12 13 23 と6回見ていくパターン for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ } } */ // vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言 // 10のi乗pow(10, i);//ただしdouble型のため注意 /*string s; stringでの文字列を数字型に変える方法 cin >> s; rep(i,s.size()-2) { int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0'; */ #include <bits/stdc++.h> #include <iomanip> //これをincludeしておかないといけない using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { // return a * b / gcd(a, b); return a / gcd(a, b) * b; } int kan_hyaku(int n) { int kurai = 0; for (int i = 0; i < 3; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ju(int n) { int kurai = 0; for (int i = 0; i < 2; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ichi(int n) { int kurai = 0; for (int i = 0; i < 1; i++) { kurai = n % 10; n /= 10; } return kurai; } int keta(int n) { int wa = 1; while (n > 0) { wa *= 10; n--; } return wa; } double kan_half(int n) { double wa = 1; while (n > 0) { // cout << "TEST"<<endl; wa *= 0.5; // cout << wa << endl; n--; } return wa; } ll facctorialMethod(ll k) { ll sum = 1; for (ll i = 1; i <= k; ++i) { sum = sum % 1000000007 * i % 1000000007; } return sum; } bool red[100010] = {}; int main() { int a, b, c; cin >> a >> b >> c; if ((a < c && c < b) || (b < c && b < a)) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
// ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(), a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second +1 << endl; } } */ // ABC_058_Cのように // s.at(j) == a のとき // cout << s.at(j)-'0' - 49 << endl; //とすると、「0」を出力してくれる。 →もっといいほかの方法はないの? //全bit探索を入れよう!! /*ABC_167_C skill up などを参考に… //https://qiita.com/hareku/items/3d08511eab56a481c7db int main() { int n = 3; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 0; bit < (1<<n); ++bit) { vector<int> S; for (int i = 0; i < n; ++i) { if (bit & (1<<i)) { // 列挙に i が含まれるか S.push_back(i); } } cout << bit << ": {"; for (int i = 0; i < (int)S.size(); ++i) { cout << S[i] << " "; } cout << "}" << endl; } } */ // next_permutation(順列列挙) /*https://note.com/memenekokaburi/n/nf0201d6002cd ABC_150_Cなど。 int main() { int n; cin >> n ; vector<int>array = {}; for(int i=0;i<n;i++){ array.push_back(i); } do{ for(int i=0; i<n; i++){ cout << array.at(i); if(i!=n-1)cout<<" "; } cout<<endl; }while(next_permutation(array.begin(),array.end())); return 0; } */ // ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble // kan_halfのようにかく /* //ABC_041_C// pair型 int main() { int n; cin >> n; vector<pair<int,int>>a(n); for(int i=0;i<n;i++){ int num; cin >> num; a.at(i).first = num; a.at(i).second = i; } sort(a.begin(), a.end()); reverse(a.begin(),a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second + 1<< endl; } } */ /*ABC_068_C //boolの配列を使って bool s[200050] = {}; bool t[200050] = {}; int main() { ll n, m; cin >> n >> m; for (int i = 0; i < m; i++){ ll a, b; cin >> a >> b; if (a == 1) { t[b] = true; } if (b == n) { s[a] = true; } } for (int i = 0; i < 200050; i++){ if (s[i] && t[i]) { cout << "POSSIBLE" << endl; return 0; } } cout << "IMPOSSIBLE" << endl; return 0; } */ // int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = // 2*10^9 再帰関数 ABC_029_C /* void f(int rest , string s){ if(rest == 0){ cout << s << endl; } else{ for(char moji = 'a' ;moji <='c' ; moji++){ f(rest-1,s+moji); } } } int main() { int n; cin >> n; f(n, ""); } */ //連想配列 ARC_081_Cの解答 //ABC073でも復習できます。 /* int main() { ll n; cin >> n; vector<ll>a(n); rep(i,n) cin>>a.at(i); map<ll,ll>mp; rep(i,n){ mp[a.at(i)]++; } ll one = 0; ll two = 0; for(auto p:mp){ // cout << p.first << " " << p.second << endl; if(p.second >= 2){ if(one <= p.first){ two = one; one = p.first; } } if(p.second >= 4){ if(one <= p.first){ two = p.first; one = p.first; } } } // cout << one << endl; // cout << two << endl; // cout << endl; cout << one * two << endl; } */ //#define pi 3.14159265359 //桁数を指定して出力する方法 //#include <iomanip>//これをincludeしておかないといけない // cout << fixed << setprecision(20)<< ans << endl; // s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま // s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま // getline(cin, s); //空白文字を含むものをまとめて入力できる。 // s配列に格納した単語を、辞書順にソートする // sort(s.begin(), s.end()); // string t = "keyence";//で文字列を格納できる // s.empty() //emptyなら1を出力 入っていれば0を出力 /*//ABC018-B 部分的にreverseをかける解法 int main() { string s; cin >> s; int n; cin >> n; vector<int>a(n); vector<int>b(n); rep(i,n) cin>>a.at(i)>>b.at(i); rep(i,n)a.at(i)--; rep(i,n)b.at(i)--; string t; rep(i,n){ t = s; for(int k=0;k<=b.at(i)-a.at(i);k++){ t.at(a.at(i)+k) = s.at(b.at(i)-k); } s = t; } cout << s << endl; } *///ABC018-B // cout << char(i+48) << // endl;//なぜかaは47と得る時がある。+48で出力もaにできる。 cout << char(97) << // endl;//アスキーコードでaを出力 // sort(b.begin(), b.end());//bという配列を小さい方からソート // reverse(b.begin(), b.end());//bという配列をリターン /*01 02 03 12 13 23 と6回見ていくパターン for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ } } */ // vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言 // 10のi乗pow(10, i);//ただしdouble型のため注意 /*string s; stringでの文字列を数字型に変える方法 cin >> s; rep(i,s.size()-2) { int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0'; */ #include <bits/stdc++.h> #include <iomanip> //これをincludeしておかないといけない using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { // return a * b / gcd(a, b); return a / gcd(a, b) * b; } int kan_hyaku(int n) { int kurai = 0; for (int i = 0; i < 3; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ju(int n) { int kurai = 0; for (int i = 0; i < 2; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ichi(int n) { int kurai = 0; for (int i = 0; i < 1; i++) { kurai = n % 10; n /= 10; } return kurai; } int keta(int n) { int wa = 1; while (n > 0) { wa *= 10; n--; } return wa; } double kan_half(int n) { double wa = 1; while (n > 0) { // cout << "TEST"<<endl; wa *= 0.5; // cout << wa << endl; n--; } return wa; } ll facctorialMethod(ll k) { ll sum = 1; for (ll i = 1; i <= k; ++i) { sum = sum % 1000000007 * i % 1000000007; } return sum; } bool red[100010] = {}; int main() { int a, b, c; cin >> a >> b >> c; if ((a < c && c < b) || (b < c && c < a)) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
877,354
877,355
u037563046
cpp
p03067
// ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(), a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second +1 << endl; } } */ // ABC_058_Cのように // s.at(j) == a のとき // cout << s.at(j)-'0' - 49 << endl; //とすると、「0」を出力してくれる。 →もっといいほかの方法はないの? //全bit探索を入れよう!! /*ABC_167_C skill up などを参考に… //https://qiita.com/hareku/items/3d08511eab56a481c7db int main() { int n = 3; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 0; bit < (1<<n); ++bit) { vector<int> S; for (int i = 0; i < n; ++i) { if (bit & (1<<i)) { // 列挙に i が含まれるか S.push_back(i); } } cout << bit << ": {"; for (int i = 0; i < (int)S.size(); ++i) { cout << S[i] << " "; } cout << "}" << endl; } } */ // next_permutation(順列列挙) /*https://note.com/memenekokaburi/n/nf0201d6002cd ABC_150_Cなど。 int main() { int n; cin >> n ; vector<int>array = {}; for(int i=0;i<n;i++){ array.push_back(i); } do{ for(int i=0; i<n; i++){ cout << array.at(i); if(i!=n-1)cout<<" "; } cout<<endl; }while(next_permutation(array.begin(),array.end())); return 0; } */ // ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble // kan_halfのようにかく /* //ABC_041_C// pair型 int main() { int n; cin >> n; vector<pair<int,int>>a(n); for(int i=0;i<n;i++){ int num; cin >> num; a.at(i).first = num; a.at(i).second = i; } sort(a.begin(), a.end()); reverse(a.begin(),a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second + 1<< endl; } } */ /*ABC_068_C //boolの配列を使って bool s[200050] = {}; bool t[200050] = {}; int main() { ll n, m; cin >> n >> m; for (int i = 0; i < m; i++){ ll a, b; cin >> a >> b; if (a == 1) { t[b] = true; } if (b == n) { s[a] = true; } } for (int i = 0; i < 200050; i++){ if (s[i] && t[i]) { cout << "POSSIBLE" << endl; return 0; } } cout << "IMPOSSIBLE" << endl; return 0; } */ // int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = // 2*10^9 再帰関数 ABC_029_C /* void f(int rest , string s){ if(rest == 0){ cout << s << endl; } else{ for(char moji = 'a' ;moji <='c' ; moji++){ f(rest-1,s+moji); } } } int main() { int n; cin >> n; f(n, ""); } */ //連想配列 ARC_081_Cの解答 //ABC073でも復習できます。 /* int main() { ll n; cin >> n; vector<ll>a(n); rep(i,n) cin>>a.at(i); map<ll,ll>mp; rep(i,n){ mp[a.at(i)]++; } ll one = 0; ll two = 0; for(auto p:mp){ // cout << p.first << " " << p.second << endl; if(p.second >= 2){ if(one <= p.first){ two = one; one = p.first; } } if(p.second >= 4){ if(one <= p.first){ two = p.first; one = p.first; } } } // cout << one << endl; // cout << two << endl; // cout << endl; cout << one * two << endl; } */ //#define pi 3.14159265359 //桁数を指定して出力する方法 //#include <iomanip>//これをincludeしておかないといけない // cout << fixed << setprecision(20)<< ans << endl; // s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま // s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま // getline(cin, s); //空白文字を含むものをまとめて入力できる。 // s配列に格納した単語を、辞書順にソートする // sort(s.begin(), s.end()); // string t = "keyence";//で文字列を格納できる // s.empty() //emptyなら1を出力 入っていれば0を出力 /*//ABC018-B 部分的にreverseをかける解法 int main() { string s; cin >> s; int n; cin >> n; vector<int>a(n); vector<int>b(n); rep(i,n) cin>>a.at(i)>>b.at(i); rep(i,n)a.at(i)--; rep(i,n)b.at(i)--; string t; rep(i,n){ t = s; for(int k=0;k<=b.at(i)-a.at(i);k++){ t.at(a.at(i)+k) = s.at(b.at(i)-k); } s = t; } cout << s << endl; } *///ABC018-B // cout << char(i+48) << // endl;//なぜかaは47と得る時がある。+48で出力もaにできる。 cout << char(97) << // endl;//アスキーコードでaを出力 // sort(b.begin(), b.end());//bという配列を小さい方からソート // reverse(b.begin(), b.end());//bという配列をリターン /*01 02 03 12 13 23 と6回見ていくパターン for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ } } */ // vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言 // 10のi乗pow(10, i);//ただしdouble型のため注意 /*string s; stringでの文字列を数字型に変える方法 cin >> s; rep(i,s.size()-2) { int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0'; */ #include <bits/stdc++.h> #include <iomanip> //これをincludeしておかないといけない using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { // return a * b / gcd(a, b); return a / gcd(a, b) * b; } int kan_hyaku(int n) { int kurai = 0; for (int i = 0; i < 3; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ju(int n) { int kurai = 0; for (int i = 0; i < 2; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ichi(int n) { int kurai = 0; for (int i = 0; i < 1; i++) { kurai = n % 10; n /= 10; } return kurai; } int keta(int n) { int wa = 1; while (n > 0) { wa *= 10; n--; } return wa; } double kan_half(int n) { double wa = 1; while (n > 0) { // cout << "TEST"<<endl; wa *= 0.5; // cout << wa << endl; n--; } return wa; } ll facctorialMethod(ll k) { ll sum = 1; for (ll i = 1; i <= k; ++i) { sum = sum % 1000000007 * i % 1000000007; } return sum; } bool red[100010] = {}; int main() { int a, b, c; cin >> a >> b >> c; if (a < c && c < b || b < c && b < a) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
// ABC_128_B// pair型の中にpair型 /*int main() { int n; cin >> n; vector<pair<pair<string,int>,int>> a(n); for(int i=0;i<n;i++){ string s; cin >> s; int num; cin >> num; num = num * -1; a.at(i).first.first = s; a.at(i).first.second = num; a.at(i).second = i; } sort(a.begin(), a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second +1 << endl; } } */ // ABC_058_Cのように // s.at(j) == a のとき // cout << s.at(j)-'0' - 49 << endl; //とすると、「0」を出力してくれる。 →もっといいほかの方法はないの? //全bit探索を入れよう!! /*ABC_167_C skill up などを参考に… //https://qiita.com/hareku/items/3d08511eab56a481c7db int main() { int n = 3; // {0, 1, ..., n-1} の部分集合の全探索 for (int bit = 0; bit < (1<<n); ++bit) { vector<int> S; for (int i = 0; i < n; ++i) { if (bit & (1<<i)) { // 列挙に i が含まれるか S.push_back(i); } } cout << bit << ": {"; for (int i = 0; i < (int)S.size(); ++i) { cout << S[i] << " "; } cout << "}" << endl; } } */ // next_permutation(順列列挙) /*https://note.com/memenekokaburi/n/nf0201d6002cd ABC_150_Cなど。 int main() { int n; cin >> n ; vector<int>array = {}; for(int i=0;i<n;i++){ array.push_back(i); } do{ for(int i=0; i<n; i++){ cout << array.at(i); if(i!=n-1)cout<<" "; } cout<<endl; }while(next_permutation(array.begin(),array.end())); return 0; } */ // ABC126_Cのように関数でdouble型で返ってきてほしい場合はdouble // kan_halfのようにかく /* //ABC_041_C// pair型 int main() { int n; cin >> n; vector<pair<int,int>>a(n); for(int i=0;i<n;i++){ int num; cin >> num; a.at(i).first = num; a.at(i).second = i; } sort(a.begin(), a.end()); reverse(a.begin(),a.end()); for(int i=0;i<n;i++){ cout << a.at(i).second + 1<< endl; } } */ /*ABC_068_C //boolの配列を使って bool s[200050] = {}; bool t[200050] = {}; int main() { ll n, m; cin >> n >> m; for (int i = 0; i < m; i++){ ll a, b; cin >> a >> b; if (a == 1) { t[b] = true; } if (b == n) { s[a] = true; } } for (int i = 0; i < 200050; i++){ if (s[i] && t[i]) { cout << "POSSIBLE" << endl; return 0; } } cout << "IMPOSSIBLE" << endl; return 0; } */ // int32 4 signed, signed int, int -2,147,483,648 ~ 2,147,483,647 = // 2*10^9 再帰関数 ABC_029_C /* void f(int rest , string s){ if(rest == 0){ cout << s << endl; } else{ for(char moji = 'a' ;moji <='c' ; moji++){ f(rest-1,s+moji); } } } int main() { int n; cin >> n; f(n, ""); } */ //連想配列 ARC_081_Cの解答 //ABC073でも復習できます。 /* int main() { ll n; cin >> n; vector<ll>a(n); rep(i,n) cin>>a.at(i); map<ll,ll>mp; rep(i,n){ mp[a.at(i)]++; } ll one = 0; ll two = 0; for(auto p:mp){ // cout << p.first << " " << p.second << endl; if(p.second >= 2){ if(one <= p.first){ two = one; one = p.first; } } if(p.second >= 4){ if(one <= p.first){ two = p.first; one = p.first; } } } // cout << one << endl; // cout << two << endl; // cout << endl; cout << one * two << endl; } */ //#define pi 3.14159265359 //桁数を指定して出力する方法 //#include <iomanip>//これをincludeしておかないといけない // cout << fixed << setprecision(20)<< ans << endl; // s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま // s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま // getline(cin, s); //空白文字を含むものをまとめて入力できる。 // s配列に格納した単語を、辞書順にソートする // sort(s.begin(), s.end()); // string t = "keyence";//で文字列を格納できる // s.empty() //emptyなら1を出力 入っていれば0を出力 /*//ABC018-B 部分的にreverseをかける解法 int main() { string s; cin >> s; int n; cin >> n; vector<int>a(n); vector<int>b(n); rep(i,n) cin>>a.at(i)>>b.at(i); rep(i,n)a.at(i)--; rep(i,n)b.at(i)--; string t; rep(i,n){ t = s; for(int k=0;k<=b.at(i)-a.at(i);k++){ t.at(a.at(i)+k) = s.at(b.at(i)-k); } s = t; } cout << s << endl; } *///ABC018-B // cout << char(i+48) << // endl;//なぜかaは47と得る時がある。+48で出力もaにできる。 cout << char(97) << // endl;//アスキーコードでaを出力 // sort(b.begin(), b.end());//bという配列を小さい方からソート // reverse(b.begin(), b.end());//bという配列をリターン /*01 02 03 12 13 23 と6回見ていくパターン for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ } } */ // vector<vector<int>> a(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言 // 10のi乗pow(10, i);//ただしdouble型のため注意 /*string s; stringでの文字列を数字型に変える方法 cin >> s; rep(i,s.size()-2) { int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0'; */ #include <bits/stdc++.h> #include <iomanip> //これをincludeしておかないといけない using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) ll gcd(ll a, ll b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) { // return a * b / gcd(a, b); return a / gcd(a, b) * b; } int kan_hyaku(int n) { int kurai = 0; for (int i = 0; i < 3; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ju(int n) { int kurai = 0; for (int i = 0; i < 2; i++) { kurai = n % 10; n /= 10; } return kurai; } int kan_ichi(int n) { int kurai = 0; for (int i = 0; i < 1; i++) { kurai = n % 10; n /= 10; } return kurai; } int keta(int n) { int wa = 1; while (n > 0) { wa *= 10; n--; } return wa; } double kan_half(int n) { double wa = 1; while (n > 0) { // cout << "TEST"<<endl; wa *= 0.5; // cout << wa << endl; n--; } return wa; } ll facctorialMethod(ll k) { ll sum = 1; for (ll i = 1; i <= k; ++i) { sum = sum % 1000000007 * i % 1000000007; } return sum; } bool red[100010] = {}; int main() { int a, b, c; cin >> a >> b >> c; if ((a < c && c < b) || (b < c && c < a)) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
[ "control_flow.branch.if.condition.change", "identifier.change" ]
877,356
877,355
u037563046
cpp
p03067
#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(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(var) \ do { \ cout << #var << " : "; \ view(var); \ } while (0) template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } using namespace std; template <class T> void view(T e) { cout << e << endl; } template <class T> void view(const vector<T> &v) { for (const auto &e : v) { cout << e << " "; } cout << endl; } template <class T> void view(const vector<vector<T>> &vv) { for (const auto &v : vv) { view(v); } } using vint = vector<int>; using vvint = vector<vector<int>>; using ll = long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<int, int>; const int inf = 1e9; const ll inf_l = 1e18; const int MAX = 1e5; int main() { int a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); if (a < c && b < c) cout << "Yes" << endl; else cout << "No" << endl; }
#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(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(var) \ do { \ cout << #var << " : "; \ view(var); \ } while (0) template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } using namespace std; template <class T> void view(T e) { cout << e << endl; } template <class T> void view(const vector<T> &v) { for (const auto &e : v) { cout << e << " "; } cout << endl; } template <class T> void view(const vector<vector<T>> &vv) { for (const auto &v : vv) { view(v); } } using vint = vector<int>; using vvint = vector<vector<int>>; using ll = long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<int, int>; const int inf = 1e9; const ll inf_l = 1e18; const int MAX = 1e5; int main() { int a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); if (a < c && c < b) cout << "Yes" << endl; else cout << "No" << endl; }
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
877,366
877,367
u697968316
cpp
p03067
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; #define all(x) x.begin(), x.end() #define rep(i, j, n) for (long long i = j; i < (long long)(n); i++) #define _GLIBCXX_DEBUG #define MOD 1000000007 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; } //(a+b-1)/b signed main() { int a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); if (a < c && c < b) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; #define all(x) x.begin(), x.end() #define rep(i, j, n) for (long long i = j; i < (long long)(n); i++) #define _GLIBCXX_DEBUG #define MOD 1000000007 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; } //(a+b-1)/b signed main() { int a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); if (a < c && c < b) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
877,368
877,369
u164181205
cpp
p03067
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; if ((A > B && C > B) || (A < B && C < B)) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; if ((A > C && C > B) || (A < C && C < B)) cout << "Yes" << endl; else cout << "No" << endl; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
877,370
877,371
u431389521
cpp
p03067
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if (a < c && b > c) { cout << "YES"; } else if (a > c && b < c) { cout << "YES"; } else { cout << "NO"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if (a < c && b > c) { cout << "Yes"; } else if (a > c && b < c) { cout << "Yes"; } else { cout << "No"; } return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
877,374
877,375
u714796740
cpp
p03067
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); puts(min(a, c) <= b && b <= max(a, b) ? "Yes" : "No"); return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); puts(min(a, b) <= c && c <= max(a, b) ? "Yes" : "No"); return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
877,382
877,383
u781095600
cpp
p03067
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if ((b - a) * (c - b) < 0) cout << "Yes" << endl; else cout << "No" << endl; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if ((c - a) * (c - b) < 0) cout << "Yes" << endl; else cout << "No" << endl; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
877,390
877,391
u495704746
cpp
p03067
#include <bits/stdc++.h> using namespace std; template <typename T> using vec = vector<T>; int main() { int a, b, c; cin >> a >> b >> c; if ((a < c and c < b) or (a > c and c > b)) cout << "No" << endl; else cout << "Yes" << endl; }
#include <bits/stdc++.h> using namespace std; template <typename T> using vec = vector<T>; int main() { int a, b, c; cin >> a >> b >> c; if ((a < c and c < b) or (a > c and c > b)) cout << "Yes" << endl; else cout << "No" << endl; }
[ "expression.operation.binary.remove" ]
877,394
877,395
u267222408
cpp
p03067
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; if (A <= C && B >= C) { cout << "Yes" << endl; } if (A >= C && B <= C) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int A, B, C; cin >> A >> B >> C; if (A <= C && B >= C) { cout << "Yes" << endl; } else if (A >= C && B <= C) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
[ "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove" ]
877,399
877,400
u237390401
cpp
p03067
#include <iostream> using namespace std; int a, b, c; int main() { cin >> a >> b >> c; cout << (a < c && c < b ? "Yes" : "No"); }
#include <iostream> using namespace std; int a, b, c; int main() { cin >> a >> b >> c; cout << (a < c ^ b < c ? "Yes" : "No"); }
[ "control_flow.loop.for.condition.change", "io.output.change", "expression.operation.binary.remove" ]
877,401
877,402
u047554023
cpp
p03067
#include <iostream> using namespace std; int a, b, c; int main() { cin >> a >> b >> c; cout << (a < b && b < c ? "Yes" : "No"); }
#include <iostream> using namespace std; int a, b, c; int main() { cin >> a >> b >> c; cout << (a < c ^ b < c ? "Yes" : "No"); }
[]
877,403
877,402
u047554023
cpp
p03067
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll, vl /*, greater<ll>*/> pql; //降順(/*昇順*/) typedef set<ll> sl; typedef pair<ll, ll> pl; typedef vector<vl> vvl; typedef vector<pl> vpl; #define rep(i, n) for (ll i = 0; i < ll(n); ++i) #define rep2(i, n) for (ll i = 1; i <= ll(n); ++i) //#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i) //#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i) #define all(v) (v).begin(), (v).end() bool chmin(ll &a, ll b) { if (b < a) { a = b; return 1; } return 0; } bool chmax(ll &a, ll b) { if (b > a) { a = b; return 1; } return 0; } const ll INF = 1LL << 60; const ll MOD = 1e9 + 7; // const ll MOD = 998244353; const ll MAX = 1e9; const char newl = '\n'; int main() { ios::sync_with_stdio(false); cin.tie(0); ll a, b, c; cin >> a >> b >> c; cout << ((a - b) * (b - c) >= 0 ? "Yes" : "No") << newl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll, vl /*, greater<ll>*/> pql; //降順(/*昇順*/) typedef set<ll> sl; typedef pair<ll, ll> pl; typedef vector<vl> vvl; typedef vector<pl> vpl; #define rep(i, n) for (ll i = 0; i < ll(n); ++i) #define rep2(i, n) for (ll i = 1; i <= ll(n); ++i) //#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i) //#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i) #define all(v) (v).begin(), (v).end() bool chmin(ll &a, ll b) { if (b < a) { a = b; return 1; } return 0; } bool chmax(ll &a, ll b) { if (b > a) { a = b; return 1; } return 0; } const ll INF = 1LL << 60; const ll MOD = 1e9 + 7; // const ll MOD = 998244353; const ll MAX = 1e9; const char newl = '\n'; int main() { ios::sync_with_stdio(false); cin.tie(0); ll a, b, c; cin >> a >> b >> c; cout << ((a - c) * (c - b) >= 0 ? "Yes" : "No") << newl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "io.output.change", "expression.operation.binary.remove" ]
877,410
877,411
u682191329
cpp
p03061
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author Apolloliu */ #include <fstream> #include <iostream> #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, b, sizeof(a)) #define UN(a) sort(all(a)), a.erase(unique(all(a)), a.end()) #define REV(a) reverse(all(a)) #define MP(a, b) make_pair(a, b) #define PAIR(a, b) pair<int, int>(a, b) typedef long long ll; typedef pair<int, int> pii; typedef pair<int, int> pii; const int MOD = 1e9 + 7; const int maxn = 1; const double EPS = 1e-8; int a[132456]; unordered_map<int, int> mp; class CGCDOnBlackboard { public: void solve(std::istream &in, std::ostream &out) { mp.clear(); int N; in >> N; int t = 1; for (int i = 0; i < N; ++i) { in >> a[i]; } int res = 1; for (int i = 0; i < 3; ++i) { int x = a[i]; for (int j = 1; j * j <= x; ++j) { if (x % j == 0) { t = 0; for (int k = 0; k < N; ++k) { if (a[k] % j == 0) t++; } if (t >= min(2, N - 1)) res = max(res, j); if (x / j == j) continue; t = 0; for (int k = 0; k < N; ++k) { if (a[k] % (x / j) == 0) t++; } if (t >= N - 1) res = max(res, (x / j)); } } } // int res = 1; // for(auto it = mp.begin(); it != mp.end(); ++it){ // if(it->second >= min(2, N-1))res = max(res, it->first); // } out << res << endl; } }; int main() { // freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(NULL); CGCDOnBlackboard solver; std::istream &in(std::cin); std::ostream &out(std::cout); solver.solve(in, out); return 0; }
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author Apolloliu */ #include <fstream> #include <iostream> #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, b, sizeof(a)) #define UN(a) sort(all(a)), a.erase(unique(all(a)), a.end()) #define REV(a) reverse(all(a)) #define MP(a, b) make_pair(a, b) #define PAIR(a, b) pair<int, int>(a, b) typedef long long ll; typedef pair<int, int> pii; typedef pair<int, int> pii; const int MOD = 1e9 + 7; const int maxn = 1; const double EPS = 1e-8; int a[132456]; unordered_map<int, int> mp; class CGCDOnBlackboard { public: void solve(std::istream &in, std::ostream &out) { mp.clear(); int N; in >> N; int t = 1; for (int i = 0; i < N; ++i) { in >> a[i]; } int res = 1; for (int i = 0; i < 2; ++i) { int x = a[i]; for (int j = 1; j * j <= x; ++j) { if (x % j == 0) { t = 0; for (int k = 0; k < N; ++k) { if (a[k] % j == 0) t++; } if (t >= N - 1) res = max(res, j); if (x / j == j) continue; t = 0; for (int k = 0; k < N; ++k) { if (a[k] % (x / j) == 0) t++; } if (t >= N - 1) res = max(res, (x / j)); } } } // int res = 1; // for(auto it = mp.begin(); it != mp.end(); ++it){ // if(it->second >= min(2, N-1))res = max(res, it->first); // } out << res << endl; } }; int main() { // freopen("input.txt", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(NULL); CGCDOnBlackboard solver; std::istream &in(std::cin); std::ostream &out(std::cout); solver.solve(in, out); return 0; }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "call.remove", "control_flow.branch.if.condition.change" ]
877,420
877,421
u608624039
cpp
p03061
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; int gcd(int a, int b) { int v0 = a, v1 = b, v2 = a % b; while (v2 != 0) { v0 = v1; v1 = v2; v2 = v0 % v1; }; return v1; } int main() { int N; cin >> N; vector<int> A(N), L(N), R(N), M(N); for (int i = 0; i < N; i++) { cin >> A[i]; } L[0] = A[0]; for (int i = 1; i < N; i++) { L[i] = gcd(L[0], A[i]); } R[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { R[N - 1 - i] = gcd(R[N - i], A[N - 1 - i]); } M[0] = R[1]; M[N - 1] = L[N - 2]; for (int i = 1; i < N - 1; i++) { M[i] = gcd(L[i - 1], R[i + 1]); } int max = 0; for (int i = 0; i < N; i++) { if (max < M[i]) { max = M[i]; } } cout << max << endl; }
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; int gcd(int a, int b) { int v0 = a, v1 = b, v2 = a % b; while (v2 != 0) { v0 = v1; v1 = v2; v2 = v0 % v1; }; return v1; } int main() { int N; cin >> N; vector<int> A(N), L(N), R(N), M(N); for (int i = 0; i < N; i++) { cin >> A[i]; } L[0] = A[0]; for (int i = 1; i < N; i++) { L[i] = gcd(L[i - 1], A[i]); } R[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { R[N - 1 - i] = gcd(R[N - i], A[N - 1 - i]); } M[0] = R[1]; M[N - 1] = L[N - 2]; for (int i = 1; i < N - 1; i++) { M[i] = gcd(L[i - 1], R[i + 1]); } int max = 0; for (int i = 0; i < N; i++) { if (max < M[i]) { max = M[i]; } } cout << max << endl; }
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "call.arguments.change", "assignment.change" ]
877,422
877,423
u430797067
cpp
p03061
#include <bits/stdc++.h> using namespace std; int eucl(int a, int b) { if (a == 0) { return b; } else { // cout << b << " "<< b%a << endl; return eucl(b % a, a); } } int main() { int N; cin >> N; std::vector<int> value(N); std::vector<int> gcd_r(N); std::vector<int> gcd_l(N); for (int i = 0; i < N; i++) { cin >> value.at(i); } gcd_l.at(0) = value.at(0); gcd_r.at(N - 1) = value.at(N - 1); for (int i = 1; i < N; i++) { gcd_l.at(i) = eucl(value.at(i), gcd_l.at(i - 1)); } for (int i = 1; i < N; i++) { gcd_r.at(N - i - 1) = eucl(value.at(N - i - 1), gcd_r.at(N - i)); } int max_gcd = gcd_r.at(1); int gcd_tmp; // for(int i=0; i < N; i++){ // cout << gcd_l.at(i) << " "; // } // cout << endl; // for(int i=0; i < N; i++){ // cout << gcd_r.at(i) << " "; // } // cout << endl; for (int i = 1; i < N - 1; i++) { gcd_tmp = eucl(gcd_l.at(i - 1), gcd_r.at(i + 1)); max_gcd = max(max_gcd, gcd_tmp); } gcd_tmp = gcd_l.at(N - 1); max_gcd = max(max_gcd, gcd_tmp); cout << max_gcd << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int eucl(int a, int b) { if (a == 0) { return b; } else { // cout << b << " "<< b%a << endl; return eucl(b % a, a); } } int main() { int N; cin >> N; std::vector<int> value(N); std::vector<int> gcd_r(N); std::vector<int> gcd_l(N); for (int i = 0; i < N; i++) { cin >> value.at(i); } gcd_l.at(0) = value.at(0); gcd_r.at(N - 1) = value.at(N - 1); for (int i = 1; i < N; i++) { gcd_l.at(i) = eucl(value.at(i), gcd_l.at(i - 1)); } for (int i = 1; i < N; i++) { gcd_r.at(N - i - 1) = eucl(value.at(N - i - 1), gcd_r.at(N - i)); } int max_gcd = gcd_r.at(1); int gcd_tmp; // for(int i=0; i < N; i++){ // cout << gcd_l.at(i) << " "; // } // cout << endl; // for(int i=0; i < N; i++){ // cout << gcd_r.at(i) << " "; // } // cout << endl; for (int i = 1; i < N - 1; i++) { gcd_tmp = eucl(gcd_l.at(i - 1), gcd_r.at(i + 1)); max_gcd = max(max_gcd, gcd_tmp); } gcd_tmp = gcd_l.at(N - 2); max_gcd = max(max_gcd, gcd_tmp); cout << max_gcd << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
877,433
877,434
u578276786
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { int t = a; a = b; b = t; } if (b == 0) return a; return gcd(b, a % b); } int main() { int n; cin >> n; int rgcd[n + 2], lgcd[n + 2], a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2) { cout << max(a[0], a[1]) << endl; return 0; } lgcd[0] = 0; lgcd[1] = a[0]; lgcd[n + 1] = 0; rgcd[0] = 0; rgcd[n] = a[n - 1]; rgcd[n + 1] = 0; for (int i = 2; i < n + 1; i++) { lgcd[i] = gcd(lgcd[i - 1], a[i - 1]); } for (int i = n - 1; i >= 1; i--) { rgcd[i] = gcd(rgcd[i + 1], a[i - 1]); } int ans = 0; for (int i = 1; i < n; i++) { ans = max(ans, gcd(rgcd[i + 1], lgcd[i - 1])); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { int t = a; a = b; b = t; } if (b == 0) return a; return gcd(b, a % b); } int main() { int n; cin >> n; int rgcd[n + 2], lgcd[n + 2], a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2) { cout << max(a[0], a[1]) << endl; return 0; } lgcd[0] = 0; lgcd[1] = a[0]; lgcd[n + 1] = 0; rgcd[0] = 0; rgcd[n] = a[n - 1]; rgcd[n + 1] = 0; for (int i = 2; i < n + 1; i++) { lgcd[i] = gcd(lgcd[i - 1], a[i - 1]); } for (int i = n - 1; i >= 1; i--) { rgcd[i] = gcd(rgcd[i + 1], a[i - 1]); } int ans = 0; for (int i = 1; i < n + 1; i++) { ans = max(ans, gcd(rgcd[i + 1], lgcd[i - 1])); } cout << ans << endl; return 0; }
[ "control_flow.loop.for.condition.change", "misc.off_by_one" ]
877,435
877,436
u174404613
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { int t = a; a = b; b = t; } if (b == 0) return a; return gcd(b, a % b); } int main() { int n; cin >> n; int rgcd[n + 2], lgcd[n + 2], a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2) { cout << max(a[0], a[1]) << endl; return 0; } lgcd[0] = 0; lgcd[1] = a[0]; lgcd[n + 1] = 0; rgcd[0] = 0; rgcd[n] = a[n - 1]; rgcd[n + 1] = 0; for (int i = 2; i < n + 1; i++) { lgcd[i] = gcd(lgcd[i - 1], a[i - 2]); } for (int i = n - 1; i >= 1; i--) { rgcd[i] = gcd(rgcd[i + 1], a[i - 1]); } int ans = 0; for (int i = 1; i < n; i++) { ans = max(ans, gcd(rgcd[i + 1], lgcd[i - 1])); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { int t = a; a = b; b = t; } if (b == 0) return a; return gcd(b, a % b); } int main() { int n; cin >> n; int rgcd[n + 2], lgcd[n + 2], a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2) { cout << max(a[0], a[1]) << endl; return 0; } lgcd[0] = 0; lgcd[1] = a[0]; lgcd[n + 1] = 0; rgcd[0] = 0; rgcd[n] = a[n - 1]; rgcd[n + 1] = 0; for (int i = 2; i < n + 1; i++) { lgcd[i] = gcd(lgcd[i - 1], a[i - 1]); } for (int i = n - 1; i >= 1; i--) { rgcd[i] = gcd(rgcd[i + 1], a[i - 1]); } int ans = 0; for (int i = 1; i < n + 1; i++) { ans = max(ans, gcd(rgcd[i + 1], lgcd[i - 1])); } cout << ans << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
877,437
877,436
u174404613
cpp
p03061
#include <algorithm> #include <cmath> #include <iostream> #include <iterator> #include <string> #include <vector> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); while (a % b != 0) { long long c = a % b; a = b; b = c; } return b; } int main() { long long n; cin >> n; vector<long long> a(n); vector<long long> l(n); vector<long long> r(n); for (long long i = 0; i < n; i++) { cin >> a[i]; } l[0] = a[0]; r[n - 1] = a[n - 1]; for (long long i = 1; i < n; i++) { l[i] = gcd(l[i - 1], a[i]); } for (long long i = n - 2; i >= 0; i--) { r[i] = gcd(r[i + 1], a[i]); } long long ans = max(r[1], l[n - 1]); for (long long i = 1; i < n - 1; i++) { long long tmp = gcd(l[i - 1], r[i + 1]); if (tmp > ans) ans = tmp; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <iterator> #include <string> #include <vector> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); while (a % b != 0) { long long c = a % b; a = b; b = c; } return b; } int main() { long long n; cin >> n; vector<long long> a(n); vector<long long> l(n); vector<long long> r(n); for (long long i = 0; i < n; i++) { cin >> a[i]; } l[0] = a[0]; r[n - 1] = a[n - 1]; for (long long i = 1; i < n; i++) { l[i] = gcd(l[i - 1], a[i]); } for (long long i = n - 2; i >= 0; i--) { r[i] = gcd(r[i + 1], a[i]); } long long ans = max(r[1], l[n - 2]); for (long long i = 1; i < n - 1; i++) { long long tmp = gcd(l[i - 1], r[i + 1]); if (tmp > ans) ans = tmp; } cout << ans << endl; // for(long long i = 0; i< n ;i++){ // cout << a[i] << " " << l[i] << " " << r[i] << endl; // } return 0; }
[ "literal.number.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
877,438
877,439
u314960567
cpp
p03061
#include <bits/stdc++.h> using namespace std; int euclidean(int a, int b) { int a1 = max(a, b); int a2 = min(a, b); if (a2 == 0) return 0; int a3 = a1 % a2; for (; a3 > 0;) { a1 = a2; a2 = a3; a3 = a1 % a2; } return a2; } int main(void) { int N; cin >> N; vector<int> A(N, 0); vector<int> L(N + 1, 0); vector<int> R(N + 1, 0); for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 1; i <= N; i++) { L[i] = euclidean(L[i - 1], A[i - 1]); } for (int i = N - 1; i >= 0; i++) { R[i] = euclidean(R[i + 1], A[i]); } int gcd = 0; for (int i = 0; i < N; i++) { gcd = max(gcd, euclidean(L[i], R[i + 1])); } cout << gcd << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int euclidean(int a, int b) { int a1 = max(a, b); int a2 = min(a, b); if (a2 == 0) return a1; int a3 = a1 % a2; for (; a3 > 0;) { a1 = a2; a2 = a3; a3 = a1 % a2; } return a2; } int main(void) { int N; cin >> N; vector<int> A(N, 0); vector<int> L(N + 1, 0); vector<int> R(N + 1, 0); for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 1; i <= N; i++) { L[i] = euclidean(L[i - 1], A[i - 1]); } for (int i = N - 1; i >= 0; i--) { R[i] = euclidean(R[i + 1], A[i]); } int gcd = 0; for (int i = 0; i < N; i++) { gcd = max(gcd, euclidean(L[i], R[i + 1])); } cout << gcd << endl; return 0; }
[ "identifier.replace.add", "literal.replace.remove", "function.return_value.change" ]
877,443
877,444
u360441331
cpp
p03061
#include <bits/stdc++.h> using namespace std; int a[100010]; int res[100010]; int cnt[100010]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int x = a[0]; int y = a[1]; int c = 0; int b = 0; for (int i = 1; i * i <= x; i++) { if (x % i == 0) { res[c] = i; c++; res[c] = x / i; c++; } } sort(res, res + c); for (int i = 1; i * i <= y; i++) { if (x % i == 0) { cnt[b] = i; b++; cnt[b] = y / i; b++; } } sort(cnt, cnt + b); int ans = -1; int ans2 = -1; for (int i = c - 1; i >= 0; i--) { int ans3 = 0; for (int j = 0; j < n; j++) { if (a[j] % res[i] != 0) { ans3++; } } if (ans3 == 0 || ans3 == 1) { ans = res[i]; break; } } for (int i = b - 1; i >= 0; i--) { int ans3 = 0; for (int j = 0; j < n; j++) { if (a[j] % cnt[i] != 0) { ans3++; } } if (ans3 == 0 || ans3 == 1) { ans2 = cnt[i]; break; } } cout << max(ans, ans2) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[100010]; int res[100010]; int cnt[100010]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int x = a[0]; int y = a[1]; int c = 0; int b = 0; for (int i = 1; i * i <= x; i++) { if (x % i == 0) { res[c] = i; c++; res[c] = x / i; c++; } } sort(res, res + c); for (int i = 1; i * i <= y; i++) { if (y % i == 0) { cnt[b] = i; b++; cnt[b] = y / i; b++; } } sort(cnt, cnt + b); int ans = -1; int ans2 = -1; for (int i = c - 1; i >= 0; i--) { int ans3 = 0; for (int j = 0; j < n; j++) { if (a[j] % res[i] != 0) { ans3++; } } if (ans3 == 0 || ans3 == 1) { ans = res[i]; break; } } for (int i = b - 1; i >= 0; i--) { int ans3 = 0; for (int j = 0; j < n; j++) { if (a[j] % cnt[i] != 0) { ans3++; } } if (ans3 == 0 || ans3 == 1) { ans2 = cnt[i]; break; } } cout << max(ans, ans2) << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
877,456
877,457
u426657245
cpp
p03061
#include <algorithm> #include <iostream> #include <iterator> #include <numeric> #include <vector> long int Euclid(long int A, long int B) { if (A < B) return Euclid(B, A); while (A % B != 0) { long int R = A % B; A = B; B = R; } return A; } int main() { long int N; std::cin >> N; std::vector<int> A(N); std::copy_n(std::istream_iterator<int>(std::cin), N, A.begin()); std::vector<long int> gcd_front(1, 1); std::vector<long int> gcd_back(1, 1); gcd_front.push_back(A[0]); gcd_back.push_back(A[N - 1]); long int gcd_f = A[0]; long int gcd_b = A[N - 1]; for (int i = 1; i < N; i++) { gcd_front.push_back(Euclid(gcd_f, A[i])); gcd_back.push_back(Euclid(gcd_b, A[N - i - 1])); gcd_f = gcd_front[i + 1]; gcd_b = gcd_back[i + 1]; } long int gcd = 0; long int max_gcd = gcd_back[N - 1]; for (int i = 2; i < N; i++) { gcd = Euclid(gcd_front[i - 1], gcd_back[N - i]); if (max_gcd <= gcd) max_gcd = gcd; } gcd = gcd_front[N - 1]; if (max_gcd <= gcd) max_gcd = gcd; std::cout << max_gcd << std::endl; return 0; }
#include <algorithm> #include <iostream> #include <iterator> #include <numeric> #include <vector> long int Euclid(long int A, long int B) { if (A < B) return Euclid(B, A); while (B != 0) { long int R = A % B; A = B; B = R; } return A; } int main() { long int N; std::cin >> N; std::vector<int> A(N); std::copy_n(std::istream_iterator<int>(std::cin), N, A.begin()); std::vector<long int> gcd_front(1, 1); std::vector<long int> gcd_back(1, 1); gcd_front.push_back(A[0]); gcd_back.push_back(A[N - 1]); long int gcd_f = A[0]; long int gcd_b = A[N - 1]; for (int i = 1; i < N; i++) { gcd_front.push_back(Euclid(gcd_f, A[i])); gcd_back.push_back(Euclid(gcd_b, A[N - i - 1])); gcd_f = gcd_front[i + 1]; gcd_b = gcd_back[i + 1]; } long int gcd = 0; long int max_gcd = gcd_back[N - 1]; for (int i = 2; i < N; i++) { gcd = Euclid(gcd_front[i - 1], gcd_back[N - i]); if (max_gcd <= gcd) max_gcd = gcd; } gcd = gcd_front[N - 1]; if (max_gcd <= gcd) max_gcd = gcd; std::cout << max_gcd << std::endl; return 0; }
[ "expression.operation.binary.remove" ]
877,460
877,461
u802260583
cpp
p03061
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ // ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ // ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ // ███████████████████ #include "bits/stdc++.h" using namespace std; #define MOD 1000000007 const double EPS = 1e-9; #define INF (1LL << 60) #define D double #define fs first #define sc second #define int long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair<int, int> P; typedef vector<vector<P>> Graph; typedef vector<int> vec; typedef vector<vector<int>> mat; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vec a(n); REP(i, n) cin >> a[i]; vec x(n), y(n); x[0] = a[0], y[n - 1] = a[n - 1]; REP(i, n - 1) x[i + 1] = __gcd(x[i], a[i]); RREP(i, n - 1) y[i] = __gcd(a[i], y[i + 1]); int ans = max(x[n - 2], y[1]); FOR(i, 1, n - 1) ans = max(ans, __gcd(x[i - 1], y[i + 1])); cout << ans << endl; return 0; }
// warm heart, wagging tail,and a smile just for you! // ███████████ // ███╬╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬████╬╬╬╬╬╬███ // ███████████ // ██╬╬╬╬╬████╬╬████╬╬╬╬╬██ // █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██ // ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██ // ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██ // ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████ // █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████ // ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███ // ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████ // ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██ // ██████████████ // ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████ // ███████ █████ // ███████████████████ #include "bits/stdc++.h" using namespace std; #define MOD 1000000007 const double EPS = 1e-9; #define INF (1LL << 60) #define D double #define fs first #define sc second #define int long long #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define ITR(itr, mp) for (auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr, mp) for (auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i, a, b) ((a) <= (i) && (i) < (b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair<int, int> P; typedef vector<vector<P>> Graph; typedef vector<int> vec; typedef vector<vector<int>> mat; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vec a(n); REP(i, n) cin >> a[i]; vec x(n), y(n); x[0] = a[0], y[n - 1] = a[n - 1]; REP(i, n - 1) x[i + 1] = __gcd(x[i], a[i + 1]); RREP(i, n - 1) y[i] = __gcd(a[i], y[i + 1]); int ans = max(x[n - 2], y[1]); FOR(i, 1, n - 1) ans = max(ans, __gcd(x[i - 1], y[i + 1])); cout << ans << endl; return 0; }
[ "assignment.change" ]
877,473
877,474
u239493918
cpp
p03061
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i]; vector<int> left(N + 1, 0), right(N + 1, 0); for (int i = 0; i < N; i++) left[i + 1] = GCD(left[i], a[i]); for (int i = N - 1; i >= N; i--) right[i] = GCD(right[i + 1], a[i]); int res = 0; for (int i = 0; i < N; i++) { int l = left[i]; int r = right[i + 1]; chmax(res, GCD(l, r)); } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i]; vector<int> left(N + 1, 0), right(N + 1, 0); for (int i = 0; i < N; i++) left[i + 1] = GCD(left[i], a[i]); for (int i = N - 1; i >= 0; i--) right[i] = GCD(right[i + 1], a[i]); int res = 0; for (int i = 0; i < N; i++) { int l = left[i]; int r = right[i + 1]; chmax(res, GCD(l, r)); } cout << res << endl; }
[ "identifier.replace.remove", "literal.replace.add", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
877,478
877,479
u579754454
cpp
p03061
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>; template <class S, class T> using P = pair<S, T>; template <class S, class T, class U> using TP = tuple<S, T, U>; using ll = long long; using ull = unsigned long long; using dbl = double; using str = string; using vll = V<ll>; using vvll = V<vll>; using vvvll = V<vvll>; using pl = P<ll, ll>; using tl = TP<ll, ll, ll>; using vpl = V<pl>; using vvpl = V<vpl>; using vtl = V<tl>; using vvtl = V<vtl>; using vs = V<str>; using vvs = V<vs>; using vd = V<dbl>; using vvd = V<vd>; using qll = queue<ll>; using qpl = queue<pl>; using stll = stack<ll>; using stpl = stack<pl>; using mapll = map<ll, ll>; using setll = set<ll>; using pqll = priority_queue<ll>; #define int ll #define fi first #define se second #define mp make_pair #define mt make_tuple #define pb push_back #define pob pop_back() #define pf push_front #define pof pop_front() #define sz size() #define bgn begin() #define en end() #define asn assign #define emp empty() #define fr front() #define bk back() #define clr clear() #define ins insert #define ers erase #define res resize #define tp top() #define p_q priority_queue #define inv inverse() #define FOR(i, a, b) for (ll i = (a); i <= (ll)(b); i++) #define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) #define REP(i, a) FOR((i), 0, (ll)(a)-1) #define REP0(i, a) FOR((i), 0, (ll)(a)) #define REP1(i, a) FOR((i), 1, (ll)(a)) #define rREP(i, a) rFOR((i), 0, (ll)(a)-1) #define rREP0(i, a) rFOR((i), 0, (ll)(a)) #define rREP1(i, a) rFOR((i), 1, (ll)(a)) #define ROR(v, i) for (auto &(i) : (v)) #define IOTA(a, n) iota((a).bgn, (a).en, (n)) #define SORT(a) sort((a).bgn, (a).en) #define rSORT(a) sort((a).rbegin(), (a).rend()) #define UNIQUE(a) (a).erase(unique((a).bgn, (a).en), (a).en) #define PREVP(a) prev_permutation((a).bgn, (a).en) #define NEXTP(a) next_permutation((a).bgn, (a).en) #define BINS(a, b) binary_search((a).bgn, (a).en, (b)) #define LOWB(a, b) (lower_bound((a).bgn, (a).en, (b)) - (a).bgn) #define UPB(a, b) (upper_bound((a).bgn, (a).en, (b)) - (a).bgn) #define CNT(a, b) count((a).bgn, (a).en, b) #define SUM(a) accumulate((a).bgn, (a).en, 0) #define REV(a) reverse((a).bgn, (a).en) #define REGS(a, b) regex_search((a), regex(b)) #define REGM(a, b) regex_match((a), regex(b)) #define yn(a) cout << ((a) ? "yes" : "no") << "\n"; #define Yn(a) cout << ((a) ? "Yes" : "No") << "\n"; #define YN(a) cout << ((a) ? "YES" : "NO") << "\n"; #define imp(a) cout << ((a) ? "possible" : "impossible") << "\n"; #define Imp(a) cout << ((a) ? "Possible" : "Impossible") << "\n"; #define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << "\n"; #define fs(a) cout << ((a) ? "second" : "first") << "\n"; #define Fs(a) cout << ((a) ? "Second" : "First") << "\n"; #define FS(a) cout << ((a) ? "SECOND" : "FIRST") << "\n"; #define sak cout << "\n"; #define sas cout << " "; #define sat cout << "\t"; #define dbg(a) cerr << (#a) << ": " << (a) << "\n"; #define dbgs(...) \ dal(#__VA_ARGS__); \ dal(__VA_ARGS__); #define c2l(a) ((ll)(a - 48)) #define a2l(a) ((ll)(a - 97)) #define A2l(a) ((ll)(a - 65)) #define l2c(a) ((char)(a + 48)) #define l2a(a) ((char)(a + 97)) #define l2A(a) ((char)(a + 65)) #define DigN2(a) ((llabs(a) == 0) ? (1) : ((ll)(log2(double(llabs(a)))) + 1)) #define DigN10(a) ((llabs(a) == 0) ? (1) : ((ll)(log10(double(llabs(a)))) + 1)) #define Dig2(a, b) (((a) >> (b)) & 1) #define Dig10(a, b) (ll)(((a) / ((ll)(pow(10.0, (double)(b))))) % 10) #define Pow2(a) ((ll)(1) << (a)) #define Pow10(a) ((ll)(pow(10.0, double(a)))) #define LSB(a) ((a) & (-(a))) #define vin(v) \ ROR((v), (i)) { cin >> (i); }; #define vllin(v, N) \ vll(v)((N)); \ vin(v); #define vllin2(a, b, N) \ vll(a)(N), (b)(N); \ REP(i, N) { cin >> (a)[i] >> (b)[i]; }; #define vsin(v, N) \ vs(v)((N)); \ vin(v); #define rdn(a, b) ((a) / (b)) #define rou(a, b) \ ((((double(a) / double(b)) - ((a) / (b))) < 0.5) ? ((a) / (b)) \ : (((a) / (b)) + 1)) #define rup(a, b) ((((a) % (b)) == 0) ? ((a) / (b)) : (((a) / (b)) + 1)) #define min(...) Min(__VA_ARGS__) #define max(...) Max(__VA_ARGS__) #define emin(a, ...) ((a) = Min((a), __VA_ARGS__)) #define emax(a, ...) ((a) = Max((a), __VA_ARGS__)) #define egcd(a, ...) ((a) = gcd((a), __VA_ARGS__)) #define elcm(a, ...) ((a) = lcm((a), __VA_ARGS__)) #define powll(a, b) (ll)(pow((double)(a), (double)(b))) #define Triangle(x1, y1, x2, y2, x3, y3) \ (((x1) - (x2)) * ((y1) - (y3)) - ((x1) - (x3)) * ((y1) - (y2))) #define svll SumV<ll> #define svvll SumV2<ll> #define li(...) \ ll __VA_ARGS__; \ Input(__VA_ARGS__); #define si(...) \ str __VA_ARGS__; \ Input(__VA_ARGS__); #define vli(size, ...) \ vll __VA_ARGS__; \ vInput(size, __VA_ARGS__); #define vsi(size, ...) \ vs __VA_ARGS__; \ vInput(size, __VA_ARGS__); // const ll MOD = 1e9 + 7; const ll MOD = 998244353; // const ll MOD = 924844033; // const ll MOD = 9007199254740881; const ll INF = 1LL << 60; // 1.15e18 const double PI = acos(-1.0); const vll DX = {0, -1, 0, 1, 0, -1, 1, 1, -1}; const vll DY = {0, 0, -1, 0, 1, -1, -1, 1, 1}; const str alp = "abcdefghijklmnopqrstuvwxyz"; const str ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void Input() {} template <class Var, class... Args> void Input(Var &var, Args &...args) { cin >> var; Input(args...); } void vInit(ll size) {} template <class T, class... Args> void vInit(ll size, V<T> &v, Args &...args) { v.res(size); vInit(size, args...); } void vInputNum(ll num) {} template <class T, class... Args> void vInputNum(ll num, V<T> &v, Args &...args) { cin >> v[num]; vInputNum(num, args...); } void vInput(ll size) {} template <class... Args> void vInput(ll size, Args &...args) { vInit(size, args...); REP(i, size) vInputNum(i, args...); } template <class S, class T> ostream &operator<<(ostream &out, const P<S, T> &p) { return out << "[" << p.fi << ", " << p.se << "]"; } template <class T> ostream &operator<<(ostream &out, V<T> &v) { if (v.emp) return out << "{}"; else { auto itr = v.bgn; out << "{" << *itr; itr++; while (itr != v.en) { out << ", " << *itr; itr++; } out << "}"; return out; } } template <class S, class T> ostream &operator<<(ostream &out, const map<S, T> &m) { if (m.emp) return out << "<[]>"; else { auto itr = m.bgn; out << "< [" << (itr->fi) << ": " << (itr->se); itr++; while (itr != m.en) { out << "], [" << (itr->fi) << ": " << (itr->se); itr++; } out << "] >"; return out; } } template <class T> ostream &operator<<(ostream &out, const set<T> &s) { if (s.emp) return out << "<>"; else { auto itr = s.bgn; out << "<" << *itr; itr++; while (itr != s.en) { out << ", " << *itr; itr++; } out << ">"; return out; } } void say() {} template <class T> void say(T t) { cout << t; } template <class Head, class... Body> void say(Head head, Body... body) { cout << head << " "; say(body...); } void sal() { cout << "\n"; } template <class... Args> void sal(Args... args) { say(args...); cout << "\n"; } void day() {} template <class T> void day(T t) { cerr << t; } template <class Head, class... Body> void day(Head head, Body... body) { cerr << head << " "; day(body...); } void dal() { cerr << "\n"; } template <class... Args> void dal(Args... args) { day(args...); cerr << "\n"; } void salv() {} template <class T> void salv(V<T> v) { if (v.emp) sal(); else { auto itr = v.bgn; say(*itr); itr++; while (itr != v.en) { sas; say(*itr); itr++; } sak; } } template <class T, class... Args> void salv(V<T> v, Args... args) { salv(v); salv(args...); } void salv2() {} template <class T> void salv2(V<V<T>> v) { if (v.emp) sal(); else { ROR(v, i) salv(i); } } template <class T, class... Args> void salv2(V<V<T>> v, Args... args) { salv2(v); salv2(args...); } template <class Monoid> struct Action { public: Monoid I; function<Monoid(Monoid, Monoid)> A; Action(Monoid I, function<Monoid(Monoid, Monoid)> A) : I(I), A(A) {} Monoid operator()() { return I; } Monoid operator()(Monoid x) { return x; } Monoid operator()(Monoid l, Monoid r) { return A(l, r); } template <class... Args> Monoid operator()(Monoid x, Args... args) { Monoid tmp = operator()(args...); return A(x, tmp); } }; template <class T> Action<T> ADD = Action<T>(0, [](T l, T r) { return l + r; }); template <> Action<str> ADD<str> = Action<str>("", [](str l, str r) { return l + r; }); template <class T1, class T2> Action<P<T1, T2>> ADD<P<T1, T2>> = Action<P<T1, T2>>(mp(ADD<T1>.I, ADD<T2>.I), [](P<T1, T2> l, P<T1, T2> r) { return mp(l.fi + r.fi, l.se + r.se); }); template <class T> Action<T> MUL = Action<T>(1, [](T l, T r) { return l * r; }); template <class T> Action<T> OR = Action<T>(0, [](T l, T r) { return l | r; }); template <class T> Action<T> XOR = Action<T>(0, [](T l, T r) { return l ^ r; }); template <class T> Action<T> AND = Action<T>(((ll)(1) << 63) - 1, [](T l, T r) { return l & r; }); template <> Action<bool> AND<bool> = Action<bool>(true, [](bool l, bool r) { return l & r; }); template <> Action<ull> AND<ull> = Action<ull>(((ull)(1) << 63) - 1, [](ull l, ull r) { return l & r; }); template <class T> Action<T> MIN = Action<T>(INF, [](T l, T r) { return (l < r) ? l : r; }); template <class T> Action<T> MAX = Action<T>(-INF, [](T l, T r) { return (l > r) ? l : r; }); template <class T> Action<T> GCD = Action<T>(0, [](T l, T r) { if (l < r) { l ^= r; r ^= l; l ^= r; } return (r ? GCD<T>(r, l % r) : l); }); template <class T> Action<T> LCM = Action<T>(1, [](T l, T r) { return (l * r) / GCD<T>(l, r); }); template <class Head> Head Min(Head head) { return head; } template <class Head, class... Body> Head Min(Head head, Body... body) { auto tmp = Min(body...); return (head < tmp) ? head : tmp; } template <class Head> Head Max(Head head) { return head; } template <class Head, class... Body> auto Max(Head head, Body... body) { auto tmp = Max(body...); return (head > tmp) ? head : tmp; } ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll gcd(ll head) { return head; } template <class... Body> ll gcd(ll head, Body... body) { return gcd(head, gcd(body...)); } ll lcm(ll head) { return head; } template <class... Body> ll lcm(ll head, Body... body) { return lcm(head, lcm(body...)); } ll Bset(ll a, ll b, ll c) { if (c) a |= b; else a &= ~b; return a; } struct UFT { public: ll tsize; ll mode; vll par; vll rank; UFT() {} UFT(const UFT &uft) {} UFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); } ll root(ll x) { return par[x] < 0 ? x : par[x] = root(par[x]); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } } ll size(ll x) { return -par[root(x)]; } }; struct pUFT { public: ll tsize; ll now; vll par; vll rank; vll mtime; vvll sizepi; vvll sizepv; pUFT() {} pUFT(const pUFT &puft) {} pUFT(ll tsizeget) { tsize = tsizeget; now = 0; par.asn(tsize, -1); rank.asn(tsize, 0); mtime.asn(tsize, INF); sizepi.asn(tsize, {0}); sizepv.asn(tsize, {1}); } ll root(ll x, ll t) { return (mtime[x] > t) ? x : root(par[x], t); } bool same(ll x, ll y, ll t) { return root(x, t) == root(y, t); } ll merge(ll x, ll y) { now++; x = root(x, now); y = root(y, now); if (x != y) { if (rank[x] < rank[y]) { par[y] += par[x]; sizepi[y].pb(now); sizepv[y].pb(-par[y]); par[x] = y; mtime[x] = now; } else { par[x] += par[y]; sizepi[x].pb(now); sizepv[x].pb(-par[x]); par[y] = x; mtime[y] = now; if (rank[x] == rank[y]) rank[x]++; } } return now; } ll size(ll x, ll t) { x = root(x, t); return sizepv[x][UPB(sizepi[x], t) - 1]; } }; struct wUFT { public: ll tsize; ll mode; vll par; vll rank; vll dweight; wUFT() {} wUFT(const wUFT &wuft) {} wUFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); dweight.asn(tsize, 0); } ll root(ll x) { if (par[x] < 0) return x; else { ll r = root(par[x]); dweight[x] += dweight[par[x]]; return par[x] = r; } } ll weight(ll x) { root(x); return dweight[x]; } ll diff(ll x, ll y) { return weight(y) - weight(x); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y, ll w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; dweight[x] = -w; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; dweight[y] = w; } } } ll size(ll x) { return -par[root(x)]; } }; template <typename valtype> class SegT { public: ll size; vector<valtype> v; valtype initv; function<valtype(valtype x, valtype y)> calc; SegT() {} SegT(const SegT &segt) {} SegT(ll sizeget, ll modeget = 0) { sizeset(sizeget); modeset(modeget); init(); } SegT(vector<valtype> cpyvec, ll modeget = 0) { sizeset(cpyvec.sz); modeset(modeget); init(); copy(cpyvec); } SegT(ll sizeget, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(sizeget); initv = initvget; calc = calcget; init(); } SegT(vector<valtype> cpyvec, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(cpyvec.sz); initv = initvget; calc = calcget; init(); copy(cpyvec); } void sizeset(ll rsize) { size = DigN2(rsize); if (rsize == Pow2(size - 1)) size--; return; } void modeset(ll mode) { switch (mode) { case 0: initv = 0; calc = [](valtype x, valtype y) { return x + y; }; break; case 1: initv = INF; calc = [](valtype x, valtype y) { return min(x, y); }; break; case 2: initv = -INF; calc = [](valtype x, valtype y) { return max(x, y); }; break; } return; } void init() { v.asn(Pow2(size + 1) - 1, initv); } void copy(vector<valtype> cpyvec) { REP(i, min(cpyvec.sz, Pow2(size))) set(i, cpyvec[i]); } ll i2v(ll i) const { if (i < 0 || i >= Pow2(size)) return -1; return Pow2(size) + i - 1; } ll top(ll i) const { if (i == 0) return -1; return (i - 1) / 2; } pl bot(ll i) const { if (i + 1 >= Pow2(size)) return mp(-1, -1); return mp(2 * i + 1, 2 * i + 2); } void set(ll i, valtype x) { i = i2v(i); v[i] = x; while (i > 0) { i = top(i); v[i] = calc(v[bot(i).fi], v[bot(i).se]); } return; } void add(ll i, valtype x) { set(i, v[i2v(i)] + x); return; } valtype operator[](const ll &i) const { return v[i2v(i)]; } // valtype que(ll a = 0, ll b = Pow2(size) - 1) { valtype que(ll a, ll b) { if (a == b) return v[i2v(a)]; if (a > b) return initv; // swap(a, b); valtype ans = initv; ll ai = i2v(a); ll bi = i2v(b); FOR(i, 1, size + 1) { if (a > b) break; if (a % Pow2(i)) { ans = calc(ans, v[ai]); a += Pow2(i - 1); ai = top(ai) + 1; } else { ai = top(ai); } if (a > b) break; if ((b + 1) % Pow2(i)) { ans = calc(ans, v[bi]); b -= Pow2(i - 1); bi = top(bi) - 1; } else { bi = top(bi); } if (a > b) break; } return ans; } valtype que(ll b) { return que(0, b); } valtype que() { return que(0, Pow2(size) - 1); } }; template <typename lentype> class Graph { public: ll size; ll mode; ll mapmode; lentype zlen; lentype ilen; vector<map<ll, ll>> v2n; vvll n2v; vector<vector<lentype>> Edge; vector<pair<lentype, ll>> Primresult; Graph() {} Graph(const Graph &graph) {} Graph(ll sizeget = 0, ll mapmodeget = 0, ll modeget = 0, lentype zlenget = 0, lentype ilenget = INF) { size = sizeget; mapmode = mapmodeget; mode = modeget; zlen = zlenget; ilen = ilenget; init(); } void init() { Edge.res(size); v2n.res(size); n2v.res(size); Primresult.asn(size, mp(ilen, -1)); } lentype lenplus(lentype l, lentype r) { return l + r; } lentype lenequal(lentype l, lentype r) { return l == r; } lentype lenlcr(lentype l, lentype r) { return l < r; } ll addV(ll vs) { size += vs; init(); return size; } void caddE(ll x, ll y, lentype c) { if (mapmode) v2n[x][y] = Edge[x].sz; Edge[x].pb(c); n2v[x].pb(y); } void csetE(ll x, ll y, lentype c) { if (mapmode) Edge[x][v2n[x][y]] = c; } void cersE(ll x, ll y) { if (mapmode) { ll n = v2n[x][y]; Edge[x][n] = ilen; n2v[x][n] = -1; v2n[x].ers(y); } } void addE(ll x, ll y, lentype c) { caddE(x, y, c); if (!mode) caddE(y, x, c); } void setE(ll x, ll y, lentype c) { csetE(x, y, c); if (!mode) csetE(y, x, c); } void ersE(ll x, ll y, lentype c) { cersE(x, y, c); if (!mode) cersE(y, x, c); } lentype getE(ll x, ll y) { if (mapmode) { if (v2n[x].count(y)) { return Edge[x][v2n[x][y]]; } } return ilen; } ll getVsz(ll x) { return Edge[x].sz; } pair<lentype, ll> getV(ll x, ll n) { if (n >= getVsz(x)) return mp(ilen, -1); return mp(Edge[x][n], n2v[x][n]); } vector<pair<lentype, vll>> Dijk(ll x) { vector<pair<lentype, vll>> result(size); REP(i, size) { result[i].fi = ilen; result[i].se = {-1}; } vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); result[x].fi = zlen; result[x].se = {-1}; while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else if (lenequal(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].se.pb(now.se); } } } } return result; } lentype Prim(ll x = 0) { lentype ans = zlen; vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); Primresult[x] = mp(zlen, -1); while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; ans = lenplus(ans, Primresult[now.se].fi); REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(nowlv.fi, Primresult[nowlv.se].fi)) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } } } } return ans; } }; /*template <class Type> class DP { public: vector<Type> v; Type initv; vll size, block; DP() {} DP(const DP &dp) {} template<class... Args> DP(Args... args) { block.asn(1, 1); Initialize(args...); } void Initialize(Type initv_) { initv = initv_; v.asn(block.bk, initv); } template<class... Args> void Initialize(ll val, Args... args) { size.pb(val); block.pb(block.bk*val); Initialize(args...); } };*/ pl Bezout(ll a, ll b) { if (b != 0) { pl xy; xy = Bezout(b, a % b); return mp(xy.se, xy.fi - ((a / b) * xy.se)); } else { return mp(1, 0); } } pl Bez(ll a, ll b, ll c) { pl xy; ll x, y, z, gc; xy = Bezout(a, b); gc = gcd(a, b); if (c % gc != 0) return mp(-1, -1); x = xy.fi * (c / gc); y = xy.se * (c / gc); if (x < 0) z = rup(-x, (b / gc)); if (x >= 0) z = -x / (b / gc); x += z * (b / gc); y -= z * (a / gc); return mp(x, y); } ll DigS10(ll n) { ll ans = 0; while (1) { ans += n % 10; n /= 10; if (!n) break; } return ans; } ll isP(ll n) { if (n <= 1) return 0; FOR(i, 2, (ll)sqrt(n) + 1) { if (n % i == 0) return 0; } return 1; } ll Tot(ll n) { if (n <= 0) return 0; ll ans = n, x = 2; while (x * x <= n) { if (n % x == 0) { ans -= ans / x; while (n % x == 0) n /= x; } x++; } if (n > 1) ans -= ans / n; return ans; } template <class T> struct Sum { public: V<T> v, s; ll size; Action<T> Add; Sum(V<T> v, Action<T> Add = ADD<T>) : v(v), size(v.sz), Add(Add) { Init(); Calc(); } void Init() { s.asn(size + 1, Add.I); } void Calc() { REP(i, size) s[i + 1] = Add(s[i], v[i]); } T operator()(ll x) { return operator()(0, x); } T operator()(ll l, ll r) { if (l < 0) l = 0; if (r >= size) r = size - 1; if (l > r) return Add.I; return s[r + 1] - s[l]; // for ADD } }; using sumll = Sum<ll>; template <class T> struct Sum2 { public: V<V<T>> v, s; ll RowSize, ColumnSize; Action<T> Add; Sum2(V<V<T>> v, Action<T> Add = ADD<T>) : v(v), RowSize(v.sz), ColumnSize(v.sz ? v[0].sz : 0), Add(Add) { Init(); Calc(); } void Init() { s.asn(RowSize + 1, V<T>(ColumnSize, Add.I)); } void Calc() { REP1(r, RowSize) { REP1(c, ColumnSize) { s[r][c] = v[r - 1][c - 1] + operator()(r, c - 1) + operator()(r - 1, c) - operator()(r - 1, c - 1); } } } T operator()(ll r, ll c) { return operator()(0, 0, r, c); } T operator()(ll r1, ll c1, ll r2, ll c2) { if (r1 < 0) r1 = 0; if (c1 < 0) c1 = 0; if (r2 >= RowSize) r2 = RowSize - 1; if (c2 >= ColumnSize) c2 = ColumnSize - 1; if (r1 > r2) return Add.I; if (c1 > c2) return Add.I; return s[r2 + 1][c2 + 1] - s[r2 + 1][c1] - s[r1][c2 + 1] + s[r1][c1]; } }; using sum2ll = Sum2<ll>; template <class T> struct Point2 { public: V<V<T>> v; ll h, w; Point2() : h(0), w(0) {} Point2(ll h, ll w) : h(h), w(w) { asn(h, w); } Point2(ll h, ll w, T val) : h(h), w(w) { asn(h, w, val); } void assign(ll h, ll w) { v.asn(h, V<T>(w)); } void assign(ll h, ll w, ll val) { v.asn(h, V<T>(w, val)); } T &operator()(ll h, ll w) { return v[h][w]; } T &operator()(pl p) { return v[p.fi][p.se]; } }; template <class T> using P2 = Point2<T>; template <ll Mod> struct Modll { public: ll v; Modll() : v(0) {} Modll(ll _v) { set(_v % Mod + Mod); } Modll &set(ll _v) { v = (_v < Mod) ? _v : (_v - Mod); return *this; } Modll pow(ll n) const { Modll x = *this, ans = 1; while (n) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } Modll inverse() const { return (*this).pow(Mod - 2); } Modll operator+(const Modll &m) const { return Modll().set(v + m.v); } Modll operator-(const Modll &m) const { return Modll().set(Mod + v - m.v); } Modll operator*(const Modll &m) const { return Modll().set((ull(v) * m.v) % Mod); } Modll operator/(const Modll &m) const { return *this * m.inv; } Modll &operator+=(const Modll &m) { return *this = *this + m; } Modll &operator-=(const Modll &m) { return *this = *this - m; } Modll &operator*=(const Modll &m) { return *this = *this * m; } Modll &operator/=(const Modll &m) { return *this = *this / m; } Modll operator-() const { return Modll(0) - *this; } explicit operator bool() const { return v != 0; } friend ostream &operator<<(ostream &out, const Modll &m) { return out << m.v; } }; using mll = Modll<MOD>; using vmll = V<mll>; using vvmll = V<vmll>; using vvvmll = V<vvmll>; template <class T> T vmin(V<T> v) { T tmp = MIN<T>.I; ROR(v, i) emin(tmp, i); return tmp; } template <class T, class... Args> T vmin(V<T> v, Args... args) { T tmp = vmin(args...); return min(vmin(v), tmp); } template <class T> T vmax(V<T> v) { T tmp = MAX<T>.I; ROR(v, i) emax(tmp, i); return tmp; } template <class T, class... Args> T vmax(V<T> v, Args... args) { T tmp = vmax(args...); return max(vmax(v), tmp); } template <class T> T vgcd(V<T> v) { T tmp = GCD<T>.I; ROR(v, i) egcd(tmp, i); return tmp; } template <class T, class... Args> T vgcd(V<T> v, Args... args) { T tmp = vgcd(args...); return gcd(vgcd(v), tmp); } template <class T> T vlcm(V<T> v) { T tmp = LCM<T>.I; ROR(v, i) elcm(tmp, i); return tmp; } template <class T, class... Args> T vlcm(V<T> v, Args... args) { T tmp = vlcm(args...); return lcm(vlcm(v), tmp); } vmll MFactMemo(2, 1); vmll MIFactMemo(2, 1); mll mFact(ll n) { if (MFactMemo.sz <= n) { ll oldsize = MFactMemo.sz; MFactMemo.res(n + 1, 1); FOR(i, oldsize, n) MFactMemo[i] = MFactMemo[i - 1] * i; } return MFactMemo[n]; } mll miFact(ll n) { if (MIFactMemo.sz <= n) { ll oldsize = MIFactMemo.sz; MIFactMemo.res(n + 1, 1); MIFactMemo.bk = mFact(n).inv; rFOR(i, oldsize + 1, n) MIFactMemo[i - 1] = MIFactMemo[i] * i; } return MIFactMemo[n]; } mll mComb(ll n, ll k) { if (n < 0 || k < 0 || n < k) return 0; return mFact(n) * miFact(k) * miFact(n - k); } ll LIS(vll v, ll m = 0) { if (v.sz > 0) { ll ans = 0; vll dp(v.sz, INF); FOR(i, 0, v.sz - 1) { dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i]; } FOR(i, 0, v.sz - 1) { if (dp[i] == INF) break; ans++; } return ans; } else { return 0; } } void PCmprs(vll &v) { if (v.sz == 0) return; vll vv(v); IOTA(vv, 0); sort(vv.bgn, vv.en, [&](ll v1, ll v2) { return v[v1] < v[v2]; }); IOTA(v, 0); sort(v.bgn, v.en, [&](ll v1, ll v2) { return vv[v1] < vv[v2]; }); return; } ll BblCnt(vll v) { PCmprs(v); SegT<ll> b(v.sz, 0); ll ans = 0; REP(i, v.sz) { ans += (i - b.que(0, v[i])); b.add(v[i], 1); } return ans; } ll Bsrch(function<bool(ll x)> f, ll mi, ll ma) { ll ng = mi - 1, ok = ma, mid; while (ok - ng > 1) { mid = (ng + ok) / 2; (f(mid) ? ok : ng) = mid; } return ok; } template <class T> V<V<T>> MultiMatrix(V<V<T>> A, V<V<T>> B, Action<T> Mul = MUL<T>, Action<T> Add = ADD<T>) { V<V<T>> ans; ll ii = A.sz; if (!ii) return ans; ll jj = A[0].sz; if (!jj) return ans; ll jj2 = B.sz; if (!jj2) return ans; if (jj != jj2) return ans; ll kk = B[0].sz; if (!kk) return ans; ans.asn(ii, V<T>(kk, 0)); REP(i, ii) { REP(k, kk) { REP(j, jj) { ans[i][k] = Add(ans[i][k], Mul(A[i][j], B[j][k])); } } } return ans; } vvll CombMemo(1000, vll(1000, -1)); ll Comb(ll n, ll k) { if ((n < 0) || (k < 0)) return 0; if (CombMemo[n][k] == -1) { if (n < k) CombMemo[n][k] = 0; else { if (n == 0) CombMemo[n][k] = 1; else if (k == 0) CombMemo[n][k] = 1; else if (n == k) CombMemo[n][k] = 1; else CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k); } } return CombMemo[n][k]; } template <class T> map<T, ll> Dict(V<T> v) { map<T, ll> m; if (!v.sz) return m; SORT(v); UNIQUE(v); REP(i, v.sz) { m[v[i]] = i; } return m; } template <class T> vll Cmprs(V<T> v) { auto m = Dict(v); vll ans(v.sz); REP(i, v.sz) { ans[i] = m[v[i]]; } return ans; } template <class T> auto vecn(T val) { return val; } template <class... Args> auto vecn(ll val, Args... args) { auto tmp = vecn(args...); return V<decltype(tmp)>(val, tmp); } void Solve(); signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; Solve(); } void Solve() { li(n); vli(n, a); if (n == 2) { cout << max(a[0], a[1]); return; } vll l(n), r(n); l[0] = a[0]; r[n - 1] = a[n - 1]; REP1(i, n - 1) { l[i] = gcd(l[i - 1], a[i]); r[n - i - 1] = gcd(r[n - i], a[n - i - 1]); } ll m = 0; REP(i, n - 1) { if (i == 0) { m = max(m, r[i + 1]); } else if (i == n - 1) { m = max(m, l[i - 1]); } else { m = max(m, gcd(r[i + 1], l[i - 1])); } } cout << m; }
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>; template <class S, class T> using P = pair<S, T>; template <class S, class T, class U> using TP = tuple<S, T, U>; using ll = long long; using ull = unsigned long long; using dbl = double; using str = string; using vll = V<ll>; using vvll = V<vll>; using vvvll = V<vvll>; using pl = P<ll, ll>; using tl = TP<ll, ll, ll>; using vpl = V<pl>; using vvpl = V<vpl>; using vtl = V<tl>; using vvtl = V<vtl>; using vs = V<str>; using vvs = V<vs>; using vd = V<dbl>; using vvd = V<vd>; using qll = queue<ll>; using qpl = queue<pl>; using stll = stack<ll>; using stpl = stack<pl>; using mapll = map<ll, ll>; using setll = set<ll>; using pqll = priority_queue<ll>; #define int ll #define fi first #define se second #define mp make_pair #define mt make_tuple #define pb push_back #define pob pop_back() #define pf push_front #define pof pop_front() #define sz size() #define bgn begin() #define en end() #define asn assign #define emp empty() #define fr front() #define bk back() #define clr clear() #define ins insert #define ers erase #define res resize #define tp top() #define p_q priority_queue #define inv inverse() #define FOR(i, a, b) for (ll i = (a); i <= (ll)(b); i++) #define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) #define REP(i, a) FOR((i), 0, (ll)(a)-1) #define REP0(i, a) FOR((i), 0, (ll)(a)) #define REP1(i, a) FOR((i), 1, (ll)(a)) #define rREP(i, a) rFOR((i), 0, (ll)(a)-1) #define rREP0(i, a) rFOR((i), 0, (ll)(a)) #define rREP1(i, a) rFOR((i), 1, (ll)(a)) #define ROR(v, i) for (auto &(i) : (v)) #define IOTA(a, n) iota((a).bgn, (a).en, (n)) #define SORT(a) sort((a).bgn, (a).en) #define rSORT(a) sort((a).rbegin(), (a).rend()) #define UNIQUE(a) (a).erase(unique((a).bgn, (a).en), (a).en) #define PREVP(a) prev_permutation((a).bgn, (a).en) #define NEXTP(a) next_permutation((a).bgn, (a).en) #define BINS(a, b) binary_search((a).bgn, (a).en, (b)) #define LOWB(a, b) (lower_bound((a).bgn, (a).en, (b)) - (a).bgn) #define UPB(a, b) (upper_bound((a).bgn, (a).en, (b)) - (a).bgn) #define CNT(a, b) count((a).bgn, (a).en, b) #define SUM(a) accumulate((a).bgn, (a).en, 0) #define REV(a) reverse((a).bgn, (a).en) #define REGS(a, b) regex_search((a), regex(b)) #define REGM(a, b) regex_match((a), regex(b)) #define yn(a) cout << ((a) ? "yes" : "no") << "\n"; #define Yn(a) cout << ((a) ? "Yes" : "No") << "\n"; #define YN(a) cout << ((a) ? "YES" : "NO") << "\n"; #define imp(a) cout << ((a) ? "possible" : "impossible") << "\n"; #define Imp(a) cout << ((a) ? "Possible" : "Impossible") << "\n"; #define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << "\n"; #define fs(a) cout << ((a) ? "second" : "first") << "\n"; #define Fs(a) cout << ((a) ? "Second" : "First") << "\n"; #define FS(a) cout << ((a) ? "SECOND" : "FIRST") << "\n"; #define sak cout << "\n"; #define sas cout << " "; #define sat cout << "\t"; #define dbg(a) cerr << (#a) << ": " << (a) << "\n"; #define dbgs(...) \ dal(#__VA_ARGS__); \ dal(__VA_ARGS__); #define c2l(a) ((ll)(a - 48)) #define a2l(a) ((ll)(a - 97)) #define A2l(a) ((ll)(a - 65)) #define l2c(a) ((char)(a + 48)) #define l2a(a) ((char)(a + 97)) #define l2A(a) ((char)(a + 65)) #define DigN2(a) ((llabs(a) == 0) ? (1) : ((ll)(log2(double(llabs(a)))) + 1)) #define DigN10(a) ((llabs(a) == 0) ? (1) : ((ll)(log10(double(llabs(a)))) + 1)) #define Dig2(a, b) (((a) >> (b)) & 1) #define Dig10(a, b) (ll)(((a) / ((ll)(pow(10.0, (double)(b))))) % 10) #define Pow2(a) ((ll)(1) << (a)) #define Pow10(a) ((ll)(pow(10.0, double(a)))) #define LSB(a) ((a) & (-(a))) #define vin(v) \ ROR((v), (i)) { cin >> (i); }; #define vllin(v, N) \ vll(v)((N)); \ vin(v); #define vllin2(a, b, N) \ vll(a)(N), (b)(N); \ REP(i, N) { cin >> (a)[i] >> (b)[i]; }; #define vsin(v, N) \ vs(v)((N)); \ vin(v); #define rdn(a, b) ((a) / (b)) #define rou(a, b) \ ((((double(a) / double(b)) - ((a) / (b))) < 0.5) ? ((a) / (b)) \ : (((a) / (b)) + 1)) #define rup(a, b) ((((a) % (b)) == 0) ? ((a) / (b)) : (((a) / (b)) + 1)) #define min(...) Min(__VA_ARGS__) #define max(...) Max(__VA_ARGS__) #define emin(a, ...) ((a) = Min((a), __VA_ARGS__)) #define emax(a, ...) ((a) = Max((a), __VA_ARGS__)) #define egcd(a, ...) ((a) = gcd((a), __VA_ARGS__)) #define elcm(a, ...) ((a) = lcm((a), __VA_ARGS__)) #define powll(a, b) (ll)(pow((double)(a), (double)(b))) #define Triangle(x1, y1, x2, y2, x3, y3) \ (((x1) - (x2)) * ((y1) - (y3)) - ((x1) - (x3)) * ((y1) - (y2))) #define svll SumV<ll> #define svvll SumV2<ll> #define li(...) \ ll __VA_ARGS__; \ Input(__VA_ARGS__); #define si(...) \ str __VA_ARGS__; \ Input(__VA_ARGS__); #define vli(size, ...) \ vll __VA_ARGS__; \ vInput(size, __VA_ARGS__); #define vsi(size, ...) \ vs __VA_ARGS__; \ vInput(size, __VA_ARGS__); // const ll MOD = 1e9 + 7; const ll MOD = 998244353; // const ll MOD = 924844033; // const ll MOD = 9007199254740881; const ll INF = 1LL << 60; // 1.15e18 const double PI = acos(-1.0); const vll DX = {0, -1, 0, 1, 0, -1, 1, 1, -1}; const vll DY = {0, 0, -1, 0, 1, -1, -1, 1, 1}; const str alp = "abcdefghijklmnopqrstuvwxyz"; const str ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void Input() {} template <class Var, class... Args> void Input(Var &var, Args &...args) { cin >> var; Input(args...); } void vInit(ll size) {} template <class T, class... Args> void vInit(ll size, V<T> &v, Args &...args) { v.res(size); vInit(size, args...); } void vInputNum(ll num) {} template <class T, class... Args> void vInputNum(ll num, V<T> &v, Args &...args) { cin >> v[num]; vInputNum(num, args...); } void vInput(ll size) {} template <class... Args> void vInput(ll size, Args &...args) { vInit(size, args...); REP(i, size) vInputNum(i, args...); } template <class S, class T> ostream &operator<<(ostream &out, const P<S, T> &p) { return out << "[" << p.fi << ", " << p.se << "]"; } template <class T> ostream &operator<<(ostream &out, V<T> &v) { if (v.emp) return out << "{}"; else { auto itr = v.bgn; out << "{" << *itr; itr++; while (itr != v.en) { out << ", " << *itr; itr++; } out << "}"; return out; } } template <class S, class T> ostream &operator<<(ostream &out, const map<S, T> &m) { if (m.emp) return out << "<[]>"; else { auto itr = m.bgn; out << "< [" << (itr->fi) << ": " << (itr->se); itr++; while (itr != m.en) { out << "], [" << (itr->fi) << ": " << (itr->se); itr++; } out << "] >"; return out; } } template <class T> ostream &operator<<(ostream &out, const set<T> &s) { if (s.emp) return out << "<>"; else { auto itr = s.bgn; out << "<" << *itr; itr++; while (itr != s.en) { out << ", " << *itr; itr++; } out << ">"; return out; } } void say() {} template <class T> void say(T t) { cout << t; } template <class Head, class... Body> void say(Head head, Body... body) { cout << head << " "; say(body...); } void sal() { cout << "\n"; } template <class... Args> void sal(Args... args) { say(args...); cout << "\n"; } void day() {} template <class T> void day(T t) { cerr << t; } template <class Head, class... Body> void day(Head head, Body... body) { cerr << head << " "; day(body...); } void dal() { cerr << "\n"; } template <class... Args> void dal(Args... args) { day(args...); cerr << "\n"; } void salv() {} template <class T> void salv(V<T> v) { if (v.emp) sal(); else { auto itr = v.bgn; say(*itr); itr++; while (itr != v.en) { sas; say(*itr); itr++; } sak; } } template <class T, class... Args> void salv(V<T> v, Args... args) { salv(v); salv(args...); } void salv2() {} template <class T> void salv2(V<V<T>> v) { if (v.emp) sal(); else { ROR(v, i) salv(i); } } template <class T, class... Args> void salv2(V<V<T>> v, Args... args) { salv2(v); salv2(args...); } template <class Monoid> struct Action { public: Monoid I; function<Monoid(Monoid, Monoid)> A; Action(Monoid I, function<Monoid(Monoid, Monoid)> A) : I(I), A(A) {} Monoid operator()() { return I; } Monoid operator()(Monoid x) { return x; } Monoid operator()(Monoid l, Monoid r) { return A(l, r); } template <class... Args> Monoid operator()(Monoid x, Args... args) { Monoid tmp = operator()(args...); return A(x, tmp); } }; template <class T> Action<T> ADD = Action<T>(0, [](T l, T r) { return l + r; }); template <> Action<str> ADD<str> = Action<str>("", [](str l, str r) { return l + r; }); template <class T1, class T2> Action<P<T1, T2>> ADD<P<T1, T2>> = Action<P<T1, T2>>(mp(ADD<T1>.I, ADD<T2>.I), [](P<T1, T2> l, P<T1, T2> r) { return mp(l.fi + r.fi, l.se + r.se); }); template <class T> Action<T> MUL = Action<T>(1, [](T l, T r) { return l * r; }); template <class T> Action<T> OR = Action<T>(0, [](T l, T r) { return l | r; }); template <class T> Action<T> XOR = Action<T>(0, [](T l, T r) { return l ^ r; }); template <class T> Action<T> AND = Action<T>(((ll)(1) << 63) - 1, [](T l, T r) { return l & r; }); template <> Action<bool> AND<bool> = Action<bool>(true, [](bool l, bool r) { return l & r; }); template <> Action<ull> AND<ull> = Action<ull>(((ull)(1) << 63) - 1, [](ull l, ull r) { return l & r; }); template <class T> Action<T> MIN = Action<T>(INF, [](T l, T r) { return (l < r) ? l : r; }); template <class T> Action<T> MAX = Action<T>(-INF, [](T l, T r) { return (l > r) ? l : r; }); template <class T> Action<T> GCD = Action<T>(0, [](T l, T r) { if (l < r) { l ^= r; r ^= l; l ^= r; } return (r ? GCD<T>(r, l % r) : l); }); template <class T> Action<T> LCM = Action<T>(1, [](T l, T r) { return (l * r) / GCD<T>(l, r); }); template <class Head> Head Min(Head head) { return head; } template <class Head, class... Body> Head Min(Head head, Body... body) { auto tmp = Min(body...); return (head < tmp) ? head : tmp; } template <class Head> Head Max(Head head) { return head; } template <class Head, class... Body> auto Max(Head head, Body... body) { auto tmp = Max(body...); return (head > tmp) ? head : tmp; } ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll gcd(ll head) { return head; } template <class... Body> ll gcd(ll head, Body... body) { return gcd(head, gcd(body...)); } ll lcm(ll head) { return head; } template <class... Body> ll lcm(ll head, Body... body) { return lcm(head, lcm(body...)); } ll Bset(ll a, ll b, ll c) { if (c) a |= b; else a &= ~b; return a; } struct UFT { public: ll tsize; ll mode; vll par; vll rank; UFT() {} UFT(const UFT &uft) {} UFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); } ll root(ll x) { return par[x] < 0 ? x : par[x] = root(par[x]); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } } ll size(ll x) { return -par[root(x)]; } }; struct pUFT { public: ll tsize; ll now; vll par; vll rank; vll mtime; vvll sizepi; vvll sizepv; pUFT() {} pUFT(const pUFT &puft) {} pUFT(ll tsizeget) { tsize = tsizeget; now = 0; par.asn(tsize, -1); rank.asn(tsize, 0); mtime.asn(tsize, INF); sizepi.asn(tsize, {0}); sizepv.asn(tsize, {1}); } ll root(ll x, ll t) { return (mtime[x] > t) ? x : root(par[x], t); } bool same(ll x, ll y, ll t) { return root(x, t) == root(y, t); } ll merge(ll x, ll y) { now++; x = root(x, now); y = root(y, now); if (x != y) { if (rank[x] < rank[y]) { par[y] += par[x]; sizepi[y].pb(now); sizepv[y].pb(-par[y]); par[x] = y; mtime[x] = now; } else { par[x] += par[y]; sizepi[x].pb(now); sizepv[x].pb(-par[x]); par[y] = x; mtime[y] = now; if (rank[x] == rank[y]) rank[x]++; } } return now; } ll size(ll x, ll t) { x = root(x, t); return sizepv[x][UPB(sizepi[x], t) - 1]; } }; struct wUFT { public: ll tsize; ll mode; vll par; vll rank; vll dweight; wUFT() {} wUFT(const wUFT &wuft) {} wUFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); dweight.asn(tsize, 0); } ll root(ll x) { if (par[x] < 0) return x; else { ll r = root(par[x]); dweight[x] += dweight[par[x]]; return par[x] = r; } } ll weight(ll x) { root(x); return dweight[x]; } ll diff(ll x, ll y) { return weight(y) - weight(x); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y, ll w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; dweight[x] = -w; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; dweight[y] = w; } } } ll size(ll x) { return -par[root(x)]; } }; template <typename valtype> class SegT { public: ll size; vector<valtype> v; valtype initv; function<valtype(valtype x, valtype y)> calc; SegT() {} SegT(const SegT &segt) {} SegT(ll sizeget, ll modeget = 0) { sizeset(sizeget); modeset(modeget); init(); } SegT(vector<valtype> cpyvec, ll modeget = 0) { sizeset(cpyvec.sz); modeset(modeget); init(); copy(cpyvec); } SegT(ll sizeget, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(sizeget); initv = initvget; calc = calcget; init(); } SegT(vector<valtype> cpyvec, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(cpyvec.sz); initv = initvget; calc = calcget; init(); copy(cpyvec); } void sizeset(ll rsize) { size = DigN2(rsize); if (rsize == Pow2(size - 1)) size--; return; } void modeset(ll mode) { switch (mode) { case 0: initv = 0; calc = [](valtype x, valtype y) { return x + y; }; break; case 1: initv = INF; calc = [](valtype x, valtype y) { return min(x, y); }; break; case 2: initv = -INF; calc = [](valtype x, valtype y) { return max(x, y); }; break; } return; } void init() { v.asn(Pow2(size + 1) - 1, initv); } void copy(vector<valtype> cpyvec) { REP(i, min(cpyvec.sz, Pow2(size))) set(i, cpyvec[i]); } ll i2v(ll i) const { if (i < 0 || i >= Pow2(size)) return -1; return Pow2(size) + i - 1; } ll top(ll i) const { if (i == 0) return -1; return (i - 1) / 2; } pl bot(ll i) const { if (i + 1 >= Pow2(size)) return mp(-1, -1); return mp(2 * i + 1, 2 * i + 2); } void set(ll i, valtype x) { i = i2v(i); v[i] = x; while (i > 0) { i = top(i); v[i] = calc(v[bot(i).fi], v[bot(i).se]); } return; } void add(ll i, valtype x) { set(i, v[i2v(i)] + x); return; } valtype operator[](const ll &i) const { return v[i2v(i)]; } // valtype que(ll a = 0, ll b = Pow2(size) - 1) { valtype que(ll a, ll b) { if (a == b) return v[i2v(a)]; if (a > b) return initv; // swap(a, b); valtype ans = initv; ll ai = i2v(a); ll bi = i2v(b); FOR(i, 1, size + 1) { if (a > b) break; if (a % Pow2(i)) { ans = calc(ans, v[ai]); a += Pow2(i - 1); ai = top(ai) + 1; } else { ai = top(ai); } if (a > b) break; if ((b + 1) % Pow2(i)) { ans = calc(ans, v[bi]); b -= Pow2(i - 1); bi = top(bi) - 1; } else { bi = top(bi); } if (a > b) break; } return ans; } valtype que(ll b) { return que(0, b); } valtype que() { return que(0, Pow2(size) - 1); } }; template <typename lentype> class Graph { public: ll size; ll mode; ll mapmode; lentype zlen; lentype ilen; vector<map<ll, ll>> v2n; vvll n2v; vector<vector<lentype>> Edge; vector<pair<lentype, ll>> Primresult; Graph() {} Graph(const Graph &graph) {} Graph(ll sizeget = 0, ll mapmodeget = 0, ll modeget = 0, lentype zlenget = 0, lentype ilenget = INF) { size = sizeget; mapmode = mapmodeget; mode = modeget; zlen = zlenget; ilen = ilenget; init(); } void init() { Edge.res(size); v2n.res(size); n2v.res(size); Primresult.asn(size, mp(ilen, -1)); } lentype lenplus(lentype l, lentype r) { return l + r; } lentype lenequal(lentype l, lentype r) { return l == r; } lentype lenlcr(lentype l, lentype r) { return l < r; } ll addV(ll vs) { size += vs; init(); return size; } void caddE(ll x, ll y, lentype c) { if (mapmode) v2n[x][y] = Edge[x].sz; Edge[x].pb(c); n2v[x].pb(y); } void csetE(ll x, ll y, lentype c) { if (mapmode) Edge[x][v2n[x][y]] = c; } void cersE(ll x, ll y) { if (mapmode) { ll n = v2n[x][y]; Edge[x][n] = ilen; n2v[x][n] = -1; v2n[x].ers(y); } } void addE(ll x, ll y, lentype c) { caddE(x, y, c); if (!mode) caddE(y, x, c); } void setE(ll x, ll y, lentype c) { csetE(x, y, c); if (!mode) csetE(y, x, c); } void ersE(ll x, ll y, lentype c) { cersE(x, y, c); if (!mode) cersE(y, x, c); } lentype getE(ll x, ll y) { if (mapmode) { if (v2n[x].count(y)) { return Edge[x][v2n[x][y]]; } } return ilen; } ll getVsz(ll x) { return Edge[x].sz; } pair<lentype, ll> getV(ll x, ll n) { if (n >= getVsz(x)) return mp(ilen, -1); return mp(Edge[x][n], n2v[x][n]); } vector<pair<lentype, vll>> Dijk(ll x) { vector<pair<lentype, vll>> result(size); REP(i, size) { result[i].fi = ilen; result[i].se = {-1}; } vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); result[x].fi = zlen; result[x].se = {-1}; while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else if (lenequal(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].se.pb(now.se); } } } } return result; } lentype Prim(ll x = 0) { lentype ans = zlen; vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); Primresult[x] = mp(zlen, -1); while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; ans = lenplus(ans, Primresult[now.se].fi); REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(nowlv.fi, Primresult[nowlv.se].fi)) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } } } } return ans; } }; /*template <class Type> class DP { public: vector<Type> v; Type initv; vll size, block; DP() {} DP(const DP &dp) {} template<class... Args> DP(Args... args) { block.asn(1, 1); Initialize(args...); } void Initialize(Type initv_) { initv = initv_; v.asn(block.bk, initv); } template<class... Args> void Initialize(ll val, Args... args) { size.pb(val); block.pb(block.bk*val); Initialize(args...); } };*/ pl Bezout(ll a, ll b) { if (b != 0) { pl xy; xy = Bezout(b, a % b); return mp(xy.se, xy.fi - ((a / b) * xy.se)); } else { return mp(1, 0); } } pl Bez(ll a, ll b, ll c) { pl xy; ll x, y, z, gc; xy = Bezout(a, b); gc = gcd(a, b); if (c % gc != 0) return mp(-1, -1); x = xy.fi * (c / gc); y = xy.se * (c / gc); if (x < 0) z = rup(-x, (b / gc)); if (x >= 0) z = -x / (b / gc); x += z * (b / gc); y -= z * (a / gc); return mp(x, y); } ll DigS10(ll n) { ll ans = 0; while (1) { ans += n % 10; n /= 10; if (!n) break; } return ans; } ll isP(ll n) { if (n <= 1) return 0; FOR(i, 2, (ll)sqrt(n) + 1) { if (n % i == 0) return 0; } return 1; } ll Tot(ll n) { if (n <= 0) return 0; ll ans = n, x = 2; while (x * x <= n) { if (n % x == 0) { ans -= ans / x; while (n % x == 0) n /= x; } x++; } if (n > 1) ans -= ans / n; return ans; } template <class T> struct Sum { public: V<T> v, s; ll size; Action<T> Add; Sum(V<T> v, Action<T> Add = ADD<T>) : v(v), size(v.sz), Add(Add) { Init(); Calc(); } void Init() { s.asn(size + 1, Add.I); } void Calc() { REP(i, size) s[i + 1] = Add(s[i], v[i]); } T operator()(ll x) { return operator()(0, x); } T operator()(ll l, ll r) { if (l < 0) l = 0; if (r >= size) r = size - 1; if (l > r) return Add.I; return s[r + 1] - s[l]; // for ADD } }; using sumll = Sum<ll>; template <class T> struct Sum2 { public: V<V<T>> v, s; ll RowSize, ColumnSize; Action<T> Add; Sum2(V<V<T>> v, Action<T> Add = ADD<T>) : v(v), RowSize(v.sz), ColumnSize(v.sz ? v[0].sz : 0), Add(Add) { Init(); Calc(); } void Init() { s.asn(RowSize + 1, V<T>(ColumnSize, Add.I)); } void Calc() { REP1(r, RowSize) { REP1(c, ColumnSize) { s[r][c] = v[r - 1][c - 1] + operator()(r, c - 1) + operator()(r - 1, c) - operator()(r - 1, c - 1); } } } T operator()(ll r, ll c) { return operator()(0, 0, r, c); } T operator()(ll r1, ll c1, ll r2, ll c2) { if (r1 < 0) r1 = 0; if (c1 < 0) c1 = 0; if (r2 >= RowSize) r2 = RowSize - 1; if (c2 >= ColumnSize) c2 = ColumnSize - 1; if (r1 > r2) return Add.I; if (c1 > c2) return Add.I; return s[r2 + 1][c2 + 1] - s[r2 + 1][c1] - s[r1][c2 + 1] + s[r1][c1]; } }; using sum2ll = Sum2<ll>; template <class T> struct Point2 { public: V<V<T>> v; ll h, w; Point2() : h(0), w(0) {} Point2(ll h, ll w) : h(h), w(w) { asn(h, w); } Point2(ll h, ll w, T val) : h(h), w(w) { asn(h, w, val); } void assign(ll h, ll w) { v.asn(h, V<T>(w)); } void assign(ll h, ll w, ll val) { v.asn(h, V<T>(w, val)); } T &operator()(ll h, ll w) { return v[h][w]; } T &operator()(pl p) { return v[p.fi][p.se]; } }; template <class T> using P2 = Point2<T>; template <ll Mod> struct Modll { public: ll v; Modll() : v(0) {} Modll(ll _v) { set(_v % Mod + Mod); } Modll &set(ll _v) { v = (_v < Mod) ? _v : (_v - Mod); return *this; } Modll pow(ll n) const { Modll x = *this, ans = 1; while (n) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } Modll inverse() const { return (*this).pow(Mod - 2); } Modll operator+(const Modll &m) const { return Modll().set(v + m.v); } Modll operator-(const Modll &m) const { return Modll().set(Mod + v - m.v); } Modll operator*(const Modll &m) const { return Modll().set((ull(v) * m.v) % Mod); } Modll operator/(const Modll &m) const { return *this * m.inv; } Modll &operator+=(const Modll &m) { return *this = *this + m; } Modll &operator-=(const Modll &m) { return *this = *this - m; } Modll &operator*=(const Modll &m) { return *this = *this * m; } Modll &operator/=(const Modll &m) { return *this = *this / m; } Modll operator-() const { return Modll(0) - *this; } explicit operator bool() const { return v != 0; } friend ostream &operator<<(ostream &out, const Modll &m) { return out << m.v; } }; using mll = Modll<MOD>; using vmll = V<mll>; using vvmll = V<vmll>; using vvvmll = V<vvmll>; template <class T> T vmin(V<T> v) { T tmp = MIN<T>.I; ROR(v, i) emin(tmp, i); return tmp; } template <class T, class... Args> T vmin(V<T> v, Args... args) { T tmp = vmin(args...); return min(vmin(v), tmp); } template <class T> T vmax(V<T> v) { T tmp = MAX<T>.I; ROR(v, i) emax(tmp, i); return tmp; } template <class T, class... Args> T vmax(V<T> v, Args... args) { T tmp = vmax(args...); return max(vmax(v), tmp); } template <class T> T vgcd(V<T> v) { T tmp = GCD<T>.I; ROR(v, i) egcd(tmp, i); return tmp; } template <class T, class... Args> T vgcd(V<T> v, Args... args) { T tmp = vgcd(args...); return gcd(vgcd(v), tmp); } template <class T> T vlcm(V<T> v) { T tmp = LCM<T>.I; ROR(v, i) elcm(tmp, i); return tmp; } template <class T, class... Args> T vlcm(V<T> v, Args... args) { T tmp = vlcm(args...); return lcm(vlcm(v), tmp); } vmll MFactMemo(2, 1); vmll MIFactMemo(2, 1); mll mFact(ll n) { if (MFactMemo.sz <= n) { ll oldsize = MFactMemo.sz; MFactMemo.res(n + 1, 1); FOR(i, oldsize, n) MFactMemo[i] = MFactMemo[i - 1] * i; } return MFactMemo[n]; } mll miFact(ll n) { if (MIFactMemo.sz <= n) { ll oldsize = MIFactMemo.sz; MIFactMemo.res(n + 1, 1); MIFactMemo.bk = mFact(n).inv; rFOR(i, oldsize + 1, n) MIFactMemo[i - 1] = MIFactMemo[i] * i; } return MIFactMemo[n]; } mll mComb(ll n, ll k) { if (n < 0 || k < 0 || n < k) return 0; return mFact(n) * miFact(k) * miFact(n - k); } ll LIS(vll v, ll m = 0) { if (v.sz > 0) { ll ans = 0; vll dp(v.sz, INF); FOR(i, 0, v.sz - 1) { dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i]; } FOR(i, 0, v.sz - 1) { if (dp[i] == INF) break; ans++; } return ans; } else { return 0; } } void PCmprs(vll &v) { if (v.sz == 0) return; vll vv(v); IOTA(vv, 0); sort(vv.bgn, vv.en, [&](ll v1, ll v2) { return v[v1] < v[v2]; }); IOTA(v, 0); sort(v.bgn, v.en, [&](ll v1, ll v2) { return vv[v1] < vv[v2]; }); return; } ll BblCnt(vll v) { PCmprs(v); SegT<ll> b(v.sz, 0); ll ans = 0; REP(i, v.sz) { ans += (i - b.que(0, v[i])); b.add(v[i], 1); } return ans; } ll Bsrch(function<bool(ll x)> f, ll mi, ll ma) { ll ng = mi - 1, ok = ma, mid; while (ok - ng > 1) { mid = (ng + ok) / 2; (f(mid) ? ok : ng) = mid; } return ok; } template <class T> V<V<T>> MultiMatrix(V<V<T>> A, V<V<T>> B, Action<T> Mul = MUL<T>, Action<T> Add = ADD<T>) { V<V<T>> ans; ll ii = A.sz; if (!ii) return ans; ll jj = A[0].sz; if (!jj) return ans; ll jj2 = B.sz; if (!jj2) return ans; if (jj != jj2) return ans; ll kk = B[0].sz; if (!kk) return ans; ans.asn(ii, V<T>(kk, 0)); REP(i, ii) { REP(k, kk) { REP(j, jj) { ans[i][k] = Add(ans[i][k], Mul(A[i][j], B[j][k])); } } } return ans; } vvll CombMemo(1000, vll(1000, -1)); ll Comb(ll n, ll k) { if ((n < 0) || (k < 0)) return 0; if (CombMemo[n][k] == -1) { if (n < k) CombMemo[n][k] = 0; else { if (n == 0) CombMemo[n][k] = 1; else if (k == 0) CombMemo[n][k] = 1; else if (n == k) CombMemo[n][k] = 1; else CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k); } } return CombMemo[n][k]; } template <class T> map<T, ll> Dict(V<T> v) { map<T, ll> m; if (!v.sz) return m; SORT(v); UNIQUE(v); REP(i, v.sz) { m[v[i]] = i; } return m; } template <class T> vll Cmprs(V<T> v) { auto m = Dict(v); vll ans(v.sz); REP(i, v.sz) { ans[i] = m[v[i]]; } return ans; } template <class T> auto vecn(T val) { return val; } template <class... Args> auto vecn(ll val, Args... args) { auto tmp = vecn(args...); return V<decltype(tmp)>(val, tmp); } void Solve(); signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; Solve(); } void Solve() { li(n); vli(n, a); if (n == 2) { cout << max(a[0], a[1]); return; } vll l(n), r(n); l[0] = a[0]; r[n - 1] = a[n - 1]; REP1(i, n - 1) { l[i] = gcd(l[i - 1], a[i]); r[n - i - 1] = gcd(r[n - i], a[n - i - 1]); } ll m = 0; REP(i, n) { if (i == 0) { m = max(m, r[i + 1]); } else if (i == n - 1) { m = max(m, l[i - 1]); } else { m = max(m, gcd(r[i + 1], l[i - 1])); } } cout << m; }
[ "expression.operation.binary.remove" ]
877,480
877,481
u172929647
cpp
p03061
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>; template <class S, class T> using P = pair<S, T>; template <class S, class T, class U> using TP = tuple<S, T, U>; using ll = long long; using ull = unsigned long long; using dbl = double; using str = string; using vll = V<ll>; using vvll = V<vll>; using vvvll = V<vvll>; using pl = P<ll, ll>; using tl = TP<ll, ll, ll>; using vpl = V<pl>; using vvpl = V<vpl>; using vtl = V<tl>; using vvtl = V<vtl>; using vs = V<str>; using vvs = V<vs>; using vd = V<dbl>; using vvd = V<vd>; using qll = queue<ll>; using qpl = queue<pl>; using stll = stack<ll>; using stpl = stack<pl>; using mapll = map<ll, ll>; using setll = set<ll>; using pqll = priority_queue<ll>; #define int ll #define fi first #define se second #define mp make_pair #define mt make_tuple #define pb push_back #define pob pop_back() #define pf push_front #define pof pop_front() #define sz size() #define bgn begin() #define en end() #define asn assign #define emp empty() #define fr front() #define bk back() #define clr clear() #define ins insert #define ers erase #define res resize #define tp top() #define p_q priority_queue #define inv inverse() #define FOR(i, a, b) for (ll i = (a); i <= (ll)(b); i++) #define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) #define REP(i, a) FOR((i), 0, (ll)(a)-1) #define REP0(i, a) FOR((i), 0, (ll)(a)) #define REP1(i, a) FOR((i), 1, (ll)(a)) #define rREP(i, a) rFOR((i), 0, (ll)(a)-1) #define rREP0(i, a) rFOR((i), 0, (ll)(a)) #define rREP1(i, a) rFOR((i), 1, (ll)(a)) #define ROR(v, i) for (auto &(i) : (v)) #define IOTA(a, n) iota((a).bgn, (a).en, (n)) #define SORT(a) sort((a).bgn, (a).en) #define rSORT(a) sort((a).rbegin(), (a).rend()) #define UNIQUE(a) (a).erase(unique((a).bgn, (a).en), (a).en) #define PREVP(a) prev_permutation((a).bgn, (a).en) #define NEXTP(a) next_permutation((a).bgn, (a).en) #define BINS(a, b) binary_search((a).bgn, (a).en, (b)) #define LOWB(a, b) (lower_bound((a).bgn, (a).en, (b)) - (a).bgn) #define UPB(a, b) (upper_bound((a).bgn, (a).en, (b)) - (a).bgn) #define CNT(a, b) count((a).bgn, (a).en, b) #define SUM(a) accumulate((a).bgn, (a).en, 0) #define REV(a) reverse((a).bgn, (a).en) #define REGS(a, b) regex_search((a), regex(b)) #define REGM(a, b) regex_match((a), regex(b)) #define yn(a) cout << ((a) ? "yes" : "no") << "\n"; #define Yn(a) cout << ((a) ? "Yes" : "No") << "\n"; #define YN(a) cout << ((a) ? "YES" : "NO") << "\n"; #define imp(a) cout << ((a) ? "possible" : "impossible") << "\n"; #define Imp(a) cout << ((a) ? "Possible" : "Impossible") << "\n"; #define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << "\n"; #define fs(a) cout << ((a) ? "second" : "first") << "\n"; #define Fs(a) cout << ((a) ? "Second" : "First") << "\n"; #define FS(a) cout << ((a) ? "SECOND" : "FIRST") << "\n"; #define sak cout << "\n"; #define sas cout << " "; #define sat cout << "\t"; #define dbg(a) cerr << (#a) << ": " << (a) << "\n"; #define dbgs(...) \ dal(#__VA_ARGS__); \ dal(__VA_ARGS__); #define c2l(a) ((ll)(a - 48)) #define a2l(a) ((ll)(a - 97)) #define A2l(a) ((ll)(a - 65)) #define l2c(a) ((char)(a + 48)) #define l2a(a) ((char)(a + 97)) #define l2A(a) ((char)(a + 65)) #define DigN2(a) ((llabs(a) == 0) ? (1) : ((ll)(log2(double(llabs(a)))) + 1)) #define DigN10(a) ((llabs(a) == 0) ? (1) : ((ll)(log10(double(llabs(a)))) + 1)) #define Dig2(a, b) (((a) >> (b)) & 1) #define Dig10(a, b) (ll)(((a) / ((ll)(pow(10.0, (double)(b))))) % 10) #define Pow2(a) ((ll)(1) << (a)) #define Pow10(a) ((ll)(pow(10.0, double(a)))) #define LSB(a) ((a) & (-(a))) #define vin(v) \ ROR((v), (i)) { cin >> (i); }; #define vllin(v, N) \ vll(v)((N)); \ vin(v); #define vllin2(a, b, N) \ vll(a)(N), (b)(N); \ REP(i, N) { cin >> (a)[i] >> (b)[i]; }; #define vsin(v, N) \ vs(v)((N)); \ vin(v); #define rdn(a, b) ((a) / (b)) #define rou(a, b) \ ((((double(a) / double(b)) - ((a) / (b))) < 0.5) ? ((a) / (b)) \ : (((a) / (b)) + 1)) #define rup(a, b) ((((a) % (b)) == 0) ? ((a) / (b)) : (((a) / (b)) + 1)) #define min(...) Min(__VA_ARGS__) #define max(...) Max(__VA_ARGS__) #define emin(a, ...) ((a) = Min((a), __VA_ARGS__)) #define emax(a, ...) ((a) = Max((a), __VA_ARGS__)) #define egcd(a, ...) ((a) = gcd((a), __VA_ARGS__)) #define elcm(a, ...) ((a) = lcm((a), __VA_ARGS__)) #define powll(a, b) (ll)(pow((double)(a), (double)(b))) #define Triangle(x1, y1, x2, y2, x3, y3) \ (((x1) - (x2)) * ((y1) - (y3)) - ((x1) - (x3)) * ((y1) - (y2))) #define svll SumV<ll> #define svvll SumV2<ll> #define li(...) \ ll __VA_ARGS__; \ Input(__VA_ARGS__); #define si(...) \ str __VA_ARGS__; \ Input(__VA_ARGS__); #define vli(size, ...) \ vll __VA_ARGS__; \ vInput(size, __VA_ARGS__); #define vsi(size, ...) \ vs __VA_ARGS__; \ vInput(size, __VA_ARGS__); // const ll MOD = 1e9 + 7; const ll MOD = 998244353; // const ll MOD = 924844033; // const ll MOD = 9007199254740881; const ll INF = 1LL << 60; // 1.15e18 const double PI = acos(-1.0); const vll DX = {0, -1, 0, 1, 0, -1, 1, 1, -1}; const vll DY = {0, 0, -1, 0, 1, -1, -1, 1, 1}; const str alp = "abcdefghijklmnopqrstuvwxyz"; const str ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void Input() {} template <class Var, class... Args> void Input(Var &var, Args &...args) { cin >> var; Input(args...); } void vInit(ll size) {} template <class T, class... Args> void vInit(ll size, V<T> &v, Args &...args) { v.res(size); vInit(size, args...); } void vInputNum(ll num) {} template <class T, class... Args> void vInputNum(ll num, V<T> &v, Args &...args) { cin >> v[num]; vInputNum(num, args...); } void vInput(ll size) {} template <class... Args> void vInput(ll size, Args &...args) { vInit(size, args...); REP(i, size) vInputNum(i, args...); } template <class S, class T> ostream &operator<<(ostream &out, const P<S, T> &p) { return out << "[" << p.fi << ", " << p.se << "]"; } template <class T> ostream &operator<<(ostream &out, V<T> &v) { if (v.emp) return out << "{}"; else { auto itr = v.bgn; out << "{" << *itr; itr++; while (itr != v.en) { out << ", " << *itr; itr++; } out << "}"; return out; } } template <class S, class T> ostream &operator<<(ostream &out, const map<S, T> &m) { if (m.emp) return out << "<[]>"; else { auto itr = m.bgn; out << "< [" << (itr->fi) << ": " << (itr->se); itr++; while (itr != m.en) { out << "], [" << (itr->fi) << ": " << (itr->se); itr++; } out << "] >"; return out; } } template <class T> ostream &operator<<(ostream &out, const set<T> &s) { if (s.emp) return out << "<>"; else { auto itr = s.bgn; out << "<" << *itr; itr++; while (itr != s.en) { out << ", " << *itr; itr++; } out << ">"; return out; } } void say() {} template <class T> void say(T t) { cout << t; } template <class Head, class... Body> void say(Head head, Body... body) { cout << head << " "; say(body...); } void sal() { cout << "\n"; } template <class... Args> void sal(Args... args) { say(args...); cout << "\n"; } void day() {} template <class T> void day(T t) { cerr << t; } template <class Head, class... Body> void day(Head head, Body... body) { cerr << head << " "; day(body...); } void dal() { cerr << "\n"; } template <class... Args> void dal(Args... args) { day(args...); cerr << "\n"; } void salv() {} template <class T> void salv(V<T> v) { if (v.emp) sal(); else { auto itr = v.bgn; say(*itr); itr++; while (itr != v.en) { sas; say(*itr); itr++; } sak; } } template <class T, class... Args> void salv(V<T> v, Args... args) { salv(v); salv(args...); } void salv2() {} template <class T> void salv2(V<V<T>> v) { if (v.emp) sal(); else { ROR(v, i) salv(i); } } template <class T, class... Args> void salv2(V<V<T>> v, Args... args) { salv2(v); salv2(args...); } template <class Monoid> struct Action { public: Monoid I; function<Monoid(Monoid, Monoid)> A; Action(Monoid I, function<Monoid(Monoid, Monoid)> A) : I(I), A(A) {} Monoid operator()() { return I; } Monoid operator()(Monoid x) { return x; } Monoid operator()(Monoid l, Monoid r) { return A(l, r); } template <class... Args> Monoid operator()(Monoid x, Args... args) { Monoid tmp = operator()(args...); return A(x, tmp); } }; template <class T> Action<T> ADD = Action<T>(0, [](T l, T r) { return l + r; }); template <> Action<str> ADD<str> = Action<str>("", [](str l, str r) { return l + r; }); template <class T1, class T2> Action<P<T1, T2>> ADD<P<T1, T2>> = Action<P<T1, T2>>(mp(ADD<T1>.I, ADD<T2>.I), [](P<T1, T2> l, P<T1, T2> r) { return mp(l.fi + r.fi, l.se + r.se); }); template <class T> Action<T> MUL = Action<T>(1, [](T l, T r) { return l * r; }); template <class T> Action<T> OR = Action<T>(0, [](T l, T r) { return l | r; }); template <class T> Action<T> XOR = Action<T>(0, [](T l, T r) { return l ^ r; }); template <class T> Action<T> AND = Action<T>(((ll)(1) << 63) - 1, [](T l, T r) { return l & r; }); template <> Action<bool> AND<bool> = Action<bool>(true, [](bool l, bool r) { return l & r; }); template <> Action<ull> AND<ull> = Action<ull>(((ull)(1) << 63) - 1, [](ull l, ull r) { return l & r; }); template <class T> Action<T> MIN = Action<T>(INF, [](T l, T r) { return (l < r) ? l : r; }); template <class T> Action<T> MAX = Action<T>(-INF, [](T l, T r) { return (l > r) ? l : r; }); template <class T> Action<T> GCD = Action<T>(0, [](T l, T r) { if (l < r) { l ^= r; r ^= l; l ^= r; } return (r ? GCD<T>(r, l % r) : l); }); template <class T> Action<T> LCM = Action<T>(1, [](T l, T r) { return (l * r) / GCD<T>(l, r); }); template <class Head> Head Min(Head head) { return head; } template <class Head, class... Body> Head Min(Head head, Body... body) { auto tmp = Min(body...); return (head < tmp) ? head : tmp; } template <class Head> Head Max(Head head) { return head; } template <class Head, class... Body> auto Max(Head head, Body... body) { auto tmp = Max(body...); return (head > tmp) ? head : tmp; } ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll gcd(ll head) { return head; } template <class... Body> ll gcd(ll head, Body... body) { return gcd(head, gcd(body...)); } ll lcm(ll head) { return head; } template <class... Body> ll lcm(ll head, Body... body) { return lcm(head, lcm(body...)); } ll Bset(ll a, ll b, ll c) { if (c) a |= b; else a &= ~b; return a; } struct UFT { public: ll tsize; ll mode; vll par; vll rank; UFT() {} UFT(const UFT &uft) {} UFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); } ll root(ll x) { return par[x] < 0 ? x : par[x] = root(par[x]); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } } ll size(ll x) { return -par[root(x)]; } }; struct pUFT { public: ll tsize; ll now; vll par; vll rank; vll mtime; vvll sizepi; vvll sizepv; pUFT() {} pUFT(const pUFT &puft) {} pUFT(ll tsizeget) { tsize = tsizeget; now = 0; par.asn(tsize, -1); rank.asn(tsize, 0); mtime.asn(tsize, INF); sizepi.asn(tsize, {0}); sizepv.asn(tsize, {1}); } ll root(ll x, ll t) { return (mtime[x] > t) ? x : root(par[x], t); } bool same(ll x, ll y, ll t) { return root(x, t) == root(y, t); } ll merge(ll x, ll y) { now++; x = root(x, now); y = root(y, now); if (x != y) { if (rank[x] < rank[y]) { par[y] += par[x]; sizepi[y].pb(now); sizepv[y].pb(-par[y]); par[x] = y; mtime[x] = now; } else { par[x] += par[y]; sizepi[x].pb(now); sizepv[x].pb(-par[x]); par[y] = x; mtime[y] = now; if (rank[x] == rank[y]) rank[x]++; } } return now; } ll size(ll x, ll t) { x = root(x, t); return sizepv[x][UPB(sizepi[x], t) - 1]; } }; struct wUFT { public: ll tsize; ll mode; vll par; vll rank; vll dweight; wUFT() {} wUFT(const wUFT &wuft) {} wUFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); dweight.asn(tsize, 0); } ll root(ll x) { if (par[x] < 0) return x; else { ll r = root(par[x]); dweight[x] += dweight[par[x]]; return par[x] = r; } } ll weight(ll x) { root(x); return dweight[x]; } ll diff(ll x, ll y) { return weight(y) - weight(x); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y, ll w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; dweight[x] = -w; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; dweight[y] = w; } } } ll size(ll x) { return -par[root(x)]; } }; template <typename valtype> class SegT { public: ll size; vector<valtype> v; valtype initv; function<valtype(valtype x, valtype y)> calc; SegT() {} SegT(const SegT &segt) {} SegT(ll sizeget, ll modeget = 0) { sizeset(sizeget); modeset(modeget); init(); } SegT(vector<valtype> cpyvec, ll modeget = 0) { sizeset(cpyvec.sz); modeset(modeget); init(); copy(cpyvec); } SegT(ll sizeget, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(sizeget); initv = initvget; calc = calcget; init(); } SegT(vector<valtype> cpyvec, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(cpyvec.sz); initv = initvget; calc = calcget; init(); copy(cpyvec); } void sizeset(ll rsize) { size = DigN2(rsize); if (rsize == Pow2(size - 1)) size--; return; } void modeset(ll mode) { switch (mode) { case 0: initv = 0; calc = [](valtype x, valtype y) { return x + y; }; break; case 1: initv = INF; calc = [](valtype x, valtype y) { return min(x, y); }; break; case 2: initv = -INF; calc = [](valtype x, valtype y) { return max(x, y); }; break; } return; } void init() { v.asn(Pow2(size + 1) - 1, initv); } void copy(vector<valtype> cpyvec) { REP(i, min(cpyvec.sz, Pow2(size))) set(i, cpyvec[i]); } ll i2v(ll i) const { if (i < 0 || i >= Pow2(size)) return -1; return Pow2(size) + i - 1; } ll top(ll i) const { if (i == 0) return -1; return (i - 1) / 2; } pl bot(ll i) const { if (i + 1 >= Pow2(size)) return mp(-1, -1); return mp(2 * i + 1, 2 * i + 2); } void set(ll i, valtype x) { i = i2v(i); v[i] = x; while (i > 0) { i = top(i); v[i] = calc(v[bot(i).fi], v[bot(i).se]); } return; } void add(ll i, valtype x) { set(i, v[i2v(i)] + x); return; } valtype operator[](const ll &i) const { return v[i2v(i)]; } // valtype que(ll a = 0, ll b = Pow2(size) - 1) { valtype que(ll a, ll b) { if (a == b) return v[i2v(a)]; if (a > b) return initv; // swap(a, b); valtype ans = initv; ll ai = i2v(a); ll bi = i2v(b); FOR(i, 1, size + 1) { if (a > b) break; if (a % Pow2(i)) { ans = calc(ans, v[ai]); a += Pow2(i - 1); ai = top(ai) + 1; } else { ai = top(ai); } if (a > b) break; if ((b + 1) % Pow2(i)) { ans = calc(ans, v[bi]); b -= Pow2(i - 1); bi = top(bi) - 1; } else { bi = top(bi); } if (a > b) break; } return ans; } valtype que(ll b) { return que(0, b); } valtype que() { return que(0, Pow2(size) - 1); } }; template <typename lentype> class Graph { public: ll size; ll mode; ll mapmode; lentype zlen; lentype ilen; vector<map<ll, ll>> v2n; vvll n2v; vector<vector<lentype>> Edge; vector<pair<lentype, ll>> Primresult; Graph() {} Graph(const Graph &graph) {} Graph(ll sizeget = 0, ll mapmodeget = 0, ll modeget = 0, lentype zlenget = 0, lentype ilenget = INF) { size = sizeget; mapmode = mapmodeget; mode = modeget; zlen = zlenget; ilen = ilenget; init(); } void init() { Edge.res(size); v2n.res(size); n2v.res(size); Primresult.asn(size, mp(ilen, -1)); } lentype lenplus(lentype l, lentype r) { return l + r; } lentype lenequal(lentype l, lentype r) { return l == r; } lentype lenlcr(lentype l, lentype r) { return l < r; } ll addV(ll vs) { size += vs; init(); return size; } void caddE(ll x, ll y, lentype c) { if (mapmode) v2n[x][y] = Edge[x].sz; Edge[x].pb(c); n2v[x].pb(y); } void csetE(ll x, ll y, lentype c) { if (mapmode) Edge[x][v2n[x][y]] = c; } void cersE(ll x, ll y) { if (mapmode) { ll n = v2n[x][y]; Edge[x][n] = ilen; n2v[x][n] = -1; v2n[x].ers(y); } } void addE(ll x, ll y, lentype c) { caddE(x, y, c); if (!mode) caddE(y, x, c); } void setE(ll x, ll y, lentype c) { csetE(x, y, c); if (!mode) csetE(y, x, c); } void ersE(ll x, ll y, lentype c) { cersE(x, y, c); if (!mode) cersE(y, x, c); } lentype getE(ll x, ll y) { if (mapmode) { if (v2n[x].count(y)) { return Edge[x][v2n[x][y]]; } } return ilen; } ll getVsz(ll x) { return Edge[x].sz; } pair<lentype, ll> getV(ll x, ll n) { if (n >= getVsz(x)) return mp(ilen, -1); return mp(Edge[x][n], n2v[x][n]); } vector<pair<lentype, vll>> Dijk(ll x) { vector<pair<lentype, vll>> result(size); REP(i, size) { result[i].fi = ilen; result[i].se = {-1}; } vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); result[x].fi = zlen; result[x].se = {-1}; while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else if (lenequal(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].se.pb(now.se); } } } } return result; } lentype Prim(ll x = 0) { lentype ans = zlen; vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); Primresult[x] = mp(zlen, -1); while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; ans = lenplus(ans, Primresult[now.se].fi); REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(nowlv.fi, Primresult[nowlv.se].fi)) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } } } } return ans; } }; /*template <class Type> class DP { public: vector<Type> v; Type initv; vll size, block; DP() {} DP(const DP &dp) {} template<class... Args> DP(Args... args) { block.asn(1, 1); Initialize(args...); } void Initialize(Type initv_) { initv = initv_; v.asn(block.bk, initv); } template<class... Args> void Initialize(ll val, Args... args) { size.pb(val); block.pb(block.bk*val); Initialize(args...); } };*/ pl Bezout(ll a, ll b) { if (b != 0) { pl xy; xy = Bezout(b, a % b); return mp(xy.se, xy.fi - ((a / b) * xy.se)); } else { return mp(1, 0); } } pl Bez(ll a, ll b, ll c) { pl xy; ll x, y, z, gc; xy = Bezout(a, b); gc = gcd(a, b); if (c % gc != 0) return mp(-1, -1); x = xy.fi * (c / gc); y = xy.se * (c / gc); if (x < 0) z = rup(-x, (b / gc)); if (x >= 0) z = -x / (b / gc); x += z * (b / gc); y -= z * (a / gc); return mp(x, y); } ll DigS10(ll n) { ll ans = 0; while (1) { ans += n % 10; n /= 10; if (!n) break; } return ans; } ll isP(ll n) { if (n <= 1) return 0; FOR(i, 2, (ll)sqrt(n) + 1) { if (n % i == 0) return 0; } return 1; } ll Tot(ll n) { if (n <= 0) return 0; ll ans = n, x = 2; while (x * x <= n) { if (n % x == 0) { ans -= ans / x; while (n % x == 0) n /= x; } x++; } if (n > 1) ans -= ans / n; return ans; } template <class T> struct Sum { public: V<T> v, s; ll size; Action<T> Add; Sum(V<T> v, Action<T> Add = ADD<T>) : v(v), size(v.sz), Add(Add) { Init(); Calc(); } void Init() { s.asn(size + 1, Add.I); } void Calc() { REP(i, size) s[i + 1] = Add(s[i], v[i]); } T operator()(ll x) { return operator()(0, x); } T operator()(ll l, ll r) { if (l < 0) l = 0; if (r >= size) r = size - 1; if (l > r) return Add.I; return s[r + 1] - s[l]; // for ADD } }; using sumll = Sum<ll>; template <class T> struct Sum2 { public: V<V<T>> v, s; ll RowSize, ColumnSize; Action<T> Add; Sum2(V<V<T>> v, Action<T> Add = ADD<T>) : v(v), RowSize(v.sz), ColumnSize(v.sz ? v[0].sz : 0), Add(Add) { Init(); Calc(); } void Init() { s.asn(RowSize + 1, V<T>(ColumnSize, Add.I)); } void Calc() { REP1(r, RowSize) { REP1(c, ColumnSize) { s[r][c] = v[r - 1][c - 1] + operator()(r, c - 1) + operator()(r - 1, c) - operator()(r - 1, c - 1); } } } T operator()(ll r, ll c) { return operator()(0, 0, r, c); } T operator()(ll r1, ll c1, ll r2, ll c2) { if (r1 < 0) r1 = 0; if (c1 < 0) c1 = 0; if (r2 >= RowSize) r2 = RowSize - 1; if (c2 >= ColumnSize) c2 = ColumnSize - 1; if (r1 > r2) return Add.I; if (c1 > c2) return Add.I; return s[r2 + 1][c2 + 1] - s[r2 + 1][c1] - s[r1][c2 + 1] + s[r1][c1]; } }; using sum2ll = Sum2<ll>; template <class T> struct Point2 { public: V<V<T>> v; ll h, w; Point2() : h(0), w(0) {} Point2(ll h, ll w) : h(h), w(w) { asn(h, w); } Point2(ll h, ll w, T val) : h(h), w(w) { asn(h, w, val); } void assign(ll h, ll w) { v.asn(h, V<T>(w)); } void assign(ll h, ll w, ll val) { v.asn(h, V<T>(w, val)); } T &operator()(ll h, ll w) { return v[h][w]; } T &operator()(pl p) { return v[p.fi][p.se]; } }; template <class T> using P2 = Point2<T>; template <ll Mod> struct Modll { public: ll v; Modll() : v(0) {} Modll(ll _v) { set(_v % Mod + Mod); } Modll &set(ll _v) { v = (_v < Mod) ? _v : (_v - Mod); return *this; } Modll pow(ll n) const { Modll x = *this, ans = 1; while (n) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } Modll inverse() const { return (*this).pow(Mod - 2); } Modll operator+(const Modll &m) const { return Modll().set(v + m.v); } Modll operator-(const Modll &m) const { return Modll().set(Mod + v - m.v); } Modll operator*(const Modll &m) const { return Modll().set((ull(v) * m.v) % Mod); } Modll operator/(const Modll &m) const { return *this * m.inv; } Modll &operator+=(const Modll &m) { return *this = *this + m; } Modll &operator-=(const Modll &m) { return *this = *this - m; } Modll &operator*=(const Modll &m) { return *this = *this * m; } Modll &operator/=(const Modll &m) { return *this = *this / m; } Modll operator-() const { return Modll(0) - *this; } explicit operator bool() const { return v != 0; } friend ostream &operator<<(ostream &out, const Modll &m) { return out << m.v; } }; using mll = Modll<MOD>; using vmll = V<mll>; using vvmll = V<vmll>; using vvvmll = V<vvmll>; template <class T> T vmin(V<T> v) { T tmp = MIN<T>.I; ROR(v, i) emin(tmp, i); return tmp; } template <class T, class... Args> T vmin(V<T> v, Args... args) { T tmp = vmin(args...); return min(vmin(v), tmp); } template <class T> T vmax(V<T> v) { T tmp = MAX<T>.I; ROR(v, i) emax(tmp, i); return tmp; } template <class T, class... Args> T vmax(V<T> v, Args... args) { T tmp = vmax(args...); return max(vmax(v), tmp); } template <class T> T vgcd(V<T> v) { T tmp = GCD<T>.I; ROR(v, i) egcd(tmp, i); return tmp; } template <class T, class... Args> T vgcd(V<T> v, Args... args) { T tmp = vgcd(args...); return gcd(vgcd(v), tmp); } template <class T> T vlcm(V<T> v) { T tmp = LCM<T>.I; ROR(v, i) elcm(tmp, i); return tmp; } template <class T, class... Args> T vlcm(V<T> v, Args... args) { T tmp = vlcm(args...); return lcm(vlcm(v), tmp); } vmll MFactMemo(2, 1); vmll MIFactMemo(2, 1); mll mFact(ll n) { if (MFactMemo.sz <= n) { ll oldsize = MFactMemo.sz; MFactMemo.res(n + 1, 1); FOR(i, oldsize, n) MFactMemo[i] = MFactMemo[i - 1] * i; } return MFactMemo[n]; } mll miFact(ll n) { if (MIFactMemo.sz <= n) { ll oldsize = MIFactMemo.sz; MIFactMemo.res(n + 1, 1); MIFactMemo.bk = mFact(n).inv; rFOR(i, oldsize + 1, n) MIFactMemo[i - 1] = MIFactMemo[i] * i; } return MIFactMemo[n]; } mll mComb(ll n, ll k) { if (n < 0 || k < 0 || n < k) return 0; return mFact(n) * miFact(k) * miFact(n - k); } ll LIS(vll v, ll m = 0) { if (v.sz > 0) { ll ans = 0; vll dp(v.sz, INF); FOR(i, 0, v.sz - 1) { dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i]; } FOR(i, 0, v.sz - 1) { if (dp[i] == INF) break; ans++; } return ans; } else { return 0; } } void PCmprs(vll &v) { if (v.sz == 0) return; vll vv(v); IOTA(vv, 0); sort(vv.bgn, vv.en, [&](ll v1, ll v2) { return v[v1] < v[v2]; }); IOTA(v, 0); sort(v.bgn, v.en, [&](ll v1, ll v2) { return vv[v1] < vv[v2]; }); return; } ll BblCnt(vll v) { PCmprs(v); SegT<ll> b(v.sz, 0); ll ans = 0; REP(i, v.sz) { ans += (i - b.que(0, v[i])); b.add(v[i], 1); } return ans; } ll Bsrch(function<bool(ll x)> f, ll mi, ll ma) { ll ng = mi - 1, ok = ma, mid; while (ok - ng > 1) { mid = (ng + ok) / 2; (f(mid) ? ok : ng) = mid; } return ok; } template <class T> V<V<T>> MultiMatrix(V<V<T>> A, V<V<T>> B, Action<T> Mul = MUL<T>, Action<T> Add = ADD<T>) { V<V<T>> ans; ll ii = A.sz; if (!ii) return ans; ll jj = A[0].sz; if (!jj) return ans; ll jj2 = B.sz; if (!jj2) return ans; if (jj != jj2) return ans; ll kk = B[0].sz; if (!kk) return ans; ans.asn(ii, V<T>(kk, 0)); REP(i, ii) { REP(k, kk) { REP(j, jj) { ans[i][k] = Add(ans[i][k], Mul(A[i][j], B[j][k])); } } } return ans; } vvll CombMemo(1000, vll(1000, -1)); ll Comb(ll n, ll k) { if ((n < 0) || (k < 0)) return 0; if (CombMemo[n][k] == -1) { if (n < k) CombMemo[n][k] = 0; else { if (n == 0) CombMemo[n][k] = 1; else if (k == 0) CombMemo[n][k] = 1; else if (n == k) CombMemo[n][k] = 1; else CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k); } } return CombMemo[n][k]; } template <class T> map<T, ll> Dict(V<T> v) { map<T, ll> m; if (!v.sz) return m; SORT(v); UNIQUE(v); REP(i, v.sz) { m[v[i]] = i; } return m; } template <class T> vll Cmprs(V<T> v) { auto m = Dict(v); vll ans(v.sz); REP(i, v.sz) { ans[i] = m[v[i]]; } return ans; } template <class T> auto vecn(T val) { return val; } template <class... Args> auto vecn(ll val, Args... args) { auto tmp = vecn(args...); return V<decltype(tmp)>(val, tmp); } void Solve(); signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; Solve(); } void Solve() { li(n); vli(n, a); if (n == 2) { cout << max(a[0], a[1]); } vll l(n), r(n); l[0] = a[0]; r[n - 1] = a[n - 1]; REP1(i, n - 1) { l[i] = gcd(l[i - 1], a[i]); r[n - i - 1] = gcd(r[n - i], a[n - i - 1]); } ll m = 0; REP(i, n - 1) { if (i == 0) { m = max(m, r[i + 1]); } else if (i == n - 1) { m = max(m, l[i - 1]); } else { m = max(m, gcd(r[i + 1], l[i - 1])); } } cout << m; }
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>; template <class S, class T> using P = pair<S, T>; template <class S, class T, class U> using TP = tuple<S, T, U>; using ll = long long; using ull = unsigned long long; using dbl = double; using str = string; using vll = V<ll>; using vvll = V<vll>; using vvvll = V<vvll>; using pl = P<ll, ll>; using tl = TP<ll, ll, ll>; using vpl = V<pl>; using vvpl = V<vpl>; using vtl = V<tl>; using vvtl = V<vtl>; using vs = V<str>; using vvs = V<vs>; using vd = V<dbl>; using vvd = V<vd>; using qll = queue<ll>; using qpl = queue<pl>; using stll = stack<ll>; using stpl = stack<pl>; using mapll = map<ll, ll>; using setll = set<ll>; using pqll = priority_queue<ll>; #define int ll #define fi first #define se second #define mp make_pair #define mt make_tuple #define pb push_back #define pob pop_back() #define pf push_front #define pof pop_front() #define sz size() #define bgn begin() #define en end() #define asn assign #define emp empty() #define fr front() #define bk back() #define clr clear() #define ins insert #define ers erase #define res resize #define tp top() #define p_q priority_queue #define inv inverse() #define FOR(i, a, b) for (ll i = (a); i <= (ll)(b); i++) #define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) #define REP(i, a) FOR((i), 0, (ll)(a)-1) #define REP0(i, a) FOR((i), 0, (ll)(a)) #define REP1(i, a) FOR((i), 1, (ll)(a)) #define rREP(i, a) rFOR((i), 0, (ll)(a)-1) #define rREP0(i, a) rFOR((i), 0, (ll)(a)) #define rREP1(i, a) rFOR((i), 1, (ll)(a)) #define ROR(v, i) for (auto &(i) : (v)) #define IOTA(a, n) iota((a).bgn, (a).en, (n)) #define SORT(a) sort((a).bgn, (a).en) #define rSORT(a) sort((a).rbegin(), (a).rend()) #define UNIQUE(a) (a).erase(unique((a).bgn, (a).en), (a).en) #define PREVP(a) prev_permutation((a).bgn, (a).en) #define NEXTP(a) next_permutation((a).bgn, (a).en) #define BINS(a, b) binary_search((a).bgn, (a).en, (b)) #define LOWB(a, b) (lower_bound((a).bgn, (a).en, (b)) - (a).bgn) #define UPB(a, b) (upper_bound((a).bgn, (a).en, (b)) - (a).bgn) #define CNT(a, b) count((a).bgn, (a).en, b) #define SUM(a) accumulate((a).bgn, (a).en, 0) #define REV(a) reverse((a).bgn, (a).en) #define REGS(a, b) regex_search((a), regex(b)) #define REGM(a, b) regex_match((a), regex(b)) #define yn(a) cout << ((a) ? "yes" : "no") << "\n"; #define Yn(a) cout << ((a) ? "Yes" : "No") << "\n"; #define YN(a) cout << ((a) ? "YES" : "NO") << "\n"; #define imp(a) cout << ((a) ? "possible" : "impossible") << "\n"; #define Imp(a) cout << ((a) ? "Possible" : "Impossible") << "\n"; #define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << "\n"; #define fs(a) cout << ((a) ? "second" : "first") << "\n"; #define Fs(a) cout << ((a) ? "Second" : "First") << "\n"; #define FS(a) cout << ((a) ? "SECOND" : "FIRST") << "\n"; #define sak cout << "\n"; #define sas cout << " "; #define sat cout << "\t"; #define dbg(a) cerr << (#a) << ": " << (a) << "\n"; #define dbgs(...) \ dal(#__VA_ARGS__); \ dal(__VA_ARGS__); #define c2l(a) ((ll)(a - 48)) #define a2l(a) ((ll)(a - 97)) #define A2l(a) ((ll)(a - 65)) #define l2c(a) ((char)(a + 48)) #define l2a(a) ((char)(a + 97)) #define l2A(a) ((char)(a + 65)) #define DigN2(a) ((llabs(a) == 0) ? (1) : ((ll)(log2(double(llabs(a)))) + 1)) #define DigN10(a) ((llabs(a) == 0) ? (1) : ((ll)(log10(double(llabs(a)))) + 1)) #define Dig2(a, b) (((a) >> (b)) & 1) #define Dig10(a, b) (ll)(((a) / ((ll)(pow(10.0, (double)(b))))) % 10) #define Pow2(a) ((ll)(1) << (a)) #define Pow10(a) ((ll)(pow(10.0, double(a)))) #define LSB(a) ((a) & (-(a))) #define vin(v) \ ROR((v), (i)) { cin >> (i); }; #define vllin(v, N) \ vll(v)((N)); \ vin(v); #define vllin2(a, b, N) \ vll(a)(N), (b)(N); \ REP(i, N) { cin >> (a)[i] >> (b)[i]; }; #define vsin(v, N) \ vs(v)((N)); \ vin(v); #define rdn(a, b) ((a) / (b)) #define rou(a, b) \ ((((double(a) / double(b)) - ((a) / (b))) < 0.5) ? ((a) / (b)) \ : (((a) / (b)) + 1)) #define rup(a, b) ((((a) % (b)) == 0) ? ((a) / (b)) : (((a) / (b)) + 1)) #define min(...) Min(__VA_ARGS__) #define max(...) Max(__VA_ARGS__) #define emin(a, ...) ((a) = Min((a), __VA_ARGS__)) #define emax(a, ...) ((a) = Max((a), __VA_ARGS__)) #define egcd(a, ...) ((a) = gcd((a), __VA_ARGS__)) #define elcm(a, ...) ((a) = lcm((a), __VA_ARGS__)) #define powll(a, b) (ll)(pow((double)(a), (double)(b))) #define Triangle(x1, y1, x2, y2, x3, y3) \ (((x1) - (x2)) * ((y1) - (y3)) - ((x1) - (x3)) * ((y1) - (y2))) #define svll SumV<ll> #define svvll SumV2<ll> #define li(...) \ ll __VA_ARGS__; \ Input(__VA_ARGS__); #define si(...) \ str __VA_ARGS__; \ Input(__VA_ARGS__); #define vli(size, ...) \ vll __VA_ARGS__; \ vInput(size, __VA_ARGS__); #define vsi(size, ...) \ vs __VA_ARGS__; \ vInput(size, __VA_ARGS__); // const ll MOD = 1e9 + 7; const ll MOD = 998244353; // const ll MOD = 924844033; // const ll MOD = 9007199254740881; const ll INF = 1LL << 60; // 1.15e18 const double PI = acos(-1.0); const vll DX = {0, -1, 0, 1, 0, -1, 1, 1, -1}; const vll DY = {0, 0, -1, 0, 1, -1, -1, 1, 1}; const str alp = "abcdefghijklmnopqrstuvwxyz"; const str ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; void Input() {} template <class Var, class... Args> void Input(Var &var, Args &...args) { cin >> var; Input(args...); } void vInit(ll size) {} template <class T, class... Args> void vInit(ll size, V<T> &v, Args &...args) { v.res(size); vInit(size, args...); } void vInputNum(ll num) {} template <class T, class... Args> void vInputNum(ll num, V<T> &v, Args &...args) { cin >> v[num]; vInputNum(num, args...); } void vInput(ll size) {} template <class... Args> void vInput(ll size, Args &...args) { vInit(size, args...); REP(i, size) vInputNum(i, args...); } template <class S, class T> ostream &operator<<(ostream &out, const P<S, T> &p) { return out << "[" << p.fi << ", " << p.se << "]"; } template <class T> ostream &operator<<(ostream &out, V<T> &v) { if (v.emp) return out << "{}"; else { auto itr = v.bgn; out << "{" << *itr; itr++; while (itr != v.en) { out << ", " << *itr; itr++; } out << "}"; return out; } } template <class S, class T> ostream &operator<<(ostream &out, const map<S, T> &m) { if (m.emp) return out << "<[]>"; else { auto itr = m.bgn; out << "< [" << (itr->fi) << ": " << (itr->se); itr++; while (itr != m.en) { out << "], [" << (itr->fi) << ": " << (itr->se); itr++; } out << "] >"; return out; } } template <class T> ostream &operator<<(ostream &out, const set<T> &s) { if (s.emp) return out << "<>"; else { auto itr = s.bgn; out << "<" << *itr; itr++; while (itr != s.en) { out << ", " << *itr; itr++; } out << ">"; return out; } } void say() {} template <class T> void say(T t) { cout << t; } template <class Head, class... Body> void say(Head head, Body... body) { cout << head << " "; say(body...); } void sal() { cout << "\n"; } template <class... Args> void sal(Args... args) { say(args...); cout << "\n"; } void day() {} template <class T> void day(T t) { cerr << t; } template <class Head, class... Body> void day(Head head, Body... body) { cerr << head << " "; day(body...); } void dal() { cerr << "\n"; } template <class... Args> void dal(Args... args) { day(args...); cerr << "\n"; } void salv() {} template <class T> void salv(V<T> v) { if (v.emp) sal(); else { auto itr = v.bgn; say(*itr); itr++; while (itr != v.en) { sas; say(*itr); itr++; } sak; } } template <class T, class... Args> void salv(V<T> v, Args... args) { salv(v); salv(args...); } void salv2() {} template <class T> void salv2(V<V<T>> v) { if (v.emp) sal(); else { ROR(v, i) salv(i); } } template <class T, class... Args> void salv2(V<V<T>> v, Args... args) { salv2(v); salv2(args...); } template <class Monoid> struct Action { public: Monoid I; function<Monoid(Monoid, Monoid)> A; Action(Monoid I, function<Monoid(Monoid, Monoid)> A) : I(I), A(A) {} Monoid operator()() { return I; } Monoid operator()(Monoid x) { return x; } Monoid operator()(Monoid l, Monoid r) { return A(l, r); } template <class... Args> Monoid operator()(Monoid x, Args... args) { Monoid tmp = operator()(args...); return A(x, tmp); } }; template <class T> Action<T> ADD = Action<T>(0, [](T l, T r) { return l + r; }); template <> Action<str> ADD<str> = Action<str>("", [](str l, str r) { return l + r; }); template <class T1, class T2> Action<P<T1, T2>> ADD<P<T1, T2>> = Action<P<T1, T2>>(mp(ADD<T1>.I, ADD<T2>.I), [](P<T1, T2> l, P<T1, T2> r) { return mp(l.fi + r.fi, l.se + r.se); }); template <class T> Action<T> MUL = Action<T>(1, [](T l, T r) { return l * r; }); template <class T> Action<T> OR = Action<T>(0, [](T l, T r) { return l | r; }); template <class T> Action<T> XOR = Action<T>(0, [](T l, T r) { return l ^ r; }); template <class T> Action<T> AND = Action<T>(((ll)(1) << 63) - 1, [](T l, T r) { return l & r; }); template <> Action<bool> AND<bool> = Action<bool>(true, [](bool l, bool r) { return l & r; }); template <> Action<ull> AND<ull> = Action<ull>(((ull)(1) << 63) - 1, [](ull l, ull r) { return l & r; }); template <class T> Action<T> MIN = Action<T>(INF, [](T l, T r) { return (l < r) ? l : r; }); template <class T> Action<T> MAX = Action<T>(-INF, [](T l, T r) { return (l > r) ? l : r; }); template <class T> Action<T> GCD = Action<T>(0, [](T l, T r) { if (l < r) { l ^= r; r ^= l; l ^= r; } return (r ? GCD<T>(r, l % r) : l); }); template <class T> Action<T> LCM = Action<T>(1, [](T l, T r) { return (l * r) / GCD<T>(l, r); }); template <class Head> Head Min(Head head) { return head; } template <class Head, class... Body> Head Min(Head head, Body... body) { auto tmp = Min(body...); return (head < tmp) ? head : tmp; } template <class Head> Head Max(Head head) { return head; } template <class Head, class... Body> auto Max(Head head, Body... body) { auto tmp = Max(body...); return (head > tmp) ? head : tmp; } ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll gcd(ll head) { return head; } template <class... Body> ll gcd(ll head, Body... body) { return gcd(head, gcd(body...)); } ll lcm(ll head) { return head; } template <class... Body> ll lcm(ll head, Body... body) { return lcm(head, lcm(body...)); } ll Bset(ll a, ll b, ll c) { if (c) a |= b; else a &= ~b; return a; } struct UFT { public: ll tsize; ll mode; vll par; vll rank; UFT() {} UFT(const UFT &uft) {} UFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); } ll root(ll x) { return par[x] < 0 ? x : par[x] = root(par[x]); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } } ll size(ll x) { return -par[root(x)]; } }; struct pUFT { public: ll tsize; ll now; vll par; vll rank; vll mtime; vvll sizepi; vvll sizepv; pUFT() {} pUFT(const pUFT &puft) {} pUFT(ll tsizeget) { tsize = tsizeget; now = 0; par.asn(tsize, -1); rank.asn(tsize, 0); mtime.asn(tsize, INF); sizepi.asn(tsize, {0}); sizepv.asn(tsize, {1}); } ll root(ll x, ll t) { return (mtime[x] > t) ? x : root(par[x], t); } bool same(ll x, ll y, ll t) { return root(x, t) == root(y, t); } ll merge(ll x, ll y) { now++; x = root(x, now); y = root(y, now); if (x != y) { if (rank[x] < rank[y]) { par[y] += par[x]; sizepi[y].pb(now); sizepv[y].pb(-par[y]); par[x] = y; mtime[x] = now; } else { par[x] += par[y]; sizepi[x].pb(now); sizepv[x].pb(-par[x]); par[y] = x; mtime[y] = now; if (rank[x] == rank[y]) rank[x]++; } } return now; } ll size(ll x, ll t) { x = root(x, t); return sizepv[x][UPB(sizepi[x], t) - 1]; } }; struct wUFT { public: ll tsize; ll mode; vll par; vll rank; vll dweight; wUFT() {} wUFT(const wUFT &wuft) {} wUFT(ll tsizeget, ll modeget = 0) { tsize = tsizeget; mode = modeget; par.asn(tsize, -1); if (!mode) rank.res(tsize, 0); dweight.asn(tsize, 0); } ll root(ll x) { if (par[x] < 0) return x; else { ll r = root(par[x]); dweight[x] += dweight[par[x]]; return par[x] = r; } } ll weight(ll x) { root(x); return dweight[x]; } ll diff(ll x, ll y) { return weight(y) - weight(x); } bool isRoot(ll x) { return x == root(x); } bool same(ll x, ll y) { return root(x) == root(y); } void merge(ll x, ll y, ll w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return; if (mode) { par[x] += par[y]; par[y] = x; } else { if (rank[x] < rank[y]) { par[y] += par[x]; par[x] = y; dweight[x] = -w; } else { par[x] += par[y]; par[y] = x; if (rank[x] == rank[y]) rank[x]++; dweight[y] = w; } } } ll size(ll x) { return -par[root(x)]; } }; template <typename valtype> class SegT { public: ll size; vector<valtype> v; valtype initv; function<valtype(valtype x, valtype y)> calc; SegT() {} SegT(const SegT &segt) {} SegT(ll sizeget, ll modeget = 0) { sizeset(sizeget); modeset(modeget); init(); } SegT(vector<valtype> cpyvec, ll modeget = 0) { sizeset(cpyvec.sz); modeset(modeget); init(); copy(cpyvec); } SegT(ll sizeget, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(sizeget); initv = initvget; calc = calcget; init(); } SegT(vector<valtype> cpyvec, valtype initvget, function<valtype(valtype x, valtype y)> calcget) { sizeset(cpyvec.sz); initv = initvget; calc = calcget; init(); copy(cpyvec); } void sizeset(ll rsize) { size = DigN2(rsize); if (rsize == Pow2(size - 1)) size--; return; } void modeset(ll mode) { switch (mode) { case 0: initv = 0; calc = [](valtype x, valtype y) { return x + y; }; break; case 1: initv = INF; calc = [](valtype x, valtype y) { return min(x, y); }; break; case 2: initv = -INF; calc = [](valtype x, valtype y) { return max(x, y); }; break; } return; } void init() { v.asn(Pow2(size + 1) - 1, initv); } void copy(vector<valtype> cpyvec) { REP(i, min(cpyvec.sz, Pow2(size))) set(i, cpyvec[i]); } ll i2v(ll i) const { if (i < 0 || i >= Pow2(size)) return -1; return Pow2(size) + i - 1; } ll top(ll i) const { if (i == 0) return -1; return (i - 1) / 2; } pl bot(ll i) const { if (i + 1 >= Pow2(size)) return mp(-1, -1); return mp(2 * i + 1, 2 * i + 2); } void set(ll i, valtype x) { i = i2v(i); v[i] = x; while (i > 0) { i = top(i); v[i] = calc(v[bot(i).fi], v[bot(i).se]); } return; } void add(ll i, valtype x) { set(i, v[i2v(i)] + x); return; } valtype operator[](const ll &i) const { return v[i2v(i)]; } // valtype que(ll a = 0, ll b = Pow2(size) - 1) { valtype que(ll a, ll b) { if (a == b) return v[i2v(a)]; if (a > b) return initv; // swap(a, b); valtype ans = initv; ll ai = i2v(a); ll bi = i2v(b); FOR(i, 1, size + 1) { if (a > b) break; if (a % Pow2(i)) { ans = calc(ans, v[ai]); a += Pow2(i - 1); ai = top(ai) + 1; } else { ai = top(ai); } if (a > b) break; if ((b + 1) % Pow2(i)) { ans = calc(ans, v[bi]); b -= Pow2(i - 1); bi = top(bi) - 1; } else { bi = top(bi); } if (a > b) break; } return ans; } valtype que(ll b) { return que(0, b); } valtype que() { return que(0, Pow2(size) - 1); } }; template <typename lentype> class Graph { public: ll size; ll mode; ll mapmode; lentype zlen; lentype ilen; vector<map<ll, ll>> v2n; vvll n2v; vector<vector<lentype>> Edge; vector<pair<lentype, ll>> Primresult; Graph() {} Graph(const Graph &graph) {} Graph(ll sizeget = 0, ll mapmodeget = 0, ll modeget = 0, lentype zlenget = 0, lentype ilenget = INF) { size = sizeget; mapmode = mapmodeget; mode = modeget; zlen = zlenget; ilen = ilenget; init(); } void init() { Edge.res(size); v2n.res(size); n2v.res(size); Primresult.asn(size, mp(ilen, -1)); } lentype lenplus(lentype l, lentype r) { return l + r; } lentype lenequal(lentype l, lentype r) { return l == r; } lentype lenlcr(lentype l, lentype r) { return l < r; } ll addV(ll vs) { size += vs; init(); return size; } void caddE(ll x, ll y, lentype c) { if (mapmode) v2n[x][y] = Edge[x].sz; Edge[x].pb(c); n2v[x].pb(y); } void csetE(ll x, ll y, lentype c) { if (mapmode) Edge[x][v2n[x][y]] = c; } void cersE(ll x, ll y) { if (mapmode) { ll n = v2n[x][y]; Edge[x][n] = ilen; n2v[x][n] = -1; v2n[x].ers(y); } } void addE(ll x, ll y, lentype c) { caddE(x, y, c); if (!mode) caddE(y, x, c); } void setE(ll x, ll y, lentype c) { csetE(x, y, c); if (!mode) csetE(y, x, c); } void ersE(ll x, ll y, lentype c) { cersE(x, y, c); if (!mode) cersE(y, x, c); } lentype getE(ll x, ll y) { if (mapmode) { if (v2n[x].count(y)) { return Edge[x][v2n[x][y]]; } } return ilen; } ll getVsz(ll x) { return Edge[x].sz; } pair<lentype, ll> getV(ll x, ll n) { if (n >= getVsz(x)) return mp(ilen, -1); return mp(Edge[x][n], n2v[x][n]); } vector<pair<lentype, vll>> Dijk(ll x) { vector<pair<lentype, vll>> result(size); REP(i, size) { result[i].fi = ilen; result[i].se = {-1}; } vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); result[x].fi = zlen; result[x].se = {-1}; while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].fi = lenplus(result[now.se].fi, nowlv.fi); result[nowlv.se].se = {now.se}; Q.set(nowlv.se, mp(result[nowlv.se].fi, nowlv.se)); } else if (lenequal(lenplus(result[now.se].fi, nowlv.fi), result[nowlv.se].fi)) { result[nowlv.se].se.pb(now.se); } } } } return result; } lentype Prim(ll x = 0) { lentype ans = zlen; vll stat(size, 0); pair<lentype, ll> now; pair<lentype, ll> nowlv; SegT<pair<lentype, ll>> Q(size, mp(ilen, -1), [](pair<lentype, ll> l, pair<lentype, ll> r) { if (l.se == -1) return r; if (r.se == -1) return l; return l.fi < r.fi ? l : r; }); Q.set(x, mp(zlen, x)); Primresult[x] = mp(zlen, -1); while (Q.que(0, size - 1).se != -1) { now = Q.que(0, size - 1); Q.set(now.se, mp(ilen, -1)); stat[now.se] = 1; ans = lenplus(ans, Primresult[now.se].fi); REP(i, getVsz(now.se)) { nowlv = getV(now.se, i); if (stat[nowlv.se]) continue; if (Q[nowlv.se].se == -1) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } else { if (lenlcr(nowlv.fi, Primresult[nowlv.se].fi)) { Primresult[nowlv.se] = mp(nowlv.fi, now.se); Q.set(nowlv.se, mp(Primresult[nowlv.se].fi, nowlv.se)); } } } } return ans; } }; /*template <class Type> class DP { public: vector<Type> v; Type initv; vll size, block; DP() {} DP(const DP &dp) {} template<class... Args> DP(Args... args) { block.asn(1, 1); Initialize(args...); } void Initialize(Type initv_) { initv = initv_; v.asn(block.bk, initv); } template<class... Args> void Initialize(ll val, Args... args) { size.pb(val); block.pb(block.bk*val); Initialize(args...); } };*/ pl Bezout(ll a, ll b) { if (b != 0) { pl xy; xy = Bezout(b, a % b); return mp(xy.se, xy.fi - ((a / b) * xy.se)); } else { return mp(1, 0); } } pl Bez(ll a, ll b, ll c) { pl xy; ll x, y, z, gc; xy = Bezout(a, b); gc = gcd(a, b); if (c % gc != 0) return mp(-1, -1); x = xy.fi * (c / gc); y = xy.se * (c / gc); if (x < 0) z = rup(-x, (b / gc)); if (x >= 0) z = -x / (b / gc); x += z * (b / gc); y -= z * (a / gc); return mp(x, y); } ll DigS10(ll n) { ll ans = 0; while (1) { ans += n % 10; n /= 10; if (!n) break; } return ans; } ll isP(ll n) { if (n <= 1) return 0; FOR(i, 2, (ll)sqrt(n) + 1) { if (n % i == 0) return 0; } return 1; } ll Tot(ll n) { if (n <= 0) return 0; ll ans = n, x = 2; while (x * x <= n) { if (n % x == 0) { ans -= ans / x; while (n % x == 0) n /= x; } x++; } if (n > 1) ans -= ans / n; return ans; } template <class T> struct Sum { public: V<T> v, s; ll size; Action<T> Add; Sum(V<T> v, Action<T> Add = ADD<T>) : v(v), size(v.sz), Add(Add) { Init(); Calc(); } void Init() { s.asn(size + 1, Add.I); } void Calc() { REP(i, size) s[i + 1] = Add(s[i], v[i]); } T operator()(ll x) { return operator()(0, x); } T operator()(ll l, ll r) { if (l < 0) l = 0; if (r >= size) r = size - 1; if (l > r) return Add.I; return s[r + 1] - s[l]; // for ADD } }; using sumll = Sum<ll>; template <class T> struct Sum2 { public: V<V<T>> v, s; ll RowSize, ColumnSize; Action<T> Add; Sum2(V<V<T>> v, Action<T> Add = ADD<T>) : v(v), RowSize(v.sz), ColumnSize(v.sz ? v[0].sz : 0), Add(Add) { Init(); Calc(); } void Init() { s.asn(RowSize + 1, V<T>(ColumnSize, Add.I)); } void Calc() { REP1(r, RowSize) { REP1(c, ColumnSize) { s[r][c] = v[r - 1][c - 1] + operator()(r, c - 1) + operator()(r - 1, c) - operator()(r - 1, c - 1); } } } T operator()(ll r, ll c) { return operator()(0, 0, r, c); } T operator()(ll r1, ll c1, ll r2, ll c2) { if (r1 < 0) r1 = 0; if (c1 < 0) c1 = 0; if (r2 >= RowSize) r2 = RowSize - 1; if (c2 >= ColumnSize) c2 = ColumnSize - 1; if (r1 > r2) return Add.I; if (c1 > c2) return Add.I; return s[r2 + 1][c2 + 1] - s[r2 + 1][c1] - s[r1][c2 + 1] + s[r1][c1]; } }; using sum2ll = Sum2<ll>; template <class T> struct Point2 { public: V<V<T>> v; ll h, w; Point2() : h(0), w(0) {} Point2(ll h, ll w) : h(h), w(w) { asn(h, w); } Point2(ll h, ll w, T val) : h(h), w(w) { asn(h, w, val); } void assign(ll h, ll w) { v.asn(h, V<T>(w)); } void assign(ll h, ll w, ll val) { v.asn(h, V<T>(w, val)); } T &operator()(ll h, ll w) { return v[h][w]; } T &operator()(pl p) { return v[p.fi][p.se]; } }; template <class T> using P2 = Point2<T>; template <ll Mod> struct Modll { public: ll v; Modll() : v(0) {} Modll(ll _v) { set(_v % Mod + Mod); } Modll &set(ll _v) { v = (_v < Mod) ? _v : (_v - Mod); return *this; } Modll pow(ll n) const { Modll x = *this, ans = 1; while (n) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } Modll inverse() const { return (*this).pow(Mod - 2); } Modll operator+(const Modll &m) const { return Modll().set(v + m.v); } Modll operator-(const Modll &m) const { return Modll().set(Mod + v - m.v); } Modll operator*(const Modll &m) const { return Modll().set((ull(v) * m.v) % Mod); } Modll operator/(const Modll &m) const { return *this * m.inv; } Modll &operator+=(const Modll &m) { return *this = *this + m; } Modll &operator-=(const Modll &m) { return *this = *this - m; } Modll &operator*=(const Modll &m) { return *this = *this * m; } Modll &operator/=(const Modll &m) { return *this = *this / m; } Modll operator-() const { return Modll(0) - *this; } explicit operator bool() const { return v != 0; } friend ostream &operator<<(ostream &out, const Modll &m) { return out << m.v; } }; using mll = Modll<MOD>; using vmll = V<mll>; using vvmll = V<vmll>; using vvvmll = V<vvmll>; template <class T> T vmin(V<T> v) { T tmp = MIN<T>.I; ROR(v, i) emin(tmp, i); return tmp; } template <class T, class... Args> T vmin(V<T> v, Args... args) { T tmp = vmin(args...); return min(vmin(v), tmp); } template <class T> T vmax(V<T> v) { T tmp = MAX<T>.I; ROR(v, i) emax(tmp, i); return tmp; } template <class T, class... Args> T vmax(V<T> v, Args... args) { T tmp = vmax(args...); return max(vmax(v), tmp); } template <class T> T vgcd(V<T> v) { T tmp = GCD<T>.I; ROR(v, i) egcd(tmp, i); return tmp; } template <class T, class... Args> T vgcd(V<T> v, Args... args) { T tmp = vgcd(args...); return gcd(vgcd(v), tmp); } template <class T> T vlcm(V<T> v) { T tmp = LCM<T>.I; ROR(v, i) elcm(tmp, i); return tmp; } template <class T, class... Args> T vlcm(V<T> v, Args... args) { T tmp = vlcm(args...); return lcm(vlcm(v), tmp); } vmll MFactMemo(2, 1); vmll MIFactMemo(2, 1); mll mFact(ll n) { if (MFactMemo.sz <= n) { ll oldsize = MFactMemo.sz; MFactMemo.res(n + 1, 1); FOR(i, oldsize, n) MFactMemo[i] = MFactMemo[i - 1] * i; } return MFactMemo[n]; } mll miFact(ll n) { if (MIFactMemo.sz <= n) { ll oldsize = MIFactMemo.sz; MIFactMemo.res(n + 1, 1); MIFactMemo.bk = mFact(n).inv; rFOR(i, oldsize + 1, n) MIFactMemo[i - 1] = MIFactMemo[i] * i; } return MIFactMemo[n]; } mll mComb(ll n, ll k) { if (n < 0 || k < 0 || n < k) return 0; return mFact(n) * miFact(k) * miFact(n - k); } ll LIS(vll v, ll m = 0) { if (v.sz > 0) { ll ans = 0; vll dp(v.sz, INF); FOR(i, 0, v.sz - 1) { dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i]; } FOR(i, 0, v.sz - 1) { if (dp[i] == INF) break; ans++; } return ans; } else { return 0; } } void PCmprs(vll &v) { if (v.sz == 0) return; vll vv(v); IOTA(vv, 0); sort(vv.bgn, vv.en, [&](ll v1, ll v2) { return v[v1] < v[v2]; }); IOTA(v, 0); sort(v.bgn, v.en, [&](ll v1, ll v2) { return vv[v1] < vv[v2]; }); return; } ll BblCnt(vll v) { PCmprs(v); SegT<ll> b(v.sz, 0); ll ans = 0; REP(i, v.sz) { ans += (i - b.que(0, v[i])); b.add(v[i], 1); } return ans; } ll Bsrch(function<bool(ll x)> f, ll mi, ll ma) { ll ng = mi - 1, ok = ma, mid; while (ok - ng > 1) { mid = (ng + ok) / 2; (f(mid) ? ok : ng) = mid; } return ok; } template <class T> V<V<T>> MultiMatrix(V<V<T>> A, V<V<T>> B, Action<T> Mul = MUL<T>, Action<T> Add = ADD<T>) { V<V<T>> ans; ll ii = A.sz; if (!ii) return ans; ll jj = A[0].sz; if (!jj) return ans; ll jj2 = B.sz; if (!jj2) return ans; if (jj != jj2) return ans; ll kk = B[0].sz; if (!kk) return ans; ans.asn(ii, V<T>(kk, 0)); REP(i, ii) { REP(k, kk) { REP(j, jj) { ans[i][k] = Add(ans[i][k], Mul(A[i][j], B[j][k])); } } } return ans; } vvll CombMemo(1000, vll(1000, -1)); ll Comb(ll n, ll k) { if ((n < 0) || (k < 0)) return 0; if (CombMemo[n][k] == -1) { if (n < k) CombMemo[n][k] = 0; else { if (n == 0) CombMemo[n][k] = 1; else if (k == 0) CombMemo[n][k] = 1; else if (n == k) CombMemo[n][k] = 1; else CombMemo[n][k] = Comb(n - 1, k - 1) + Comb(n - 1, k); } } return CombMemo[n][k]; } template <class T> map<T, ll> Dict(V<T> v) { map<T, ll> m; if (!v.sz) return m; SORT(v); UNIQUE(v); REP(i, v.sz) { m[v[i]] = i; } return m; } template <class T> vll Cmprs(V<T> v) { auto m = Dict(v); vll ans(v.sz); REP(i, v.sz) { ans[i] = m[v[i]]; } return ans; } template <class T> auto vecn(T val) { return val; } template <class... Args> auto vecn(ll val, Args... args) { auto tmp = vecn(args...); return V<decltype(tmp)>(val, tmp); } void Solve(); signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; Solve(); } void Solve() { li(n); vli(n, a); if (n == 2) { cout << max(a[0], a[1]); return; } vll l(n), r(n); l[0] = a[0]; r[n - 1] = a[n - 1]; REP1(i, n - 1) { l[i] = gcd(l[i - 1], a[i]); r[n - i - 1] = gcd(r[n - i], a[n - i - 1]); } ll m = 0; REP(i, n) { if (i == 0) { m = max(m, r[i + 1]); } else if (i == n - 1) { m = max(m, l[i - 1]); } else { m = max(m, gcd(r[i + 1], l[i - 1])); } } cout << m; }
[ "control_flow.return.add", "expression.operation.binary.remove" ]
877,482
877,481
u172929647
cpp
p03061
#include <cmath> #include <iostream> #include <map> #include <vector> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } int *L = new int[N]; int *R = new int[N]; L[0] = A[0]; R[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { L[i] = gcd(A[i - 1], A[i]); } for (int i = N - 2; i >= 0; i--) { R[i] = gcd(R[i + 1], A[i]); } int ans = R[1]; for (int i = 1; i < N - 1; i++) { ans = max(ans, gcd(L[i - 1], R[i + 1])); } ans = max(ans, L[N - 2]); cout << ans << endl; return 0; }
#include <cmath> #include <iostream> #include <map> #include <vector> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } int *L = new int[N]; int *R = new int[N]; L[0] = A[0]; R[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { L[i] = gcd(L[i - 1], A[i]); } for (int i = N - 2; i >= 0; i--) { R[i] = gcd(R[i + 1], A[i]); } int ans = R[1]; for (int i = 1; i < N - 1; i++) { ans = max(ans, gcd(L[i - 1], R[i + 1])); } ans = max(ans, L[N - 2]); cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
877,485
877,486
u811978802
cpp
p03061
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v.begin(), v.end()) #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) 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; } template <class T1, class T2> ostream &operator<<(ostream &s, pair<T1, T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template <class T> ostream &operator<<(ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template <class T> ostream &operator<<(ostream &s, vector<vector<T>> P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template <class T> ostream &operator<<(ostream &s, set<T> P) { EACH(it, P) { s << "<" << *it << "> "; } return s << endl; } template <class T1, class T2> ostream &operator<<(ostream &s, map<T1, T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } typedef long long ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) int gcd(int a, int b) { if ((0 == a) || (0 == b)) return 0; if (a < b) { swap(a, b); } if (a % b == 0) { return b; } else { return gcd(a, a % b); } } int gcd1(int a, int b) { return b ? gcd1(b, a % b) : a; } int main() { int N; int a[100010]; cin >> N; for (int i = 0; i < N; i++) cin >> a[i]; vector<int> front(N + 1, 0); vector<int> back(N + 1, 0); for (int i = 0; i < N; i++) { front[i + 1] = gcd(front[i], a[i]); // cerr<<front[i+1]<<" "<<back[i+1]<<endl; } for (int i = N - 1; i >= 0; i--) { back[i] = gcd1(back[i + 1], a[i]); } int ans = 0; for (int i = 0; i < N; i++) { int tmp = gcd1(front[i], back[i + 1]); // cerr<<front[i]<<" "<< back[i+1]<<endl; ans = max(ans, tmp); // cout<<ans<<endl; } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v.begin(), v.end()) #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) \ for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) 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; } template <class T1, class T2> ostream &operator<<(ostream &s, pair<T1, T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template <class T> ostream &operator<<(ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template <class T> ostream &operator<<(ostream &s, vector<vector<T>> P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template <class T> ostream &operator<<(ostream &s, set<T> P) { EACH(it, P) { s << "<" << *it << "> "; } return s << endl; } template <class T1, class T2> ostream &operator<<(ostream &s, map<T1, T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } typedef long long ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) int gcd(int a, int b) { if ((0 == a) || (0 == b)) return 0; if (a < b) { swap(a, b); } if (a % b == 0) { return b; } else { return gcd(a, a % b); } } int gcd1(int a, int b) { return b ? gcd1(b, a % b) : a; } int main() { int N; int a[100010]; cin >> N; for (int i = 0; i < N; i++) cin >> a[i]; vector<int> front(N + 1, 0); vector<int> back(N + 1, 0); for (int i = 0; i < N; i++) { front[i + 1] = gcd1(front[i], a[i]); // cerr<<front[i+1]<<" "<<back[i+1]<<endl; } for (int i = N - 1; i >= 0; i--) { back[i] = gcd1(back[i + 1], a[i]); } int ans = 0; for (int i = 0; i < N; i++) { int tmp = gcd1(front[i], back[i + 1]); // cerr<<front[i]<<" "<< back[i+1]<<endl; ans = max(ans, tmp); // cout<<ans<<endl; } cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.change", "call.function.change" ]
877,491
877,492
u074445770
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { int tmp = a; a = b; b = tmp; } if (b == 0) return b; int r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } int main() { int n, ans = 0; cin >> n; vector<int> a(n), l(n + 1, 0), r(n + 2, 0); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { l[i + 1] = gcd(l[i], a[i]); r[n - i] = gcd(r[n - i + 1], a[n - i - 1]); } for (int i = 0; i <= n; i++) ans = max(ans, gcd(l[i], r[i + 2])); cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { int tmp = a; a = b; b = tmp; } if (b == 0) return a; int r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } int main() { int n, ans = 0; cin >> n; vector<int> a(n), l(n + 1, 0), r(n + 2, 0); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { l[i + 1] = gcd(l[i], a[i]); r[n - i] = gcd(r[n - i + 1], a[n - i - 1]); } for (int i = 0; i <= n; i++) ans = max(ans, gcd(l[i], r[i + 2])); cout << ans << "\n"; }
[ "identifier.change", "function.return_value.change" ]
877,493
877,494
u303884911
cpp
p03061
#include <algorithm> #include <iostream> #include <vector> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> L(n + 1); vector<int> R(n + 1); for (int i = 0; i < n - 1; i++) { L[i + 1] = gcd(L[i], a[i]); } for (int i = n - 1; i >= 0; i--) { R[i] = gcd(R[i + 1], a[i]); } int ans = 0; for (int i = 0; i < n - 1; i++) { ans = max(ans, gcd(L[i], R[i + 1])); } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int gcd(int a, int b) { // a < b return b == 0 ? a : gcd(b, a % b); } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> L(n + 1); vector<int> R(n + 1); for (int i = 0; i < n - 1; i++) { L[i + 1] = gcd(L[i], a[i]); } for (int i = n - 1; i >= 0; i--) { R[i] = gcd(R[i + 1], a[i]); } int ans = 0; for (int i = 0; i < n; i++) { ans = max(ans, gcd(L[i], R[i + 1])); } cout << ans << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
877,499
877,500
u150861392
cpp
p03061
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; using namespace std; priority_queue<ll> PrimeFact(ll N) { priority_queue<ll> que; while (1) { bool isPrime = true; for (ll i = 2LL; i * i <= N; i++) { if (N % i == 0LL) { que.push(i); N /= i; isPrime = false; break; } } if (isPrime) { que.push(N); break; } } return que; } //======================================== int main() { int N; cin >> N; ll a[N]; for (int i = 0; i < N; i++) cin >> a[i]; priority_queue<ll> q1 = PrimeFact(a[0]); priority_queue<ll> q2 = PrimeFact(a[1]); ll ans1 = 1; ll t[N]; for (int i = 0; i < N; i++) t[i] = a[i]; bool pos_dfd = false; while (!q1.empty()) { int x = q1.top(); q1.pop(); int cnt = 0; int pos = -1; for (int i = 0; i < N; i++) { if (t[i] % x == 0) cnt++; else { if (!pos_dfd) pos = i; } } if (cnt == N) { ans1 *= x; for (int i = 0; i < N; i++) t[i] /= x; } else if (cnt == N - 1 && !pos_dfd) { ans1 *= x; pos_dfd = true; t[pos] = a[0]; for (int i = 0; i < N; i++) t[i] /= x; } } //------------------------------------------- ll ans2 = 1; for (int i = 0; i < N; i++) t[i] = a[i]; pos_dfd = false; while (!q2.empty()) { int x = q2.top(); q2.pop(); int cnt = 0; int pos = -1; for (int i = 0; i < N; i++) { if (t[i] % x == 0) cnt++; else { if (!pos_dfd) pos = i; } } if (cnt == N) { ans2 *= x; for (int i = 0; i < N; i++) t[i] /= x; } else if (cnt == N - 1 && !pos_dfd) { ans2 *= x; pos_dfd = true; t[pos] = a[0]; for (int i = 0; i < N; i++) t[i] /= x; } } cout << max(ans1, ans2) << endl; }
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; using namespace std; priority_queue<ll> PrimeFact(ll N) { priority_queue<ll> que; while (1) { bool isPrime = true; for (ll i = 2LL; i * i <= N; i++) { if (N % i == 0LL) { que.push(i); N /= i; isPrime = false; break; } } if (isPrime) { que.push(N); break; } } return que; } //======================================== int main() { int N; cin >> N; ll a[N]; for (int i = 0; i < N; i++) cin >> a[i]; priority_queue<ll> q1 = PrimeFact(a[0]); priority_queue<ll> q2 = PrimeFact(a[1]); ll ans1 = 1; ll t[N]; for (int i = 0; i < N; i++) t[i] = a[i]; bool pos_dfd = false; while (!q1.empty()) { ll x = q1.top(); q1.pop(); int cnt = 0; int pos = -1; for (int i = 0; i < N; i++) { if (t[i] % x == 0LL) cnt++; else { if (!pos_dfd) pos = i; } } if (cnt == N) { ans1 *= x; for (int i = 0; i < N; i++) t[i] /= x; } else if (cnt == N - 1 && !pos_dfd) { ans1 *= x; pos_dfd = true; t[pos] = a[0]; for (int i = 0; i < N; i++) t[i] /= x; } } //------------------------------------------- ll ans2 = 1; for (int i = 0; i < N; i++) t[i] = a[i]; pos_dfd = false; while (!q2.empty()) { int x = q2.top(); q2.pop(); int cnt = 0; int pos = -1; for (int i = 0; i < N; i++) { if (t[i] % x == 0) cnt++; else { if (!pos_dfd) pos = i; } } if (cnt == N) { ans2 *= x; for (int i = 0; i < N; i++) t[i] /= x; } else if (cnt == N - 1 && !pos_dfd) { ans2 *= x; pos_dfd = true; t[pos] = a[1]; for (int i = 0; i < N; i++) t[i] /= x; } } cout << max(ans1, ans2) << endl; }
[ "variable_declaration.type.change", "control_flow.branch.if.condition.change", "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change" ]
877,503
877,504
u492131209
cpp
p03061
// // Created on 2019-02-09. // #include "bits/stdc++.h" using namespace std; typedef long long ll; template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; } #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define ALL(v) (v).begin(), (v).end() #define RALL(a) (a).rbegin(), (a).rend() #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #define PB push_back #define INF 1e9 #define MOD 1e9 + 7 #define EPS 1e-9 typedef vector<int> vi; typedef vector<string> vs; typedef vector<vi> vvi; typedef pair<int, int> pii; ll gcd(ll a, ll b) { if (a % b == 0) return (b); else return (gcd(b, a % b)); } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N), l(N, 0), r(N, 0); REP(i, N) { cin >> A[i]; } for (int i = 0; i < N - 1; ++i) l[i + 1] = gcd(l[i], A[i]); for (int i = N - 1; i >= 1; --i) r[i - 1] = gcd(r[i], A[i]); ll ans = 1; REP(i, N) ans = max(ans, gcd(l[i], r[i])); cout << ans << endl; return 0; }
// // Created on 2019-02-09. // #include "bits/stdc++.h" using namespace std; typedef long long ll; template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; } #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define ALL(v) (v).begin(), (v).end() #define RALL(a) (a).rbegin(), (a).rend() #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #define PB push_back #define INF 1e9 #define MOD 1e9 + 7 #define EPS 1e-9 typedef vector<int> vi; typedef vector<string> vs; typedef vector<vi> vvi; typedef pair<int, int> pii; ll gcd(ll a, ll b) { if (b == 0) return (a); else return (gcd(b, a % b)); } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N), l(N, 0), r(N, 0); REP(i, N) { cin >> A[i]; } for (int i = 0; i < N - 1; ++i) l[i + 1] = gcd(l[i], A[i]); for (int i = N - 1; i >= 1; --i) r[i - 1] = gcd(r[i], A[i]); ll ans = 1; REP(i, N) ans = max(ans, gcd(l[i], r[i])); cout << ans << endl; return 0; }
[ "expression.operation.binary.remove", "identifier.change", "function.return_value.change" ]
877,512
877,513
u299377613
cpp
p03061
#include <algorithm> #include <iostream> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long max(long long a, long long b) { if (a > b) return a; else return b; } int main(void) { // Your code here! int N; cin >> N; long long A[N]; for (int i = 0; i < N; i++) cin >> A[i]; long long dpl[N + 1]; long long dpr[N + 1]; dpl[0] = A[0]; dpr[0] = A[N - 1]; for (int i = 0; i < N; i++) { dpl[i + 1] = gcd(dpl[i], A[i]); } for (int i = 0; i < N; i++) { dpr[i + 1] = gcd(dpr[i], A[N - 1 - i]); } int maxv = 0; for (int i = 1; i <= N - 2; i++) { maxv = max(maxv, gcd(dpl[i], dpr[i])); } maxv = max(maxv, dpr[N - 1]); maxv = max(maxv, dpl[N - 1]); cout << maxv << endl; }
#include <algorithm> #include <iostream> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long max(long long a, long long b) { if (a > b) return a; else return b; } int main(void) { // Your code here! int N; cin >> N; long long A[N]; for (int i = 0; i < N; i++) cin >> A[i]; long long dpl[N + 1]; long long dpr[N + 1]; dpl[0] = A[0]; dpr[0] = A[N - 1]; for (int i = 0; i < N; i++) { dpl[i + 1] = gcd(dpl[i], A[i]); } for (int i = 0; i < N; i++) { dpr[i + 1] = gcd(dpr[i], A[N - 1 - i]); } int maxv = 0; for (int i = 2; i <= N - 1; i++) { maxv = max(maxv, gcd(dpl[i - 1], dpr[N - i])); } maxv = max(maxv, dpr[N - 1]); maxv = max(maxv, dpl[N - 1]); cout << maxv << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "assignment.change" ]
877,516
877,515
u279137361
cpp
p03061
#include <algorithm> #include <iostream> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long max(long long a, long long b) { if (a > b) return a; else return b; } int main(void) { // Your code here! int N; cin >> N; long long A[N]; for (int i = 0; i < N; i++) cin >> A[i]; long long dpl[N + 1]; long long dpr[N + 1]; dpl[0] = A[0]; dpr[0] = A[N - 1]; for (int i = 0; i < N; i++) { dpl[i + 1] = gcd(dpl[i], A[i]); } for (int i = 0; i < N; i++) { dpr[i + 1] = gcd(dpr[i], A[N - 1 - i]); } int maxv = 0; for (int i = 1; i <= N - 1; i++) { maxv = max(maxv, gcd(dpl[i - 1], dpr[N - i - 2])); } maxv = max(maxv, dpr[N - 1]); maxv = max(maxv, dpl[N - 1]); maxv = max(maxv, dpl[N]); cout << maxv << endl; }
#include <algorithm> #include <iostream> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long max(long long a, long long b) { if (a > b) return a; else return b; } int main(void) { // Your code here! int N; cin >> N; long long A[N]; for (int i = 0; i < N; i++) cin >> A[i]; long long dpl[N + 1]; long long dpr[N + 1]; dpl[0] = A[0]; dpr[0] = A[N - 1]; for (int i = 0; i < N; i++) { dpl[i + 1] = gcd(dpl[i], A[i]); } for (int i = 0; i < N; i++) { dpr[i + 1] = gcd(dpr[i], A[N - 1 - i]); } int maxv = 0; for (int i = 2; i <= N - 1; i++) { maxv = max(maxv, gcd(dpl[i - 1], dpr[N - i])); } maxv = max(maxv, dpr[N - 1]); maxv = max(maxv, dpl[N - 1]); maxv = max(maxv, dpl[N]); cout << maxv << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.remove" ]
877,517
877,518
u279137361
cpp
p03061
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; #define INF 2147483647 #define LINF 9223372036854775807 #define MOD 1000000007 #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define MODE 1 #ifdef MODE #define DEB(X) cout << #X << ": " << X << " "; #define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " "; #define END cout << endl; #else #define DEB(X) \ {} #define ARDEB(i, X) \ {} #define END \ {} #endif typedef long long ll; //最大公約数 ll gcd(ll a, ll b) { if (a == 0 || b == 0) return max(a, b); if (a < b) { ll sw; sw = a; a = b; b = sw; } ll r; while ((r = a % b) != 0) { a = b; b = r; } return b; } signed main() { int n, a[111111]; int f[111111], b[111111]; cin >> n; rep(i, n) cin >> a[i]; int g; f[0] = 0; for (int i = 0; i < n; i++) { f[i + 1] = gcd(f[i], a[i]); } b[n] = 0; for (int i = n - 1; i >= 0; i--) { b[i] = gcd(b[i + 1], a[i]); } int max = 0; rep(i, n) { max = std::max(gcd(f[i - 1], b[i]), max); // DEB(a[i-1])END // DEB(a[i])END } cout << max << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; #define INF 2147483647 #define LINF 9223372036854775807 #define MOD 1000000007 #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define MODE 1 #ifdef MODE #define DEB(X) cout << #X << ": " << X << " "; #define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " "; #define END cout << endl; #else #define DEB(X) \ {} #define ARDEB(i, X) \ {} #define END \ {} #endif typedef long long ll; //最大公約数 ll gcd(ll a, ll b) { if (a == 0 || b == 0) return max(a, b); if (a < b) { ll sw; sw = a; a = b; b = sw; } ll r; while ((r = a % b) != 0) { a = b; b = r; } return b; } signed main() { int n, a[111111]; int f[111111], b[111111]; cin >> n; rep(i, n) cin >> a[i]; int g; f[0] = 0; for (int i = 0; i < n; i++) { f[i + 1] = gcd(f[i], a[i]); } b[n] = 0; for (int i = n - 1; i >= 0; i--) { b[i] = gcd(b[i + 1], a[i]); } int max = 0; rep(i, n) { max = std::max(gcd(f[i], b[i + 1]), max); // DEB(a[i-1])END // DEB(a[i])END } cout << max << endl; }
[ "expression.operation.binary.remove", "assignment.change" ]
877,522
877,523
u901561754
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> ii; typedef pair<ll, int> li; typedef pair<int, ll> il; typedef vector<ii> vii; typedef vector<il> vil; typedef vector<li> vli; #define F first #define S second #define pb(x) push_back(x) #define mp(a, b) make_pair(a, b) #define sz size() #define all(A) A.begin(), A.end() #define mem(a, b) memset(a, b, sizeof(a)) #define f0(i, b) for (int i = 0; i < (b); i++) #define f1(i, b) for (int i = 1; i <= (b); i++) #define f2(i, a, b) for (int i = (a); i <= (b); i++) #define fr(i, b, a) for (int i = (b); i >= (a); i--) #define rep(i, a, b, c) for (int i = (a); i != (b); i += (c)) #define mod 1000000007 #define forr(i, n) for (i = 0; i < n; i++) #define whilee(i, t) while (i != t) #define sl(a) scanf("%lld", &a) #define pl(a) printf("%lld\n", a) #define scan(x) \ do { \ while ((x = getchar()) < '0') \ ; \ for (x -= '0'; '0' <= (_ = getchar()); x = (x << 3) + (x << 1) + _ - '0') \ ; \ } while (0) char _; // for(auto it =A.begin(); it!=A.end(); it++) // sort(A.begin(),A.end()); // binary_search(A.begin(),A.end(),x); // reverse(A.begin(), A.end()); // cout << *max_element(A.begin(), A.end()); // cout << *min_element(A.begin(), A.end()); // count(A.begin(), A.end(), X); //counts the occurrences of X // distance(A.begin(),A.end()); //distance between first to last element // accumulate(A.begin(), A.end(), 0); //add // next_permutation(A.begin(), A.end()); // prev_permutation(A.begin(), A.end()); // swap(S[0], T[0]); // scanf("%d",&x); // printf("%d\n",x); // while (scanf("%d %d", &a, &b) == 2) // printf("Case %d: %d\n", t++, a); // vector <int> A; // deque <int> A; // queue <int> A; // stack <int> A; // set <int> A; // map <int,int> A; // pair <int,int> A ; // vector <pair <int,int>> A ; // bitset<32> bset1; // char ch; // string S, T, U; ll gcd(ll a, ll b) { if (b == 0) { return a; } return gcd(b, a % b); } ll i, j, k, a, b, c = 0, d, f, g, h, l, m, n, p, q, r, s, t = 1, u, v, w, x, y, z, maxx = INT_MIN, minn = INT_MAX, ans = 1, sum = 0, cnt = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // NULL cout.tie(nullptr); // NULL // scan(n); cin >> n; ll A[n], left[n], right[n]; forr(i, n) { cin >> A[i]; if (i == 0) { left[i] = A[i]; } else { left[i] = gcd(left[i - 1], A[i]); } } fr(i, n - 1, 0) { if (i == n - 1) { right[i] = A[i]; } else { right[i] = gcd(right[i + 1], A[i]); } } maxx = (left[n - 2], right[1]); for (i = 1; i < n - 1; i++) { ans = gcd(left[i - 1], right[i + 1]); if (ans > maxx) { maxx = ans; } } cout << maxx << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> ii; typedef pair<ll, int> li; typedef pair<int, ll> il; typedef vector<ii> vii; typedef vector<il> vil; typedef vector<li> vli; #define F first #define S second #define pb(x) push_back(x) #define mp(a, b) make_pair(a, b) #define sz size() #define all(A) A.begin(), A.end() #define mem(a, b) memset(a, b, sizeof(a)) #define f0(i, b) for (int i = 0; i < (b); i++) #define f1(i, b) for (int i = 1; i <= (b); i++) #define f2(i, a, b) for (int i = (a); i <= (b); i++) #define fr(i, b, a) for (int i = (b); i >= (a); i--) #define rep(i, a, b, c) for (int i = (a); i != (b); i += (c)) #define mod 1000000007 #define forr(i, n) for (i = 0; i < n; i++) #define whilee(i, t) while (i != t) #define sl(a) scanf("%lld", &a) #define pl(a) printf("%lld\n", a) #define scan(x) \ do { \ while ((x = getchar()) < '0') \ ; \ for (x -= '0'; '0' <= (_ = getchar()); x = (x << 3) + (x << 1) + _ - '0') \ ; \ } while (0) char _; // for(auto it =A.begin(); it!=A.end(); it++) // sort(A.begin(),A.end()); // binary_search(A.begin(),A.end(),x); // reverse(A.begin(), A.end()); // cout << *max_element(A.begin(), A.end()); // cout << *min_element(A.begin(), A.end()); // count(A.begin(), A.end(), X); //counts the occurrences of X // distance(A.begin(),A.end()); //distance between first to last element // accumulate(A.begin(), A.end(), 0); //add // next_permutation(A.begin(), A.end()); // prev_permutation(A.begin(), A.end()); // swap(S[0], T[0]); // scanf("%d",&x); // printf("%d\n",x); // while (scanf("%d %d", &a, &b) == 2) // printf("Case %d: %d\n", t++, a); // vector <int> A; // deque <int> A; // queue <int> A; // stack <int> A; // set <int> A; // map <int,int> A; // pair <int,int> A ; // vector <pair <int,int>> A ; // bitset<32> bset1; // char ch; // string S, T, U; ll gcd(ll a, ll b) { if (b == 0) { return a; } return gcd(b, a % b); } ll i, j, k, a, b, c = 0, d, f, g, h, l, m, n, p, q, r, s, t = 1, u, v, w, x, y, z, maxx = INT_MIN, minn = INT_MAX, ans = 1, sum = 0, cnt = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // NULL cout.tie(nullptr); // NULL // scan(n); cin >> n; ll A[n], left[n], right[n]; forr(i, n) { cin >> A[i]; if (i == 0) { left[i] = A[i]; } else { left[i] = gcd(left[i - 1], A[i]); } } fr(i, n - 1, 0) { if (i == n - 1) { right[i] = A[i]; } else { right[i] = gcd(right[i + 1], A[i]); } } maxx = max(left[n - 2], right[1]); for (i = 1; i < n - 1; i++) { ans = gcd(left[i - 1], right[i + 1]); if (ans > maxx) { maxx = ans; } } cout << maxx << endl; return 0; }
[ "call.add" ]
877,529
877,530
u779159351
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } vector<int> r_g(n + 1); r_g.at(n) = 0; for (int i = n - 1; i >= 0; i--) { r_g.at(i) = gcd(r_g.at(i + 1), a.at(i)); } int ans = r_g.at(0); int g = 0; for (int i = 1; i < n; i++) { ans = max(ans, gcd(g, r_g.at(i))); g = gcd(g, a.at(i - 1)); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } vector<int> r_g(n + 1); r_g.at(n) = 0; for (int i = n - 1; i >= 0; i--) { r_g.at(i) = gcd(r_g.at(i + 1), a.at(i)); } int ans = r_g.at(0); int g = 0; for (int i = 1; i <= n; i++) { ans = max(ans, gcd(g, r_g.at(i))); g = gcd(g, a.at(i - 1)); } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
877,533
877,534
u465233477
cpp
p03061
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int main() { ll n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<ll> left(n, 0); vector<ll> right(n, 0); for (int i = 0; i < n; i++) left[i + 1] = gcd(left[i], a[i]); for (int i = n - 1; i >= 0; i--) right[i] = gcd(right[i + 1], a[i]); int res = 0; for (int i = 0; i < n; i++) { int l = left[i]; int r = right[i + 1]; if (res < gcd(l, r)) { res = gcd(l, r); } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int main() { ll n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<ll> left(n + 1, 0); vector<ll> right(n + 1, 0); for (int i = 0; i < n; i++) left[i + 1] = gcd(left[i], a[i]); for (int i = n - 1; i >= 0; i--) right[i] = gcd(right[i + 1], a[i]); int res = 0; for (int i = 0; i < n; i++) { int l = left[i]; int r = right[i + 1]; if (res < gcd(l, r)) { res = gcd(l, r); } } cout << res << endl; return 0; }
[ "assignment.change" ]
877,535
877,536
u568419568
cpp
p03061
#include <algorithm> #include <cmath> #include <iostream> using namespace std; const int maxn = 200005; int n; int a[maxn], pre[maxn], pos[maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (i == 0) { pre[i] = a[i]; } else { pre[i] = __gcd(pre[i - 1], a[i]); } } for (int i = n - 1; i >= 0; i--) { if (i == n - 1) { pos[i] = a[i]; } else { pos[i] = __gcd(pos[i + 1], a[i]); } } int ans = max(pre[1], pos[n - 2]); for (int i = 1; i < n - 1; i++) { ans = max(ans, __gcd(pre[i - 1], pos[i + 1])); } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> using namespace std; const int maxn = 200005; int n; int a[maxn], pre[maxn], pos[maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (i == 0) { pre[i] = a[i]; } else { pre[i] = __gcd(pre[i - 1], a[i]); } } for (int i = n - 1; i >= 0; i--) { if (i == n - 1) { pos[i] = a[i]; } else { pos[i] = __gcd(pos[i + 1], a[i]); } } int ans = max(pos[1], pre[n - 2]); for (int i = 1; i < n - 1; i++) { ans = max(ans, __gcd(pre[i - 1], pos[i + 1])); } cout << ans << endl; return 0; }
[ "identifier.change", "call.arguments.change" ]
877,539
877,540
u930838529
cpp
p03061
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define chmin(a, b) ((a) = min((a), (b))) #define chmax(a, b) ((a) = max((a), (b))) #define fs first #define sc second #define eb emplace_back using namespace std; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> T; const ll MOD = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1); const double eps = 1e-10; int dx[] = {1, 0, -1, 0}; int dy[] = {0, -1, 0, 1}; int gcd(int x, int y) { if (y == 0) return x; else return gcd(y, x % y); } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> l(n, a[0]), r(n, a[n - 1]); for (int i = 1; i < n; i++) { l[i] = gcd(a[i], l[i - 1]); r[n - 1 - i] = gcd(a[n - 1 - i], r[n - i]); } int ans = max(l[n - 2], r[1]); for (int i = 1; i < n - 1; i++) { int num = gcd(l[i - 1], r[n - i]); chmax(ans, num); } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define chmin(a, b) ((a) = min((a), (b))) #define chmax(a, b) ((a) = max((a), (b))) #define fs first #define sc second #define eb emplace_back using namespace std; typedef long long ll; typedef pair<int, int> P; typedef tuple<int, int, int> T; const ll MOD = 1e9 + 7; const ll INF = 1e18; const double pi = acos(-1); const double eps = 1e-10; int dx[] = {1, 0, -1, 0}; int dy[] = {0, -1, 0, 1}; int gcd(int x, int y) { if (y == 0) return x; else return gcd(y, x % y); } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> l(n, a[0]), r(n, a[n - 1]); for (int i = 1; i < n; i++) { l[i] = gcd(a[i], l[i - 1]); r[n - 1 - i] = gcd(a[n - 1 - i], r[n - i]); } int ans = max(l[n - 2], r[1]); for (int i = 1; i < n - 1; i++) { int num = gcd(l[i - 1], r[i + 1]); chmax(ans, num); } cout << ans << endl; }
[ "expression.operation.binary.remove" ]
877,541
877,542
u049420296
cpp
p03061
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int m_f[n]; int m_b[n]; m_f[0] = a[0]; m_b[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { m_f[i] = gcd(m_f[i - 1], a[i]); m_b[n - i - 1] = gcd(m_f[n - i], a[n - i - 1]); } int ans = 1; ans = max(ans, m_f[n - 2]); ans = max(ans, m_b[1]); for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(m_f[i - 1], m_b[i + 1])); } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int m_f[n]; int m_b[n]; m_f[0] = a[0]; m_b[n - 1] = a[n - 1]; for (int i = 1; i < n; i++) { m_f[i] = gcd(m_f[i - 1], a[i]); m_b[n - i - 1] = gcd(m_b[n - i], a[n - i - 1]); } int ans = 1; ans = max(ans, m_f[n - 2]); ans = max(ans, m_b[1]); for (int i = 1; i < n - 1; i++) { ans = max(ans, gcd(m_f[i - 1], m_b[i + 1])); } cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
877,543
877,544
u167604613
cpp
p03061
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define ALL(x) (x).begin(), (x).end() #define SZ(x) int((x).size()) #define OUT(x) cout << (x) << endl; typedef long long ll; typedef vector<int> V; typedef vector<vector<int>> VV; typedef pair<int, int> P; typedef map<string, int> M; typedef unordered_map<int, int> HM; typedef set<int> S; typedef queue<int> Q; int GCD(ll a, ll b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { int n; cin >> n; V a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } V left(n), right(n); left[0] = a[0]; for (int i = 1; i < n; i++) { left[i] = GCD(left[i - 1], a[i]); } right[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { right[i] = GCD(right[i + 1], a[i]); } int ans = 0; for (int i = 0; i < n; i++) { if (i == 0) { ans = max(ans, right[1]); } else if (i == n - 1) { ans = max(ans, left[n - 1]); } else { ans = max(ans, GCD(left[i - 1], right[i + 1])); } } OUT(ans); } // wa
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define ALL(x) (x).begin(), (x).end() #define SZ(x) int((x).size()) #define OUT(x) cout << (x) << endl; typedef long long ll; typedef vector<int> V; typedef vector<vector<int>> VV; typedef pair<int, int> P; typedef map<string, int> M; typedef unordered_map<int, int> HM; typedef set<int> S; typedef queue<int> Q; int GCD(ll a, ll b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { int n; cin >> n; V a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } V left(n), right(n); left[0] = a[0]; for (int i = 1; i < n; i++) { left[i] = GCD(left[i - 1], a[i]); } right[n - 1] = a[n - 1]; for (int i = n - 2; i >= 0; i--) { right[i] = GCD(right[i + 1], a[i]); } int ans = 0; for (int i = 0; i < n; i++) { if (i == 0) { ans = max(ans, right[1]); } else if (i == n - 1) { ans = max(ans, left[n - 2]); } else { ans = max(ans, GCD(left[i - 1], right[i + 1])); } } OUT(ans); } // wa
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
877,547
877,548
u901615543
cpp
p03061
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int N, tmp, ans = 0; cin >> N; int A[N]; int left[N], right[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } left[0] = A[0]; right[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { left[i] = gcd(left[i - 1], A[i]); } for (int i = N - 2; N >= i; i++) { right[i] = gcd(right[i + 1], A[i]); } ans = max(ans, right[1]); for (int i = 0; i < N - 2; i++) { tmp = gcd(left[i], right[i + 2]); ans = max(ans, tmp); } ans = max(ans, left[N - 2]); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int N, tmp, ans = 0; cin >> N; int A[N]; int left[N], right[N]; for (int i = 0; i < N; i++) { cin >> A[i]; } left[0] = A[0]; right[N - 1] = A[N - 1]; for (int i = 1; i < N; i++) { left[i] = gcd(left[i - 1], A[i]); } for (int i = N - 2; i >= 0; i--) { right[i] = gcd(right[i + 1], A[i]); } ans = max(ans, right[1]); for (int i = 0; i < N - 2; i++) { tmp = gcd(left[i], right[i + 2]); ans = max(ans, tmp); } ans = max(ans, left[N - 2]); cout << ans << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
877,549
877,550
u074306398
cpp