malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int f[100005];   int g[100005];   int h[1000005];   int v[100005];   int main() {     int n, m = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &f[i]);     }     for (int i = 1; i <= n; i++) {       if (v[i] == 0) {         if (f[i] == i) {           m++;           h[m] = i;           v[i] = m;           g[i] = m;         } else {           if (v[f[i]] == 0) {             if (f[f[i]] == f[i]) {               m++;               h[m] = f[i];               v[f[i]] = m;               g[f[i]] = m;               g[i] = m;             } else {               puts( -1 );               return 0;             }           } else {             g[i] = v[f[i]];           }         }       }     }     printf( %d n , m);     for (int i = 1; i <= n; i++) {       printf( %d  , g[i]);     }     puts(  );     for (int i = 1; i <= m; i++) {       printf( %d  , h[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   int a[MAXN], b[MAXN], c[MAXN];   int tb[MAXN];   int d, n;   long long x;   long long getNextX() {     x = (x * 37 + 10007) % 1000000007;     return x;   }   void initAB() {     for (int i = 0; i < n; i = i + 1) {       a[i] = i + 1;     }     for (int i = 0; i < n; i = i + 1) {       swap(a[i], a[getNextX() % (i + 1)]);     }     for (int i = 0; i < n; i = i + 1) {       if (i < d)         b[i] = 1;       else         b[i] = 0;     }     for (int i = 0; i < n; i = i + 1) {       swap(b[i], b[getNextX() % (i + 1)]);     }   }   struct node {     int p, num;     bool operator<(const node &t) const { return num > t.num; }   };   node nd[MAXN];   int main() {     while (cin >> n >> d >> x) {       initAB();       int cnt = 10000000;       for (int i = 0; i < n; i++) {         nd[i].num = a[i];         nd[i].p = i;       }       sort(nd, nd + n);       int l = 0;       for (int i = 0; i < n; i++) {         if (b[i] == 1) {           tb[l++] = i;         }       }       memset(c, -1, sizeof(c));       for (int i = 0; i < n; i++) {         int p = nd[i].p;         for (int j = 0; j < l && cnt > 0; j++) {           if (p + tb[j] < n && c[p + tb[j]] == -1) {             c[p + tb[j]] = a[p];           }           cnt--;         }       }       for (int i = 0; i < n; i++) {         if (c[i] == -1) {           c[i] = 0;           for (int j = 0; j < l && i - tb[j] >= 0; j++) {             c[i] = max(c[i], a[i - tb[j]] * b[tb[j]]);           }         }         printf( %d n , c[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       string s;       cin >> s;       long long int i = 0;       string ans = s;       string w;       string temp;       long long int k = 1;       while (i != n) {         if ((n - i) % 2 == 0) {           w = s.substr(i, n - i) + s.substr(0, i);         } else {           temp = s.substr(0, i);           reverse(temp.begin(), temp.end());           w = s.substr(i, n - i) + temp;         }         if (w.compare(ans) < 0) {           ans = w;           k = i + 1;         }         i += 1;       }       cout << ans << endl;       cout << k << endl;     }     return 0;   }
#include <bits/stdc++.h>   const double PI = acos(-1.0);   const double EPS = 1e-9;   using namespace std;   template <typename F, typename S>   ostream &operator<<(ostream &os, const pair<F, S> &p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  { ;     typename vector<T>::const_iterator it;     for (it = v.begin(); it != v.end(); it++) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  } ;   }   template <typename T>   ostream &operator<<(ostream &os, const set<T> &v) {     os <<  [ ;     typename set<T>::const_iterator it;     for (it = v.begin(); it != v.end(); it++) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  ] ;   }   template <typename F, typename S>   ostream &operator<<(ostream &os, const map<F, S> &v) {     os <<  [ ;     typename map<F, S>::const_iterator it;     for (it = v.begin(); it != v.end(); it++) {       if (it != v.begin()) os <<  ,  ;       os << it->first <<   =   << it->second;     }     return os <<  ] ;   }   template <class T>   void deb_array(T *arr, int length) {     for (int i = 0; i < length; i++) {       cout << arr[i] <<    ;     }     cout <<   n ;   }   const int maxn = 500;   const double INF = 1e18 + 1;   double p[maxn][maxn], dp[maxn][maxn], prob[maxn][maxn];   int n, m;   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     m = 1 << n;     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= m; j++) {         cin >> p[i][j];         p[i][j] /= 100;       }     }     for (int i = 0; i <= m; i++) {       for (int j = 0; j <= m; j++) {         prob[i][j] = 1.0;       }     }     for (int i = 1; i <= n; i++) {       int k = (1 << i);       int bonus = k >> 1;       for (int j = 0; j <= m; j += k) {         int b = j;         int e = j + k;         int m = (b + e) / 2;         for (int c = j + 1; c <= m; c++) {           prob[i][c] = 0;           for (int d = m + 1; d <= e; d++) {             prob[i][c] = prob[i][c] + prob[i - 1][c] * prob[i - 1][d] * p[c][d];           }         }         for (int c = m + 1; c <= e; c++) {           prob[i][c] = 0;           for (int d = j + 1; d <= m; d++) {             prob[i][c] = prob[i][c] + prob[i - 1][c] * prob[i - 1][d] * p[c][d];           }         }         for (int c = m + 1; c <= e; c++) {           if (prob[i][c] == 0 || (dp[i - 1][c] == 0 && i != 1)) {             continue;           }           for (int d = j + 1; d <= m; d++) {             dp[i][c] =                 max(dp[i][c], dp[i - 1][c] + dp[i - 1][d] + prob[i][c] * bonus);           }         }         for (int c = j + 1; c <= m; c++) {           if (prob[i][c] == 0 || (dp[i - 1][c] == 0 && i != 1)) {             continue;           }           for (int d = m + 1; d <= e; d++) {             dp[i][c] =                 max(dp[i][c], dp[i - 1][c] + dp[i - 1][d] + prob[i][c] * bonus);           }         }       }     }     cout << fixed << setprecision(12) << *max_element(dp[n], dp[n] + m + 1)          <<   n ;     return 0;   }
#include <bits/stdc++.h>   const int INF = 200000000;   using namespace std;   int timer, lg, n;   vector<vector<int> > g;   vector<vector<int> > dp(200005);   int time_in[200005], time_out[200005], parent[200005], a[200005];   void DFS(int, int);   bool issubtree(int, int);   int lca(int, int);   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     g.resize(n + 1);     lg = log2(n + 1);     for (int k = 0; k <= n; k++) dp[k].resize(lg + 1);     for (int k = 2; k <= n; k++) {       int x;       cin >> x;       a[k] = x;       g[x].push_back(k);       g[k].push_back(x);     }     int u = 1;     int v = 2;     int dist = 1;     DFS(1, 0);     cout << 1 <<    ;     for (int k = 3; k <= n; k++) {       int lca1 = lca(u, k);       int lca2 = lca(v, k);       if (lca1 > lca2) {         if (lca1 >= dist) {           v = k;           dist = lca1;         }       } else {         if (lca2 >= dist) {           u = k;           dist = lca2;         }       }       cout << dist <<    ;     }     return 0;   }   void DFS(int v, int p) {     parent[v] = p;     dp[v][0] = p;     for (int k = 1; k <= lg; k++) dp[v][k] = dp[dp[v][k - 1]][k - 1];     time_in[v] = timer++;     for (int k = 0; k < g[v].size(); k++) {       int to = g[v][k];       if (to == p) continue;       DFS(to, v);     }     time_out[v] = timer++;   }   bool issubtree(int a, int b) {     if (time_in[a] <= time_in[b] && time_out[b] <= time_out[a]) return 1;     return 0;   }   int lca(int a, int b) {     if (issubtree(a, b)) {       int cnt = 0;       for (int k = lg; k >= 0; k--) {         if (dp[b][k] == 0) continue;         if (issubtree(dp[b][k], a)) continue;         b = dp[b][k];         cnt += pow(2, k);       }       return cnt + 1;     }     if (issubtree(b, a)) {       int cnt = 0;       for (int k = lg; k >= 0; k--) {         if (dp[a][k] == 0) continue;         if (issubtree(dp[a][k], b)) continue;         a = dp[a][k];         cnt += pow(2, k);       }       return cnt + 1;     }     int cnt = 0;     int sav = a;     for (int k = lg; k >= 0; k--) {       if (dp[a][k] == 0) continue;       if (issubtree(dp[a][k], b)) continue;       a = dp[a][k];       cnt += pow(2, k);     }     a = sav;     for (int k = lg; k >= 0; k--) {       if (dp[b][k] == 0) continue;       if (issubtree(dp[b][k], a)) continue;       b = dp[b][k];       cnt += pow(2, k);     }     return cnt + 2;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     string b;     cin >> a >> b;     while (a++) {       int i = a;       string comp =   ;       while (i > 0) {         int c = i % 10;         if (c == 4 || c == 7) {           comp = to_string(c) + comp;         }         i /= 10;       }       if (comp == b) {         cout << a;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int h1, h2;   int a, b;   int ans = 0;   int main() {     scanf( %d%d , &h1, &h2);     scanf( %d%d , &a, &b);     h1 += a * 8;     if (h1 >= h2)       printf( 0 n );     else if (h1 < h2 && b >= a)       printf( -1 n );     else if (h1 < h2 && b < a) {       int num1 = (h2 - h1) % ((a - b) * 12);       if (num1 == 0)         printf( %d n , (h2 - h1) / ((a - b) * 12));       else         printf( %d n , (h2 - h1) / ((a - b) * 12) + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma warning(disable : 4996)   class BIT {    public:     vector<int> bit;     int size_ = 0;     void init(int sz) {       size_ = sz + 2;       bit.resize(size_ + 2, 0);     }     void add(int pos, int x) {       pos++;       while (pos <= size_) {         bit[pos] += x;         pos += (pos & -pos);       }     }     int sum(int pos) {       int s = 0;       pos++;       while (pos >= 1) {         s += bit[pos];         pos -= (pos & -pos);       }       return s;     }     int searchs(int pos) {       int cl = 0, cr = size_ + 1, cm, minx = (1 << 30);       for (int i = 0; i < 22; i++) {         cm = ((cl + cr) >> 1);         int v = sum(cm);         if (v >= pos) {           minx = min(minx, cm);           cr = cm;         } else {           cl = cm;         }       }       return minx;     }   };   int N, A[1 << 18];   int Q, K[1 << 18], P[1 << 18], ans[1 << 18];   vector<pair<int, int>> rem;   vector<int> G[1 << 18];   BIT Z;   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) scanf( %d , &A[i]);     scanf( %d , &Q);     for (int i = 1; i <= Q; i++) scanf( %d%d , &K[i], &P[i]);     for (int i = 1; i <= N; i++) rem.push_back(make_pair(-A[i], i));     for (int i = 1; i <= Q; i++) G[K[i]].push_back(i);     sort(rem.begin(), rem.end());     Z.init(N + 2);     for (int i = 1; i <= N; i++) {       Z.add(rem[i - 1].second, 1);       for (int j = 0; j < G[i].size(); j++) {         int idx = G[i][j];         int val = Z.searchs(P[idx]);         ans[idx] = A[val];       }     }     for (int i = 1; i <= Q; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   inline long long rd() {     long long x = 0, w = 1;     char ch = 0;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 3) + (x << 1) + (ch ^ 48);       ch = getchar();     }     return x * w;   }   int to[N << 2], nt[N << 2], hd[N << 1], dg[N << 1], tot = 1;   void add(int x, int y) {     ++tot, to[tot] = y, nt[tot] = hd[x], hd[x] = tot, ++dg[x];     ++tot, to[tot] = x, nt[tot] = hd[y], hd[y] = tot, ++dg[y];   }   bool cs[N << 2], ban[N << 2], v[N << 1];   int n, m, a[N][2], b[N << 1];   void dfs(int x) {     v[x] = 1;     for (int &i = hd[x]; i; i = nt[i]) {       if (ban[i]) continue;       int y = to[i];       ban[i] = ban[i ^ 1] = 1, cs[i] = 1;       dfs(y);     }   }   int main() {     n = rd();     for (int i = 1; i <= n; ++i)       a[i][0] = b[i * 2 - 1] = rd(), a[i][1] = b[i * 2] = rd() + 1;     sort(b + 1, b + n + n + 1), m = unique(b + 1, b + n + n + 1) - b - 1;     for (int i = 1; i <= n; ++i) {       a[i][0] = lower_bound(b + 1, b + m + 1, a[i][0]) - b;       a[i][1] = lower_bound(b + 1, b + m + 1, a[i][1]) - b;       add(a[i][0], a[i][1]);     }     for (int i = 1, la = 0; i <= m; ++i)       if (dg[i] & 1) {         if (!la)           la = i;         else           add(la, i), la = 0;       }     for (int i = 1; i <= m; ++i)       if (!v[i]) dfs(i);     for (int i = 1; i <= n; ++i) printf( %d  , cs[i << 1]);     return 0;   }
#include <bits/stdc++.h>   int main() {     int d1, d2, d3, sum = 0;     scanf( %d%d%d , &d1, &d2, &d3);     if (d1 >= d2) {       sum += d2;     } else {       sum += d1;     }     if (d1 + d2 >= d3) {       sum += d3;     } else {       sum += d1 + d2;     }     if ((d1 >= d2) && (d1 <= d2 + d3)) {       sum += d1;     } else if ((d1 >= d2) && (d1 > d2 + d3)) {       sum += d2 + d3;     } else if ((d2 >= d1) && (d2 <= d1 + d3)) {       sum += d2;     } else {       sum += d1 + d3;     }     printf( %d , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000 * 100 + 10, mod = 1000000007;   long long a[maxn];   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int t;     t = 1;     while (t--) {       long long n;       cin >> n;       for (int i = 0; i < n; i++) {         cin >> a[i];       }       cout <<  9??>>??0  << endl;       for (int i = 0; i < 9; i++) cout << i <<  ??<>  << i + 1 << endl;       cout <<  ??<>1  << endl;       for (int i = 0; i <= 9; i++) cout <<  ?  << i <<  >>  << i <<  ?  << endl;       for (int i = 0; i < 9; i++) cout << i <<  ?<>  << i + 1 << endl;       cout <<  9?>>??0  << endl;       cout <<  >>?  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6 + 3;   const int INF = 1e9;   const int MOD = 1e9 + 7;   int main() {     long long n;     long long ans = 1;     cin >> n;     long long p = 2;     while (n > 1 && p * p <= n) {       if (n % p)         p++;       else {         n /= p;         if (ans % p) ans *= p;       }     }     if (ans % n) ans *= n;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> r1, r2, cr;   int main() {     int n, prev = 0;     cin >> n;     r1.push_back(0);     r2.push_back(0);     for (int i = 0; i < n - 1; i++) {       int w;       cin >> w;       w += prev;       prev = w;       r1.push_back(w);     }     prev = 0;     for (int i = 0; i < n - 1; i++) {       int w;       cin >> w;       w += prev;       prev = w;       r2.push_back(w);     }     for (int i = 0; i < n; i++) {       int w;       cin >> w;       cr.push_back(w);     }     int minl = cr[0] + r2[n - 1], pos = 0;     for (int i = 0; i < n; i++) {       int cal = cr[i] + r1[i] + (r2[n - 1] - r2[i]);       if (cal < minl) {         pos = i;         minl = cal;       }     }     int minl2 = 100000;     for (int i = 0; i < n; i++) {       if (i == pos) {         continue;       }       int cal = cr[i] + r1[i] + (r2[n - 1] - r2[i]);       if (cal < minl2) {         minl2 = cal;       }     }     cout << minl + minl2;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-11;   const int INFINITE = 0x3f3f3f3f;   template <class T>   inline void checkmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   inline void checkmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <class T>   inline T lowbit(T n) {     return (n ^ (n - 1)) & n;   }   template <class T>   inline int countbit(T n) {     return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));   }   typedef vector<int> VI;   typedef vector<VI> VII;   typedef vector<string> VS;   const long long MAXP = 1000000LL;   long long add(string a, string b, string c) {     if (a.size() == 0 || b.size() == 0 || c.size() == 0) return -1LL * INFINITE;     if ((a.size() > 1 && a[0] ==  0 ) || (b.size() > 1 && b[0] ==  0 ) ||         (c.size() > 1 && c[0] ==  0 ))       return -1LL * INFINITE;     if (a.size() > 7 || b.size() > 7 || c.size() > 7) return -1LL * INFINITE;     long long aa = 0;     for (int i = (int)(0); i < (int)(a.size()); i++) aa = aa * 10 + (a[i] -  0 );     if (aa > MAXP) return -1LL * INFINITE;     long long bb = 0;     for (int i = (int)(0); i < (int)(b.size()); i++) bb = bb * 10 + (b[i] -  0 );     if (bb > MAXP) return -1LL * INFINITE;     long long cc = 0;     for (int i = (int)(0); i < (int)(c.size()); i++)       cc = cc * 10LL + (c[i] -  0 );     if (cc > MAXP) return -1LL * INFINITE;     return (aa + bb + cc);   }   int main() {     ios::sync_with_stdio(false);     string s;     cin >> s;     int l = (int)s.size();     long long maxm = -1LL * INFINITE;     for (int i = (int)(0); i < (int)(l - 2); i++)       for (int j = (int)(i + 1); j < (int)(l - 1); j++) {         string a = s.substr(0, i + 1);         string b = s.substr(i + 1, j - i);         string c = s.substr(j + 1);         checkmax(maxm, add(a, b, c));       }     if (maxm == -1LL * INFINITE)       cout <<  -1 n ;     else       cout << maxm << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Kid {     int v, d;     long long p;     int id;   };   void Transform(vector<Kid>& q) {     int idx = -1;     for (int i = 0; i < q.size(); ++i) {       if (q[i].p < 0) {         idx = i;         break;       }     }     if (idx == -1) return;     for (int i = idx + 1; i < q.size(); ++i) {       q[i].p -= q[idx].d;     }     q.erase(q.begin() + idx);     Transform(q);   }   int main() {     int n;     cin >> n;     vector<Kid> q(n);     int kid = 0;     for (Kid& k : q) {       cin >> k.v >> k.d >> k.p;       k.id = kid++;     }     vector<int> ans;     while (!q.empty()) {       Kid k = q[0];       q.erase(q.begin());       assert(k.p >= 0);       ans.push_back(k.id);       for (int i = 0; i < min((int)q.size(), k.v); ++i) {         q[i].p -= (k.v - i);       }       Transform(q);     }     cout << ans.size() << endl;     for (int id : ans) {       cout << id + 1 <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 100000 + 10;   struct NODE {     long long int index;     long long int a;     bool operator<(const NODE& x) const { return a < x.a; }   } node[M];   struct SUR {     long long int index;     long long int a;     bool operator<(const SUR& x) const { return index < x.index; }   } sur[M];   int main() {     long long int n, k;     cin >> n >> k;     long long int bk = k;     long long int sum = 0;     for (int i = 0; i < n; i++) {       cin >> node[i].a;       node[i].index = i + 1;       sum += node[i].a;     }     sort(node, node + n);     if (sum < bk) {       cout <<  -1  << endl;     } else {       if (sum > bk) {         long long int p1 = 0;         vector<long long int> psum;         vector<long long int> id;         long long int pmin = 0;         while (p1 < n) {           long long int p2 = p1;           while (p2 < n && node[p2].a == node[p1].a) {             p2++;           }           p2--;           long long int value = (node[p1].a - pmin) * (n - 1 - p1 + 1);           psum.push_back(value);           id.push_back(p1);           pmin = node[p1].a;           p2++;           p1 = p2;         }         long long int tsum = 0;         int index = -1;         for (int i = 0; i < psum.size(); i++) {           if (tsum + psum[i] <= k) {             tsum += psum[i];           } else {             index = i;             break;           }         }         long long int res = k - tsum;         res = res % (n - id[index]);         int istart = 0;         for (int i = id[index]; i < n; i++) {           sur[istart].a = node[i].a;           sur[istart++].index = node[i].index;         }         sort(sur, sur + istart);         long long int lastmin = (id[index] - 1 >= 0 ? node[id[index] - 1].a : 0);         long long int div = (k - tsum) / (n - id[index]);         for (int i = 0; i < istart; i++) {           if (i < res) {             sur[i].a = sur[i].a - 1 - lastmin - div;           } else {             sur[i].a = sur[i].a - lastmin - div;           }         }         vector<int> ans;         for (int i = 0; i < istart; i++) {           if (sur[(i + res) % istart].a > 0) {             ans.push_back(sur[(i + res) % istart].index);           }         }         for (int i = 0; i < ans.size(); i++) {           cout << ans[i];           if (i < ans.size() - 1) {             cout <<    ;           } else {             cout << endl;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double p[100010];   double E[100010];   int main() {     int n;     cin >> n;     p[0] = 0;     E[0] = 0;     double ans = 0;     for (int i = 1; i <= n; ++i) {       cin >> p[i];       E[i] = (1.0 - p[i - 1]) * p[i] + 2 * p[i] * p[i - 1] + p[i] * E[i - 1];       ans += E[i];     }     cout << setprecision(10) << ans << endl;   }
#include <bits/stdc++.h>   constexpr int N = 1.5e5, M = 1 << 18;   int n, q;   int parent[N], dep[N];   char ch[N];   int down[N], h[N], deg[N];   int mx[N][26], edge[N][26], sum[N];   int e[N][2];   int bad;   void add(int u, int c, int v) {     u = down[u];     edge[u][c] += v;     for (u = parent[u]; u != -1; u = parent[u]) {       bad -= sum[u] > h[u];       sum[u] -= mx[u][c];       mx[u][c] = 0;       for (int i = 0; i < deg[u]; ++i)         mx[u][c] = std::max(mx[u][c], mx[e[u][i]][c] + edge[e[u][i]][c]);       sum[u] += mx[u][c];       bad += sum[u] > h[u];     }   }   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     std::cin >> n >> q;     parent[0] = -1;     for (int i = 1; i < n; ++i) {       std::cin >> parent[i] >> ch[i];       --parent[i];       e[parent[i]][deg[parent[i]]++] = i;     }     for (int i = n - 1; i > 0; --i) h[parent[i]] = h[i] + 1;     for (int i = 1; i < n; ++i) {       if (h[parent[i]] != h[i] + 1) {         while (q--) std::cout <<  Fou n ;         return 0;       }       if (parent[i] != 0 && deg[parent[i]] == 1) parent[i] = parent[parent[i]];     }     for (int i = n - 1; i > 0; --i) down[i] = deg[i] == 1 ? down[e[i][0]] : i;     for (int i = 0; i < n; ++i) deg[i] = 0;     for (int i = 1; i < n; ++i)       if (down[i] == i) e[parent[i]][deg[parent[i]]++] = i;     for (int i = 1; i < n; ++i)       if (ch[i] !=  ? ) add(i, ch[i] -  a , 1);     while (q--) {       int v;       char c;       std::cin >> v >> c;       --v;       if (ch[v] !=  ? ) add(v, ch[v] -  a , -1);       if (c !=  ? ) add(v, c -  a , 1);       ch[v] = c;       if (bad == 0) {         int ans = 0;         for (int i = 0; i < 26; ++i) ans += (i + 1) * (h[0] - sum[0] + mx[0][i]);         std::cout <<  Shi   << ans <<   n ;       } else {         std::cout <<  Fou n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     int x[5001], y[5001], z[5001];     scanf( %d , &n);     double mx = -10;     for (int i = 0; i < n; i++) {       scanf( %d , x + i);       mx = max(mx, x[i] * 1.0);     }     scanf( %d , &m);     for (int i = 0; i < m; i++) scanf( %d , y + i);     scanf( %d , &k);     for (int i = 0; i < k; i++) scanf( %d , z + i);     double A, B;     scanf( %lf %lf , &A, &B);     double mn = 2e9 * 1.0;     for (int j = 0; j < m; j++) {       for (int l = 0; l < k; l++) {         mn = min((A * z[l] * 1.0) / (B * y[j] * 1.0), mn);       }     }     printf( %.10f n , mx * 1.0 / sqrt(1.0 + mn));   }