malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct dn {     int c, z;   } a[500001], b[500001];   int s1[500001], s2[500001];   int aa, bb;   int flag;   struct da {     int x, y;   };   vector<da> ans;   void jh(int u, int v) {     if (!flag)       ans.push_back((da){s1[u], s2[v]});     else       ans.push_back((da){s2[v], s1[u]});     flag ^= 1;     dn x[10], y[10];     int xx = 0, yy = 0;     for (int i = u + 1; i <= aa; i++) x[++xx] = a[i];     for (int i = v + 1; i <= bb; i++) y[++yy] = b[i];     aa = u;     bb = v;     if (aa && yy && y[1].c == a[u].c) y[1].z += a[u].z, aa--;     if (bb && xx && x[1].c == b[v].c) x[1].z += b[v].z, bb--;     for (int i = 1; i <= yy; i++)       a[aa + 1] = y[i], s1[aa + 1] = s1[aa] + y[i].z, aa++;     for (int i = 1; i <= xx; i++)       b[bb + 1] = x[i], s2[bb + 1] = s2[bb] + x[i].z, bb++;   }   void cl() {     if (a[aa].c == b[bb].c) {       if (aa == 2 && bb == 2) {         jh(0, 1);         jh(1, 1);       } else if (aa == 1 && bb == 2) {         jh(1, 1);       } else if (aa == 1 && bb == 3) {         jh(1, 2);         jh(0, 1);       } else if (aa == 2 && bb == 1) {         jh(1, 1);       } else if (aa == 3 && bb == 1) {         jh(2, 1);         jh(1, 0);       }     } else {       if (aa == 2 && bb == 2) {         jh(1, 1);       } else if (aa == 1 && bb == 3) {         jh(1, 1);         jh(1, 1);       } else if (aa == 1 && bb == 2) {         jh(0, 1);       } else if (aa == 3 && bb == 1) {         jh(1, 1);         jh(1, 1);       } else if (aa == 2 && bb == 1) {         jh(1, 0);       }     }   }   char aaa[1000010], bbb[1000010];   int main() {     scanf( %s%s , aaa + 1, bbb + 1);     for (int i = 1; aaa[i]; i++) {       int j = i;       while (aaa[j + 1] == aaa[i]) j++;       a[++aa] = (dn){aaa[i] ==  b , j - i + 1};       i = j;     }     for (int i = 1; bbb[i]; i++) {       int j = i;       while (bbb[j + 1] == bbb[i]) j++;       b[++bb] = (dn){bbb[i] ==  b , j - i + 1};       i = j;     }     for (int i = 1; i <= aa; i++) s1[i] = s1[i - 1] + a[i].z;     for (int i = 1; i <= bb; i++) s2[i] = s2[i - 1] + b[i].z;     if (aa == 1) {       if (bb <= 3)         cl();       else {         int u = bb - 3;         if (b[u].c == a[1].c)           jh(0, u);         else           jh(1, u);       }     } else if (bb == 1) {       if (aa <= 3)         cl();       else {         int u = aa - 3;         if (a[u].c == b[1].c)           jh(u, 0);         else           jh(u, 1);       }     }     for (;;) {       if (aa + bb <= 4) {         cl();         break;       }       if (a[aa].c == b[bb].c) {         if (aa > bb)           jh(aa - 2, bb - 1);         else           jh(aa - 1, bb - 2);       } else {         if (abs(aa - bb) <= 1)           jh(aa - 1, bb - 1);         else if (aa > bb)           jh(aa - 3, bb - 1);         else           jh(aa - 1, bb - 3);       }     }     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) printf( %d %d n , ans[i].x, ans[i].y);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 51;   const int tot = maxn * maxn;   long long input[maxn];   long long dp[maxn][tot][maxn];   long long dp2[maxn][tot][maxn];   long long comb[maxn + 1][maxn + 1];   int N, M;   void init() {     cin >> N;     for (int i = 0; i < N; i++) {       cin >> input[i];     }     cin >> M;     comb[0][0] = 1;     for (int i = 1; i <= maxn; i++) {       comb[i][0] = 1;       for (int j = 1; j <= i; j++) {         comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];       }     }   }   long long factorial[maxn];   bool vst[maxn];   void run() {     int total = 0;     for (int i = 0; i < N; i++) {       total += input[i];     }     if (total <= M) {       cout << N << endl;       return;     }     for (int i = 0; i < N; i++) {       memset(vst, 0, sizeof(vst));       vst[i] = 1;       dp[i][0][0] = 1;       int cnt = 0;       for (int j = 0; j < N; j++) {         if (vst[j] == 0) {           cnt++;           for (int k = 0; k < tot; k++) {             for (int t = 0; t <= cnt; t++) {               dp2[i][k][t] = dp[i][k][t];             }           }           for (int k = 0; k < tot; k++) {             for (int t = 0; t <= cnt; t++) {               if (dp[i][k][t] && (k + input[j] < tot)) {                 dp2[i][k + input[j]][t + 1] += dp[i][k][t];               }             }           }           for (int k = 0; k < tot; k++) {             for (int t = 0; t <= cnt; t++) {               dp[i][k][t] = dp2[i][k][t];             }           }         }       }     }     double ans = 0;     for (int i = M; i >= 0; i--) {       for (int j = 0; j < N; j++) {         if (i + input[j] > M) {           for (int k = 0; k < N; k++) {             double tmp = dp[j][i][k] * 1.0 / comb[N][k];             tmp /= (N - k);             tmp *= k;             ans += tmp;           }         }       }     }     printf( %.8lf n , ans);   }   void baoli() {     const int n = 50;     int tmp[n];     cout << n <<    ;     for (int i = 0; i < n; i++) {       tmp[i] = i + 1;       cout << tmp[i] <<    ;     }     int m = 100;     cout << m << endl;     double ans = 0;     for (int test = 0; test <= 10000; test++) {       random_shuffle(tmp, tmp + n);       int sum = 0;       for (int i = 0; i < n; i++) {         sum += tmp[i];         if (sum > m) {           ans += i;           break;         }       }     }     cout << ans / 10000 << endl;   }   int main() {     init();     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int a, b, c;     cin >> a >> b >> c;     a = abs(a) + abs(b);     if (a > c)       cout <<  NO  << endl;     else {       if ((c - a) % 2 == 0)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a;     for (int i = 0; i <= 9; i++) {       cout << i << endl;       cout << flush;       a =   ;       getline(cin, a);       if (a ==  no ) {         continue;       } else {         if (a ==  don t think so  || a ==  great!  || a ==  don t touch me!  ||             a ==  not bad  || a ==  cool ) {           cout <<  normal ;         } else {           if (a ==  are you serious  || a ==  worse  || a ==  terrible  ||               a ==  don t even  || a ==  no way  || a ==  go die in a hole ) {             cout <<  grumpy ;           } else {             cout <<  normal ;           }         }         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   vector<int> v[N];   int num[N];   int q[N];   int cnt;   int check(int mid) {     int t = num[0] + mid, res = 0, tot = 0;     for (int i = 1; i <= 100000; i++) {       for (int j = 0; j <= max(-1, num[i] - t); j++) tot++, res += v[i][j];     }     if (tot > mid) return 1 << 30;     cnt = 0;     for (int i = 1; i <= 100000; i++) {       for (int j = max(0, num[i] - t + 1); j <= num[i] - 1; j++)         q[++cnt] = v[i][j];     }     sort(q + 1, q + cnt + 1);     for (int i = 1; i <= mid - tot; i++) res += q[i];     return res;   }   int main() {     int x, y;     int n;     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x >> y;       if (x == 0 || y == 0)         num[0]++;       else         v[x].push_back(y), num[x]++;     }     for (int i = 1; i <= 100000; i++) {       sort(v[i].begin(), v[i].end());     }     int f = 1;     for (int i = 1; i <= n; i++) {       if (num[i] >= num[0]) f = false;     }     if (f) {       puts( 0 );       return 0;     }     int l = 1, r = n;     int ans = 1 << 30;     while (l <= r) {       int mid1 = l + (r - l) / 3;       int f1 = check(mid1);       int mid2 = r - (r - l) / 3;       int f2 = check(mid2);       if (f1 <= f2)         r = mid2 - 1, ans = min(ans, f1);       else         l = mid1 + 1, ans = min(ans, f2);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const long long INF = 1e17 + 7;   const int N = 1e4 + 7;   const int M = 5e6 + 7;   long long x[N], y[N];   long long ax, ay, bx, by, a, b, t;   signed main() {     ios::sync_with_stdio(false);     cin >> x[0] >> y[0] >> ax >> ay >> bx >> by;     int n = 0;     for (; x[n] < INF && y[n] < INF; n++) {       x[n + 1] = x[n] * ax + bx;       y[n + 1] = y[n] * ay + by;       if (x[n + 1] >= INF || y[n + 1] >= INF) break;     }     cin >> a >> b >> t;     long long ans = 0;     for (int l = 0; l <= n; l++) {       for (int r = l; r <= n; r++) {         unsigned long long to =             min(abs(a - x[l]) + abs(b - y[l]), abs(a - x[r]) + abs(b - y[r]));         to += abs(x[l] - x[r]) + abs(y[l] - y[r]);         if (to <= t) ans = max(ans, r - l + 1ll);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   int main() {     fastio();     long long int a, b;     long long int mx = INT_MIN;     long long int n, mn = INT_MAX;     cin >> n;     long long int ar[n];     for (int i = 0; i < n; i++) {       cin >> ar[i];       mn = min(mn, ar[i]);       mx = max(ar[i], mx);     }     long long int res = mx - mn + 1;     cout << res - n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   vector<int> nums, fact;   int a, b, n;   void precomp() {     fact.resize(n + 1);     fact[0] = 1;     for (int i = 1; i <= n; ++i) fact[i] = 1ll * fact[i - 1] * i % mod;   }   void gener() {     int _max = log10(max(a, b) * n);     queue<int> q;     q.push(0);     while (!q.empty()) {       int top = q.front();       q.pop();       nums.push_back(top);       if ((int)log10(top) == _max) continue;       for (int i : {a, b}) q.push(10 * top + i);     }   }   void egcd(int a, int b, int& x, int& y) {     if (b == 0) {       x = 1;       y = 0;       return;     }     int x1, y1;     egcd(b, a % b, x1, y1);     x = y1;     y = x1 - (a / b) * y1;   }   int inv_mod(int a) {     int x, y;     egcd(a, mod, x, y);     return (x + mod) % mod;   }   int binom(int n, int k) {     int top = fact[n];     int bot = 1ll * fact[k] * fact[n - k] % mod;     return 1ll * top * inv_mod(bot) % mod;   }   int main() {     cin >> a >> b >> n;     precomp();     gener();     int ans = 0;     for (int c : nums) {       int top = c - b * n;       int bot = a - b;       if (top % bot) continue;       int res = top / bot;       if (res >= 0 && res <= n) ans = (ans + binom(n, res)) % mod;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, h, count = 0;     cin >> n >> h;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       if (a[i] > h)         count += 2;       else         count += 1;     }     cout << count;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     vector<int> s(6);     for (int i = 0; i < 6; i++) {       if ((1 << i) & a) s[i]++;     }     int res = 0;     res += (16 * s[0]);     res += (2 * s[1]);     res += (8 * s[2]);     res += (4 * s[3]);     res += s[4];     res += (32 * s[5]);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int l[6];   int main() {     int n, m, a;     cin >> m >> n;     for (int i = 0; i < m; i++) {       for (int i = 1; i <= n; i++) {         cin >> a;         l[i] = max(l[i - 1], l[i]) + a;       }       cout << l[n] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     std::ios_base::sync_with_stdio(false);     int n;     std::cin >> n;     std::vector<std::vector<bool> > g(n, std::vector<bool>(n, 0));     for (int row = 0; row < n; row++) {       std::string s;       std::cin >> s;       for (int col = 0; col < s.size(); col++) {         g[row][col] = s[col] -  0 ;       }     }     std::vector<int> a(n);     for (int p = 0; p < n; p++) {       std::cin >> a[p];     }     bool done(false);     std::vector<int> guests;     while (!done) {       done = true;       for (int p = 0; p < n; p++) {         if (a[p] != 0) {           continue;         }         done = false;         guests.push_back(p);         for (int q = 0; q < n; q++) {           a[q] -= g[p][q];         }         break;       }     }     std::cout << guests.size() << std::endl;     for (int p = 0; p < guests.size(); p++) {       std::cout << (1 + guests[p]) << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int a[111][111][111];   int color[111][111][111], cc;   char second[111];   void visit(queue<pair<pair<int, int>, int> >* q, int x, int y, int z) {     if (a[x][y][z] == 1 && color[x][y][z] != cc) {       color[x][y][z] = cc;       q->push(make_pair(make_pair(x, y), z));     }   }   void go(int x, int y, int z, int mx, int my, int mz) {     assert(a[x][y][z] == 1);     if (mx > n) mx = n;     if (my > m) my = m;     if (mz > k) mz = k;     ++cc;     queue<pair<pair<int, int>, int> > q;     color[x][y][z] = cc;     q.push(make_pair(make_pair(x, y), z));     while (!q.empty()) {       pair<pair<int, int>, int> fr = q.front();       q.pop();       int x = fr.first.first;       int y = fr.first.second;       int z = fr.second;       if (x + 1 <= mx) visit(&q, x + 1, y, z);       if (y + 1 <= my) visit(&q, x, y + 1, z);       if (z + 1 <= mz) visit(&q, x, y, z + 1);     }   }   bool reachable(int x, int y, int z) {     if (x + 1 < n && a[x + 1][y][z] == 1 && color[x + 1][y][z] != cc) {       return false;     }     if (y + 1 < m && a[x][y + 1][z] == 1 && color[x][y + 1][z] != cc) {       return false;     }     if (z + 1 < k && a[x][y][z + 1] == 1 && color[x][y][z + 1] != cc) {       return false;     }     return true;   }   bool critical(int x, int y, int z) {     if (x > 0 && a[x - 1][y][z] == 1) {       go(x - 1, y, z, x + 1, y + 1, z + 1);       if (!reachable(x, y, z)) {         return true;       }     }     if (y > 0 && a[x][y - 1][z] == 1) {       go(x, y - 1, z, x + 1, y + 1, z + 1);       if (!reachable(x, y, z)) {         return true;       }     }     if (z > 0 && a[x][y][z - 1] == 1) {       go(x, y, z - 1, x + 1, y + 1, z + 1);       if (!reachable(x, y, z)) {         return true;       }     }     return false;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         scanf( %s , second);         for (int t = 0; t < k; t++) {           a[i][j][t] = (second[t] ==  1 );         }       }     }     int res = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         for (int t = 0; t < k; t++) {           if (a[i][j][t] == 1) {             a[i][j][t] = 0;             res += critical(i, j, t);             a[i][j][t] = 1;           }         }       }     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1005;   long long n, m, q, ans;   bool vizitat[N][N];   long long dp[N][N][2];   bool verifica(long long i, long long j) {     if (i < 1 || j < 1 || i > n || j > m) return false;     return true;   }   long long cnt(long long i, long long j) {     long long answer = 0;     for (long long it = 0; it <= 1; it++) {       long long up = 0;       long long lin = i;       long long col = j;       while (verifica(lin, col) && vizitat[lin][col] == false) {         if (up % 2 == it) {           lin--;         } else {           col--;         }         up++;       }       long long down = 0;       lin = i;       col = j;       while (verifica(lin, col) && vizitat[lin][col] == false) {         if (down % 2 == it) {           col++;         } else {           lin++;         }         down++;       }       answer += up * down;     }     answer--;     return answer;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> q;     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= m; j++) {         dp[i][j][1] = dp[i][j - 1][0] + 1;         dp[i][j][0] = dp[i - 1][j][1] + 1;         ans += dp[i][j][1];         ans += dp[i][j][0];       }     }     ans -= n * m;     while (q--) {       long long lin, col;       cin >> lin >> col;       if (vizitat[lin][col] == true) {         vizitat[lin][col] = false;         ans += cnt(lin, col);       } else {         ans -= cnt(lin, col);         vizitat[lin][col] = true;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define pb push_back   #define ll long long   #define ff first   #define ss second      void solve()   {       int n;      cin>>n;         int sum=0;      int cnt=1;         while(sum<n)      {        sum+=cnt;        cnt+=1;      }      if(sum-1==n)       cout<<cnt;     else       cout<<cnt-1;     cout<<  n ;           }            int main()   {       ios_base::sync_with_stdio(false);       cin.tie(NULL);       #ifndef ONLINE_JUDGE          freopen( input.txt , r ,stdin);          freopen( output.txt , w ,stdout);        #endif       int q=1;       cin>>q;          while(q--)     {          solve();         }         return 0;               }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int ar[n + 5];     int br[n + 5];     int mark[200005];     memset(mark, 0, sizeof mark);     for (int i = 0; i < n; i++) {       cin >> ar[i];       br[i] = ar[i];     }     sort(br, br + n, greater<int>());     int sum = 0;     int cr[n + 5];     int c = 0;     for (int i = 0; i < k; i++) {       sum += br[i];       for (int j = 0; j < n; j++) {         if (br[i] == ar[j]) {           ar[j] = 0;           cr[c++] = j;         }       }     }     sort(cr, cr + k);     cout << sum << endl;     if (k == 1)       cout << n << endl;     else {       for (int i = 0; i < k; i++) {         if (i == 0) {           cout << cr[i] + 1 <<    ;         } else if (i == k - 1) {           int p = cr[i] - cr[i - 1];           p += n - cr[i] - 1;           cout << p << endl;         } else {           cout << cr[i] - cr[i - 1] <<    ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int m, q;   int a[3];   string dday;   int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   string tostring(int x) {     string temp =   ;     for (int i = 0; i < 2; i++) {       temp = (char)( 0  + x % 10) + temp;       x /= 10;     }     return temp;   }   bool solve() {     sort(a, a + 3);     do {       if (a[1] > 12) continue;       if (a[2] % 4 == 0) {         if (a[1] == 2 && a[0] > 29) continue;       } else if (a[1] == 2 && a[0] > 28)         continue;       if (a[1] != 2 && a[0] > days[a[1] - 1]) continue;       a[2] += 18;       if (a[2] > 100) continue;       string temp = tostring(a[2]);       temp.push_back( . );       temp += tostring(a[1]);       temp.push_back( . );       temp += tostring(a[0]);       if (temp <= dday) {         return true;       }       a[2] -= 18;     } while (next_permutation(a, a + 3));     return false;   }   int main() {     scanf( %d.%d.%d , &a[0], &a[1], &a[2]);     dday = tostring(a[2]);     dday.push_back( . );     dday += tostring(a[1]);     dday.push_back( . );     dday += tostring(a[0]);     scanf( %d.%d.%d , &a[0], &a[1], &a[2]);     if (solve())       cout <<  YES n ;     else       cout <<  NO n ;   }
#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     if (n == 0) {       printf( 1 );     } else if (n % 2 == 0) {       if (n % 4 == 0) {         printf( 6 );       } else {         printf( 4 );       }     } else if (n % 2 != 0) {       if (n % 4 == 1) {         printf( 8 );       } else {         printf( 2 );       }     }     return 0;   }
#include <bits/stdc++.h>      #define fi first   #define se second   #define mp make_pair      using namespace std;   using ll = long long;   using pii = pair<int, int>;      constexpr double eps = 1e-8;   constexpr int NINF = 0xc0c0c0c0;   constexpr int INF = 0x3f3f3f3f;   constexpr ll mod = 1e9 + 7;   constexpr ll N = 1e6 + 5;      int n, a[N], f[N], l[N], r[N], cnt[N];      int main() {       ios::sync_with_stdio(false);       cin.tie(nullptr);          cin >> n;       for (int i = 1; i <= n; i++) {           cin >> a[i];           if (!l[a[i]]) l[a[i]] = i;       }       for (int i = n; i; i--) {           if (!r[a[i]]) r[a[i]] = i;       }       for (int i = n; i; i--) {           cnt[a[i]]++;           if (i == l[a[i]]) {               f[i] = max(cnt[a[i]] + f[r[a[i]] + 1], f[i + 1]);           } else {               f[i] = max(cnt[a[i]], f[i + 1]);           }       }       cout << n - f[1] <<   n ;          return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int ans = 1e9, n, a[2000 + 5], b[2000 + 5], cnt, num[720 + 5], A[6],       c[720 + 5][5];   int id[10][10][10][10], f[15000005], q[15000005], top;   void dfs(int x, int v) {     ++cnt;     num[cnt] = x - 1;     id[A[1]][A[2]][A[3]][A[4]] = cnt;     for (int j = 1; j < x; ++j) c[cnt][j] = A[j];     if (x > 4) return;     for (int i = v; i <= 9; ++i) A[x] = i, dfs(x + 1, i);     A[x] = 0;   }   inline int ID(int x, int y, int z) { return x * 720 * 10 + y * 10 + z; }   void Try(int x, int y, int z, int v) {     int d = ID(x, y, z);     if (v < f[d]) f[q[++top] = d] = v;   }   int main() {     dfs(1, 1);     memset(f, 40, sizeof(f));     n = read();     for (int i = 1; i <= n; ++i) a[i] = read(), b[i] = read();     f[q[top = 1] = ID(0, id[0][0][0][0], 1)] = 0;     for (int i = 1; i <= top; ++i) {       int x = q[i] / 720 / 10, y = (q[i] / 10) % 720, z = q[i] % 10, v = f[q[i]];       if (z < 9) Try(x, y, z + 1, v + 1);       if (z > 1) Try(x, y, z - 1, v + 1);       int nn = 0;       for (int j = 1; j <= num[y]; ++j)         if (c[y][j] != z) A[++nn] = c[y][j];       for (int j = nn + 1; j <= 4; ++j) A[j] = 0;       Try(x, id[A[1]][A[2]][A[3]][A[4]], z, v + (num[y] - nn));       if (x < n && a[x + 1] == z && num[y] < 4) {         int nn = 0, k = 1;         for (; k <= num[y]; ++k)           if (c[y][k] <= b[x + 1])             A[++nn] = c[y][k];           else             break;         A[++nn] = b[x + 1];         for (; k <= num[y]; ++k) A[++nn] = c[y][k];         while (nn < 4) A[++nn] = 0;         Try(x + 1, id[A[1]][A[2]][A[3]][A[4]], z, v + 1);       }     }     for (int i = 1; i <= 9; ++i) ans = min(ans, f[ID(n, id[0][0][0][0], i)]);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 1e9 + 5;   const int N = 1e6 + 5;   long long ans = 0;   int main() {     int n;     cin >> n;     int a[n + 1];     for (int(i) = (0); (i) < (n); i++) {       cin >> a[i];     }     sort(a, a + n);     int x;     x = (n - 1) / 2;     cout << a[x];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       int a[n];       bool ok = true;       bool f = true;       for (int i = 0; i < n; i++) {         cin >> a[i];         if (!ok) continue;         if (f && a[i] < i) {           f = false;         }         if (!f && a[i] < n - i - 1) ok = false;       }       if (n % 2 == 0 && a[n / 2] == (n / 2 - 1) && a[n / 2 - 1] == (n / 2 - 1))         ok = false;       if (ok)         cout <<  Yes n ;       else         cout <<  No n ;     }     return 0;   }