malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000006;   long long num[MAXN << 2];   long long sum[MAXN << 2];   long long N;   void pushup(int rt) {     num[rt] = num[rt << 1] + num[rt << 1 | 1];     sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];   }   void update(int P, int C, int l, int r, int rt) {     if (l == r) {       num[rt] += C;       sum[rt] += 1ll * P * C;       return;     }     int m = (l + r) / 2;     if (P <= m)       update(P, C, l, m, rt << 1);     else       update(P, C, m + 1, r, rt << 1 | 1);     pushup(rt);   }   long long query(int K, int l, int r, int rt) {     if (l == r) {       if (l == MAXN) {         return 0;       }       if (K > 0) {         return 1ll * K * l;       } else         return 0;     }     int m = (l + r) / 2;     if (num[rt << 1] >= K) {       return query(K, l, m, rt << 1);     } else {       return sum[rt << 1] + query(K - num[rt << 1], m + 1, r, rt << 1 | 1);     }   }   vector<pair<int, int> > C[MAXN];   vector<pair<int, int> > O[MAXN];   int main() {     int K, M;     scanf( %d%d%d , &N, &K, &M);     int l, r, c, p;     for (int i = 0; i < M; i++) {       scanf( %d%d%d%d , &l, &r, &c, &p);       C[l].push_back(make_pair(p, c));       O[r].push_back(make_pair(p, c));     }     long long ans = 0;     for (int i = 1; i <= N; i++) {       for (int j = 0; j < C[i].size(); j++)         update(C[i][j].first, C[i][j].second, 1, MAXN, 1);       ans += query(K, 1, MAXN, 1);       for (int j = 0; j < O[i].size(); j++)         update(O[i][j].first, -O[i][j].second, 1, MAXN, 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[1000000 + 9] = {0};   long long a1[1000000 + 9] = {0};   long long a2[1000000 + 9] = {0};   long long a3[1000000 + 9] = {0};   long long a4[1000000 + 9] = {0};   long long a5[1000000 + 9] = {0};   long long a6[1000000 + 9] = {0};   long long a7[1000000 + 9] = {0};   long long a8[1000000 + 9] = {0};   long long a9[1000000 + 9] = {0};   int main() {     long long a, b, c = 0, d, e, i, j, k, l = 0;     for (i = 1; i <= 1000000; i++) {       a = i;     xx:       c = 1;       while (a) {         b = a % 10;         a /= 10;         if (b > 0) c *= b;       }       if (c > 9 && dp[c] == 0) {         a = c;         goto xx;       } else {         if (dp[c] == 0)           dp[i] = c;         else           dp[i] = dp[c];       }     }     for (i = 1; i <= 1000000; i++) {       a1[i] += a1[i - 1];       a2[i] += a2[i - 1];       a3[i] += a3[i - 1];       a4[i] += a4[i - 1];       a5[i] += a5[i - 1];       a6[i] += a6[i - 1];       a7[i] += a7[i - 1];       a8[i] += a8[i - 1];       a9[i] += a9[i - 1];       if (dp[i] == 1) a1[i]++;       if (dp[i] == 2) a2[i]++;       if (dp[i] == 3) a3[i]++;       if (dp[i] == 4) a4[i]++;       if (dp[i] == 5) a5[i]++;       if (dp[i] == 6) a6[i]++;       if (dp[i] == 7) a7[i]++;       if (dp[i] == 8) a8[i]++;       if (dp[i] == 9) a9[i]++;     }     cin >> a;     while (a--) {       cin >> c >> d >> e;       l = 0;       if (e == 1) {         l = a1[d] - a1[c - 1];       }       if (e == 2) {         l = a2[d] - a2[c - 1];       }       if (e == 3) {         l = a3[d] - a3[c - 1];       }       if (e == 4) {         l = a4[d] - a4[c - 1];       }       if (e == 5) {         l = a5[d] - a5[c - 1];       }       if (e == 6) {         l = a6[d] - a6[c - 1];       }       if (e == 7) {         l = a7[d] - a7[c - 1];       }       if (e == 8) {         l = a8[d] - a8[c - 1];       }       if (e == 9) {         l = a9[d] - a9[c - 1];       }       cout << l << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   bool comp(int a, int b) { return (a > b); }   int gcd(long long int a, long long int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   int main(void) {     int n, p;     cin >> n >> p;     int l[n], r[n], i;     long long int c, cp, l1, l2;     double ans = 0;     for (i = 0; i < n; ++i) cin >> l[i] >> r[i];     for (i = 0; i < n; ++i) {       l1 = r[i] - l[i] + 1;       l2 = r[(i - 1 + n) % n] - l[(i - 1 + n) % n] + 1;       c = r[i] / p - (l[i] - 1) / p;       cp = r[(i - 1 + n) % n] / p - (l[(i - 1 + n) % n] - 1) / p;       ans += (2000.0 * (c * l2 + cp * l1 - (c * cp))) / (l1 * l2);     }     printf( %.10lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   using maxHeap = priority_queue<int>;   using minHeap = priority_queue<int, vector<int>, greater<int>>;   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int t, x;     double d, p;     cout << fixed << setprecision(10);     for (cin >> t; t; t--) {       cin >> x;       d = x;       if (x * x - 4 * x < 0) {         cout <<  N n ;       } else {         p = sqrt(d * d - 4 * d);         cout <<  Y   << (d - p) / 2 <<     << (d + p) / 2 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int const N = 3e5 + 3;   int ans[N];   int temp[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     vector<pair<int, pair<int, int>>> edges;     for (int i = (0); i < (m); ++i) {       int u, v, w;       cin >> u >> v >> w;       --u;       --v;       edges.push_back({w, {u, v}});     }     sort(begin(edges), end(edges));     fill(ans, ans + n, 0);     fill(temp, temp + n, 0);     for (int i = (0); i < (m); ++i) {       vector<int> cand;       int cur = edges[i].first;       while (i < m && edges[i].first == cur) {         int u = edges[i].second.first;         int v = edges[i].second.second;         cand.push_back(v);         temp[v] = max(temp[v], ans[u] + 1);         ++i;       }       --i;       for (auto& e : cand) {         ans[e] = max(temp[e], ans[e]);         temp[e] = 0;       }     }     cout << *max_element(ans, ans + n) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<int>;   using vll = vector<ll>;   struct vec {     ll x;     ll y;   };   void solve() {     ll t, sx, sy, ex, ey;     cin >> t >> sx >> sy >> ex >> ey;     string s;     cin >> s;     for (int i = 0, time = 0; i < s.size(); ++i, ++time) {       vec d = {ex - sx, ey - sy};       char quater;       if (d.x > 0 && d.y > 0)         quater = 1;       else if (d.x < 0 && d.y > 0)         quater = 2;       else if (d.x < 0 && d.y < 0)         quater = 3;       else if (d.x > 0 && d.y < 0)         quater = 4;       else if (d.x > 0 && d.y == 0)         quater = 5;       else if (d.x == 0 && d.y > 0)         quater = 6;       else if (d.x < 0 && d.y == 0)         quater = 7;       else         quater = 8;       switch (s[i]) {         case  E :           if (quater == 1 || quater == 4 || quater == 5)             sx++;           else             continue;           break;         case  N :           if (quater == 1 || quater == 2 || quater == 6)             sy++;           else             continue;           break;         case  W :           if (quater == 2 || quater == 3 || quater == 7)             sx--;           else             continue;           break;         case  S :           if (quater == 3 || quater == 4 || quater == 8)             sy--;           else             continue;       }       if (sx == ex && sy == ey) {         cout << time + 1 <<   n ;         return;       }     }     cout << -1 <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t = 1;     while (t-- > 0) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   string str;   int main() {     cin >> str;     int hun, ten, one;     if (str.size() == 1) {       if (str[0] ==  8  || str[0] ==  0 ) {         cout <<  YES n ;         cout << str << endl;       } else         cout <<  NO n  << endl;     } else if (str.size() == 2) {       ten = str[0] -  0 ;       ten *= 10;       one = str[1] -  0 ;       if ((ten + one) % 8 == 0) {         cout <<  YES n ;         cout << str << endl;       } else if ((ten / 10 == 8) || one == 8) {         cout <<  YES n ;         cout << 8 << endl;       } else if (!ten || !one) {         cout <<  YES n ;         cout << 0 << endl;       } else         cout <<  NO n  << endl;     } else {       for (int i = 0; i < str.size(); i++)         if (str[i] ==  8  || str[i] ==  0 ) {           cout <<  YES n ;           cout << str[i] << endl;           return 0;         }       for (int i = 0; i < str.size() - 1; i++) {         ten = str[i] -  0 ;         ten *= 10;         for (int j = i + 1; j < str.size(); j++) {           one = str[j] -  0 ;           int temp = ten + one;           if (temp % 8 == 0) {             cout <<  YES n ;             cout << temp << endl;             return 0;           }         }       }       for (int i = 0; i < str.size() - 2; i++) {         hun = str[i] -  0 ;         hun *= 100;         for (int j = i + 1; j < str.size() - 1; j++) {           ten = str[j] -  0 ;           ten *= 10;           for (int k = j + 1; k < str.size(); k++) {             one = str[k] -  0 ;             int temp = hun + ten + one;             if (temp % 8 == 0) {               cout <<  YES n ;               cout << temp << endl;               return 0;             }           }         }       }       cout <<  NO n  << endl;     }     return 0;   }
#include <bits/stdc++.h>   long long n, i, res;   using namespace std;   int main() {     cin >> n;     long long a[n];     for (i = 0; i < n; i++) cin >> a[i];     int l = 0, r = n - 1;     long long suma = 0, sumb = 0;     while (l <= r) {       if (suma < sumb) {         suma += a[l];         l++;       } else {         if (suma == sumb) {           res = max(res, suma);           suma += a[l];           l++;         } else {           sumb += a[r];           r--;         }       }     }     if (suma == sumb) res = max(res, suma);     cout << res;     return 0;   }
#include <bits/stdc++.h>   int main() {     using namespace std;     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m, k, t;     cin >> n >> m >> k >> t;     vector<pair<int, int>> w;     for (int i = 0, r, c; i < k; i++, w.push_back(make_pair(r, c))) cin >> r >> c;     sort(w.begin(), w.end());     const char* s[] = { Carrots ,  Kiwis ,  Grapes };     for (int r, c; t--;) {       cin >> r >> c;       auto v = make_pair(r, c);       auto vi = upper_bound(w.begin(), w.end(), v) - w.begin();       int i = (r - 1) * m + c - 1;       if (vi && w[vi - 1] == v)         cout <<  Waste  <<   n ;       else         cout << s[(i - vi) % 3] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int q;   int h, w, k;   int a[600][600];   int dist[17][17];   int dp[17][65539];   int from[17][65539];   int pos[17];   int getdown(int x, int y) {     int sum = 0;     for (int i = x - 4; i <= x; i++) {       for (int j = y - 2; j <= y + 2; j++) {         sum += a[i][j];       }     }     return sum;   }   int getup(int x, int y) {     int sum = 0;     for (int i = x; i <= x + 4; i++) {       for (int j = y - 2; j <= y + 2; j++) {         sum += a[i][j];       }     }     return sum;   }   int main() {     cin >> q;     for (int ii = 0; ii < q; ii++) {       scanf( %d %d %d , &h, &w, &k);       for (int i = 0; i < h; i++) {         for (int j = 0; j < w; j++) {           scanf( %d , &a[i][j]);         }       }       for (int i = 0; i < k; i++) {         for (int j = 0; j < k; j++) {           if (i != j) {             dist[i][j] = 0;             for (int kk = 5; kk < w - 5; kk++) {               dist[i][j] += abs(getdown((i + 1) * (h / k) - 1, kk) -                                 getup(j * (h / k), kk));             }           }         }       }       for (int mask = 0; mask < (1 << k); mask++) {         for (int who = 0; who < k; who++) {           dp[who][mask] = 1000000000;         }       }       for (int mask = 0; mask < (1 << k); mask++) {         for (int who = 0; who < k; who++) {           if (!((1 << who) & mask)) {             continue;           }           if (mask == (1 << who)) {             dp[who][mask] = 0;           }           if (dp[who][mask] == 1000000000) {             continue;           }           for (int next = 0; next < k; next++) {             if (!((1 << next) & mask)) {               int NewMask = mask | (1 << next);               if (dp[next][NewMask] > dp[who][mask] + dist[who][next]) {                 dp[next][NewMask] = dp[who][mask] + dist[who][next];                 from[next][NewMask] = who;               }             }           }         }       }       int ans = 1000000000;       int i, j;       for (int who = 0; who < k; who++) {         ans = min(ans, dp[who][(1 << k) - 1]);         if (ans == dp[who][(1 << k) - 1]) {           i = who;           j = (1 << k) - 1;         }       }       vector<int> anss;       while (j != 0) {         int ni = from[i][j];         anss.push_back(i + 1);         j ^= (1 << i);         i = ni;       }       reverse(anss.begin(), anss.end());       for (int i = 0; i < (int)anss.size(); i++) {         pos[anss[i]] = i + 1;       }       for (int i = 1; i <= k; i++) {         printf( %d  , pos[i]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)   #define int long long int   #define double long double   #define endl   n    const int mod = 1000000007;   using namespace std;      int modExpo(int x , int n)   {    int ans = 1;    while (n > 0) {     if ( n & 1 == 1 ) ans = ( ans * x ) % mod;     x = ( x * x ) % mod; n = n / 2;    }    return ans;   }                                 void solve()   {    vector<int> v(4);    for(int i=0;i<4;i++)     cin>>v[i];       int x = max(v[0] , v[1]);    int y = max(v[2] , v[3]);       if(x < v[2] && x < v[3])    {     cout<< NO n ;     return;    }        if(y < v[0] && y < v[1])    {     cout<< NO n ;     return;    }        cout<< YES n ;    // cout<<x<<y;   }                                 int32_t main()   {   #ifndef ONLINE_JUDGE    freopen( input.txt ,  r , stdin);    freopen( output.txt ,  w , stdout);   #endif       fast;    int tt;    cin >> tt;    while (tt--)    {     solve();    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2 * 100 * 1000 + 10;   string s, t;   int d[N];   int LastSeen[N];   void input() {     cin >> s >> t;     return;   }   void PrePros() {     int keep = (int)(t.size()) - 1, pnt = (int)(s.size()) - 1;     while (keep >= 0) {       if (s[pnt] == t[keep]) {         LastSeen[keep] = pnt;         keep--;       }       pnt--;     }     LastSeen[t.size()] = s.size();     t.push_back( * );     return;   }   void solve() {     PrePros();     int lastfound = 0;     for (int i = 0; i < s.size(); i++) {       d[i] = LastSeen[lastfound] - i;       if (s[i] == t[lastfound]) lastfound++;     }     return;   }   void output() {     int ans = 0;     for (int i = 0; i < s.size(); i++) ans = max(ans, d[i]);     cout << ans << endl;     return;   }   int main() {     input();     solve();     output();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   void input() {}   int main() {     fastio();     input();     long long int n;     cin >> n;     long long int sum = -1;     map<long long int, long long int> make_pair;     for (long long int i = 0; i < n; i++) {       long long int x;       cin >> x;       make_pair[x - i] += x;       sum = max(sum, make_pair[x - i]);     }     cout << sum <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double a, b, c, d;   int main() {     char st =  e ;     cin >> a >> b >> c >> d;     if (a / b == b / c && b / c == c / d) st =  g ;     if (a - b == b - c && b - c == c - d) st =  a ;     if (st ==  e )       cout << 42 << endl;     else if (st ==  g ) {       int d1 = d, b1 = b, a1 = a;       if (d * b / a == d1 * b1 / a1)         cout << d * b / a << endl;       else         cout << 42 << endl;     } else       cout << d + b - a << endl;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using db = double;   using pii = pair<int, int>;   using vi = vector<int>;   const int N = 1e5 + 100;   int n, d[N], f[N][2], ans;   vi G[N];   void dfs(int x, int fz) {     f[x][0] = 0, f[x][1] = 1;     for (int y : G[x])       if (y != fz) {         dfs(y, x);         ans = max({ans, f[x][0] + f[y][0], f[x][0] + f[y][1], f[x][1] + f[y][0]});         f[x][0] = max({f[x][0], f[y][0] + d[x] - 2, f[y][1] + d[x] - 2});         f[x][1] = max({f[x][1], f[y][0] + 1});       }     ans = max(ans, f[x][1]);   }   signed main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       G[x].push_back(y), G[y].push_back(x);       d[x]++, d[y]++;     }     dfs(1, 0);     printf( %d n , ans);     fprintf(stderr,  time=%.4f n , (db)clock() / CLOCKS_PER_SEC);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long r, g, b;     cin >> r >> g >> b;     long long ans = 0;     long long tr, tg, tb;     for (long long i = 0; i <= min({r, g, b, 2LL}); i++) {       long long t = i;       tr = r;       tg = g;       tb = b;       tr -= i;       tg -= i;       tb -= i;       t += (tr / 3 + tg / 3 + tb / 3);       ans = max(ans, t);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = (long long)(1e9 + 7);   const int inf = (int)INFINITY;   const long long INF = (long long)INFINITY;   const int MAX = (int)(2e5 + 5);   const int maxn = 2e5 + 5;   int n, m, k, p[maxn], path[maxn];   vector<int> in[maxn], out[maxn];   int maxa, mina;   set<pair<long long, long long> > st;   void dijkstra() {     while (st.size()) {       pair<long long, long long> x = *st.begin();       st.erase(x);       int i = x.second;       for (auto A : in[i]) {         if (path[i] + 1 < path[A]) {           st.erase(pair<long long, long long>(path[A], A));           path[A] = path[i] + 1;           st.insert(pair<long long, long long>(path[A], A));         }       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> m;     for (long long i = 0; i < (m); ++i) {       int u, v;       cin >> u >> v;       out[u].push_back(v);       in[v].push_back(u);     }     cin >> k;     for (int i = 1; i <= k; ++i) cin >> p[i];     memset(path, 63, sizeof path);     path[p[k]] = 0;     st.insert(pair<long long, long long>(0, p[k]));     dijkstra();     for (int i = 2; i <= k; ++i) {       if (path[p[i]] != path[p[i - 1]] - 1) {         ++mina;         ++maxa;       } else {         int e = 0;         for (auto A : out[p[i - 1]])           if (A != p[i] && path[A] == path[p[i]]) e = 1;         maxa += e;       }     }     cout << mina <<     << maxa;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[1010], y[1010];   int lef(int x1, int y1, int x2, int y2) {     if (x1) x1 = (x1 > 0 ? 1 : -1);     if (y1) y1 = (y1 > 0 ? 1 : -1);     if (x2) x2 = (x2 > 0 ? 1 : -1);     if (y2) y2 = (y2 > 0 ? 1 : -1);     if (x1 == 0 && y1 == 1) {       if (x2 == 1)         return 0;       else         return 1;     }     if (x1 == 0 && y1 == -1) {       if (x2 == 1)         return 1;       else         return 0;     }     return lef(-x2, -y2, -x1, -y1) > 0 ? 0 : 1;   }   int main() {     int n, i, num1, num2;     while (cin >> n) {       for (i = 0; i <= n; i++) {         scanf( %d %d , &x[i], &y[i]);       }       x[n + 1] = x[1];       y[n + 1] = y[1];       num1 = num2 = 0;       for (i = 1; i <= n; i++) {         if (lef((x[i] - x[i - 1]), (y[i] - y[i - 1]), (x[i + 1] - x[i]),                 (y[i + 1] - y[i])))           num1++;         else           num2++;       }       cout << min(num1, num2) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   char s1[100100], s2[100100];   long long ini;   long long mod(long long a) {     return ((a % 1000000007LL) + 1000000007LL) % 1000000007LL;   }   long long func(char* s, int t, bool som) {     long long r = 0;     long long ul = 0;     long long soma = 0, ls = ini;     long long qt = 0LL;     bool tem = false;     long long sum, lst, val, bas, qtd;     sum = lst = ini;     val = 0;     bas = 3LL;     qtd = 1LL;     for (int i = t - 1, j = 0; i >= 0; i--, j++) {       ul = (ul * 10 + s[j] -  0 ) % 1000000007LL;       long long bas2 = (bas * bas) % 1000000007LL;       if (s[i] ==  7 ) {         if (qt > 0)           r = (r + ((qt - 1) * bas2) % 1000000007LL +                (bas * (2 * soma - ls - ini)) % 1000000007LL +                (lst * (ini + bas)) % 1000000007LL) %               1000000007LL;         r = (r + val) % 1000000007LL;         soma = (soma + sum + qt * bas) % 1000000007LL;         qt = (qt + qtd) % 1000000007LL;         if (tem) ls = (ls + bas) % 1000000007LL;         tem = true;       } else if (!tem)         ls = (ls + bas) % 1000000007LL;       val = (2 * val + (lst * (bas + ini)) % 1000000007LL +              (bas2 * (qtd - 1)) % 1000000007LL +              (bas * (2 * sum - lst - ini)) % 1000000007LL) %             1000000007LL;       sum = (2 * sum + qtd * bas) % 1000000007LL;       lst = (lst + bas) % 1000000007LL;       bas = (bas * 10) % 1000000007LL;       qtd = (qtd * 2) % 1000000007LL;     }     if (tem) return (r + ul * ls) % 1000000007LL;     return r;   }   int main() {     int tam;     scanf( %s %s , s1, s2);     tam = strlen(s1);     ini = 0;     for (int i = 0; i < tam; i++) ini = (ini * 10 + 4LL) % 1000000007LL;     cout << mod(func(s2, tam, true) - func(s1, tam, false)) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double eps = -1e12;   inline bool eq(const long double &x, const long double &y) {     return abs(x - y) < eps || abs(x - y) < eps * abs(x);   }   int main() {     long double x, y, z;     cin >> x >> y >> z;     string expression[12] = { x^y^z ,  x^z^y ,  (x^y)^z ,  (x^z)^y ,                               y^x^z ,  y^z^x ,  (y^x)^z ,  (y^z)^x ,                               z^x^y ,  z^y^x ,  (z^x)^y ,  (z^y)^x };     vector<long double> ans(12, 0);     long double res = -1000;     long double logx = log(x);     long double logy = log(y);     long double logz = log(z);     ans[0] = pow(y, z) * logx;     ans[1] = pow(z, y) * logx;     ans[2] = logx * y * z;     ans[3] = ans[2];     ans[4] = pow(x, z) * logy;     ans[5] = pow(z, x) * logy;     ans[6] = logy * x * z;     ans[7] = ans[6];     ans[8] = pow(x, y) * logz;     ans[9] = pow(y, x) * logz;     ans[10] = logz * y * x;     ans[11] = ans[10];     int index = 0;     for (int i = 0; i < 12; ++i) {       if (ans[i] > res && !eq(ans[i], res)) {         res = ans[i];         index = i;       }     }     cout << expression[index] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     double X, Y, Z;     void Get() { scanf( %lf%lf%lf , &X, &Y, &Z); }   };   Point operator-(Point A, Point B) {     return (Point){A.X - B.X, A.Y - B.Y, A.Z - B.Z};   }   double operator*(Point A, Point B) { return A.X * B.X + A.Y * B.Y + A.Z * B.Z; }   const double inf = 1e9;   const double eps = 1e-6;   double Solve(Point A, Point V, double R) {     double a = V * V, b = A * V * 2, c = A * A - R * R;     double Delta = b * b - 4 * a * c;     if (Delta < -eps) return inf;     Delta = sqrt(fabs(Delta));     double T0 = (-b + Delta) / (2 * a), T1 = (-b - Delta) / (2 * a);     return (T0 < 0) ? inf : ((T1 < 0) ? T0 : T1);   }   int main() {     Point O, V;     O.Get();     V.Get();     double R, Ans = inf;     scanf( %lf , &R);     int N;     scanf( %d , &N);     while (N--) {       Point _O;       _O.Get();       double r;       scanf( %lf , &r);       Ans = min(Ans, Solve(O - _O, V, R + r));       int M;       scanf( %d , &M);       while (M--) {         Point Delta;         Delta.Get();         Ans = min(Ans, Solve(O - _O - Delta, V, R));       }     }     if (Ans == inf)       printf( -1 n );     else       printf( %0.10lf n , Ans);     return 0;   }