malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int arr[4005];   int nxt[4005], prv[4005];   map<int, int> M;   map<int, int> Q;   int main() {     int n;     cin >> n;     int ans = 0;     for (int i = 0; i < n; ++i) {       cin >> arr[i];       if (M.find(arr[i]) != M.end()) {         nxt[M[arr[i]]] = i;         prv[i] = M[arr[i]];         Q[arr[i]]++;         ans = max(ans, Q[arr[i]]);       } else {         prv[i] = -1;         Q[arr[i]]++;         ans = max(ans, Q[arr[i]]);       }       M[arr[i]] = i;       nxt[i] = -1;     }     for (int i = 0; i < n; ++i) {       if (prv[i] != -1) {         continue;       }       for (int j = i + 1; j < n; ++j) {         if (prv[j] != -1) {           continue;         }         int cur = 2;         int t1 = i, t2 = j;         while (t1 != -1 && t2 != -1) {           if (t1 < t2) {             if (nxt[t1] > t2) {               ++cur;             }             t1 = nxt[t1];           } else {             if (nxt[t2] > t1) {               ++cur;             }             t2 = nxt[t2];           }         }         ans = max(ans, cur);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int b = 3e6;   long long a[b];   void ans(long long x, long long y, long long k, long long i) {     long long sidl = k + k * y, ans = k;     long long ez1 = (sidl - 3 + x) / (x - 1);     ans += ez1;     a[i] = ans;   }   int main() {     long long t, x, y, k, j;     cin >> t;     for (int i = 0; i < t; i++) {       cin >> x >> y >> k;       ans(x, y, k, i);     }     for (int i = 0; i < t; i++) cout << a[i] << endl;     return 0;   };
#include <bits/stdc++.h>   using namespace std;   int test() {     long long n;     cin >> n;     long long cL = 0, cR = 0;     long long si = 3 * 100001;     long long *right = new long long[si], *left = new long long[si];     for (long long i = 0; i < si; i++) {       right[i] = 0;       left[i] = 0;     }     long long prop = 0, l = 0, r = 0;     string temp;     for (long long i = 0; i < n; i++) {       cin >> temp;       long long tempS = temp.size();       for (long long i = 0; i < tempS; i++) {         if (temp[i] ==  ( ) {           cL++;           l++;         } else {           cR++;           if (l != 0)             l--;           else             r++;         }       }       if (r != 0 && l != 0) {       } else if (cR == cL)         prop++;       else if (cR > cL)         right[cR - cL]++;       else         left[cL - cR]++;       l = 0;       r = 0;       cL = 0;       cR = 0;     }     long long S = 0;     for (long long i = 0; i < si; i++) {       if (right[i] != 0 && left[i] != 0) {         S += right[i] * left[i];       }     }     S += prop * prop;     cout << S;     return 0;   }   int hacker() { return 0; }   int main() {     while (true) {       return test();       cout <<   n n-- ;       hacker();       cout <<   n n n----------------------------- n n n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-6;   double n, r;   bool check(double R) {     double x1 = r + R;     double y1 = 0;     double x2 = cos(2 * acos(-1) / n) * (r + R);     double y2 = sin(2 * acos(-1) / n) * (r + R);     double len = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));     if (len <= 2 * R)       return true;     else       return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> r;     double l1 = 0, r1 = 10000;     for (int i = 0; i < 500; i++) {       double mm = (l1 + r1) / 2.0;       if (check(mm))         r1 = mm;       else         l1 = mm;     }     cout.fixed;     cout.precision(15);     cout << l1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     cin >> a;     cin >> b;     cin >> c;     int d = a + b - c;     int e = b + c - a;     int f = a + c - b;     if (d < 0 || e < 0 || f < 0 || e % 2 || d % 2 || f % 2) {       cout <<  Impossible ;       return 0;     }     cout << d / 2 <<     << e / 2 <<     << f / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int l, r, num;   } a[100005];   int n, ans[100005];   bool cmp(node x, node y) {     if (x.l == y.l) return x.r < y.r;     return x.l < y.l;   }   void solve() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i].l >> a[i].r;       a[i].num = i + 1;     }     sort(a + 1, a + n + 1, cmp);     set<int> F;     int mx = -1;     for (int i = 1; i <= n - 1; i++) {       F.insert(a[i].num);       mx = max(mx, a[i].r);       if (mx < a[i + 1].l) {         for (int j = 1; j <= n; j++) {           if (F.count(a[j].num))             ans[a[j].num] = 1;           else             ans[a[j].num] = 2;         }         for (int j = 2; j <= n + 1; j++) cout << ans[j] <<    ;         cout << endl;         return;       }     }     cout << -1 << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, a, b, c, d, e, f, g, h;     cin >> n;     vector<long long int> values(n), kalues(n), malues;     for (int i = 0; i < n; i++) {       cin >> values[i];       cin >> kalues[i];       kalues[i]--;       malues.push_back(values[i]);       malues.push_back(kalues[i]);     }     sort(values.begin(), values.end());     sort(kalues.begin(), kalues.end());     sort(malues.begin(), malues.end());     long long int mini = -5, year = -1;     malues.erase(unique(malues.begin(), malues.end()), malues.end());     for (int i = 0; i < 2 * n; i++) {       long long int helebele =           lower_bound(kalues.begin(), kalues.end(), malues[i]) - kalues.begin();       helebele += n - (upper_bound(values.begin(), values.end(), malues[i]) -                        values.begin());       if (mini < n - helebele) mini = n - helebele, year = malues[i];     }     cout << year <<     << mini << endl;   }
#include <bits/stdc++.h>   using namespace std;   char s[55];   int l;   int df[55][10];   int f(int pos, int c) {     if (pos == l) return 1;     if (df[pos][c] != -1) return df[pos][c];     int res = 0;     int nn = c + s[pos];     res += f(pos + 1, nn / 2);     if (nn & 1) res += f(pos + 1, (nn + 1) / 2);     return df[pos][c] = res;   }   bool good() {     for (int i = 1; i < l; i++) {       int nn = s[i] + s[i - 1];       if (nn & 1) {         if (nn / 2 != s[i] && (nn + 1) / 2 != s[i]) return false;       } else {         if (nn / 2 != s[i]) return false;       }     }     return true;   }   int main() {     memset(df, -1, sizeof(df));     scanf( %s , s);     l = strlen(s);     for (int i = 0; i < l; i++) s[i] -=  0 ;     long long ans = 0;     for (int i = 0; i < 10; i++) ans += f(1, i);     if (good()) ans--;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int INF = 1e9;   using namespace std;   int R, C, frow, fcol, row, col, srow, scol, nxcol, nxrow;   int ans, intest[1005][1005], goal;   char grid[1005][1005];   queue<pair<int, int> > q;   const int dr[4] = {-1, 0, 1, 0};   const int dc[4] = {0, -1, 0, 1};   bool inside(int r, int c) { return r > 0 && c > 0 && r <= R && c <= C; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> R >> C;     for (int r = 1; r <= R; r++) {       for (int c = 1; c <= C; c++) {         cin >> grid[r][c];         intest[r][c] = INF;         if (grid[r][c] ==  S )           srow = r, scol = c;         else if (grid[r][c] ==  E )           frow = r, fcol = c;       }     }     intest[frow][fcol] = 0;     q.push(make_pair(frow, fcol));     while (!q.empty()) {       pair<int, int> cur = q.front();       q.pop();       row = cur.first;       col = cur.second;       for (int i = 0; i <= 3; i++) {         nxrow = row + dr[i];         nxcol = col + dc[i];         if (!inside(nxrow, nxcol)) continue;         if (grid[nxrow][nxcol] ==  T ) continue;         if (intest[nxrow][nxcol] != INF) continue;         intest[nxrow][nxcol] = intest[row][col] + 1;         q.push(make_pair(nxrow, nxcol));       }     }     goal = intest[srow][scol];     for (int i = 1; i <= R; i++) {       for (int j = 1; j <= C; j++) {         if (grid[i][j] -  0  > 0 && grid[i][j] < 58) {           srow = i, scol = j;           if (intest[srow][scol] <= goal) ans += (grid[i][j] -  0 );         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x, y, z;   int _x, _y, _z;   int a[6];   long long int ans = 0LL;   int main() {     ios::sync_with_stdio(false);     cin >> x >> y >> z;     cin >> _x >> _y >> _z;     for (int i = 0; i < 6; i++) cin >> a[i];     if (y < 0) ans += a[0];     if (y > _y) ans += a[1];     if (z < 0) ans += a[2];     if (z > _z) ans += a[3];     if (x < 0) ans += a[4];     if (x > _x) ans += a[5];     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int SZ = 8e6 + 10;   const int INF = 1e9 + 10;   const int mod = 998244353;   const long double eps = 1e-8;   long long read() {     long long n = 0;     char a = getchar();     bool flag = 0;     while (a >  9  || a <  0 ) {       if (a ==  - ) flag = 1;       a = getchar();     }     while (a <=  9  && a >=  0 ) {       n = n * 10 + a -  0 , a = getchar();     }     if (flag) n = -n;     return n;   }   int a[SZ], f[1010][1010], b[SZ], c[SZ];   int main() {     int n = read(), k = read();     for (int i = 1; i <= n; i++) a[i] = read();     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         b[++b[0]] = a[j] - a[i];       }     }     sort(b + 1, b + 1 + b[0]);     b[0] = unique(b + 1, b + 1 + b[0]) - b - 1;     int ans = 0;     for (int j = 1; j <= b[0]; j++) {       int minx = b[j];       if (minx > 1e5 / (k - 1)) break;       for (int i = 1; i <= n; i++) f[i][1] = f[i - 1][1] + 1;       for (int l = 2; l <= k; l++) {         for (int i = 2, lst = 0; i <= n; i++) {           while (lst < i && a[lst + 1] <= a[i] - minx) lst++;           f[i][l] = f[lst][l - 1];         }         for (int i = 1; i <= n; i++) (f[i][l] += f[i - 1][l]) %= mod;       }       c[j] = f[n][k];     }     for (int j = 1; j <= b[0]; j++)       (ans += 1ll * b[j] * (c[j] - c[j + 1] + mod) % mod) %= mod;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int book[3];   char s[105], rs[105];   int main() {     int t, ans, n;     scanf( %d , &t);     for (int i = 0; i < t; i++) {       scanf( %d , &n);       ans = 0;       memset(rs,   0 , sizeof(rs));       for (int i = 0; i < 3; i++) {         scanf( %d , &book[i]);       }       scanf( %s , s);       for (int i = 0; i < n; i++) {         if (s[i] ==  R ) {           if (book[1] > 0) {             ans++;             book[1]--;             rs[i] =  P ;           }         } else if (s[i] ==  P ) {           if (book[2] > 0) {             ans++;             book[2]--;             rs[i] =  S ;           }         } else {           if (book[0] > 0) {             ans++;             book[0]--;             rs[i] =  R ;           }         }       }       if (ans >= (n + 1) / 2) {         int k = 0;         for (int i = 0; i < n; i++) {           if (rs[i] ==   0 ) {             while (book[k] == 0) k++;             if (k == 0)               rs[i] =  R ;             else if (k == 1)               rs[i] =  P ;             else               rs[i] =  S ;             book[k]--;           }         }         printf( YES n%s n , rs);       } else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   long long le[N], ri[N], mid, lee, rii;   long long a[N], b[N], c[N], mp[35], ans, n, answ, idx, idx1, pw[35], bb;   int main() {     std::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     pw[0] = 1;     for (int i = 1; i <= 35; i++) {       pw[i] = pw[i - 1] * 2;     }     for (int i = 0; i <= 30; i++) {       for (int j = 1; j <= n; j++) {         b[j] += a[j] & pw[i];         c[j] = b[j];       }       std::stable_sort(c + 1, c + n + 1);       idx = n;       for (int j = 1; j <= n; j++) {         idx = max(idx, j + 1LL);         bb = 0;         while (c[j] + c[idx] >= pw[i] && idx > j) {           idx--;           bb = 1;         }         if (bb == 1) idx++;         if (c[j] + c[idx] < pw[i] || idx > n)           le[j] = -1;         else           le[j] = idx;       }       idx = n;       for (int j = 1; j <= n; j++) {         idx = max(idx, j + 1LL);         while (c[j] + c[idx] >= pw[i + 1] && idx > j + 1) {           idx--;         }         if (c[j] + c[idx] >= pw[i + 1] || idx > n)           ri[j] = -1;         else           ri[j] = idx;       }       for (int j = 1; j <= n; j++) {         if (le[j] != -1 && ri[j] != -1) mp[i] += ri[j] - le[j] + 1;       }       idx = n;       for (int j = 1; j <= n; j++) {         idx = max(idx, j + 1LL);         bb = 0;         while (c[j] + c[idx] >= pw[i + 1] + pw[i] && idx > j) {           bb = 1;           idx--;         }         if (bb == 1) idx++;         if (c[j] + c[idx] < pw[i + 1] + pw[i] || idx > n)           le[j] = -1;         else           le[j] = idx;       }       idx = n;       for (int j = 1; j <= n; j++) {         idx = max(idx, j + 1LL);         while (c[j] + c[idx] >= pw[i + 2] && idx > j + 1) {           idx--;         }         if (c[j] + c[idx] >= pw[i + 2] || idx > n)           ri[j] = -1;         else           ri[j] = idx;       }       for (int j = 1; j <= n; j++) {         if (le[j] != -1 && ri[j] != -1) mp[i] += ri[j] - le[j] + 1;       }     }     for (int i = 0; i <= 30; i++) {       if (mp[i] % 2) answ += (1LL << i);     }     cout << answ << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[20000], num[20000];   int dp[400];   int n, m, t, k, ans, maxm;   int main() {     scanf( %d%d , &n, &m);     maxm = 0;     ans = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       num[a[i]]++;       maxm = max(maxm, num[a[i]]);     }     t = min(n, m);     k = t;     int temp = 0;     while (--k) {       temp += n;       for (int i = 1; i <= n; i++) a[temp + i] = a[i];     }     for (int i = 1; i <= n * t; i++) {       dp[a[i]]++;       for (int j = a[i] - 1; j >= 0; j--) dp[a[i]] = max(dp[a[i]], dp[j] + 1);       ans = max(dp[a[i]], ans);     }     ans += maxm * (m - t);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   const int inf = 1500000000;   const int d = 1e9 + 7;   using namespace std;   struct triple {     int a;     int b;     int c;     bool flag;     triple() { flag = true; }   };   int main() {     int n;     cin >> n;     vector<triple> t(n - 1, triple());     vector<int> adj[n + 1];     for (int i = 1; i <= n - 2; i++) {       cin >> t[i].a >> t[i].b >> t[i].c;       adj[t[i].a].push_back(i);       adj[t[i].b].push_back(i);       adj[t[i].c].push_back(i);     }     int first;     triple f;     for (int i = 1; i <= n; i++) {       if (adj[i].size() == 1) {         first = i;         f = t[adj[i][0]];         break;       }     }     int second;     if (adj[f.a].size() == 2) {       second = f.a;     }     if (adj[f.b].size() == 2) {       second = f.b;     }     if (adj[f.c].size() == 2) {       second = f.c;     }     vector<int> perm;     perm.push_back(first);     perm.push_back(second);     while (perm.size() != n) {       int third;       for (int i = 0; i < adj[first].size(); i++) {         int ind = adj[first][i];         if (t[ind].flag == true) {           t[ind].flag = false;           third = (t[ind].a + t[ind].b + t[ind].c) - first - second;           perm.push_back(third);           first = second;           second = third;           break;         }       }     }     for (int i = 0; i < perm.size(); i++) cout << perm[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int k;   string s;   int main() {     cin >> k;     cin >> s;     int n = s.length();     for (int i = 0; i < n; ++i) {       if (s[i] ==  ?  && s[n - i - 1] ==  ? ) {         continue;       } else if (s[i] ==  ? ) {         s[i] = s[n - i - 1];       } else if (s[n - i - 1] ==  ? ) {         s[n - i - 1] = s[i];       } else if (s[i] != s[n - i - 1]) {         cout <<  IMPOSSIBLE ;         return 0;       }     }     bool flag[26];     memset(flag, 0, sizeof(flag));     for (int i = 0; i < n; ++i) {       if (s[i] !=  ? ) {         flag[s[i] -  a ] = true;       }     }     int miss = 0;     for (int c = 0; c < k; ++c) {       if (!flag[c]) {         ++miss;       }     }     int have = 0;     for (int i = 0; i <= n - i - 1; ++i) {       if (s[i] ==  ? ) {         ++have;       }     }     if (miss > have) {       cout <<  IMPOSSIBLE ;       return 0;     }     for (int i = 0; i < n; ++i) {       if (s[i] ==  ? ) {         if (have > miss) {           s[i] = s[n - i - 1] =  a ;         } else {           for (int c = 0; c < k; ++c) {             if (!flag[c]) {               s[i] = s[n - i - 1] = c +  a ;               flag[c] = true;               break;             }           }           --miss;         }         --have;       }     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   const long double EPS = 1e-10;   const long long int MOD = 1000000007ll;   const long long int mod1 = 1000000009ll;   const long long int mod2 = 1100000009ll;   int INF = (int)1e9;   long long int INFINF = (long long int)1e18;   int debug = 0;   long double PI = acos(-1.0);   using namespace std;   long long int bit_count(long long int _x) {     long long int _ret = 0;     while (_x) {       if (_x % 2 == 1) _ret++;       _x /= 2;     }     return _ret;   }   long long int bit(long long int _mask, long long int _i) {     return (_mask & (1 << _i)) == 0 ? 0 : 1;   }   long long int powermod(long long int _a, long long int _b,                          long long int _m = MOD) {     long long int _r = 1;     while (_b) {       if (_b % 2 == 1) _r = (_r * _a) % _m;       _b /= 2;       _a = (_a * _a) % _m;     }     return _r;   }   long long int add(long long int a, long long int b, long long int m = MOD) {     long long int x = a + b;     while (x >= m) x -= m;     while (x < 0) x += m;     return x;   }   long long int sub(long long int a, long long int b, long long int m = MOD) {     long long int x = a - b;     while (x < 0) x += m;     while (x >= m) x -= m;     return x;   }   long long int mul(long long int a, long long int b, long long int m = MOD) {     long long int x = a * 1ll * b;     x %= m;     if (x < 0) x += m;     return x;   }   int N, M, K;   vector<int> G[1010];   bool spec[1010];   bool vis[1010];   int tot, cnt;   vector<int> sizes;   void dfs(int u) {     tot++;     cnt++;     vis[u] = true;     for (int v : G[u]) {       if (!vis[v]) {         dfs(v);       }     }   }   int main() {     if (0) {       freopen( input.txt ,  r , stdin);       debug = 1;     }     srand(time(NULL));     scanf( %d , &N);     scanf( %d , &M);     scanf( %d , &K);     for (int i = 1; i <= K; i++) {       int x;       scanf( %d , &x);       spec[x] = true;     }     for (int i = 1; i <= M; i++) {       int u, v;       scanf( %d , &u);       scanf( %d , &v);       G[u].push_back(v);       G[v].push_back(u);     }     for (int i = 1; i <= N; i++) {       if (spec[i]) {         cnt = 0;         dfs(i);         sizes.push_back(cnt);       }     }     sort(sizes.begin(), sizes.end());     reverse(sizes.begin(), sizes.end());     sizes[0] += (N - tot);     long long int ans = 0;     for (int it : sizes) {       ans += (it * (it - 1)) / 2;     }     cout << ans - M;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Q>   void inin(Q &x) {     x = 0;     int f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = 1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     x = f ? -x : x;   }   int n, a[100010], b[100010];   long long sum[100010], ans[100010], tot[100010];   int erfen(int x, int l, int r) {     int ll = l, rr = r, mid;     while (ll < rr) {       mid = (ll + rr) >> 1;       if (sum[mid] - sum[l - 1] < x)         ll = mid + 1;       else         rr = mid;     }     if (ll == n && sum[n] - sum[l - 1] < x) return n + 1;     return ll;   }   int main() {     inin(n);     for (int i = (1); i <= (n); i++) inin(a[i]);     for (int i = (1); i <= (n); i++) inin(b[i]), sum[i] = sum[i - 1] + b[i];     for (int i = (1); i <= (n); i++) {       int x = erfen(a[i], i, n);       tot[x]--;       ans[x] += a[i] - (sum[x - 1] - sum[i - 1]);       tot[i] += tot[i - 1] + 1;       ans[i] += 1LL * b[i] * tot[i];     }     for (int i = (1); i <= (n); i++) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long sze = 1e5 + 2;   const long long inf = 0x3f3f3f3f;   void solve() {     long long n, k;     cin >> n;     cin >> k;     long long swap = k;     long long last = n;     long long i = 1;     bool turn = true;     while (swap) {       if (turn) {         cout << i <<    ;         i++;         turn = false;       } else {         cout << last <<    ;         last--;         turn = true;       }       swap--;     }     if (k % 2 == 0) {       while (last >= i) {         cout << last <<    ;         last--;       }       return;     }     while (i <= last) {       cout << i <<    ;       i++;     }   }   signed main() {     long long test = 1;     while (test--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     vector<pair<int, int> > v, re;     scanf( %d %d  , &a, &b);     v.push_back(make_pair(a, b));     scanf( %d %d  , &a, &b);     v.push_back(make_pair(a, b));     scanf( %d %d  , &a, &b);     v.push_back(make_pair(a, b));     sort(v.begin(), v.end());     pair<int, int> A = v[0], B = v[1], C = v[2];     int x = A.first, y = A.second;     re.push_back(make_pair(x, y));     if (C.second > A.second) {       int dy = max(min(B.second, C.second), A.second);       for (int i = A.second + 1; i <= dy; i++) {         re.push_back(make_pair(x, i));       }       y = dy;       for (int i = A.first + 1; i <= C.first; i++) {         re.push_back(make_pair(i, y));       }       x = C.first;       for (int i = y + 1; i <= C.second; i++) {         re.push_back(make_pair(x, i));       }     } else {       int dy = min(max(B.second, C.second), A.second);       for (int i = A.second - 1; i >= dy; i--) {         re.push_back(make_pair(x, i));       }       y = dy;       for (int i = A.first + 1; i <= C.first; i++) {         re.push_back(make_pair(i, y));       }       x = C.first;       for (int i = y - 1; i >= C.second; i--) {         re.push_back(make_pair(x, i));       }     }     if (B.second > y) {       for (int i = y + 1; i <= B.second; i++) {         re.push_back(make_pair(B.first, i));       }     } else {       for (int i = y - 1; i >= B.second; i--) {         re.push_back(make_pair(B.first, i));       }     }     printf( %d n , re.size());     for (int i = 0; i < re.size(); i++) {       printf( %d %d n , re[i].first, re[i].second);     }   }
#include <bits/stdc++.h>   using namespace std;   int len, pos;   void insert(int x) {     len++;     if (x <= pos) pos++;   }   void erase(int x) {     if (x >= pos)       len = x;     else       len -= x, pos -= x;   }   int main() {     int m, t;     scanf( %d%d%d%d , &len, &pos, &m, &t);     while (t--) {       int type, x;       scanf( %d%d , &type, &x);       if (type == 1)         insert(x);       else         erase(x);       printf( %d %d n , len, pos);     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int sz = 5e5 + 10;   int ar[sz];   int main() {     int n, ans;     while (cin >> n) {       for (int i = 0; i < n; i++) cin >> ar[i];       sort(ar, ar + n);       ans = n;       for (int i = n - 1, j = (n / 2) - 1; j >= 0; j--) {         if (ar[i] >= ar[j] * 2) {           ans--;           i--;         }       }       cout << ans <<   n ;     }     return 0;   }