malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK: 1024000000,1024000000 )   using namespace std;   inline int getint() {     int _x = 0;     char _tc = getchar();     while (_tc <  0  || _tc >  9 ) _tc = getchar();     while (_tc >=  0  && _tc <=  9 ) _x *= 10, _x += (_tc -  0 ), _tc = getchar();     return _x;   }   const int N = 1e6 + 35;   const int NN = N * 4;   int lazy[NN], mx[NN], a[N], b[N];   void push_down(int rt) {     if (lazy[rt]) {       lazy[rt << 1] += lazy[rt];       lazy[rt << 1 | 1] += lazy[rt];       mx[rt << 1] += lazy[rt];       mx[rt << 1 | 1] += lazy[rt];       lazy[rt] = 0;     }   }   void push_up(int rt) { mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]); }   void update(int rt, int l, int r, int L, int R, int v) {     if (L <= l && r <= R) {       lazy[rt] += v;       mx[rt] += v;       return;     }     int mid = l + r >> 1;     push_down(rt);     if (L <= mid) update(rt << 1, l, mid, L, R, v);     if (R > mid) update(rt << 1 | 1, mid + 1, r, L, R, v);     push_up(rt);   }   int query(int rt, int l, int r) {     if (l == r) {       return l;     }     push_down(rt);     int mid = l + r >> 1;     if (mx[rt << 1 | 1] > 0) return query(rt << 1 | 1, mid + 1, r);     return query(rt << 1, l, mid);   }   int main() {     int n, m, q;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), update(1, 1, N, 1, a[i], 1);     for (int i = 1; i <= m; i++) scanf( %d , &b[i]), update(1, 1, N, 1, b[i], -1);     scanf( %d , &q);     while (q--) {       int op, x, y;       scanf( %d%d%d , &op, &x, &y);       if (op == 1) {         update(1, 1, N, 1, a[x], -1);         a[x] = y;         update(1, 1, N, 1, a[x], 1);       } else {         update(1, 1, N, 1, b[x], 1);         b[x] = y;         update(1, 1, N, 1, b[x], -1);       }       if (mx[1] <= 0)         puts( -1 );       else         printf( %d n , query(1, 1, N));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using uint = unsigned int;   template <typename T>   inline void read(T& x) {     x = 0;     long long f = 1;     register char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c & 15);     x *= f;   }   template <typename T>   inline void print(T x) {     if (!x) {       putchar( 0 );       return;     }     static long long st[105];     if (x < 0) putchar( - ), x = -x;     long long tp = 0;     while (x) st[++tp] = x % 10, x /= 10;     while (tp) putchar(st[tp--] +  0 );   }   template <typename T>   inline void print(T x, char c) {     print(x);     putchar(c);   }   template <typename T, typename... Args>   inline void read(T& x, Args&... args) {     read(x);     read(args...);   }   template <typename T>   inline void sort(vector<T>& v) {     sort(v.begin(), v.end());     return;   }   template <typename T>   inline void unique(vector<T>& v) {     sort(v);     v.erase(unique(v.begin(), v.end()), v.end());   }   template <typename T>   inline void cmax(T& x, T y) {     if (x < y) x = y;     return;   }   template <typename T>   inline void cmin(T& x, T y) {     if (x > y) x = y;     return;   }   const long long Mod = LLONG_MAX;   inline long long QP(long long x, long long y) {     long long ans = 1;     for (; y; y >>= 1, x = (x * x) % Mod)       if (y & 1) ans = (ans * x) % Mod;     return ans;   }   template <typename T>   inline T gcd(T x, T y) {     if (y == 0) return x;     return gcd(y, x % y);   }   template <typename T>   inline T lcm(T x, T y) {     return x * y / gcd(x, y);   }   template <typename T>   inline void mul(T& x, T y) {     x = 1LL * x * y;     if (x >= Mod) x %= Mod;   }   template <typename T>   inline void add(T& x, T y) {     if ((x += y) >= Mod) x -= Mod;   }   template <typename T>   inline void sub(T& x, T y) {     if ((x -= y) < 0) x += Mod;   }   signed main() {     long long T;     read(T);     while (T--) {       string s;       getline(cin, s);       vector<long long> od, ev, ans;       for (auto x : s)         if (x -  0  & 1)           od.push_back(x -  0 );         else           ev.push_back(x -  0 );       reverse(ev.begin(), ev.end());       reverse(od.begin(), od.end());       long long st1 = ev.size(), st2 = od.size();       while (st1 || st2) {         if (!st2 || (st1 && ev[st1 - 1] < od[st2 - 1])) {           ans.push_back(ev[--st1]);         } else {           ans.push_back(od[--st2]);         }       }       for (long long x : ans) print(x);       putchar(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const long long MAXN = 4e3 + 7;   const long long MAXM = 1e6 + 7;   const long long MOD = 1e9 + 7;   const double eps = 1e-6;   const double pi = acos(-1.0);   long long quick_pow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = (1LL * ans * a) % MOD;       a = (1LL * a * a) % MOD;       b >>= 1;     }     return ans;   }   int c[305][305];   long long ksm1[305], ksm2[305];   int main() {     long long n, k;     scanf( %lld%lld , &n, &k);     c[0][0] = 1;     c[1][0] = c[1][1] = 1;     for (int i = 2; i <= n; i++) {       c[i][0] = 1;       for (int j = 1; j <= i; j++)         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;     }     ksm1[0] = ksm2[0] = 1;     for (int i = 1; i <= n; i++)       ksm1[i] = (ksm1[i - 1] * k) % MOD, ksm2[i] = (ksm2[i - 1] * (k - 1)) % MOD;     long long ans = 0;     long long t = 1;     for (int i = 0; i <= n; i++) {       ans += t * c[n][i] * quick_pow((ksm1[n - i] * ksm2[i] - ksm2[n]) % MOD, n) %              MOD;       t *= -1;       ans %= MOD;     }     printf( %lld n , (ans % MOD + MOD) % MOD);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename... T>   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<  =  << a <<  ,  ;     err(++it, args...);   }   const long long inf = 1LL << 60;   const long long md = 1000000007;   vector<long long> adj[200005];   long long vis[200005] = {0};   void bfs(long long s) {     queue<long long> q;     vis[s] = 1;     q.push(s);     while (!q.empty()) {       long long s = q.front();       q.pop();       for (auto i : adj[s]) {         if (vis[i]) continue;         vis[i] = vis[s] + 1;         q.push(i);       }     }   }   long long vis2[200005] = {0};   void bfs2(long long s) {     queue<long long> q;     vis2[s] = 1;     q.push(s);     while (!q.empty()) {       long long s = q.front();       q.pop();       for (auto i : adj[s]) {         if (vis2[i]) continue;         vis2[i] = vis2[s] + 1;         q.push(i);       }     }   }   bool comp(pair<long long, long long> a, pair<long long, long long> b) {     return a.first - a.second < b.first - b.second;   }   void solve() {     long long n, m, k;     cin >> n >> m >> k;     long long a[k];     for (long long i = 0; i < k; i++) {       cin >> a[i];     }     for (long long i = 0; i < m; i++) {       long long x, y;       cin >> x >> y;       adj[x].push_back(y);       adj[y].push_back(x);     }     bfs(1);     bfs2(n);     pair<long long, long long> d[k];     for (long long i = 0; i < k; i++) {       d[i] = {vis[a[i]], vis2[a[i]]};     }     sort(d, d + k, comp);     long long ans = 0;     long long mx = -inf;     for (long long i = 0; i < k; i++) {       ans = max(ans, mx + d[i].second);       mx = max(mx, d[i].first);     }     cout << min(vis[n] - 1, ans - 1);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     for (long long i = 1; i <= t; i++) {       solve();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10, inf = 0x3f3f3f3f;   void cmin(int& x, int y) {     if (x > y) {       x = y;     }   }   int n, a[N];   long long answer;   vector<int> adj[N];   void dfs(int u, int p, int d, int s) {     if (d & 1) {       answer += a[u] - s;       s = a[u];     } else {       int minv = inf;       for (auto v : adj[u]) {         if (v != p) {           cmin(minv, a[v]);         }       }       if (minv < s) {         puts( -1 );         exit(0);       } else if (minv != inf) {         answer += minv - s;         s = minv;       }     }     for (auto v : adj[u]) {       if (v != p) {         dfs(v, u, d + 1, s);       }     }   }   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; ++i) {       int x;       scanf( %d , &x);       adj[x].push_back(i);     }     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);     }     dfs(1, 0, 1, 0);     printf( %lld n , answer);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( -ffloat-store )   #pragma GCC optimize( -fno-defer-pop )   long long power(long long a, long long b, long long m) {     if (b == 0) return 1;     if (b == 1) return a % m;     long long t = power(a, b / 2, m);     t = (t * t) % m;     if (b & 1) t = (t * a) % m;     return t;   }   using namespace std;   int main() {     ;     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long a, b, c, d;       cin >> a >> b >> c >> d;       long long x, y, x1, y1, x2, y2;       cin >> x >> y >> x1 >> y1 >> x2 >> y2;       if (x2 - x1 == 0 && (a != 0 || b != 0)) {         cout <<  NO  << endl;         continue;       }       if (y2 - y1 == 0 && (c != 0 || d != 0)) {         cout <<  NO  << endl;         continue;       }       long long disx, disy;       disx = b - a;       disy = d - c;       if (0 <= disx) {         if (x2 - x < disx) {           cout <<  NO  << endl;           continue;         }       } else {         if (x - x1 < (-disx)) {           cout <<  NO  << endl;           continue;         }       }       if (0 <= disy) {         if (y2 - y < disy) {           cout <<  NO  << endl;           continue;         }       } else {         if (y - y1 < (-disy)) {           cout <<  NO  << endl;           continue;         }       }       cout <<  YES  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int x[100000];   int dist(int a, int b) { return abs(a - b); }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> x[i];     cout << dist(x[0], x[1]) <<     << dist(x[0], x[n - 1]) << endl;     for (int i = 1; i < n - 1; i++)       cout << min(dist(x[i], x[i - 1]), dist(x[i], x[i + 1])) <<                << max(dist(x[i], x[0]), dist(x[i], x[n - 1])) << endl;     cout << dist(x[n - 1], x[n - 2]) <<     << dist(x[0], x[n - 1]) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string s;     int sz;     cin >> n;     cin >> s;     sz = s.size();     int count = 0;     bool valid = true;     for (int i = 0; i < sz; i++) {       if (s[i] ==  1 ) {         if (i < sz - 1 && s[i + 1] ==  1 ) {           valid = false;         }         count++;       } else {         if ((i == 0 || s[i - 1] ==  0 )) {           if (i == sz - 1 || s[i + 1] ==  0 ) {             valid = false;           }         }       }     }     if (valid == true && count > 0) {       cout <<  Yes  << endl;     } else {       cout <<  No  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 500, mod = 998244353;   int K, tmp[N], tmpa[N], tmpb[N], rev[N], b[N], tw[N], w[N], limn, n, qn;   vector<int> a[N];   int qpower(int a, int b) {     int ans = 1;     for (; b; b >>= 1, a = 1ll * a * a % mod)       if (b & 1) ans = 1ll * ans * a % mod;     return ans;   }   void prework(int n) {     limn = 1;     while (limn <= n) limn <<= 1;     for (int i = 1; i < limn; i++)       rev[i] = (rev[i >> 1] >> 1) | ((i & 1) ? (limn >> 1) : 0);     for (int i = 1; i < limn; i <<= 1) {       int omg = qpower(3, (mod - 1) / (i << 1));       w[i] = 1;       for (int j = 1; j < i; j++) w[i + j] = 1ll * w[i + j - 1] * omg % mod;     }   }   void NTT(int a[], int l) {     for (int i = 0; i < l; i++) tmp[rev[i] / (limn / l)] = a[i];     for (int i = 1; i < l; i <<= 1)       for (int j = 0; j < l; j += i << 1)         for (int k = 0; k < i; k++) {           int x = tmp[j + k], y = 1ll * w[i + k] * tmp[i + j + k] % mod;           tmp[j + k] = (x + y) % mod, tmp[i + j + k] = (x - y) % mod;         }     for (int i = 0; i < l; i++) a[i] = tmp[i];   }   void mul(const vector<int> A, const vector<int> B, vector<int>& c) {     int la = A.size(), lb = B.size(), n = la + lb - 1;     int l = 1;     while (l < n) l <<= 1;     for (int i = 0; i < la; i++) tmpa[i] = A[i];     for (int i = la; i < l; i++) tmpa[i] = 0;     for (int i = 0; i < lb; i++) tmpb[i] = B[i];     for (int i = lb; i < l; i++) tmpb[i] = 0;     NTT(tmpa, l), NTT(tmpb, l);     for (int i = 0; i < l; i++) tmpa[i] = 1ll * tmpa[i] * tmpb[i] % mod;     reverse(tmpa + 1, tmpa + l);     NTT(tmpa, l);     int iv = mod - (mod - 1) / l;     if (K + 1 < n) n = K + 1;     c.resize(n);     for (int i = 0; i < n; i++) c[i] = 1ll * tmpa[i] * iv % mod;   }   void solve(int rot, int lt, int rt) {     if (lt == rt) {       a[rot].resize(2);       a[rot][0] = 1, a[rot][1] = b[lt];       return;     }     int mid = (lt + rt) >> 1;     solve(rot << 1, lt, mid), solve(rot << 1 | 1, mid + 1, rt);     mul(a[rot << 1], a[rot << 1 | 1], a[rot]);   }   int main() {     scanf( %d%d , &n, &K);     prework(n);     for (int i = 1; i <= n; i++) scanf( %d , tw + i);     scanf( %d , &qn);     for (int i = 1, opt, l, r, q, d; i <= qn; i++) {       scanf( %d , &opt);       if (opt == 1) {         scanf( %d%d%d , &q, &l, &d);         for (int j = 1; j <= n; j++) b[j] = q - tw[j];         b[l] = q - d;         solve(1, 1, n);         printf( %d n , (a[1][K] + mod) % mod);       } else {         scanf( %d%d%d%d , &q, &l, &r, &d);         for (int j = 1; j <= n; j++) b[j] = q - tw[j];         for (int j = l; j <= r; j++) b[j] -= d;         solve(1, 1, n);         printf( %d n , (a[1][K] + mod) % mod);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int x = 0; x < n; x++) {       cin >> a[x];     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         for (int k = 0; k < n; ++k) {           if (a[i] == a[j] + a[k] && (i != j && j != k && i != k)) {             cout << i + 1 <<     << j + 1 <<     << k + 1 << endl;             return 0;           }         }       }     }     cout <<  -1  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct FenwickTree {     int n;     vector<int> bit;     FenwickTree(int n) {       this->n = n + 1;       bit.assign(n + 1, 0);     }     int sum(int r) {       int sum = 0;       while (r > 0) {         sum += bit[r];         r -= (r & -r);       }       return sum;     }     int sum(int l, int r) { return sum(r) - sum(l - 1); }     void add(int index, int val) {       while (index < n) {         bit[index] += val;         index += (index & -index);       }     }     int getNum(int index) { return sum(index, index); }   };   int main() {     int n, k, a, b, q;     cin >> n >> k >> a >> b >> q;     FenwickTree antes = FenwickTree(n);     FenwickTree depois = FenwickTree(n);     while (q--) {       int type, d, val;       cin >> type >> d;       if (type == 1) {         cin >> val;         int aux1 = min(b - antes.getNum(d), val);         int aux2 = min(a - depois.getNum(d), val);         antes.add(d, aux1);         depois.add(d, aux2);       } else {         int resp = 0;         resp += antes.sum(d - 1);         resp += depois.sum(d + k, n);         cout << resp << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, a, b, x, y, ans = 0;   pair<int, int> m[111111];   long long sum = 0;   int main() {     scanf( %d%d%d%d , &n, &d, &a, &b);     for (int i = 0; i < n; i++) {       scanf( %d%d , &x, &y);       m[i].first = a * x + b * y;       m[i].second = i + 1;     }     sort(m, m + n);     for (int i = 0; i < n; i++) {       sum += m[i].first;       if (sum > d) break;       ans++;     }     printf( %d n , ans);     for (int i = 0; i < ans; i++) printf( %d  , m[i].second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int LIMIT = 3e5;   long long n, m, a[LIMIT], p[LIMIT], d[LIMIT];   long long gcd(long long a, long long b) {     if (a % b == 0) return b;     return gcd(b, a % b);   }   int main() {     scanf( %lld %lld , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %lld , &a[i]);     }     for (int i = 0; i < m; i++) {       scanf( %lld , &p[i]);     }     for (int i = 0; i < (n - 1); i++) {       d[i] = a[i + 1] - a[i];     }     long long gcdAll = d[0];     for (int i = 1; i < (n - 1); i++) {       gcdAll = gcd(d[i], gcdAll);     }     for (int i = 0; i < m; i++) {       if ((gcdAll % p[i]) == 0) {         printf( %s n%lld %d ,  YES , a[0], (i + 1));         return 0;       }     }     printf( %s ,  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int Q[N], S[N], ok[N + N], Sav[N], mat[N + N][N];   int dp[N + N][N];   int solve(int p, int k) {     if (ok[p]) return k == 0;     if (!k) return 0;     if (dp[p][k] != -1) return dp[p][k];     return dp[p][k] = solve(p - 1, k - 1) | solve(p + 1, k - 1);   }   int main() {     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> Q[i], Sav[Q[i]] = i, mat[100][i] = i;     for (int i = 1; i <= n; i++) cin >> S[i];     for (int i = 99; i >= 0; i--)       for (int j = 1; j <= n; j++) mat[i][j] = mat[i + 1][Sav[j]];     for (int i = 101; i <= 200; i++)       for (int j = 1; j <= n; j++) mat[i][j] = mat[i - 1][Q[j]];     for (int i = 0; i <= 200; i++) {       ok[i] = 1;       for (int j = 1; j <= n; j++) ok[i] &= mat[i][j] == S[j];     }     memset(dp, -1, sizeof(dp));     puts(solve(100, k) ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int i, a, n, sum = 0, hand = 0;     vector<long long int> v;     cin >> n;     v.clear();     for (i = 0; i < n; i++) {       cin >> a;       if (a % 2 != 0) hand++;       v.push_back(a);       sum += a;     }     long long int value = 1e13;     if (hand % 2 != 0) {       for (i = 0; i < v.size(); i++) {         if (v[i] & 1) value = min(v[i], value);       }       sum -= value;     }     cout << sum << endl;     v.clear();   }
#include <bits/stdc++.h>   inline int getint() {     int x = 0, p = 1;     char c = getchar();     while (c <= 32) c = getchar();     if (c == 45) p = -p, c = getchar();     while (c > 32) x = x * 10 + c - 48, c = getchar();     return x * p;   }   using namespace std;   const int N = 110;   const int M = 25;   int dp[N][M][M], n, k, res, tmp[N][M][M];   vector<int> G[N];   inline void add(int &x, int y) {     x += y;     if (x >= 1000000007) x -= 1000000007;   }   inline int mul(int x, int y) {     long long ans = 1ll * x * y;     return ans % 1000000007;   }   void go(int x, int p) {     vector<int> v;     for (int(i) = 0; (i) < (G[x].size()); (i)++) {       int to = G[x][i];       if (to != p) {         go(to, x);         v.push_back(to);       }     }     tmp[0][1][M - 1] = tmp[0][0][1] = 1;     for (int(i) = 0; (i) < (v.size()); (i)++) {       int x = v[i];       for (int(i0) = 0; (i0) < (M); (i0)++)         for (int(i1) = 0; (i1) < (M); (i1)++) tmp[i + 1][i0][i1] = 0;       for (int(i0) = 0; (i0) < (k + 2); (i0)++)         for (int(i1) = 0; (i1) < (M); (i1)++) {           for (int(i2) = 0; (i2) < (k + 2); (i2)++)             for (int(i3) = 0; (i3) < (M); (i3)++) {               int hh = mul(tmp[i][i0][i1], dp[x][i2][i3]);               if ((!i2 || i1 + i2 - 1 <= k) && (!i0 || i0 + i3 - 1 <= k)) {                 add(tmp[i + 1][0][min(i1, i3 + 1)], hh);                 continue;               }               if (!i2 || i1 + i2 - 1 <= k) {                 add(tmp[i + 1][i0][min(i1, i3 + 1)], hh);                 continue;               }               if (!i0 || i0 + i3 - 1 <= k) {                 if (i2 <= k) add(tmp[i + 1][i2 + 1][min(i1, i3 + 1)], hh);                 continue;               }               if (i2 <= k) add(tmp[i + 1][max(i0, i2 + 1)][min(i1, i3 + 1)], hh);             }         }     }     for (int(i) = 0; (i) < (k + 2); (i)++)       for (int(j) = 0; (j) < (M); (j)++) dp[x][i][j] = tmp[v.size()][i][j];   }   int main() {     n = getint();     k = getint();     for (int(i) = 0; (i) < (n - 1); (i)++) {       int x = getint() - 1, y = getint() - 1;       G[x].push_back(y);       G[y].push_back(x);     }     go(0, -1);     for (int i = 1; i <= k + 1; i++)       if (dp[0][0][i] > 0) add(res, dp[0][0][i]);     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     double x, y;     Point() : x(0), y(0) {}     Point(double _x, double _y) : x(_x), y(_y) {}     bool operator<(const Point &b) const { return tie(x, y) < tie(b.x, b.y); }     bool operator==(const Point &b) const { return tie(x, y) == tie(b.x, b.y); }     Point operator+(const Point &b) const { return Point(x + b.x, y + b.y); }     Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }     double operator*(const Point &b) const { return x * b.x + y * b.y; }     double operator%(const Point &b) const { return x * b.y - y * b.x; }     Point operator*(const double &b) const { return Point(x * b, y * b); }     double abs() { return sqrt(abs2()); }     double abs2() { return x * x + y * y; }   };   long long cross(Point o, Point a, Point b) { return (a - o) % (b - o); }   vector<Point> convex_hull(vector<Point> &pt) {     sort(pt.begin(), pt.end());     int top = 0;     vector<Point> stk(2 * pt.size());     for (int i = 0; i < (int)pt.size(); i++) {       while (top >= 2 && cross(stk[top - 2], stk[top - 1], pt[i]) <= 0) top--;       stk[top++] = pt[i];     }     for (int i = pt.size() - 2, t = top + 1; i >= 0; i--) {       while (top >= t && cross(stk[top - 2], stk[top - 1], pt[i]) <= 0) top--;       stk[top++] = pt[i];     }     stk.resize(top - 1);     return stk;   }   int N, R;   int ans;   vector<Point> convexP, chp, sol;   int dis2(Point a, Point b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);   }   void DFS(int i, int prv, int val) {     if (i >= N) {       if (val > ans) {         ans = val;         sol = chp;       }       return;     }     for (int j = prv; j < (int)convexP.size(); j++) {       int c = 0;       for (auto pt : chp) c += (pt - convexP[j]).abs2();       chp.push_back(convexP[j]);       DFS(i + 1, j, val + c);       chp.pop_back();     }   }   int main() {     vector<Point> pt;     cin >> N >> R;     if (N % 2 == 0) {       for (int i = 0; i < N / 2; i++) {         sol.push_back(Point(R, 0));         sol.push_back(Point(-R, 0));       }       for (int i = 0; i < N; i++)         for (int j = 0; j < i; j++) ans += (sol[i] - sol[j]).abs2();     } else {       for (int i = -R; i <= R; i++) {         for (int j = -R; j <= R; j++) {           if (i * i + j * j <= R * R) {             pt.push_back(Point(i, j));           }         }       }       convexP = convex_hull(pt);       ans = 0;       DFS(0, 0, 0);     }     cout << ans << endl;     for (auto p : sol) cout << p.x <<     << p.y << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string str;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> str;     int ans = 0;     for (int i = 0; i < n; i += 2) {       int cnt = 0;       if (str[i] ==  a )         cnt++;       else         cnt--;       if (str[i + 1] ==  a )         cnt++;       else         cnt--;       if (cnt != 0) {         if (str[i] ==  a )           str[i] =  b ;         else           str[i] =  a ;         ans++;       }     }     cout << ans <<   n ;     cout << str <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) {       long long n;       cin >> n;       string s;       cin >> s;       cout << n + 1 << endl;     }     return 0;   }