malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const double PI = acos(-1.0);   const int MOD = 1000 * 1000 * 1000 + 7;   const int INF = 2000 * 1000 * 1000;   const int MAXN = 55;   template <typename T>   inline T sqr(T n) {     return n * n;   }   int n;   long long m;   long long weight[MAXN];   int ans[MAXN];   int main() {     scanf( %d%I64d , &n, &m);     weight[0] = 1ll << (n - 1);     for (int i = 1; i <= n; i++) {       weight[i] = max(weight[i - 1] >> 1, 1ll);     }     int l = 1, r = n;     int num = 1;     long long cur = 0;     while (l <= r) {       if (l == r || cur + weight[num] >= m) {         ans[l] = num;         l++;       } else {         cur += weight[num];         ans[r] = num;         r--;       }       num++;     }     for (int i = 1; i <= n; i++) {       printf( %d%c , ans[i],    n [i == n]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 32005;   int n, m, i, j, f;   int a[N];   long long ans;   int main() {     scanf( %d%d , &n, &m);     for (i = m + 1; i <= (n + 1) / 2; i++) {       for (j = m + 1; j < 2 * i; j++) {         f = (i * (2 * i - j) + (n + 1) * (2 * j - i)) / (i + j);         f = max(f, m);         if (f > n - m) continue;         a[i] += n - m - f;       }     }     for (i = m + 1; i <= (n + 1) / 2; i++) ans += 2 * a[i];     if (n & 1) ans -= a[i - 1];     printf( %I64d n , 3 * ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const long long mod = 1e9 + 7;   long long n, m;   struct mat {     int a[105][105];     mat() { memset(a, 0, sizeof(a)); }     mat operator*(const mat &b) const {       mat c;       for (int i = (1); i < (m + 1); i++) {         for (int j = (1); j < (m + 1); j++) {           for (int k = (1); k < (m + 1); k++) {             c.a[i][j] = (c.a[i][j] + a[i][k] % mod * b.a[k][j] % mod) % mod;           }         }       }       return c;     }   };   mat mod_pow(mat x, long long n) {     mat res;     for (int i = (1); i < (m + 1); i++) res.a[i][i] = 1;     while (n > 0) {       if (n & 1) res = res * x;       x = x * x;       n >>= 1;     }     return res;   }   int main() {     cin >> n >> m;     mat b, x, ans;     for (int i = (1); i < (m + 1); i++) b.a[i][1] = 1;     for (int i = (2); i < (m + 1); i++) x.a[i][i - 1] = 1;     x.a[1][1] = 1;     x.a[1][m] = 1;     ans = mod_pow(x, n - m + 1) * b;     cout << ans.a[1][1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 210000;   int n;   int oke[maxn], okp[maxn];   struct edge {     int y, nex;   } a[maxn << 1];   int len, fir[maxn];   inline void ins(const int x, const int y) {     a[++len] = (edge){y, fir[x]};     fir[x] = len;   }   int siz[maxn], mxs[maxn];   void dfs(const int x, const int fa) {     siz[x] = 1;     for (int k = fir[x], y = a[k].y; k; k = a[k].nex, y = a[k].y)       if (y != fa) {         dfs(y, x);         siz[x] += siz[y];         mxs[x] = max(mxs[x], siz[y]);       }   }   int root, t1, t2;   int d[maxn], f[maxn], f2[maxn];   bool cmp(const int x, const int y) {     return f[x] == f[y] ? f2[x] < f2[y] : f[x] < f[y];   }   int t[maxn], tp;   void Hash(const int x, const int fa) {     siz[x] = 1;     for (int k = fir[x], y = a[k].y; k; k = a[k].nex, y = a[k].y)       if (y != fa && oke[k]) Hash(y, x), siz[x] += siz[y];     tp = 0;     for (int k = fir[x], y = a[k].y; k; k = a[k].nex, y = a[k].y)       if (y != fa && oke[k]) t[++tp] = y;     sort(t + 1, t + tp + 1, cmp);     d[x] = tp + (fa != 0);     f[x] = f2[x] = siz[x];     for (int i = 1; i <= tp; i++) {       int y = t[i];       f[x] = f[x] * (siz[y] + 1) * f[y];       f2[x] = f2[x] + (siz[y] + 2) * (f2[y] + 1);     }   }   int ans[maxn];   void cal(const int x, const int fa) {     if (okp[x] && d[x] < 4) ans[x]++;     for (int k = fir[x], y = a[k].y; k; k = a[k].nex, y = a[k].y)       if (y != fa && oke[k]) cal(y, x);     tp = 0;     for (int k = fir[x], y = a[k].y; k; k = a[k].nex, y = a[k].y)       if (y != fa && oke[k]) t[++tp] = y;     sort(t + 1, t + tp + 1, cmp);     for (int i = 1; i <= tp; i++) {       int y = t[i], ty = t[i - 1];       if (f[y] != f[ty] || f2[y] != f2[ty]) ans[x] += ans[y];     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       ins(x, y), ins(y, x);     }     dfs(1, 0);     for (int i = 1; i <= n; i++)       if (mxs[i] * 2 <= n && (n - siz[i]) * 2 <= n) {         if (!t1)           t1 = i;         else           t2 = i;       }     for (int i = 1; i <= len; i++) oke[i] = 1;     for (int i = 1; i <= n; i++) okp[i] = 1;     if (t2) {       for (int k = fir[t1], y = a[k].y; k; k = a[k].nex, y = a[k].y)         if (y == t2) oke[k] = 0;       for (int k = fir[t2], y = a[k].y; k; k = a[k].nex, y = a[k].y)         if (y == t1) oke[k] = 0;       okp[root = ++n] = 0;       ins(root, t1), ins(root, t2);       oke[len - 1] = oke[len] = 1;     } else       root = t1;     Hash(root, 0);     cal(root, 0);     printf( %d n , ans[root]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int ts;     cin >> ts;     while (ts--) {       string s, t;       cin >> s >> t;       int n = (int)s.size();       map<string, int> cnt;       for (int i = 0; i < n; i += 2) {         string cur =   ;         cur += s[i];         cur += s[i + 1];         sort(cur.begin(), cur.end());         cnt[cur]++;       }       for (int i = 0; i < n; i += 2) {         string cur =   ;         cur += t[i];         cur += t[i + 1];         sort(cur.begin(), cur.end());         cnt[cur]--;       }       bool bad = false;       for (auto c : cnt) {         if (c.second != 0) {           bad = true;         }       }       if (bad) {         cout << -1 <<   n ;         continue;       }       while (true) {         int start = rnd() % (n / 2 + 1);         vector<int> ord;         if (start != 0) {           ord.push_back(start - 1);         }         string cur = s, me = t;         reverse(cur.begin(), cur.begin() + 2 * start);         int its = 0;         bool bad = false;         while (cur.size() > 0) {           int ind = (int)me.size() - 2;           vector<int> sh;           for (int i = (int)cur.size() - 2; i >= 0; i -= 2) {             sh.push_back(i);           }           shuffle(sh.begin() + 1, sh.end(), rnd);           bool mda = false;           for (int i : sh) {             if (cur[i] == me[ind] && cur[i + 1] == me[ind + 1]) {               if (i + 2 != (int)cur.size()) {                 ord.push_back(i / 2);                 reverse(cur.begin(), cur.begin() + i + 2);                 ord.push_back(ind / 2);                 reverse(cur.begin(), cur.end());               }               mda = true;               break;             }           }           if (!mda) {             vector<int> sh;             for (int i = 0; i < (int)cur.size(); i += 2) {               sh.push_back(i);             }             shuffle(sh.begin(), sh.end(), rnd);             for (int i : sh) {               if (cur[i] == me[ind + 1] && cur[i + 1] == me[ind]) {                 ord.push_back(i / 2);                 reverse(cur.begin(), cur.begin() + i + 2);                 ord.push_back(0);                 reverse(cur.begin(), cur.begin() + 2);                 ord.push_back(ind / 2);                 reverse(cur.begin(), cur.end());                 break;               }             }           }           if (ord.size() > n + 1) {             bad = true;             break;           }           for (int it = 0; it < 2; it++) {             cur.pop_back(), me.pop_back();           }         }         if (bad) {           continue;         } else {           cout << ord.size() <<   n ;           string f = s, g = t;           for (int a : ord) {             cout << 2 * (a + 1) <<    ;           }           cout <<   n ;           break;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   string s;   long long n;   bool len(char x) {     return x ==  a  || x ==  e  || x ==  i  || x ==  o  || x ==  u  || x ==  y ;   }   int main() {     cin >> n;     cin >> s;     cout << s[0];     for (int i = 1; i < n; i++) {       if (len(s[i]) && len(s[i - 1])) continue;       cout << s[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3,  Ofast ,  inline )   using namespace std;   mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   const long long maxn = (long long)1e6 + 5;   const long long mod = 998244353;   const long long inf = 0x3f3f3f3f;   long long T = 1;   vector<long long> v[maxn], vec[maxn];   long long dep[maxn], pre[maxn];   long long maxx;   void dfs(long long now) {     maxx = max(maxx, dep[now]);     vec[dep[now]].push_back(now);     for (auto &to : v[now]) {       if (dep[to]) continue;       pre[to] = now;       dep[to] = dep[now] + 1;       dfs(to);     }   }   void solve() {     long long n, m;     cin >> n >> m;     maxx = 1;     for (long long i = 1; i <= n; ++i) v[i].clear(), vec[i].clear(), dep[i] = 0;     for (long long i = 1; i <= m; ++i) {       long long x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     dep[1] = 1;     dfs(1);     if (maxx > (n + 1) / 2) {       cout <<  PATH n ;       stack<long long> s;       long long now = vec[maxx][0];       while (now) {         s.push(now);         now = pre[now];       }       cout << s.size() <<   n ;       while (!s.empty()) {         cout << s.top() <<    ;         s.pop();       }       cout <<   n ;       return;     }     cout <<  PAIRING n ;     long long ans = 0;     for (long long i = 1; i <= maxx; ++i) {       ans += vec[i].size() / 2;     }     cout << ans <<   n ;     for (long long i = 1; i <= maxx; ++i) {       for (long long j = 0; j + 1 < vec[i].size(); j += 2) {         cout << vec[i][j] <<     << vec[i][j + 1] <<   n ;       }     }   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     vector<long long> vec(n);     for (long long i = 0; i < n; i++) {       cin >> vec[i];     }     vec.push_back(vec.back());     long long ans = 1;     long long cnt = 1;     for (long long i = 1; i < n; i++) {       if (vec[i] > vec[i - 1] * 2) {         ans = max(ans, cnt);         cnt = 0;       }       cnt++;     }     ans = max(ans, cnt);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const double eps = 1e-9;   int main() {     int n;     scanf( %d , &n);     double inch = (double)n / 3;     int ninch = (int)inch;     if (inch - (double)ninch >= 0.5) ++ninch;     printf( %d %d n , ninch / 12, ninch % 12);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:20000000 )   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<string> a;     string s;     for (int i = (0); (i) < (n); (i)++) {       cin >> s;       a.push_back( #  + s +  # );     }     int x = 1;     long long r = 0;     bool g = true;     for (int i = 0; i < n - 1; i++) {       if (a[i + 1][x] ==  . ) {         r++;         continue;       }       int left = x, right = x;       int wall = 0;       bool down = false;       while (!down) {         if (g) {           if (a[i + 1][right] ==  . ) {             r += right - x + 1;             x = right;             break;           }           for (int j = right + 1;; j++) {             if (a[i][j] ==  + ) {               wall = 0;               right = j;               r += j - x;               x = j - 1;               g = false;               break;             } else if (a[i][j] ==  # ) {               wall++;               right = j - 1;               r += j - x;               x = j - 1;               g = false;               break;             } else if (a[i + 1][j] ==  . ) {               r += j - x + 1;               x = j;               down = true;               break;             }           }         } else {           if (a[i + 1][left] ==  . ) {             r += x - left + 1;             x = left;             break;           }           for (int j = left - 1;; j--) {             if (a[i][j] ==  + ) {               wall = 0;               left = j;               r += x - j;               x = j + 1;               g = true;               break;             } else if (a[i][j] ==  # ) {               wall++;               left = j + 1;               r += x - j;               x = j + 1;               g = true;               break;             } else if (a[i + 1][j] ==  . ) {               r += x - j + 1;               x = j;               down = true;               break;             }           }         }         if (wall == 2) {           cout <<  Never ;           return 0;         }       }     }     cout << r;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     node *l, *r, *p;     long long v, s, z, w, t, k, i;     node(long long v, long long i)         : l(0), r(0), p(0), v(v), s(1), z(0), w(0), t(v), k(1), i(i) {}   };   inline bool is_root(node *n) {     return n->p == NULL || n->p->l != n && n->p->r != n;   }   inline bool left(node *n) { return n == n->p->l; }   inline long long size(node *n) { return n ? n->s + n->z : 0; }   inline long long tot(node *n) { return n ? n->t : 0; }   inline void push(node *n) {     n->s += n->z;     n->w += n->z;     n->k += 2 * n->z * (n->s - n->w);     if (n->l) n->l->z += n->z;     if (n->r) n->r->z += n->z;     n->z = 0;   }   inline void update(node *n) {     push(n);     n->t = tot(n->l) + tot(n->r) + n->v * (n->s - n->w);   }   inline void connect(node *n, node *p, bool l) {     (l ? p->l : p->r) = n;     if (n) n->p = p;   }   inline void rotate(node *n) {     node *p = n->p, *g = p->p;     bool l = left(n);     connect(l ? n->r : n->l, p, l);     if (!is_root(p))       connect(n, g, left(p));     else       n->p = g;     connect(p, n, !l);     update(p), update(n);   }   inline void splay(node *n) {     while (!is_root(n)) {       node *p = n->p, *g = p->p;       if (!is_root(p)) push(g);       push(p), push(n);       if (!is_root(p)) rotate(left(n) ^ left(p) ? n : p);       rotate(n);     }     push(n);   }   inline node *find_root(node *n) {     if (n == NULL) return NULL;     while (n->l) {       push(n);       n = n->l;     }     return n;   }   inline node *expose(node *n) {     node *last = NULL;     for (node *m = n; m; m = m->p) {       splay(m);       m->w = size(find_root(last));       m->r = last;       last = m;       update(m);     }     splay(n);     return last;   }   void link(node *m, node *n) {     expose(m), expose(n);     m->p = n;     n->z += size(m);   }   void cut(node *n) {     expose(n);     n->l->z -= size(n);     n->l->p = NULL;     n->l = NULL;   }   node *lca(node *m, node *n) {     expose(m);     return expose(n);   }   const int MAXN = 50005;   long long N, M, P[MAXN], A, B, ans;   char C;   node *V[MAXN];   int main() {     cin >> N;     cout << fixed << setprecision(9);     for (int i = 1; i < N; i++) {       cin >> P[i];       P[i]--;     }     for (int i = 0; i < N; i++) {       int v;       cin >> v;       V[i] = new node(v, i);       ans += v;     }     for (int i = 1; i < N; i++) {       link(V[i], V[P[i]]);       ans += 2 * tot(V[P[i]]) * size(V[i]);     }     cout << 1.0 * ans / N / N <<   n ;     cin >> M;     while (M--) {       cin >> C >> A >> B;       if (C ==  P ) {         node *v = V[A - 1], *u = V[B - 1];         if (lca(u, v) == v) swap(u, v);         expose(v);         ans -= 2 * tot(v->l) * size(v);         cut(v);         link(v, u);         ans += 2 * tot(u) * size(v);       } else {         node *v = V[A - 1];         expose(v);         update(v);         ans += (B - v->v) * v->k;         v->v = B;       }       cout << 1.0 * ans / N / N <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   constexpr int N = 3e3;   uint16_t a[N], lst[N], nxt[N], cnxt[20], dp[N][N];   int main() {     cin.tie(0), ios::sync_with_stdio(0);     int t, n;     cin >> t;     while (t--) {       cin >> n;       for (int i = 0; i < n; ++i) {         cin >> a[i], --a[i];       }       memset(lst, 0, n * sizeof *lst);       for (int i = 0; i < n; ++i) {         ++lst[a[i]];       }       int w = -1, r = 0, purged = 0;       while (r < n) {         if (w >= 0 && a[w] == a[r]) {           if (--lst[a[r++]] == 1) {             --w;             ++purged;           }         } else if (lst[a[r]] == 1) {           ++r;           ++purged;         } else {           a[++w] = a[r++];         }       }       memset(lst, -1, n * sizeof *lst);       n = w + 1;       memset(nxt, 127, n * sizeof *nxt);       for (int i = 0; i < n; ++i) {         if (lst[a[i]] != (uint16_t)-1) {           nxt[lst[a[i]]] = i;         }         lst[a[i]] = i;       }       for (int i = n - 1; i > -1; --i) {         auto* cnxte = cnxt;         for (int z = nxt[i]; z < n; z = nxt[z]) {           *cnxte++ = z;         }         *cnxte = n;         cnxte = cnxt;         for (int j = i + 1; j < n; ++j) {           if (a[j] == a[i]) {             ++cnxte;           }           int t = dp[i + 1][j] - 1;   #pragma GCC unroll 20           for (const auto* z = cnxt; z < cnxte; ++z) {             t = max(t, dp[i + 1][*z - 1] + dp[*z][j]);           }           dp[i][j] = t + 1;         }       }       cout << (n ? n - dp[0][n - 1] : 0) - 1 + purged <<   n ;       ;     }   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> seg[2100000], lazy[2100000];   pair<int, int> Merge(pair<int, int> l, pair<int, int> r) {     if (l < r)       return l;     else       return r;   }   void Propagate(int n, int l, int r) {     if (lazy[n] != make_pair(0x3f3f3f3f, 0)) {       if (l != r) {         lazy[n << 1] = Merge(lazy[n << 1], lazy[n]);         lazy[n << 1 | 1] = Merge(lazy[n << 1 | 1], lazy[n]);       }       seg[n] = Merge(seg[n], lazy[n]);       lazy[n] = make_pair(0x3f3f3f3f, 0);     }   }   pair<int, int> Update(int L, int R, pair<int, int> val, int n, int l, int r) {     Propagate(n, l, r);     if (r < L || R < l) return seg[n];     if (L <= l && r <= R) {       lazy[n] = Merge(lazy[n], val);       Propagate(n, l, r);       return seg[n];     }     int mid = l + r >> 1;     return seg[n] = Merge(Update(L, R, val, n << 1, l, mid),                           Update(L, R, val, n << 1 | 1, mid + 1, r));   }   pair<int, int> Query(int L, int R, int n, int l, int r) {     Propagate(n, l, r);     if (r < L || R < l) return make_pair(0x3f3f3f3f, 0);     if (L <= l && r <= R) return seg[n];     int mid = l + r >> 1;     return Merge(Query(L, R, n << 1, l, mid),                  Query(L, R, n << 1 | 1, mid + 1, r));   }   int N, M;   vector<pair<int, int> > v[300001];   pair<int, int> dp[300001];   int main() {     for (int i = 0; i < 2100000; i++) seg[i] = lazy[i] = make_pair(0x3f3f3f3f, 0);     ios::sync_with_stdio(0);     cin.tie(0);     cin.exceptions(ios::badbit | ios::failbit);     cin >> N >> M;     vector<int> com;     for (int i = 1; i <= M; i++) {       int n, l, r;       cin >> n >> l >> r;       r++;       v[n].push_back({l, r});       com.push_back(l);       com.push_back(r);     }     sort(com.begin(), com.end());     com.erase(unique(com.begin(), com.end()), com.end());     for (int i = 1; i <= N; i++)       for (auto &[l, r] : v[i]) {         l = lower_bound(com.begin(), com.end(), l) - com.begin();         r = lower_bound(com.begin(), com.end(), r) - com.begin();       }     for (int i = 1; i <= N; i++) {       dp[i] = {i - 1, 0};       for (auto [l, r] : v[i]) {         auto it = Query(l, r - 1, 1, 0, (int)com.size() - 1);         dp[i] = min(dp[i], make_pair(it.first + i, it.second));       }       for (auto [l, r] : v[i]) {         Update(l, r - 1, make_pair(dp[i].first - i - 1, i), 1, 0,                (int)com.size() - 1);       }     }     int res = 0x3f3f3f3f, n = 0;     for (int i = 1; i <= N; i++) {       int val = dp[i].first + (N - i);       if (res > val) res = val, n = i;     }     set<int> s;     for (int i = 1; i <= N; i++) s.insert(i);     while (n) {       s.erase(n);       n = dp[n].second;     }     cout << res <<   n ;     if (res) {       for (int i : s) cout << i <<    ;       cout <<   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 n, x;     cin >> n >> x;     long long count = 0;     if (n >= x) {       for (long long i = 1; i < n + 1; i++) {         if (x % i == 0) {           count++;         }       }     } else {       for (long long i = 2; i < n + 1; i++) {         if (x % i == 0 && ((x / i) <= n)) {           count++;         }       }     }     cout << count;   }
#include <bits/stdc++.h>   using namespace std;   void show_trace() { cout << endl; }   template <typename Start, typename... Rem>   void show_trace(Start S, Rem... R) {     cout <<     << S;     show_trace(R...);   }   const int INFi = 2139062143;   const long long INF = 1e18;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     string s, t;     cin >> s >> t;     int ct1 = count(s.begin(), s.end(),  a ) + count(t.begin(), t.end(),  a );     int ct2 = count(s.begin(), s.end(),  b ) + count(t.begin(), t.end(),  b );     if (ct1 % 2 != 0 || ct2 % 2 != 0) {       cout << -1 <<   n ;       return 0;     }     vector<int> ab, ba;     for (int i = 0; i < n; i++) {       if (s[i] == t[i]) continue;       if (s[i] ==  a  && t[i] ==  b )         ab.push_back(i);       else         ba.push_back(i);     }     int sz1 = ab.size();     int sz2 = ba.size();     vector<pair<int, int> > ans;     for (int i = 1; i < sz1 - (sz1 % 2); i += 2) {       ans.push_back({ab[i], ab[i - 1]});     }     for (int i = 1; i < sz2 - (sz2 % 2); i += 2) {       ans.push_back({ba[i], ba[i - 1]});     }     assert(sz1 % 2 == sz2 % 2);     if (sz1 % 2) {       ans.push_back({ab[sz1 - 1], ab[sz1 - 1]});       ans.push_back({ab[sz1 - 1], ba[sz2 - 1]});     }     cout << ans.size() <<   n ;     for (auto [x, y] : ans) cout << x + 1 <<     << y + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     string s;     cin >> s;     vector<string> all;     for (long long i = 0; i <= 9; i++) {       all.push_back(s);       for (char &c : s)         if (c ==  9 )           c =  0 ;         else           c++;     }     string ans = s;     for (string &x : all) {       for (long long i = 0; i < n; i++) {         string y = x;         rotate(y.begin(), y.begin() + y.size() - i, y.end());         ans = min(y, ans);       }     }     cout << ans <<   n ;   }   void solve(bool testcase) {     long long t;     cin >> t;     while (t--) solve();   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double a[100009][2];   long double maxi(long double a, long double b) {     if (a > b)       return a;     else       return b;   }   bool solve(long double mid, int n, long double p) {     long double req = 0;     for (int i = 0; i < n; i++) {       req += maxi(0.00, mid * a[i][0] - a[i][1]);     }     if (req > mid * p)       return false;     else       return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long double n, p, sum = 0, count = 0, m, flag = 0, ans = 0, k;     cin >> n >> p;     long double l = 0, r = 1e10;     for (int i = 0; i < n; i++) {       cin >> a[i][0] >> a[i][1];     }     while (flag < 1000) {       long double m = (l + r) / 2;       if (solve(m, n, p))         ans = m, l = m;       else         r = m;       flag++;     }     if (ans >= 1e10) {       cout << -1;       return 0;     }     cout << setprecision(8) << ans;     return 0;   }