malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int n, m, cev, b, a[100005], k;   string s;   vector<int> v;   int main() {     scanf( %lld %lld %lld , &n, &m, &k);     if (n <= 0 && m <= 0 && n < k && m < k && k > n + m) {       printf( -1 n );       return 0;     }     if (n < m) swap(n, m);     while (n < k) {       cev += (n - m) / n;       if (n * ((n - m) / n) == 0) {         m += n;         cev++;       } else         m += n * ((n - m) / n);       if (n < m) swap(n, m);     }     printf( %lld , cev);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long min(unsigned long long x, unsigned long long y) {     if (x < y) return x;     return y;   }   unsigned long long max(unsigned long long x, unsigned long long y) {     if (x < y) return y;     return x;   }   long long min(long long x, long long y) {     if (x < y) return x;     return y;   }   long long max(long long x, long long y) {     if (x < y) return y;     return x;   }   double min(double x, double y) {     if (x < y) return x;     return y;   }   double max(double x, double y) {     if (x < y) return y;     return x;   }   unsigned long long gcd(unsigned long long x, unsigned long long y) {     if (!x) return y;     if (!y) return x;     if (x > y) swap(x, y);     return gcd(x, y % x);   }   unsigned long long inv(unsigned long long a, unsigned long long c) {     if (a == 1) {       return 1;     }     return ((c - (c / a)) * inv(c % a, c)) % c;   }   void printv(vector<int> &a) {     int n = a.size();     for (int i = 0; i < n; ++i) {       cout << a[i] <<    ;     }     cout <<   END n ;   }   pair<int, int> dfs(int u, int pre, vector<int> adj[]) {     vector<int> d;     int maxd = 0, diameter = 0;     for (int i = 0; i < adj[u].size(); ++i) {       int v = adj[u][i];       if (v != pre) {         pair<int, int> cur = dfs(v, u, adj);         diameter = max(diameter, cur.first);         maxd = max(maxd, cur.second);         d.push_back(cur.second);       }     }     sort(d.begin(), d.end());     maxd++;     if (d.size() > 1) {       int m = d.size();       diameter = max(diameter, d[m - 1] + 1 + d[m - 2]);     } else {       diameter = max(diameter, maxd);     }     return make_pair(diameter, maxd);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       int n, a, b, da, db;       cin >> n >> a >> b >> da >> db;       a--;       b--;       vector<int> adj[n];       for (int i = 0; i < n - 1; ++i) {         int u, v;         cin >> u >> v;         u--;         v--;         adj[u].push_back(v);         adj[v].push_back(u);       }       vector<int> dist(n, INT_MAX);       queue<int> q;       q.push(a);       dist[a] = 0;       while (!q.empty()) {         int u = q.front();         q.pop();         for (int i = 0; i < adj[u].size(); ++i) {           int v = adj[u][i];           if (dist[v] == INT_MAX) {             dist[v] = dist[u] + 1;             q.push(v);           }         }       }       pair<int, int> pp = dfs(0, -1, adj);       int longest_path = pp.first;       if ((dist[b] > da) && (db > 2 * da) && (longest_path > 2 * da + 1)) {         cout <<  Bob n ;       } else {         cout <<  Alice n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k, countt = 0, counts = 0, maxi = 0;     cin >> n >> k;     long long int a[n];     for (long long int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] == -1)         counts++;       else         countt++;     }     for (long long int b = 0; b < k; b++) {       long long int ts = counts, tt = countt;       for (long long int j = 0; b + (j * k) + 1 <= n; j++) {         if (a[b + (j * k) + 1] == -1)           ts--;         else           tt--;       }       maxi = max(maxi, abs(ts - tt));     }     cout << maxi << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int H, M, S, X, Y;   bool A, B;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> H >> M >> S >> X >> Y;     A = 1;     B = 1;     H = H % 12;     if (X > Y) {       swap(X, Y);     }     if (S > 5 * X && S < 5 * Y) {       B = 0;     } else {       A = 0;     }     if (60 * M + S > 300 * X && 60 * M + S < 300 * Y) {       B = 0;     } else {       A = 0;     }     if (120 * H + M + S > 120 * X && 120 * H + M + S < 120 * Y) {       B = 0;     } else {       A = 0;     }     if (A || B) {       cout <<  yes n ;     } else {       cout <<  no n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   char s[1000];   bool check_type() {     int i;     for (i = 1; s[i]; i++) {       if (!isdigit(s[i]) && isdigit(s[i - 1])) return true;     }     return false;   }   void first() {     int i, n = 0, m = 0;     for (i = 0; !isdigit(s[i]); i++) n = 26 * n + s[i] -  A  + 1;     for (; s[i]; i++) m = 10 * m + s[i] -  0 ;     cout <<  R  << m <<  C  << n << endl;   }   void second() {     int i, j, n = 0, m = 0, z = 0;     for (i = 1; isdigit(s[i]); i++) n = 10 * n + s[i] -  0 ;     for (++i; s[i]; i++) m = 10 * m + s[i] -  0 ;     while (m) {       s[z++] = m % 26 +  A  - 1;       if (s[z - 1] <  A ) {         s[z - 1] =  Z ;         m -= 26;       }       m /= 26;     }     for (j = z - 1; j >= 0; j--) cout << s[j];     cout << n << endl;   }   int main() {     int i;     cin >> n;     for (i = 1; i <= n; i++) {       scanf( %s , &s);       check_type();       if (!check_type())         first();       else         second();     }     return 0;   }
#include <bits/stdc++.h>   long long int power(int x, int y) {     int i = 0;     long long int result = 1;     for (i = 0; i < y; i++) result = result * x;     return result;   }   int main() {     int r, d, r1;     int n;     int x, y;     int i = 0;     double dist = 0;     int count = 0;     double temp1, temp2;     scanf( %d %d , &r, &d);     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d %d %d , &x, &y, &r1);       dist = power(x, 2) + power(y, 2);       dist = sqrt(dist);       temp1 = dist + r1;       temp2 = dist - r1;       if (temp1 <= r && temp2 >= r - d) count++;     }     printf( %d , count);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void getZarr(const string &str, int Z[]) {     int n = str.length();     int L, R, k;     L = R = 0;     for (int i = 1; i < n; ++i) {       if (i > R) {         L = R = i;         while (R < n && str[R - L] == str[R]) R++;         Z[i] = R - L;         R--;       } else {         k = i - L;         if (Z[k] < R - i + 1)           Z[i] = Z[k];         else {           L = i;           while (R < n && str[R - L] == str[R]) R++;           Z[i] = R - L;           R--;         }       }     }   }   void search(const string &text, const string &pattern, int Z[]) {     string concat = pattern + text;     int l = concat.length();     getZarr(concat, Z);     for (int i = 0; i < (int)text.size(); ++i) Z[i] = Z[i + (int)pattern.size()];   }   const int mod = 998244353;   string a, l, r;   int Z1[(int)2e6 + 5];   int Z2[(int)2e6 + 5];   long long cs[1000000 + 2];   int main() {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     cin >> a >> l >> r;     search(a, l, Z1);     search(a, r, Z2);     cs[a.size()] = 1;     for (int i = (int)a.size() - 1; i >= 0; --i) {       const long long curr = [&](const int &i) {         if (a[i] ==  0 ) return l !=  0  ? 0 : cs[i + 1] - cs[i + 2];         int lo = i + (int)l.size();         int hi = i + (int)r.size();         if (lo > (int)a.size()) return 0LL;         if (Z1[i] < (int)l.size() && a[i + Z1[i]] < l[Z1[i]]) lo++;         if (hi > (int)a.size())           hi = (int)a.size();         else {           if (Z2[i] < (int)r.size()) {             if (a[i + Z2[i]] > r[Z2[i]]) {               hi--;             }           }         }         if (lo > hi) return 0LL;         return cs[lo] - cs[hi + 1];       }(i);       cs[i] = (curr + cs[i + 1]) % mod;     }     const long long ans = ((cs[0] - cs[1]) % mod + mod) % mod;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   const double EPS = 1e-9;   const long long MOD = 1000000007;   const int INF = 2000 * 1000 * 1000 + 5;   const int MAX = 1005;   using namespace std;   int popcount(int n) {     bitset<32> b(n);     return b.count();   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) {     long long temp = gcd(a, b);     return temp ? (a / temp * b) : 0;   }   template <typename T>   T modpow(T base, T exp, T modulus) {     base %= modulus;     T result = 1;     while (exp > 0) {       if (exp & 1) result = (result * base) % modulus;       base = (base * base) % modulus;       exp >>= 1;     }     return result;   }   inline bool isInteger(const std::string& s) {     if (s.empty() || ((!isdigit(s[0])) && (s[0] !=  - ) && (s[0] !=  + )))       return false;     char* p;     strtol(s.c_str(), &p, 10);     return (*p == 0);   }   int main() {     int n;     cin >> n;     vector<string> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     string s;     cin >> s;     string slower = s;     for (int i = 0; i < slower.length(); i++) slower[i] = tolower(s[i]);     vector<bool> b(s.length());     char letter;     cin >> letter;     for (int i = 0; i < n; i++) {       for (int j = 0; j < v[i].length(); j++) v[i][j] = tolower(v[i][j]);       int pos = slower.find(v[i]);       while (pos != -1) {         for (int j = 0; j < v[i].length(); j++) b[pos + j] = 1;         pos = slower.find(v[i], pos + 1);       }     }     for (int i = 0; i < s.length(); i++) {       if (b[i]) {         if (tolower(s[i]) != tolower(letter))           if (islower(s[i]))             s[i] = tolower(letter);           else             s[i] = toupper(letter);         else if (tolower(s[i]) == tolower(letter) && tolower(letter) !=  a )           if (islower(s[i]))             s[i] =  a ;           else             s[i] =  A ;         else if (islower(s[i]))           s[i] =  b ;         else           s[i] =  B ;       }     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     vector<pair<int, int>> v;     set<int> s;     for (int i = 0; i < n; i++) {       cin >> a[i];       v.push_back(make_pair(a[i], i));       s.insert(a[i]);     }     int m = s.size();     sort(v.begin(), v.end());     vector<int> r;     for (auto i : s) {       r.push_back(i);     }     if (n == 1) {       cout << 1 << endl;       cout << a[0] <<     << 0;     } else {       int x = 0;       vector<vector<int>> p(m);       for (int i = 0; i < n; i++) {         if (i == 0 || v[i].first == v[i - 1].first) {           p[x].push_back(v[i].second);         } else {           x++;           p[x].push_back(v[i].second);         }       }       vector<pair<int, int>> o;       for (int i = 0; i < m; i++) {         if (p[i].size() == 1) {           o.push_back(make_pair(r[i], 0));         } else {           bool f = true;           int x = p[i][1] - p[i][0];           for (int j = 2; j < p[i].size(); j++) {             if ((p[i][j - 1] + x) != p[i][j]) {               f = false;               break;             }           }           if (f == true) {             o.push_back(make_pair(r[i], x));           }         }       }       cout << o.size() << endl;       for (int i = 0; i < o.size(); i++) {         cout << o[i].first <<     << o[i].second << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<int> a, id(n + 1), res(n + 1);     a.push_back(-1);     for (int i = 0, j; i < n; i++) {       cin >> j;       if (a.back() != j) a.push_back(j);     }     int m = a.size() - 1;     queue<array<int, 3>> q;     vector<int> pr(m + 1), nx(m + 1, m + 1);     for (int i = 1; i <= m; i++) {       nx[id[a[i]]] = i;       id[a[i]] = i;       q.push({i, i, 1});     }     fill(id.begin(), id.end(), 0);     for (int i = m; i > 0; i--) {       pr[id[a[i]]] = i;       id[a[i]] = i;     }     res[1] = m;     for (int i = 2; i <= n; i++) {       queue<array<int, 3>> p;       while (!q.empty()) {         auto [xl, xr, xc] = q.front();         q.pop();         int tm = xc;         bool fnd = false;         while (!q.empty()) {           auto &[l, r, c] = q.front();           for (; l <= r; l++) {             if (pr[l] < xl) {               if (xc == i) {                 fnd = true;                 p.push({xl, l - 1, xc});                 break;               }               xc++;             }             if (r < nx[l]) c--;           }           if (fnd) break;           q.pop();         }         if (!fnd) p.push({xl, m, xc});       }       res[i] = p.size();       q.swap(p);     }     for (int i = 1; i <= n; i++) cout << res[i] <<    n [i == n];   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100010];   int b[100010];   long long dp[100010][2];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     for (int i = 1; i <= n; ++i) {       cin >> b[i];     }     dp[1][0] = a[1];     dp[1][1] = b[1];     long long ans = max(a[1], b[1]);     for (int i = 2; i <= n; ++i) {       dp[i][0] = max(dp[i - 1][1], max(dp[i - 2][0], dp[i - 2][1])) + a[i];       dp[i][1] = max(dp[i - 1][0], max(dp[i - 2][0], dp[i - 2][1])) + b[i];       ans = max(ans, dp[i][0]);       ans = max(ans, dp[i][1]);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, pos, l, r;     cin >> n >> pos >> l >> r;     if (pos > r) {       if (l - 1 == 0) {         cout << 0 + pos - r + 1;       } else {         cout << pos - r + 1 + r - l + 1;       }     } else if (pos < l) {       if (n == r) {         cout << l - pos + 1;       } else {         cout << l - pos + 1 + r - l + 1;       }     } else {       int x1 = pos - l;       int x2 = r - pos;       int min;       if (x1 < x2)         min = x1;       else         min = x2;       int t1, t2;       if (l == 1)         t1 = 0;       else         t1 = x1 + 1;       if (r == n)         t2 = 0;       else         t2 = x2 + 1;       if (t1 != 0 && t2 != 0) {         cout << t1 + t2 + min;       } else {         cout << t1 + t2;       }     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   char CRTBUFF[30000];   struct debugger {     static void call(const char* it) {}     template <typename T, typename... aT>     static void call(const char* it, T a, aT... rest) {       string b;       for (; *it && *it !=  , ; ++it)         if (*it !=    ) b += *it;       cerr << b <<  =  << a <<    ;       call(++it, rest...);     }   };   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(NULL);     };     long long n, k, m, d, ans = 0, p, x;     cin >> n >> k >> m >> d;     for (int i = (0); i < (d); i += (1)) {       if (i > (n - 1) / k) continue;       long long p = i * k + 1, x = min(m, n / p);       ans = max(ans, x * (i + 1));     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   template <class T>   void chmin(T &a, const T &b) {     if (a > b) a = b;   }   template <class T>   void chmax(T &a, const T &b) {     if (a < b) a = b;   }   long long dp[200020];   const long long INF = 1e18;   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int N;     cin >> N;     vector<long long> A(N);     for (int i = 0; i < (N); ++i) cin >> A[i];     vector<pair<long long, int>> v;     for (int i = 0; i < (N); ++i) v.push_back(make_pair(A[i], i));     sort(v.begin(), v.end());     for (int i = 0; i <= N; i++) dp[i] = INF;     dp[0] = 0;     for (int i = 0; i < N; i++) {       int idx = v[i].second;       long long mi = A[idx], ma = A[idx];       for (int j = 0; j < 5; j++) {         if (i + j >= N) break;         int nex = v[i + j].second;         chmin(mi, A[nex]);         chmax(ma, A[nex]);         if (j >= 2) chmin(dp[i + 1 + j], dp[i] + ma - mi);       }     }     long long K = dp[N];     vector<int> ans(N, 0);     int tar = N;     int col = 1;     for (int i = N - 1; i >= 0; i--) {       int idx = v[i].second;       long long mi = A[idx], ma = A[idx];       for (int j = 0; j < 5; j++) {         if (i + j >= N) break;         if (i + j >= tar) break;         int nex = v[i + j].second;         chmin(mi, A[nex]);         chmax(ma, A[nex]);         if (j >= 2 && i + j == tar - 1) {           long long res = dp[i] + ma - mi;           if (res == dp[tar]) {             for (int k = 0; k <= j; k++) ans[i + k] = col;             col++;             tar = i;             break;           }         }       }     }     cout << K <<     << col - 1 << endl;     vector<int> res(N, 0);     for (int i = 0; i < (N); ++i) res[v[i].second] = ans[i];     for (int i = 0; i < N; i++) cout << res[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int tree[27][2000000 + 5];   vector<int> data[244];   int del[2000000 + 6];   int read(int t, int idx) {     int sum = 0;     while (idx > 0) {       sum += tree[t][idx];       idx -= (idx & -idx);     }     return sum;   }   void update(int t, int idx, int val) {     while (idx <= 2000000) {       tree[t][idx] += val;       idx += (idx & -idx);     }   }   int bin(int t, int tar) {     int i = 1, j = 2000000;     while (i < j) {       int x = (i + j) / 2;       if (tar <= read(t, x))         j = x;       else         i = x + 1;     }     return i;   }   void init() {     for (int i = 1; i <= 26; ++i) {       int siz = data[i].size();       for (int j = 1; j <= siz + 1; ++j) update(i, j, 1);     }   }   int main() {     int k, ll, n, p;     char c;     string ss;     cin >> k >> ss;     ll = ss.length();     ss =     + ss;     for (int i = 1; i <= k; ++i) {       for (int p = 1; p <= ll; ++p) {         data[ss[p] -  a  + 1].push_back(p + (i - 1) * ll);       }     }     init();     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> p >> c;       int num = bin(c -  a  + 1, p);       del[data[c -  a  + 1][num - 1]] = 1;       update(c -  a  + 1, num, -1);     }     for (int i = 1; i <= k; ++i) {       for (int p = 1; p <= ll; ++p) {         if (del[p + (i - 1) * ll] == 0) printf( %c , ss[p]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   constexpr int full = 0x7fffffff;   bool is_valid(const vector<int> &idx, const int max_i, const int i) {     if (max_i < 0) return true;     if (idx.at(i) == max_i) {       return is_valid(idx, max_i - 1, i + 1);     }     int j;     for (j = 1; idx.at(i) + j <= max_i; j++) {       if (idx.at(i + j) != idx.at(i) + j) {         return false;       }     }     return is_valid(idx, idx.at(i) - 1, i + j);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int Ncases, N;     cin >> Ncases;     for (int _case = 0; _case < Ncases; _case++) {       cin >> N;       int p;       vector<int> idx(N, -1);       for (int i = 0; i < N; i++) {         cin >> p;         idx.at(p - 1) = i;       }       bool repeat = false;       for (const int v : idx) {         if (v == -1) {           cout <<  No  << endl;           repeat = true;           break;         }       }       if (!repeat) {         if (is_valid(idx, N - 1, 0)) {           cout <<  Yes  << endl;         } else {           cout <<  No  << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     for (int k = 0; k < t; k++) {       int n, m;       cin >> n >> m;       vector<vector<int>> a(max(n, m), vector<int>(max(n, m)));       vector<vector<int>> id(n * m, vector<int>(2));       vector<vector<int>> c(n, vector<int>(m));       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cin >> a[i][j];           id[a[i][j] - 1][1] = j;         }       }       for (int i = 0; i < m; i++) {         for (int j = 0; j < n; j++) {           cin >> a[i][j];           id[a[i][j] - 1][0] = j;         }       }       for (int k = 0; k < n * m; k++) {         int i = id[k][0], j = id[k][1];         c[i][j] = k + 1;       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cout << c[i][j] <<    ;         }         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const long long inf = 1e9;   const long long ninf = LLONG_MIN;   const double eps = 1e-12;   const long long N = 1000005;   const long long LOGN = 19;   const double PI = 3.14159265358979323846;   long long n, m;   long long d[505][505], is[505][505], ini[505][505], last[505][505];   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (int i = 0; i < 505; i++)       for (int j = 0; j < 505; j++) d[i][j] = inf, ini[i][j] = inf;     for (int i = 0; i < m; i++) {       long long x, y, l;       cin >> x >> y >> l;       d[x][y] = l;       d[y][x] = l;       ini[x][y] = l;       ini[y][x] = l;       is[x][y] = 1;       is[y][x] = 1;     }     for (int i = 1; i <= n; i++) d[i][i] = 0;     for (int k = 1; k <= n; k++) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           d[i][j] = min(d[i][j], d[i][k] + d[k][j]);         }       }     }     for (int i = 1; i <= n; i++) {       for (int k = 1; k <= n; k++) {         for (int j = 1; j <= n; j++) {           if (d[i][j] == inf) continue;           if (d[i][k] + ini[k][j] == d[i][j]) {             last[i][j]++;           }         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         long long ans = 0;         for (int k = 1; k <= n; k++) {           if (d[i][k] + d[k][j] == d[i][j]) {             ans += last[i][k];           }         }         cout << ans <<    ;       }     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[4], b[4], n, m;   void f1() {     a[0] = 0;     b[0] = 1;     a[1] = 0;     b[1] = m;     a[2] = 0;     b[2] = 0;     a[3] = 0;     b[3] = m - 1;   }   void f2() {     b[0] = 0;     a[0] = 1;     b[1] = 0;     a[1] = n;     b[2] = 0;     a[2] = 0;     b[3] = 0;     a[3] = n - 1;   }   void f3() {     a[0] = n;     b[0] = m;     a[1] = 0;     b[1] = 0;     a[2] = 0;     b[2] = m;     a[3] = n;     b[3] = 0;     double x = m, y = n;     if (2 * sqrt(x * x + (y - 1) * (y - 1)) > x + sqrt(x * x + y * y)) {       a[0] = 1;       b[0] = 0;       a[1] = n;       b[1] = m;       a[2] = 0;       b[2] = 0;       a[3] = n - 1;       b[3] = m;     }   }   void f4() {     a[0] = n;     b[0] = m;     a[1] = 0;     b[1] = 0;     a[2] = n;     b[2] = 0;     a[3] = 0;     b[3] = m;     double x = n, y = m;     if (2 * sqrt(x * x + (y - 1) * (y - 1)) > x + sqrt(x * x + y * y)) {       a[0] = 0;       b[0] = 1;       a[1] = n;       b[1] = m;       a[2] = 0;       b[2] = 0;       a[3] = n;       b[3] = m - 1;     }   }   int main() {     cin >> n >> m;     if (n == 0)       f1();     else if (m == 0)       f2();     else if (n <= m)       f3();     else       f4();     for (int i = 0; i < 4; i++) cout << a[i] <<     << b[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[100005], b[100005], dp[100005][5];   long long fun(long long pos, long long ck) {     if (pos > n) {       return 0;     }     if (dp[pos][ck] != -1) {       return dp[pos][ck];     }     long long res = 0, res1 = 0, res2 = 0;     if (ck == 0) {       res += max(a[pos] + fun(pos + 1, 1), b[pos] + fun(pos + 1, 2));     } else if (ck == 1) {       res += max(b[pos] + fun(pos + 1, 2), fun(pos + 1, 0));     } else {       res += max(a[pos] + fun(pos + 1, 1), fun(pos + 1, 0));     }     return dp[pos][ck] = res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     while (cin >> n) {       for (int i = 1; i <= n; i++) {         cin >> a[i];       }       for (int i = 1; i <= n; i++) {         cin >> b[i];       }       memset(dp, -1, sizeof(dp));       long long ans = fun(1, 0);       cout << ans << endl;     }     return 0;   }