malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 * 1000 + 20;   const int N5 = 300 * 1000 + 10;   const int N3 = 3000 + 20;   const long long mod = 1000 * 1000 * 1000 + 9;   const long long inf = LLONG_MAX / 2;   long long dp[2][N], par[N], rnk[N];   long long __pow(long long x, int y) {     if (y == 0) return 1;     return __pow(x * x % mod, y / 2) % mod * (y & 1 ? x : 1) % mod;   }   int find_root(int v) {     if (par[v] == v) {       return v;     }     return par[v] = find_root(par[v]);   }   void _merge(int a, int b) {     int r_a = find_root(a);     int r_b = find_root(b);     if (rnk[r_a] > rnk[r_b]) {       swap(r_a, r_b);     }     par[r_a] = r_b;     if (rnk[r_a] == rnk[r_b]) {       rnk[r_b]++;     }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     int t = 0;     for (int i = 1; i <= n; i++) par[i] = i;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       if (find_root(x) != find_root(y)) {         t++;         _merge(x, y);       }       cout << ((__pow(2, i - t) + mod) - 1) % mod <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b, c;     cin >> a >> b >> c;     if (a[0] == c[2] && a[1] == c[1] && a[2] == c[0] && b[0] == b[2])       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long I1 = 1e9;   const long long I2 = 1e18;   const int32_t M1 = 1e9 + 7;   const int32_t M2 = 998244353;   template <typename T, typename T1>   T maxn(T &a, T1 b) {     if (b > a) a = b;     return a;   }   template <typename T, typename T1>   T minn(T &a, T1 b) {     if (b < a) a = b;     return a;   }   const int M = 3005;   bool cc[M][M];   long long int dis[M][M];   set<pair<pair<long long int, long long int>, long long int> > s;   vector<long long int> a[M];   void solve() {     int n, m, k;     cin >> n >> m >> k;     for (long long int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       a[x].push_back(y);       a[y].push_back(x);     }     for (long long int i = 0; i < k; i++) {       int x, y, z;       cin >> x >> y >> z;       s.insert({{x, y}, z});     }     queue<pair<long long int, long long int> > q;     q.push({1, 1});     while (!q.empty()) {       pair<long long int, long long int> cur = q.front();       int x = cur.first, y = cur.second;       q.pop();       cc[cur.first][cur.second] = true;       for (auto u : a[y]) {         if (s.count({{x, y}, u})) continue;         if (cc[y][u] == true) continue;         cc[y][u] = true;         dis[y][u] = dis[x][y] + 1;         q.push({y, u});       }     }     long long int d = I1, i = n, prev = n;     for (long long int i = 1; i <= n; i++) {       if (dis[i][n] != 0) minn(d, dis[i][n]);     }     if (d == I1) {       cout <<  -1  << endl;       return;     }     cout << d << endl;     vector<long long int> ans;     ans.push_back(n);     while (i != 1) {       long long int ind = -1;       for (long long int j = 1; j <= n; j++) {         if (dis[j][i] == d) {           ind = j;           break;         }       }       ans.push_back(ind);       prev = i;       i = ind;       d--;     }     reverse(ans.begin(), ans.end());     for (auto u : ans) cout << u <<    ;     cout << endl;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int testcase = 1;     while (testcase--) solve();     return 0;   }
#include <bits/stdc++.h>   const long long MOD = 1000 * 1000 * 1000 + 7;   const long long MOD1 = 998244353;   const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;   using namespace std;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (long long)(res * x);       y = y >> 1;       if (x <= 100000000) x = (long long)(x * x);     }     return res;   }   long long val[5001][5001];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long a[n + 1];     for (int(i) = (1); (i) < (n + 1); ++(i)) {       cin >> a[i];       val[i][i] = a[i];     }     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= n - i + 1; j++) {         val[j][j + i - 1] = val[j][j + i - 2] ^ val[j + 1][j + i - 1];       }     }     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= n - i + 1; j++) {         val[j][j + i - 1] =             max(val[j][j + i - 1], max(val[j][j + i - 2], val[j + 1][j + i - 1]));       }     }     long long q;     cin >> q;     while (q--) {       long long x, y;       cin >> x >> y;       cout << val[x][y] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename TT>   ostream& operator<<(ostream& out, pair<T, TT> t) {     return out <<  (  << t.first <<  ,  << t.second <<  ) ;   }   template <typename T>   ostream& operator<<(ostream& out, vector<T> t) {     for (int i = 0; i < ((int)(t).size()); i++) out << t[i] <<    ;     return out;   }   template <typename T>   inline bool cmin(T& a, const T& b) {     return a > b ? a = b, 1 : 0;   }   template <typename T>   inline bool cmax(T& a, const T& b) {     return a < b ? a = b, 1 : 0;   }   template <typename T>   void read(T& x) {     int f = 1;     char ch;     x = 0;     while (!isdigit(ch = getchar()))       ;     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     x *= f;   }   const int NX = 201234;   int n, m, p[NX];   map<int, int> e[NX];   int main() {     read(n);     read(m);     for (int i = 1, u, v; i <= m; i++) {       read(u);       read(v);       e[u][v] = e[v][u] = true;     }     for (int i = 1; i <= n; i++) p[i] = i;     for (int T = 200; T--;) {       random_shuffle(p + 1, p + n + 1);       int cnt = 0;       for (int i = 1; i <= n; i++) {         int l = p[i], r = p[i % n + 1];         cnt += !e[l].count(r);       }       if (cnt >= m) {         for (int i = 1; i <= n; i++) {           int l = p[i], r = p[i % n + 1];           if (!e[l].count(r)) {             printf( %d %d n , l, r);             if (!--m) return 0;           }         }       }     }     puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int func(int n) {     int sum = 1;     if (n == 3) return 4;     if (n == 2) return 2;     if (n == 1) return 1;     if (n % 2 == 0) {       sum += 2 * (n / 2 - 1) + 1 + func(n - 2);     } else {       sum += 2 * (n - 1) / 2 + func(n - 2);     }     return sum;   }   int main() {     {       int n;       int r = 1;       int i = 0;       cin >> n;       cout << func(n);       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   string s;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> s;     long long n = s.size();     long long a = 0, b = 0;     for (auto f : s) {       a += (f ==  1 );       b += (f ==  0 );     }     long long z = n - a - b;     if (a < b + z) {       cout <<  00  << endl;     }     if (n % 2 == 0 && s[n - 1] !=  0 ) {       long long a1 = a, b1 = b;       if (s[n - 1] ==  ? ) {         a1++;       }       if (a1 <= n / 2 && b1 <= n / 2) {         cout <<  01  << endl;       }     } else if (s[n - 1] !=  0 ) {       long long a1 = a, b1 = b;       if (s[n - 1] ==  ? ) {         a1++;       }       if (a1 <= n / 2 + 1 && b1 <= n / 2) {         cout <<  01  << endl;       }     }     if (n % 2 == 0 && s[n - 1] !=  1 ) {       long long a1 = a, b1 = b;       if (s[n - 1] ==  ? ) {         b1++;       }       if (a1 <= n / 2 && b1 <= n / 2) {         cout <<  10  << endl;       }     } else if (s[n - 1] !=  1 ) {       long long a1 = a, b1 = b;       if (s[n - 1] ==  ? ) {         b1++;       }       if (a1 <= n / 2 + 1 && b1 <= n / 2) {         cout <<  10  << endl;       }     }     if (a + z > b + 1) {       cout <<  11  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e3 + 5;   int a[N], n;   int dp[N][N / 2][2][2];   int solve(int idx, int lft, bool b4, bool b44) {     if (lft < 0) return 1e9;     if (idx == n) {       if (lft) return 1e9;       return 0;     }     int &ret = dp[idx][lft][b4][b44];     if (~ret) return ret;     ret = solve(idx + 1, lft, 0, b4);     if (!b4) {       int x;       int cost1 = 0, cost2 = 0;       if (b44) {         x = min(a[idx - 1], a[idx - 2] - 1);       } else         x = a[idx - 1];       if (idx) cost1 = max(0, x - (a[idx] - 1));       if (idx != n - 1) {         cost2 = max(0, a[idx + 1] - (a[idx] - 1));       }       ret = min(ret, solve(idx + 1, lft - 1, 1, 0) + cost1 + cost2);     }     return ret;   }   int main() {     memset(dp, -1, sizeof dp);     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , a + i);     for (int i = 1; i <= (n + 1) / 2; i++) {       printf( %d  , solve(0, i, 0, 0));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int mod = 1e9 + 7;   const int sz = 1e5 + 10;   int main() {     int n, x;     set<int> ans, st, ha;     while (cin >> n) {       ans.clear();       st.clear();       for (int i = 0; i < n; i++) {         ha.clear();         cin >> x;         ha.insert(x);         ans.insert(x);         for (int xx : st) {           ha.insert(x | xx);           ans.insert(x | xx);         }         st = ha;       }       cout << ans.size() <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> arr(n + 1, -1);     for (int i = 1; i <= n; i++) {       int temp;       cin >> temp;       arr[i] = temp;     }     int ans = 0;     vector<int> mini(n + 1, -1);     vector<int> maxi(n + 1, -1);     vector<int> equal(n + 1, -1);     equal[1] = 1;     mini[1] = 1;     maxi[1] = 1;     for (int i = 2; i <= n; i++) {       if (arr[i] != arr[i - 1])         equal[i] = 1;       else {         equal[i] = equal[i - 1] + 1;         mini[i] = mini[i - 1] + 1;         maxi[i] = maxi[i - 1] + 1;       }       if (arr[i] > arr[i - 1]) {         maxi[i] = max(mini[i - 1] + 1, equal[i - 1] + 1);         mini[i] = 1;       }       if (arr[i] < arr[i - 1]) {         mini[i] = max(maxi[i - 1] + 1, equal[i - 1] + 1);         maxi[i] = 1;       }       int temp = max(mini[i], max(maxi[i], equal[i]));       if (temp > ans) ans = temp;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 51123987;   string s;   int n;   long long d[50 + 10][50 + 10][150 + 10][3];   int NEXT[150 + 10][5];   inline int nex(int MIN, int c) { return NEXT[MIN][c]; }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> s;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= 3; ++j) {         NEXT[i][j] = n + 1;         for (int l = i - 1; l < s.size(); ++l)           if (s[l] == char(j +  a  - 1)) {             NEXT[i][j] = l + 1;             break;           }       }     {       int ind = nex(1, 1);       if (ind <= n) d[1][0][ind][1] = 1;       ind = nex(1, 2);       if (ind <= n) d[0][1][ind][1] = 1;       ind = nex(1, 3);       if (ind <= n) d[0][0][ind][1] = 1;     }     for (int i = 2; i <= n; ++i) {       for (int j = 0; j <= 50; ++j)         for (int l = 0; l <= 50; ++l)           for (int k = 1; k <= n; ++k) {             int ind = nex(k, 1);             if (ind <= n) {               d[j + 1][l][ind][0] += d[j][l][k][1];               if (d[j + 1][l][ind][0] > mod) d[j + 1][l][ind][0] -= mod;             }             ind = nex(k, 2);             if (ind <= n) {               d[j][l + 1][ind][0] += d[j][l][k][1];               if (d[j][l + 1][ind][0] > mod) d[j][l + 1][ind][0] -= mod;             }             ind = nex(k, 3);             if (ind <= n) {               d[j][l][ind][0] += d[j][l][k][1];               if (d[j][l][ind][0] > mod) d[j][l][ind][0] -= mod;             }           }       for (int j = 0; j <= 50; ++j)         for (int l = 0; l <= 50; ++l)           for (int k = 1; k <= n; ++k) {             d[j][l][k][1] = d[j][l][k][0];             d[j][l][k][0] = 0;           }     }     long long ans = 0;     for (int j = 0; j <= 50; ++j)       for (int l = 0; l <= 50; ++l)         for (int k = 1; k <= n; ++k) {           int a = j;           int b = l;           int c = n - j - l;           if (a >= 0 && b >= 0 && c >= 0)             if (abs(a - b) <= 1 && abs(b - c) <= 1 && abs(a - c) <= 1) {               ans += d[j][l][k][1];               ans %= mod;             }         }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int val, l, r;   } a[100010];   int rt, n;   bool to[100010];   map<int, bool> ma;   vector<int> v;   void dfs(int u, int maxx, int minn) {     if (u == -1) return;     if (a[u].val > maxx && a[u].val < minn) ma[a[u].val] = true;     dfs(a[u].l, maxx, min(a[u].val, minn));     dfs(a[u].r, max(a[u].val, maxx), minn);     return;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &a[i].val, &a[i].l, &a[i].r);       if (a[i].l != -1) to[a[i].l] = true;       if (a[i].r != -1) to[a[i].r] = true;     }     for (int i = 1; i <= n; i++)       if (to[i] == false) rt = i;     dfs(rt, -1, 1e9 + 1);     int ans = 0;     for (int i = 1; i <= n; i++)       if (ma[a[i].val] == false) ans++;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     bool used[n];     for (int i = 0; i <= n - 1; i++) used[i] = false;     int a = 0, b = n - 1;     for (int i = 0; i <= k - 1; i++) {       if (i & 1)         used[b] = true;       else         used[a] = true;       if (i & 1)         cout << (1 + (b--));       else         cout << (1 + (a++));       cout <<    ;     }     if (k & 1) {       for (int i = 0; i <= n - 1; i++) {         if (!used[i]) {           cout << i + 1 <<    ;         }       }     } else {       for (int i = n - 1; i >= 0; --i) {         if (!used[i]) {           cout << i + 1 <<    ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[26];   char s[100001];   int gcd(int a, int b) {     if (a % b == 0) {       return b;     } else {       return gcd(b, a % b);     }   }   int main() {     int n, ans, sum = 0, c = 0, i, j, k, l;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       sum += a[i];       if (a[i] % 2 == 1) c++;     }     if (c >= 2) {       ans = 0;       for (i = 0, j = 0; i < n; i++) {         while (a[i] > 0) {           s[j++] =  a  + i;           a[i]--;         }       }     } else {       ans = a[0];       for (i = 1; i < n; i++) ans = gcd(ans, a[i]);       if (c == 1) {         int p;         for (i = 0; i < n; i++) {           if (a[i] % 2 == 1) {             p = i;             a[i] -= ans;           }         }         for (i = 0, l = 0; i < ans * 2; i++) {           if (i % 2 == 0) {             for (j = 0; j < n; j++) {               for (k = 0; k < a[j] / ans / 2; k++) s[l++] =  a  + j;             }             s[l++] =  a  + p;           } else {             for (j = n - 1; j >= 0; j--) {               for (k = 0; k < a[j] / ans / 2; k++) s[l++] =  a  + j;             }           }         }       } else {         for (i = 0, l = 0; i < ans; i++) {           if (i % 2 == 0) {             for (j = 0; j < n; j++) {               for (k = 0; k < a[j] / ans; k++) s[l++] =  a  + j;             }           } else {             for (j = n - 1; j >= 0; j--) {               for (k = 0; k < a[j] / ans; k++) s[l++] =  a  + j;             }           }         }       }     }     printf( %d n , ans);     printf( %s n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int d, n, a, s = 0, k;     scanf( %d , &d);     scanf( %d , &n);     scanf( %d , &a);     for (k = 1; k < n; k++) {       s += d - a;       scanf( %d , &a);     }     printf( %d n , s);     return 0;   }
#include <bits/stdc++.h>   int main(void) {     int n, m;     scanf( %d %d , &n, &m);     long long a[1000 + 1];     long long t[1000 + 1 + 1][1000 + 1];     for (int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     for (int j = 0; j <= n; j++) t[n + 1][j] = 0;     for (int i = n; i >= 1; i--) {       for (int j = 0; j <= n; j++) {         t[i][j] =             std::min(t[i + 1][j] - a[i], (j > 0) ? t[i + 1][j - 1] : 1LL << 60LL);         t[i][j] = std::max(t[i][j], 0LL);       }     }     std::vector<std::pair<long long, int>> values;     for (int j = 0; j <= n; j++) {       if (j == 0 || t[1][j] != t[1][j - 1])         values.push_back(std::make_pair(t[1][j], j));     }     std::sort(values.begin(), values.end());     for (int i = 0; i < m; i++) {       long long b;       scanf( %lld , &b);       auto it =           std::lower_bound(values.begin(), values.end(), std::make_pair(b, -1));       if (it == values.end() || it->first > b) it--;       printf( %d n , it->second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18 + 7;   long long f[53], fac[53];   long long add(long long a, long long b) { return min(INF, a + b); }   long long mul(long long a, long long b) {     if (INF / a < b) return INF;     return a * b;   }   const int N = 50;   long long g(int n) {     if (n == 1) return 1;     return fac[n - 2];   }   void init() {     fac[0] = 1;     for (int i = 1; i <= N; i++) fac[i] = mul(fac[i - 1], i);     f[0] = 1;     for (int i = 1; i <= N; i++)       for (int j = 1; j <= i; j++) f[i] = add(f[i], mul(f[i - j], g(j)));     return;   }   int p[53];   int q[53];   bool vis[53];   int find(int x) {     while (q[x]) x = q[x];     return x;   }   void getq(int n, long long k) {     if (n == 1) {       q[1] = 1;       return;     }     for (int i = 1; i <= n; i++) q[i] = vis[i] = 0;     q[1] = n;     vis[n] = 1;     for (int i = 2; i < n; i++) {       long long num = fac[n - i - 1];       for (int j = 1; j <= n; j++)         if (j != i && !vis[j] && find(j) != i) {           if (k <= num) {             q[i] = j;             vis[j] = true;             break;           }           k -= num;         }     }     for (int i = 1; i <= n; i++)       if (!vis[i]) q[n] = i;     return;   }   void getp(int n, long long k) {     if (!n) return;     int len = 0;     for (int i = 1; i <= n; i++) {       long long num = mul(g(i), f[n - i]);       if (k <= num) {         len = i;         break;       }       k -= num;     }     long long num = f[n - len];     long long need = (k - 1) / num + 1;     getp(n - len, k - (need - 1) * num);     for (int i = n; i > len; i--) p[i] = p[i - len] + len;     getq(len, need);     for (int i = 1; i <= len; i++) p[i] = q[i];     return;   }   int main() {     init();     int t;     scanf( %d , &t);     while (t--) {       int n;       long long k;       scanf( %d %lld , &n, &k);       if (f[n] < k)         printf( -1 n );       else {         getp(n, k);         for (int i = 1; i <= n; i++) printf( %d  , p[i]);         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   bitset<100005> m[70], tmp, tmpp;   int f[100], ftop = 60;   int ans[100010];   void swap(int x, int y) {     tmp = m[x];     m[x] = m[y];     m[y] = tmp;   }   int main() {     int i, j, k, d = 60;     long long x, s = 0;     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %I64d , &x);       s ^= x;       for (j = 0; j < 60; ++j)         if (x & (1ll << j)) m[j][i] = 1;     }     for (i = 59; ~i; --i)       if (!(s & (1ll << i))) {         --d;         tmpp = m[i];         for (j = i; j < d; ++j) m[j] = m[j + 1];         m[d] = tmpp;       }     for (i = 59; ~i; --i) {       if (i >= d) m[i][0] = 1;       for (j = 59; j >= ftop; --j)         if (m[i][f[j]]) m[i] ^= m[j];       for (k = 1; k <= n && m[i][k] == 0; ++k)         ;       if (n < k)         m[i][0] = 0;       else {         for (j = 59; j >= ftop; --j)           if (m[j][k]) m[j] ^= m[i];         --ftop;         f[ftop] = k;         swap(ftop, i);       }     }     for (i = 59; i >= ftop; --i)       if (m[i][0]) ans[f[i]] = 1;     for (i = 1; i <= n; ++i) printf( %d  , ans[i] ? 1 : 2);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 300011, log_n = 32, max_m = 111, mod = 1000000007,             inf = 1011111111;   const long double eps = 1e-7;   struct bor {     stack<pair<int, int> > st;     int t[max_n][27], res[max_n], sz[max_n], n;     bor() {       for (int i = 0; i < max_n; ++i) {         for (int q = 0; q < 27; ++q) {           t[i][q] = -1;         }       }     }     void add(int x, int y, char c) { t[x][c -  a ] = y; }     int get_sz(int v) {       int ans = 1;       for (int i = 0; i < 26; ++i) {         if (t[v][i] != -1) {           ans += get_sz(t[v][i]);         }       }       return sz[v] = ans;     }     int mrg(int v, int v1) {       int ans = 1;       for (int i = 0; i < 27; ++i) {         if (t[v][i] != -1 && t[v1][i] != -1) {           ans += mrg(t[v][i], t[v1][i]);         } else if (t[v][i] != -1) {           t[v1][i] = t[v][i];           st.push(make_pair(v1, i));         }       }       return ans;     }     void get(int v, int p) {       int mx = 0, mxx = -1;       for (int i = 0; i < 26; ++i) {         if (t[v][i] != -1 && mx < sz[t[v][i]]) {           mx = sz[t[v][i]];           mxx = i;         }       }       if (mxx == -1) {         return;       }       res[p]++;       for (int i = 0; i < 26; ++i) {         if (i == mxx) continue;         if (t[v][i] != -1) {           res[p] += mrg(t[v][i], t[v][mxx]);         }       }       while (st.size()) {         t[st.top().first][st.top().second] = -1;         st.pop();       }     }     void get_all(int v, int p) {       get(v, p);       for (int i = 0; i < 26; ++i) {         if (t[v][i] != -1) {           get_all(t[v][i], p + 1);         }       }     }   };   bor br;   int n;   int main() {     cin >> n;     for (int i = 0; i < n - 1; ++i) {       int a, b;       char c;       cin >> a >> b >> c;       br.add(a - 1, b - 1, c);     }     br.get_sz(0);     br.get_all(0, 0);     int mx = 0, mxx = 0;     for (int i = 0; i < n; ++i) {       if (mx < br.res[i]) {         mx = br.res[i];         mxx = i;       }     }     cout << n - mx << endl << mxx + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double a, b, c, d;     cin >> a >> b >> c >> d;     double mx;     mx = (a / b) * (1 / (1 - (1 - a / b) * (1 - c / d)));     std::cout << std::setprecision(9) << mx <<   n ;   }