malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool cmp(pair<long long int, long long int> pa1,            pair<long long int, long long int> pa2) {     return pa1.second < pa2.second;   }   int main() {     long long int n, k, i, mn, cnt;     cin >> n >> k;     long long int a[5001];     for (i = 0; i < n; i++) cin >> a[i];     long long int has[5001] = {0};     for (i = 0; i < n; i++) {       has[a[i]]++;     }     mn = *max_element(has, has + 5001);     if (mn <= k && k <= n) {       cout <<  YES n ;       pair<long long int, long long int> pa[5001];       for (i = 0; i < n; i++) {         pa[i].first = a[i];         pa[i].second = i;       }       sort(pa, pa + n);       cnt = 1;       for (i = 0; i < n; i++) {         pa[i].first = cnt;         cnt++;         if (cnt == k + 1) cnt = 1;       }       sort(pa, pa + n, cmp);       for (i = 0; i < n; i++) cout << pa[i].first <<    ;     } else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int f[150000];   int find(int x) {     if (x == f[x])       return f[x];     else {       return f[x] = find(f[x]);     }   }   int a[150000];   int num[150000];   int main() {     ios::sync_with_stdio(false);     int n, m;     while (cin >> n >> m) {       memset(a, 0, sizeof(a));       memset(num, 0, sizeof(num));       for (int i = 1; i <= n; i++) f[i] = i;       for (int i = 0; i < m; i++) {         int x, y;         cin >> x >> y;         a[x]++;         a[y]++;         x = find(x), y = find(y);         if (x != y) f[x] = y;       }       for (int i = 1; i <= n; i++) {         find(i);       }       for (int i = 1; i <= n; i++) {         num[f[i]]++;       }       bool flag = true;       for (int i = 1; i <= n; i++) {         if (a[i] != num[f[i]] - 1) {           flag = false;           break;         }       }       if (flag)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, c, a[100005], sign[100005];   bool sign_ch[100005];   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> a[i];     sign[n] = 1;     c = a[n];     for (int i = n - 1; i >= 1; i--) {       if (c >= a[i]) {         c -= a[i];         sign[i] = -1;       } else {         c = a[i] - c;         sign[i] = 1;         sign_ch[i + 1] = true;       }     }     int flip = 0;     for (int i = 1; i <= n; i++) {       if (sign_ch[i] == true) flip = !flip;       char ch;       ch = sign[i] == 1 ?  +  :  - ;       if (flip) ch = ch ==  +  ?  -  :  + ;       putchar(ch);     }     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, r[1010], c[1010], rc[1010], rr[1010], tr[1010], tc[1010], rtc[1010],       rtr[1010];   class portal {    public:     int ix, iy, ox, oy;   };   vector<portal> ans;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &r[i]);       rr[r[i]] = i;     }     for (int i = 1; i <= n; i++) {       scanf( %d , &c[i]);       rc[c[i]] = i;     }     for (int i = 1; i <= n; i++) tr[i] = tc[i] = rtr[i] = rtc[i] = i;     for (int i = 1; i <= n; i++) {       if (tc[i] == rc[i] && tr[i] == rr[i]) continue;       ans.push_back((portal){i, rtc[rc[i]], rtr[rr[i]], i});       int t1 = tc[i], t2 = tr[i];       swap(tc[i], tc[rtc[rc[i]]]);       swap(tr[i], tr[rtr[rr[i]]]);       swap(rtc[rc[i]], rtc[t1]);       swap(rtr[rr[i]], rtr[t2]);     }     printf( %d n , ans.size());     for (portal x : ans) printf( %d %d %d %d n , x.ix, x.iy, x.ox, x.oy);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> row, col, A;   vector<pair<pair<int, int>, int> > mat;   int grid[111][111];   void shift_up(int c, int n, int m) {     int i, temp;     temp = grid[n][c];     for (i = n; i > 1; i--) grid[i][c] = grid[i - 1][c];     grid[1][c] = temp;   }   void shift_left(int r, int n, int m) {     int i, temp;     temp = grid[r][m];     for (i = m; i > 1; i--) grid[r][i] = grid[r][i - 1];     grid[r][1] = temp;   }   int main() {     int n, q, i, m, j, type, id, r, c, x;     cin >> n >> m >> q;     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) grid[i][j] = 0;     while (q--) {       cin >> type;       A.push_back(type);       if (type == 2) {         cin >> id;         col.push_back(id);       } else if (type == 1) {         cin >> id;         row.push_back(id);       } else {         cin >> r >> c >> x;         mat.push_back(make_pair(make_pair(r, c), x));       }     }     int im = mat.size() - 1, ir = row.size() - 1, ic = col.size() - 1;     for (i = A.size() - 1; i >= 0; i--) {       type = A[i];       if (type == 2) {         c = col[ic];         ic--;         shift_up(c, n, m);       } else if (type == 1) {         r = row[ir];         ir--;         shift_left(r, n, m);       } else {         r = mat[im].first.first;         c = mat[im].first.second;         x = mat[im].second;         grid[r][c] = x;         im--;       }     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) cout << grid[i][j] <<    ;       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     cin >> n >> x;     if (n == 3) {       cout <<  >vv  << endl <<  ^<.  << endl <<  ^.<  << endl;       cout << 1 <<     << 3;     }     if (n == 5) {       cout <<  >...v  << endl            <<  v.<..  << endl            <<  ..^..  << endl            <<  >....  << endl            <<  ..^.<  << endl;       cout << 1 <<     << 1;     }     if (n == 100) {       cout <<  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.>.>.>                 .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.v             << endl;       for (int i = 0; i < 49; i++) {         cout <<  ^v.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<                   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<               << endl;         cout <<  ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.>.>                   .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.v               << endl;       }       cout <<  ^<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<                 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<             << endl;       cout << 1 <<     << 1;     }   }
#include <bits/stdc++.h>   using namespace std;   struct sir {     int val, ind;   };   sir sv[200005];   int n, m, k, v[200005], part[200005], t = 0;   long long sum = 0;   bool B[200005];   bool comp(sir X, sir Y) { return X.val > Y.val; }   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i) {       cin >> v[i];       sv[i].val = v[i];       sv[i].ind = i;     }     sort(sv + 1, sv + n + 1, comp);     for (int i = 1; i <= m * k; ++i) {       B[sv[i].ind] = 1;       sum += sv[i].val;     }     int nr = 0;     for (int i = 1; i <= n; ++i) {       if (B[i]) nr++;       if (nr == m && t < k - 1) {         nr = 0;         part[++t] = i;       }     }     cout << sum <<   n ;     for (int i = 1; i <= t; ++i) cout << part[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     for (int i = 0; i < n; ++i) {       for (int x = 0; x < n; ++x)         if (i == x)           cout << k <<    ;         else           cout << 0 <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long h[100000];   int main() {     int n;     cin >> n;     for (int j = 0; j < n; ++j) {       cin >> h[j];     }     long long max = h[n - 1];     long long answer[100000];     answer[n - 1] = 0;     for (int i = n - 2; i >= 0; --i) {       if (h[i] > max) {         max = h[i];         answer[i] = 0;       } else {         answer[i] = max - h[i] + 1;       }     }     for (int i = 0; i < n; ++i) {       cout << answer[i] <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<pair<int, int>> parent[1000001], hv[1000001], vv[1000001];   vector<vector<pair<int, int>>> edges[1000001];   vector<int> vals[1000001], done[1000001];   pair<int, int> get(pair<int, int> x) {     pair<int, int> k = parent[x.first][x.second];     if (parent[k.first][k.second] == k)       return k;     else       return parent[k.first][k.second] = get(k);   }   void unite(pair<int, int> a, pair<int, int> c) {     a = get(a), c = get(c);     if (a == c) return;     parent[c.first][c.second] = a;   }   int dp(pair<int, int> x) {     x = get(x);     if (edges[x.first][x.second].size() == 0) return 1;     if (done[x.first][x.second]) return done[x.first][x.second];     sort(edges[x.first][x.second].begin(), edges[x.first][x.second].end());     edges[x.first][x.second].erase(         unique(edges[x.first][x.second].begin(), edges[x.first][x.second].end()),         edges[x.first][x.second].end());     int ans = 0;     for (pair<int, int> i : edges[x.first][x.second]) ans = max(ans, dp(i));     return done[x.first][x.second] = (ans + 1);   }   int main() {     cin >> n >> m;     for (int i = 0; i < m; i++)       parent[i].resize(n), edges[i].resize(n), vals[i].resize(n),           done[i].resize(n);     for (int j = 0; j < n; j++)       for (int i = 0; i < m; i++) {         pair<int, int> x = make_pair(i, j);         scanf( %d , &vals[x.first][x.second]), parent[x.first][x.second] = x;         vv[i].push_back(make_pair(vals[x.first][x.second], j)),             hv[j].push_back(make_pair(vals[x.first][x.second], i));       }     for (int i = 0; i < m; i++) {       sort(vv[i].begin(), vv[i].end());       for (int j = 0; j < n - 1; j++)         if (vv[i][j].first == vv[i][j + 1].first)           unite(make_pair(i, vv[i][j].second), make_pair(i, vv[i][j + 1].second));     }     for (int j = 0; j < n; j++) {       sort(hv[j].begin(), hv[j].end());       for (int i = 0; i < m - 1; i++)         if (hv[j][i].first == hv[j][i + 1].first)           unite(make_pair(hv[j][i].second, j), make_pair(hv[j][i + 1].second, j));     }     for (int i = 0; i < m; i++)       for (int j = 0; j < n - 1; j++)         if (vv[i][j].first < vv[i][j + 1].first) {           pair<int, int> a = get(make_pair(i, vv[i][j + 1].second));           pair<int, int> c = get(make_pair(i, vv[i][j].second));           edges[a.first][a.second].push_back(c);         }     for (int j = 0; j < n; j++)       for (int i = 0; i < m - 1; i++)         if (hv[j][i].first < hv[j][i + 1].first) {           pair<int, int> a = get(make_pair(hv[j][i + 1].second, j));           pair<int, int> c = get(make_pair(hv[j][i].second, j));           edges[a.first][a.second].push_back(c);         }     for (int j = 0; j < n; j++) {       for (int i = 0; i < m; i++) printf( %d  , dp(make_pair(i, j)));       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     long long int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     long long int pre = 0;     int counter = 0;     while (counter < n && arr[counter] != 0) {       pre++;       counter++;     }     long long int post = 0;     counter = n - 1;     while (counter >= 0 && arr[counter] != 0) {       counter--;       post++;     }     counter = 0;     long long int mx = 0;     for (int i = 0; i < n; i++) {       if (arr[i] == 0) {         if (mx < counter) mx = counter;         counter = 0;       } else {         counter++;       }     }     if (counter > mx) mx = counter;     if (mx < pre + post) mx = pre + post;     cout << mx <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ii = pair<int, int>;   using iii = tuple<int, int, int>;   using vi = vector<int>;   int main(void) {     ios::sync_with_stdio(false), cin.tie(NULL);     int n;     cin >> n;     vector<iii> a(n);     int maxr = 0, i = 0;     for (auto &[r, l, ix] : a) {       cin >> l >> r;       ix = i++;       maxr = max(maxr, r);     }     sort(begin(a), end(a));     vi used(maxr + 1, 0), ans(n);     for (auto [r, l, i] : a) {       while (used[l]) l++;       ans[i] = l;       used[l] = true;     }     for (auto x : ans) cout << x <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     size_t n, w, m;     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr),         cin >> n >> w >> m;     struct bottle_t {       size_t amount, id;     } bottle, poured;     stack<bottle_t> bottles, non_empty;     vector<bottle_t> cup[m];     for (bottle.amount = m, bottle.id = 1; bottle.id <= n; bottle.id++)       bottles.push(bottle);     for (size_t i = 0, unfilled = n; i < m; i++, unfilled = n) {       while (!non_empty.empty()) bottles.push(non_empty.top()), non_empty.pop();       do {         bottle = bottles.top(), bottles.pop();         if (bottle.amount > unfilled && bottle.amount < m) {           cout <<  NO ;           return 0;         }         poured = bottle;         if (unfilled < poured.amount) poured.amount = unfilled;         cup[i].push_back(poured);         if ((bottle.amount -= poured.amount) > 0) non_empty.push(bottle);       } while ((unfilled -= poured.amount) > 0);     }     cout <<  YES  <<   n ;     long double scale_factor = (long double)w / (long double)m;     for (size_t i = 0; i < m; i++, cout <<   n )       for (size_t j = 0, k = cup[i].size(); j < k; j++)         cout << cup[i][j].id <<     << fixed << setprecision(6)              << scale_factor * cup[i][j].amount <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int min(int s, int t) {     if (s <= t) return s;     return t;   }   int max(int s, int t) {     if (s >= t) return s;     return t;   }   int main(void) {     int cases;     int n, s, t, m, k;     cin >> cases;     while (cases--) {       cin >> n >> s >> t;       m = s + t;       k = m - n;       cout << max(s - k, t - k) + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x;     int a[2] = {0};     char c;     while (scanf( %c , &c) != -1) {       a[c -  x ]++;     }     if (a[0] > a[1]) {       x = a[0] - a[1];       for (int i = 0; i < x; i++) {         printf( %c ,  x );       }       printf(  n );     } else {       x = a[1] - a[0];       for (int i = 0; i < x; i++) {         printf( %c ,  y );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool comp(int x, int y) { return x > y; }   bool myComp(pair<int, int> x, pair<int, int> y) {     if (x.first < y.first) return true;     if (x.first > y.first) return false;     return x.second > y.second;   }   int lucky[] = {4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777};   int main() {     int n, m;     cin >> n >> m;     int last = m - 1;     for (int i = 0; i < n; i++) {       bool print = false;       for (int j = 0; j < m; j++) {         if (i % 2 == 0)           cout <<  # ;         else {           if (j != last) {             cout <<  . ;           } else {             cout <<  # ;           }         }       }       if (i % 2 != 0) {         if (last == 0)           last = m - 1;         else           last = 0;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int it;     int TUX;     cin >> TUX;     int FOO = 0, BAR = 0, BAZ = 0, QUZ = 1;     for (int i = TUX; i != 0; i--) {       int PUR;       cin >> PUR;       FOO += PUR;       BAR++;       it = ((max((FOO * QUZ), (BAR * BAZ))) == (FOO * QUZ));       if (it) {         BAZ = FOO;         QUZ = BAR;       }     }     cout << ((double)BAZ) / ((double)QUZ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool areParanthesisBalanced(string expr) {     stack<char> s;     char x;     for (int i = 0; i < expr.length(); i++) {       if (expr[i] ==  (  || expr[i] ==  [  || expr[i] ==  { ) {         s.push(expr[i]);         continue;       }       if (s.empty()) return false;       switch (expr[i]) {         case  ) :           x = s.top();           s.pop();           if (x ==  {  || x ==  [ ) return false;           break;         case  } :           x = s.top();           s.pop();           if (x ==  (  || x ==  [ ) return false;           break;         case  ] :           x = s.top();           s.pop();           if (x ==  (  || x ==  { ) return false;           break;       }     }     return (s.empty());   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     cin.ignore();     string s;     cin >> s;     int op = 0;     int ans = 0;     int st = -1, en = -1;     for (int i = 0; i < n; ++i) {       if (st == -1) {         st = i;       }       if (s[i] ==  ( ) {         op++;       } else {         op--;       }       if (op == 0) {         if (areParanthesisBalanced(s.substr(st, i - st + 1))) {         } else {           ans += i - st + 1;         }         st = -1;       }     }     if (op == 0) {       cout << ans <<   n ;     } else {       cout <<  -1 n ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, i, j, k = 0, z, x;     scanf( %d , &n);     for (i = 1; i < n; i++) {       for (j = i; j < n; j++) {         z = i * i + j * j;         x = sqrt(z);         if (x * x == z && x <= n) {           k++;         }       }     }     printf( %d , k);     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 200005;   int n, m, tot, a[MAXN], b[MAXN], pa[MAXN], pb[MAXN], tr[MAXN], ans[MAXN * 10];   bool tag[MAXN * 10], used[MAXN * 10];   template <typename T>   inline void read(T &x) {     int fl = 0, ch;     while (ch = getchar(), ch < 48 || 57 < ch) fl ^= !(ch ^ 45);     x = (ch & 15);     while (ch = getchar(), 47 < ch && ch < 58) x = x * 10 + (ch & 15);     if (fl) x = -x;   }   struct ASK {     int opt, x, y, id;   } q[MAXN * 10], qq[MAXN * 10];   void upd(int i, int x) {     for (; i <= n; i += i & -i) tr[i] += x;   }   int qry(int i) {     int res = 0;     for (; i; i &= i - 1) res += tr[i];     return res;   }   void cdq(int l, int r) {     if (l >= r) return;     int mid = l + r >> 1;     cdq(l, mid), cdq(mid + 1, r);     int i = l, j = mid + 1;     for (int k = l; k <= r; ++k) {       if (i <= mid && (j > r || q[i].x <= q[j].x)) {         if (q[i].opt == 2) upd(q[i].y, 1);         if (q[i].opt == 3) upd(q[i].y, -1);         qq[k] = q[i++], used[k] = 1;       } else {         if (q[j].opt == 1) ans[q[j].id] += qry(q[j].y);         qq[k] = q[j++];       }     }     for (int k = l; k <= r; ++k) {       q[k] = qq[k];       if (used[k] == 1) {         if (q[k].opt == 2)           upd(q[k].y, -1);         else if (q[k].opt == 3)           upd(q[k].y, 1);         used[k] = 0;       }     }   }   int main() {     read(n), read(m);     for (int i = 1; i <= n; ++i) read(a[i]), pa[a[i]] = i;     for (int i = 1; i <= n; ++i) read(b[i]), pb[b[i]] = i;     for (int i = 1; i <= n; ++i) ++tot, q[tot] = (ASK){2, pa[i], pb[i]};     for (int i = 1; i <= m; ++i) {       ++tot, read(q[tot].opt);       if (q[tot].opt == 1) {         int l1, r1, l2, r2;         read(l1), read(r1), read(l2), read(r2);         tag[tot--] = 1;         ++tot, q[tot] = (ASK){1, r1, r2, tot};         ++tot, q[tot] = (ASK){1, l1 - 1, r2, tot};         ++tot, q[tot] = (ASK){1, r1, l2 - 1, tot};         ++tot, q[tot] = (ASK){1, l1 - 1, l2 - 1, tot};       } else {         int x, y;         read(x), read(y);         --tot;         ++tot, q[tot] = (ASK){3, pa[b[x]], x, 0};         ++tot, q[tot] = (ASK){3, pa[b[y]], y, 0};         ++tot, q[tot] = (ASK){2, pa[b[x]], y, 0};         ++tot, q[tot] = (ASK){2, pa[b[y]], x, 0};         std::swap(b[x], b[y]), std::swap(pb[b[x]], pb[b[y]]);       }     }     cdq(1, tot);     for (int i = 1; i <= tot; ++i)       if (tag[i] == 1)         printf( %d n , ans[i] - ans[i + 1] - ans[i + 2] + ans[i + 3]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000100;   const long long MOD = 1e9 + 7;   int N, M;   string P;   int y[MAXN], fail[MAXN];   bool good[MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin >> N >> M >> P;     for (int i = 0; i < M; i++) {       cin >> y[i];       y[i]--;     }     fail[0] = -1;     for (int i = 1; i < P.length(); i++) {       int cloc = fail[i - 1];       while (cloc > -1 && P[i] != P[cloc + 1]) cloc = fail[cloc];       if (cloc == -1 && P[i] != P[0]) cloc = -2;       fail[i] = cloc + 1;     }     for (int i = 0; i < MAXN; i++) good[i] = false;     int cloc = (int)P.length() - 1;     while (cloc != -1) {       good[cloc] = true;       cloc = fail[cloc];     }     for (int i = 0; i < M - 1; i++) {       int diff = (y[i + 1] - y[i]);       if (diff >= P.length()) continue;       if (!good[P.length() - 1 - diff]) {         cout <<  0 n ;         return 0;       }     }     int xloc = 0;     long long res = 1;     for (int i = 0; i < N; i++) {       if (xloc < M - 1 && y[xloc + 1] == i) xloc++;       if (xloc >= M || y[xloc] > i || y[xloc] + P.size() <= i) {         res = (26 * res) % MOD;       }     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100100;   pair<long double, long double> a[N];   int n;   bool f(long double mid) {     long double l[n], r[n];     multiset<pair<long double, int>> xex;     for (int i = 0; i < n; i++) {       l[i] = 1.0 * a[i].first - a[i].second * mid;       xex.insert({l[i], -1});       r[i] = 1.0 * a[i].first + a[i].second * mid;       xex.insert({r[i], 1});     }     int cnt = 0;     for (auto it = xex.begin(); it != xex.end(); it++) {       if ((*it).second == -1) {         cnt++;       } else {         cnt--;       }       if (cnt == n) return true;     }     {       bool f = true;       for (int i = 0; i < n; i++) {         if (l[i] <= a[0].first) {           f = false;           break;         }       }       if (f) return true;     }     {       bool f = true;       for (int i = 0; i < n; i++) {         if (a[n - 1].first <= r[i]) {           f = false;           break;         }       }       if (f) return true;     }     return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i].first;     }     for (int i = 0; i < n; i++) {       cin >> a[i].second;     }     sort(a, a + n);     long double ans = 1e9;     long double l = 0.0, r = 1e9;     while (r - l >= 0.0000001) {       long double mid = (1.0 * l + r) / 2.0;       if (f(mid)) {         ans = mid;         r = mid;       } else {         l = mid;       }     }     cout << fixed << setprecision(8) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[15];   inline int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + (ch ^ 48), ch = getchar();     return x * f;   }   int main() {     int t = read();     while (t--) {       int n = read(), x = 0, y = 0, s = 0, xx = 0, yy = 0;       while (n) a[++s] = n % 10, n /= 10;       for (int i = s; i; i--)         if (i & 1)           x = x * 10 + a[i];         else           y = y * 10 + a[i];       printf( %d n , (x + 1) * (y + 1) - 2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[200007];   void input() {     scanf( %d , &n);     int i;     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }   }   void solve() {     int i;     for (i = 1; i <= n; i++) {       if ((a[i] % 2) == 1) {         if (i != n && (a[i + 1] != 0)) {           a[i]--;           a[i + 1]--;         }       }     }     for (i = 1; i <= n; i++) {       if ((a[i] % 2) != 0) {         printf( NO n );         return;       }     }     printf( YES n );   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[10010];   int main() {     int n;     cin >> n;     while (n--) {       string a;       cin >> a;       for (int i = 0; i < a.size(); i++) {         s[i] = a[i];       }       sort(s, s + a.size());       if (s[0] == s[a.size() - 1]) {         cout << -1 << endl;       } else {         for (int i = 0; i < a.size(); i++) {           cout << s[i];         }         cout << endl;       }     }   }