malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   namespace WorkSpace {   const double pi = acos(-1.0);   int N;   double r, v;   bool Check(double mid, double l) {     double len = 2 * pi * r;     double ang = mid / len * 2 * pi;     double A = r - r * (cos(ang));     double B = r * sin(ang);     return sqrt(A * A + B * B) + mid > l;   }   void Deal(double s, double t) {     double l = 0, r = t - s;     double mid;     int Cnt = 0;     while (Cnt <= 40) {       ++Cnt;       mid = (l + r) / 2;       if (Check(mid, t - s))         r = mid;       else         l = mid;     }     printf( %.10lf n , l / v);   }   void Main() {     scanf( %d%lf%lf , &N, &r, &v);     while (N--) {       double s, t;       scanf( %lf%lf , &s, &t);       Deal(s, t);     }     return;   }   }  // namespace WorkSpace   int main() { WorkSpace ::Main(); }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 9;   string s;   long long t, h, ans = 1e10;   long long n;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     cin >> s;     for (int i = 0; i < (n); i++) {       if (s[i] ==  T )         t++;       else         h++;     }     for (int i = 0; i < (n); i++) {       long long cur = i, res = 0;       for (int j = 0; j < (t); j++) {         if (s[cur] !=  T ) res++;         cur = (cur + 1) % n;       }       ans = min(ans, res);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, flag = 1;     char ch = 0;     while (!isdigit(ch)) {       ch = getchar();       if (ch ==  - ) flag = -1;     }     while (isdigit(ch)) {       x = (x << 3) + (x << 1) + ch -  0 ;       ch = getchar();     }     return x * flag;   }   const long long mo = 1e9 + 7;   long long x, y, fac[110000];   long long exgcd(long long a, long long b) {     if (!b) {       x = 1;       y = 0;       return a;     }     long long d = exgcd(b, a % b);     long long t = x;     x = y;     y = t - (a / b) * y;     return d;   }   long long f(long long o) {     exgcd(o, mo);     return (x % mo + mo) % mo;   }   long long c(long long a, long long b) {     long long up = fac[a];     long long down = (fac[b] * fac[a - b]) % mo;     return (up * f(down)) % mo;   }   long long a[110000];   bool vis[110000];   int main() {     long long n, k = 0, t = 0, i, x, ans = 0;     n = read();     for (i = 1, fac[0] = 1; i <= n; i++) {       fac[i] = (fac[i - 1] * i) % mo;       a[i] = read();       if (a[i] != -1) {         vis[a[i]] = 1;         if (a[i] == i) {           printf( 0 );           return 0;         }       }     }     for (i = 1; i <= n; i++) k += (a[i] == -1 && !vis[i]), t += (a[i] == -1);     for (i = 0; i <= k; i++) {       x = (c(k, i) * fac[t - i]) % mo;       if (i & 1)         ans = ((ans - x) % mo + mo) % mo;       else         ans = (ans + x) % mo;     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       if (n == 1) {         cout << 0 <<   n ;         continue;       }       long long int ans = 0;       while (n != 1) {         ans++;         if (n % 2 == 0) {           n = n / 2;         } else if (n % 3 == 0) {           n = 2 * n / 3;         } else if (n % 5 == 0) {           n = 4 * n / 5;         } else {           ans = -1;           break;         }       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   const long long llinf = 1e18 + 7;   const double eps = 1e-15;   const int mod = 1e9 + 7;   int main() {     ios::sync_with_stdio(false);     int n, a[100001], k;     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     int i = n;     while (i > 0 && a[n] == a[i]) i--;     if (i >= k)       cout << -1;     else       cout << i;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[200000 + 5];   vector<int> g[200000 + 5];   int cnt = 0;   void dfs(int x, int fa) {     cnt++;     if (cnt > n) return;     printf( %d  , x);     for (int i = 0; i < g[x].size(); i++) {       int y = g[x][i];       if (y == fa) continue;       dfs(y, x);     }   }   int main() {     scanf( %d , &n);     int xx, yy;     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d , &x), scanf( %d , &y);       if (i == 1) xx = x, yy = y;       g[y].push_back(x), g[x].push_back(y);     }     if (g[1][0] != xx && g[1][0] != yy) swap(g[1][0], g[1][1]);     dfs(1, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (a == 0)       return b;     else       return gcd(b % a, a);   }   long long int lcm(long long int a, long long int b) {     return (a * b) / gcd(a, b);   }   long long int fact(long long int n) {     if (n == 0)       return 1;     else       return n * fact(n - 1);   }   void solve(long long int t) {     long long int n, k;     cin >> n >> k;     long long int x = n / 2;     long long int rem = k - (x - 1);     if (n == 1) {       if (k == 0) {         cout <<  1 ;         return;       } else {         cout <<  -1 ;         return;       }     } else if (n == 2) {       if (k == 0) {         cout <<  -1 ;       } else {         cout << k <<     << k * 2;       }       return;     }     if (rem <= 0) {       cout <<  -1 ;       return;     }     cout << rem <<     << rem * 2 <<    ;     long long int c = 1;     for (long long int i = 1; i < x; i++) {       while (c == rem || c + 1 == rem || c == rem * 2 || c + 1 == rem * 2) {         c += 1;       }       cout << c <<     << c + 1 <<    ;       c += 2;       while (c == rem || c + 1 == rem || c == rem * 2 || c + 1 == rem * 2) {         c += 1;       }     }     if (n % 2 != 0) cout << c;   }   int main() {     cin.tie(0);     ios::sync_with_stdio(0);     cout.tie(0);     long long int T = 1;     for (long long int t = 1; t <= T; t++) {       solve(t);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100000];   int b[100000];   bool judge(long long x, int n, long long k) {     for (int i = 0; i < n; ++i) {       k -= max(0LL, a[i] * x - b[i]);       if (k < 0) {         return false;       }     }     return true;   }   int main(void) {     int n, k;     assert(scanf( %d%d , &n, &k) == 2);     for (int i = 0; i < n; ++i) {       assert(scanf( %d , &a[i]) == 1);     }     for (int i = 0; i < n; ++i) {       assert(scanf( %d , &b[i]) == 1);     }     long long l = 0, r = 2000000001;     while (r - l > 1) {       long long m = (l + r) / 2;       if (judge(m, n, k)) {         l = m;       } else {         r = m;       }     }     printf( %I64d n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long mod(long long n, long long m) {     long long ret = n % m;     if (ret < 0) ret += m;     return ret;   }   long long gcd(long long a, long long b) {     return (b == 0LL ? a : gcd(b, a % b));   }   long long exp(long long a, long long b, long long m) {     if (b == 0LL) return 1LL;     if (b == 1LL) return mod(a, m);     long long k = mod(exp(a, b / 2, m), m);     if (b & 1LL) {       return mod(a * mod(k * k, m), m);     } else       return mod(k * k, m);   }   const int N = 100100;   int mat[N][2][2];   void solve(vector<set<pair<int, int>>>& vs) {     if ((int)vs[0].size() == 1) return;     vector<int> big(4, -1e9);     set<pair<int, int>>::iterator it[4];     for (int j = 0; j < 4; j++) {       it[j] = vs[j].begin();     }     int here = -1;     int op = 0;     for (; it[0] != vs[0].end();) {       op++;       for (int j = 0; j < 4; j++) {         if (j >= 2) {           big[j] = max(big[j], -mat[it[j]->second][0][j & 1]);           it[j]++;         } else {           big[j] = max(big[j], mat[it[j]->second][1][j & 1]);           it[j]++;         }       }       if (it[0] == vs[0].end()) break;       for (int j = 0; j < 4; j++) {         if (j >= 2) {           if (it[j]->first >= big[j]) {             here = j;             break;           }         } else {           if (big[j] <= it[j]->first) {             here = j;             break;           }         }       }       if (here != -1) break;     }     if (here == -1) {       cout <<  NO             <<   n ;       exit(0);     }     vector<set<pair<int, int>>> novo(4, set<pair<int, int>>());     set<pair<int, int>>::iterator it2 = vs[here].begin();     vector<int> ids;     while (it2 != it[here]) {       int id = it2->second;       it2++;       for (int j = 0; j < 4; j++) {         if (j < 2) {           novo[j].insert(pair<int, int>(mat[id][j >> 1][j & 1], id));           vs[j].erase(pair<int, int>(mat[id][j >> 1][j & 1], id));         } else {           novo[j].insert(pair<int, int>(-mat[id][j >> 1][j & 1], id));           vs[j].erase(pair<int, int>(-mat[id][j >> 1][j & 1], id));         }       }     }     solve(novo);     solve(vs);   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       for (int j = 0; j < 2; j++) {         for (int k = 0; k < 2; k++) {           cin >> mat[i][j][k];         }       }     }     vector<set<pair<int, int>>> vs(4, set<pair<int, int>>());     for (int j = 0; j < 4; j++) {       for (int i = 1; i <= n; i++) {         if (j < 2)           vs[j].insert(pair<int, int>(mat[i][j >> 1][j & 1], i));         else           vs[j].insert(pair<int, int>(-mat[i][j >> 1][j & 1], i));       }     }     solve(vs);     cout <<  YES           <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long int t;     t = 1;     while (t--) {       long long int n, i, j, k;       cin >> n;       map<long long int, long long int> m;       vector<long long int> a, b;       for (i = 0; i < n; i++) {         cin >> j;         a.push_back(j);       }       for (i = 0; i < n; i++) {         cin >> j;         b.push_back(j);       }       for (i = 0; i < n; i++) {         m[a[i]] = b[i];       }       for (i = 1; i < n + 1; i++) cout << m[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxi = 3e6;   vector<int> ans;   int a[maxi];   int cnt[maxi];   int c[maxi];   void solve() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       c[i] = 0;       cnt[i] = 0;     }     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       c[x]++;     }     for (int i = 1; i <= n; i++)       if (c[i]) cnt[c[i]]++;     for (int i = 1; i <= n; i++) cnt[i] += cnt[i - 1];     int ans = n;     for (int i = 2; i <= n; i++) {       int rez = 0;       int ima = 0;       for (int j = 1; j <= n / i + 1; j++) {         int first = max((j - 1) * i + 1, (i - 1) * j);         int sc = min(n, i * j);         if (first > sc) continue;         rez += j * (cnt[sc] - cnt[first - 1]);         ima += cnt[sc] - cnt[first - 1];       }       if (ima == cnt[n]) ans = min(ans, rez);     }     printf( %d n , ans);   }   int main() {     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 5;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = res * x;       y = y >> 1;       x = x * x;     }     return res;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long a[n];       for (long long i = 0; i < n; i++) cin >> a[i];       set<long long> s;       bool f = 1;       if (k == 1) {         cout <<  YES  <<   n ;         continue;       }       for (long long i = 0; i < n; i++) {         if (a[i] == 0) continue;         long long temp = a[i];         while (temp > 0) {           for (long long j = 0; j < 1e5; j++) {             if (temp < power(k, j)) {               temp -= power(k, j - 1);               if (s.count(j - 1)) {                 f = 0;                 break;               } else {                 s.insert(j - 1);               }               break;             }           }         }         if (f == 0 || temp != 0) {           f = 0;           break;         }       }       cout << (f == 0 ?  NO  :  YES ) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 7;   const long long INF = 1LL << 60;   const long long mod = 1e9 + 7;   const long double eps = 1e-8;   const long double pi = acos(-1.0);   template <class T>   inline bool chmax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <class T>   inline bool chmin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   long long f(long long l, long long p) {     long long w = l / p;     long long p2 = l % p, p1 = p - p2;     return p1 * w * w + p2 * (w + 1) * (w + 1);   }   void solve() {     long long n, k;     cin >> n >> k;     vector<long long> a(n);     long long ans = 0;     priority_queue<pair<long long, pair<long long, long long>>> pque;     for (long long i = 0; i < n; i++) {       cin >> a[i];       ans += a[i] * a[i];       pque.push({f(a[i], 1) - f(a[i], 2), {a[i], 2}});     }     for (long long i = 0; i < k - n; i++) {       auto x = pque.top();       pque.pop();       ans -= x.first;       long long l = x.second.first, p = x.second.second;       pque.push({f(l, p) - f(l, p + 1), {l, p + 1}});     }     cout << ans << endl;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     solve();     return 0;   }
#include <stdio.h>   #include <stdlib.h>   #define N 200000   #define Q 100000   #define N_ ((N + Q * 2) * (LG + 1))   #define LG 20   #define B (1 << LG)   int ll[1 + N_], rr[1 + N_], sz[1 + N_], msk0[1 + N_], msk1[1 + N_], lz[1 + N_], _ = 1;   void put(int u, int lg, int x) {int tmp, x0, x1;if (u == 0)return;if ((x & 1 << lg - 1) != 0)tmp = ll[u], ll[u] = rr[u], rr[u] = tmp;    x0 = msk0[u] & ~x | msk1[u] & x, x1 = msk1[u] & ~x | msk0[u] & x;msk0[u] = x0, msk1[u] = x1;lz[u] ^= x;}   void pus(int u, int lg) {if (lz[u])put(ll[u], lg - 1, lz[u]), put(rr[u], lg - 1, lz[u]), lz[u] = 0;}   void pul(int u) {int l = ll[u], r = rr[u];sz[u] = sz[l] + sz[r], msk0[u] = msk0[l] | msk0[r], msk1[u] = msk1[l] | msk1[r];}   int add(int u, int lg, int a) {if (u == 0)u = _++;if (lg == 0)sz[u] = 1, msk0[u] = a ^ B - 1, msk1[u] = a;    else {if ((a & 1 << lg - 1) == 0)ll[u] = add(ll[u], lg - 1, a);else rr[u] = add(rr[u], lg - 1, a);pul(u);}return u;}   void split(int *u, int *v, int lg, int l, int r, int ql, int qr) {    int m;       if (qr <= l || r <= ql || *u == 0) {     *v = 0;     return;    }    if (ql <= l && r <= qr) {     *v = *u, *u = 0;     return;    }    pus(*u, lg), *v = _++;    m = (l + r) / 2;    split(&ll[*u], &ll[*v], lg - 1, l, m, ql, qr), split(&rr[*u], &rr[*v], lg - 1, m, r, ql, qr);    pul(*u), pul(*v);   }      void merge(int *u, int *v, int lg) {if (*u == 0) {*u = *v;return;}if (*v == 0 || lg == 0)return;pus(*u, lg), pus(*v, lg);merge(&ll[*u], &ll[*v], lg - 1), merge(&rr[*u], &rr[*v], lg - 1);pul(*u);}   void update_or(int u, int lg, int x) {    if (u == 0)     return;    if ((x & msk0[u] & msk1[u]) == 0) {     put(u, lg, x & msk0[u]);     return;    }    pus(u, lg);    if ((x & 1 << lg - 1) != 0)     put(ll[u], lg - 1, 1 << lg - 1), merge(&rr[u], &ll[u], lg - 1), ll[u] = 0;    update_or(ll[u], lg - 1, x), update_or(rr[u], lg - 1, x);    pul(u);   }      int query(int u, int lg, int l, int r, int ql, int qr) {    int m;       if (qr <= l || r <= ql || u == 0)     return 0;    if (ql <= l && r <= qr)     return sz[u];    pus(u, lg);    m = (l + r) / 2;    return query(ll[u], lg - 1, l, m, ql, qr) + query(rr[u], lg - 1, m, r, ql, qr);   }      int main() {    int n, q, i, u;       scanf( %d%d , &n, &q);    u = 0;    for (i = 0; i < n; i++) {     int a;        scanf( %d , &a);     u = add(u, LG, a);    }    while (q--) {     int type, l, r;        scanf( %d%d%d , &type, &l, &r), r++;     if (type != 4) {      int x, v;         scanf( %d , &x);      split(&u, &v, LG, 0, B, l, r);      if (type == 1)       put(v, LG, B - 1), update_or(v, LG, x ^ B - 1), put(v, LG, B - 1);      else if (type == 2)       update_or(v, LG, x);      else       put(v, LG, x);      merge(&u, &v, LG);     } else      printf( %d n , query(u, LG, 0, B, l, r));    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   long long fpo(long long x, long long y);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int t;     cin >> t;     while (t--) {       int n;       char s[1000];       cin >> n >> s;       if (n > 2) {         cout <<  YES               <<   n ;         cout << 2 <<   n ;         cout << s[0] <<    ;         for (int i = 1; i < n; i++) {           cout << s[i];         }       } else {         if (s[0] < s[1]) {           cout <<  YES                 <<   n ;           cout << 2 <<   n ;           cout << s[0] <<     << s[1];         } else           cout <<  NO                 <<    ;       }       cout <<               <<   n ;     }     return 0;   }   long long fpo(long long x, long long y) {     if (y == 0)       return 1;     else {       long long tem = fpo(x, y / 2);       if (y % 2 == 0)         return (tem * tem) % mod;       else         return (((tem * tem) % mod) * x) % mod;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, f = 0, g = 0;       cin >> n;       long long int a[n + 1];       vector<long long int> v;       for (long long int i = 0; i < n; i++) {         cin >> a[i];         if (a[i] == 1 and g == 0)           f++;         else           g++;       }       if (g == 0) {         if (f % 2)           cout <<  First n ;         else           cout <<  Second n ;       } else {         if (f % 2)           cout <<  Second n ;         else           cout <<  First n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long a[3], d, ans = 0;     cin >> a[0] >> a[1] >> a[2] >> d;     sort(a, a + 3);     if (a[1] - a[0] < d) ans += (d - (a[1] - a[0]));     if (a[2] - a[1] < d) ans += (d - (a[2] - a[1]));     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int Ask(string s) {     cout << s <<   n ;     cout.flush();     int diff;     cin >> diff;     if (diff == 0) exit(0);     return diff;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( input.txt ,  r )) {       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);     }     int n = Ask( b ) + 1;     if (n > 300) {       string s =   ;       for (int i = 1; i < (int)n; ++i) s +=  a ;       Ask(s);     }     string s =   ;     for (int i = 1; i <= (int)n; ++i) s +=  b ;     int cur = Ask(s);     if (cur == n) {       s =   ;       for (int i = 1; i < (int)n; ++i) s +=  a ;       int ok = Ask(s);       assert(ok == 0);       return 0;     }     string ans = s;     for (int pos = 0; pos < (int)n; ++pos) {       s = ans;       s[pos] =  a ;       int tmp = Ask(s);       if (tmp < cur) ans[pos] =  a , cur = tmp;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct elem {     int le, num, ri;     elem() {}     elem(int inle, int innum, int inri) {       le = inle;       num = innum;       ri = inri;     }   };   elem operator+(elem e1, elem e2) {     return elem(e1.le, e1.num + e2.num + (e1.ri and e2.le ? 1 : 0), e2.ri);   }   vector<elem> genera(int n) {     vector<elem> v;     for (int i = 0; i + i <= n; i++) v.push_back(elem(0, i, 0));     for (int i = 0; i + i + 1 <= n; i++) {       v.push_back(elem(0, i, 1));       v.push_back(elem(1, i, 0));     }     for (int i = 0; i + i + 2 <= n; i++) v.push_back(elem(1, i, 1));     return v;   }   bool puede(elem e1, elem e2, int k, int x) {     for (int i = 3; i <= k; i++) {       elem nexte1 = e2;       elem nexte2 = e1 + e2;       e1 = nexte1;       e2 = nexte2;       if (e2.num > x) return false;     }     return e2.num == x;   }   void escribe(elem e, int n) {     if (e.le) cout <<  C ;     for (int i = 0; i < e.num; i++) cout <<  AC ;     for (int i = e.le + e.ri + 2 * e.num; i < n; i++) cout <<  B ;     if (e.ri) cout <<  A ;     cout << endl;   }   int main() {     int k, x, n, m;     cin >> k >> x >> n >> m;     vector<elem> v1 = genera(n);     vector<elem> v2 = genera(m);     for (int i = 0; i < int(v1.size()); i++) {       for (int j = 0; j < int(v2.size()); j++) {         if (puede(v1[i], v2[j], k, x)) {           escribe(v1[i], n);           escribe(v2[j], m);           exit(0);         }       }     }     cout <<  Happy new year!  << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct rec {     long long w, h, c;   } a[200010] = {0};   int n;   long long ans;   vector<long long> p, sum;   double ABS_dec(double x1, double x2) {     if (x1 < x2) return x2 - x1;     return x1 - x2;   }   void quick_sort(struct rec a[], long h, long e) {     long i = h, j = e;     struct rec val;     val = a[(h + e) / 2];     a[(h + e) / 2] = a[h];     do {       while (i < j && ((val.w < a[j].w) || (val.w == a[j].w && val.h < a[j].h)))         j--;       if (i < j) a[i++] = a[j];       while (i < j && ((val.w > a[i].w) || (val.w == a[i].w && val.h > a[i].h)))         i++;       if (i < j) a[j--] = a[i];     } while (i < j);     a[i] = val;     if (i - 1 > h) quick_sort(a, h, i - 1);     if (i + 1 < e) quick_sort(a, i + 1, e);   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   void DFS(int i, long long k, long long gh) {     if (i < p.size()) {       int j;       DFS(i + 1, k, gh);       for (j = 1; j <= sum[i]; j++) {         k *= p[i];         DFS(i + 1, k, gh);       }     } else {       k = a[1].c / k;       if (gh % k == 0) ans++;     }   }   bool Is_valid() {     long long i, j, q;     long long gw, gh, k;     double tmp;     gw = gh = a[1].c;     ans = 0;     for (i = 2; i <= n; i++) {       if (a[i].w != a[i - 1].w)         break;       else         gw = gcd(gw, a[i].c);     }     if (i <= n) {       q = i - 1;       if (n % q) return false;       i = 1;       while (i + q <= n) {         if (a[i].w == a[i + q].w || a[i].h != a[i + q].h) return false;         gh = gcd(gh, a[i + q].c);         for (j = i + 1; j < i + q; j++) {           if (a[j + q].w != a[j + q - 1].w) return false;           if (a[j + q].h != a[j].h) return false;           if (ABS_dec((double)a[j].c / a[j - 1].c,                       (double)a[j + q].c / a[j + q - 1].c) > 0.0000001)             return false;         }         i += q;       }     }     k = gw;     for (i = 2; i <= sqrt(k); i++)       if (k % i == 0) {         p.push_back(i);         sum.push_back(0);         while (k % i == 0) k /= i, sum[sum.size() - 1]++;       }     if (k > 1) p.push_back(k), sum.push_back(1);     DFS(0, 1, gh);     return true;   }   int main() {     int i, j, k;     bool isYES = true;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %I64d %I64d %I64d , &a[i].w, &a[i].h, &a[i].c);     }     quick_sort(a, 1, n);     Is_valid();     printf( %I64d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, t, k, x[(int)1e6], i;   int main() {     cin >> n;     for (i = 0; i < n; i++) cin >> x[i];     sort(x, x + n), n = unique(x, x + n) - x;     cin >> a >> b;     while (a > b) {       k = a - 1;       for (i = 0; i < n; i++)         if (a - a % x[i] < b)           x[i] = x[n - 1], n--, i--;         else           k = min(k, a - a % x[i]);       a = k, t++;     }     cout << t;   }