malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 201;   int a[maxn], N, L, K;   double f[maxn][maxn][maxn * 2], p[maxn];   int main() {     scanf( %d%d%d , &N, &L, &K);     for (int i = 0; i < N; ++i) {       scanf( %lf , &p[i]);       p[i] /= 100;     }     for (int i = 0; i < N; ++i) scanf( %d , &a[i]);     f[0][0][N + min(N, K)] = 1;     for (int i = 0; i < N; ++i)       for (int j = 0; j <= N; ++j)         for (int k = -N; k <= N; ++k)           if (f[i][j][N + k] > 0) {             f[i + 1][j + 1][N + min(k + a[i], N)] += p[i] * f[i][j][N + k];             f[i + 1][j][N + k] += (1 - p[i]) * f[i][j][N + k];           }     double ans = 0;     for (int j = L; j <= N; ++j)       for (int k = N; k <= N + N; ++k) ans += f[N][j][k];     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   set<int> s[100005];   int color[100005];   int main() {     int n, m;     while (~scanf( %d%d , &n, &m)) {       int i, j, tmp = 0;       int u, v, ans;       for (i = 1; i <= n; i++) scanf( %d , &color[i]);       for (j = 0; j < m; j++) {         scanf( %d%d , &u, &v);         if (color[u] != color[v]) {           s[color[v]].insert(color[u]);           s[color[u]].insert(color[v]);         }       }       ans = color[1];       for (i = 1; i <= n; i++) {         if (s[color[i]].size() > tmp ||             (s[color[i]].size() == tmp && color[i] < ans)) {           tmp = s[color[i]].size();           ans = color[i];         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, l;   long long dp[250005];   short big_arr[250005], small_arr[5001];   long long pre[51], sum[51], suf[51], mx[51], maxx = -1e5;   long long solve(int indx, long long curSum) {     if (indx == m + 1) return -2000;     short &i = big_arr[indx];     long long &res = dp[indx];     if (~res) return res;     res = pre[i];     if (curSum + sum[i] >= suf[i] && curSum + sum[i] > 0)       res = max(res, solve(indx + 1, curSum + sum[i]) + sum[i]);     else if (suf[i] > 0)       res = max(res, solve(indx + 1, suf[i]) + suf[i] - curSum);     else       res = max(res, solve(indx + 1, 0) - curSum);     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL), cout.tie(NULL);     cin >> n >> m;     fill(pre, pre + 51, -1e5);     fill(suf, suf + 51, -1e5);     fill(mx, mx + 51, -1e5);     fill(dp, dp + 250005, -1);     for (int i = 0; i < n; i++) {       cin >> l;       long long tmp = 0;       for (int j = 0; j < l; j++) {         cin >> small_arr[j];         mx[i] = max((long long)small_arr[j], mx[i]);         if (tmp < 0) tmp = 0;         tmp += small_arr[j];         mx[i] = max(mx[i], tmp);         sum[i] += small_arr[j];         pre[i] = max(pre[i], sum[i]);       }       tmp = 0;       for (int j = l - 1; j >= 0; j--) {         tmp += small_arr[j];         suf[i] = max(suf[i], tmp);       }     }     for (int i = 1; i <= m; i++) {       cin >> big_arr[i];       big_arr[i]--;       maxx = max(mx[big_arr[i]], maxx);     }     cout << max(solve(1, 0), maxx) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 9901;   template <class T>   int countbit(T n) {     int t = 0;     while (n) n &= n - 1, ++t;     return t;   }   template <class T>   T lowbit(T n) {     return n & (-n);   }   const double eps = 1e-8;   const double pi = acos(-1.0);   const int INF = 0x7f7f7f7f;   const int maxn = 111111;   void File() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);   }   long long c[66][66];   long long go(long long n, long long t) {     int cnt = 0;     long long tt = t;     while (tt) tt >>= 1, ++cnt;     int arr[65];     int i, size = 0;     while (n) arr[size++] = n & 1, n >>= 1;     reverse(arr, arr + size);     long long ans = 0;     bool flag;     int ct = count(arr, arr + size, 1);     for (i = 0; i < size; ++i) {       flag = true;       if (arr[i]) {         if (size - i == ct && ct == cnt && cnt)           ans++, flag = false;         else {           if (cnt >= 0) ans += c[size - i - 1][cnt], --cnt;         }         --ct;       }       if (i && !cnt) {         ans++;         break;       }       if (!flag) break;     }     if (t == 1) ans--;     return ans;   }   int main() {     ios::sync_with_stdio(false);     int i, j;     for (i = 0; i < 66; ++i) {       c[i][i] = c[i][0] = 1;     }     for (i = 1; i < 66; ++i) {       for (j = 1; j < i; ++j) {         c[i][j] = c[i - 1][j - 1] + c[i - 1][j];       }     }     long long n, t;     cin >> n >> t;     int k = countbit(t);     if (k == 1)       cout << go(n + 1, t) << endl;     else       cout << 0 << endl;     return 0;   }
#include <bits/stdc++.h>   struct Point {     int x, y;     Point* next;     bool operator<(const Point& p) const { return 1ll * p.x * y < 1ll * x * p.y; }   } P[200010], *np = P;   std::map<long long, Point*> fir;   std::map<Point, int> M;   int main() {     int q, s = 0;     scanf( %d , &q);     while (q--) {       int t, x, y;       scanf( %d%d%d , &t, &x, &y);       long long d = 1ll * x * x + 1ll * y * y;       if (t == 1) {         M[(Point){x, y}]++;         for (Point* p = fir[d]; p; p = p->next)           M[(Point){x + p->x, y + p->y}] += 2;         *np = (Point){x, y, fir[d]};         fir[d] = np++;         s++;       }       if (t == 2) {         M[(Point){x, y}]--;         if (fir[d] && fir[d]->x == x && fir[d]->y == y) fir[d] = fir[d]->next;         ;         for (Point* p = fir[d]; p; p = p->next) {           if (p->next && p->next->x == x && p->next->y == y)             p->next = p->next->next;           ;           M[(Point){x + p->x, y + p->y}] -= 2;         }         s--;       }       if (t == 3) printf( %d n , s - M[(Point){x, y}]);     }   }
#include <bits/stdc++.h>   using namespace std;   long long expo(long long x, long long n, long long m) {     if (n == 0)       return 1;     else if (n % 2 == 0)       return expo((x * x) % m, n / 2, m);     else       return (x * expo((x * x) % m, (n - 1) / 2, m)) % m;   }   string DtoB(int j) {     string s =   ;     for (int i = 32; i >= 0; i--) {       int k = j >> i;       if (k & 1)         s +=  1 ;       else         s +=  0 ;     }     return s;   }   void solve() {     int n;     cin >> n;     int arr[n];     int s[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];       s[i] = arr[i];     }     sort(s, s + n);     map<int, int> m;     for (int i = 0; i < n; i++) m[s[i]] = i;     vector<vector<int> > ans;     int visit[n];     memset(visit, 0, sizeof(visit));     ;     for (int i = 0; i < n; i++) {       if (visit[i] == 0) {         vector<int> p;         for (int j = i; visit[j] == 0; j = m[arr[j]]) {           p.push_back(j + 1);           visit[j] = 1;         }         ans.push_back(p);       }     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i].size() <<    ;       for (int j = 0; j < ans[i].size(); j++) cout << ans[i][j] <<    ;       cout << endl;     }     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:320000000 )   using namespace std;   const double EPS = 1e-9;   const int INF = 0x7f7f7f7f;   const double PI = acos(-1.0);   template <class T>   inline T Abs(T n) {     return ((n) < 0 ? -(n) : (n));   }   template <class T>   inline T Max(T x, T y) {     return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;   }   template <class T>   inline T Min(T x, T y) {     return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;   }   template <class T>   inline T Swap(T &a, T &b) {     a = a ^ b;     b = a ^ b;     a = a ^ b;   }   template <class T>   inline T gcd(T a, T b) {     return (b) == 0 ? (a) : gcd((b), ((a) % (b)));   }   template <class T>   inline T lcm(T a, T b) {     return ((a) / gcd((a), (b)) * (b));   }   template <class T>   inline T bigmod(T p, T e, T M) {     long long ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return (T)ret;   }   template <class T>   inline T modinverse(T a, T M) {     return bigmod(a, M - 2, M);   }   struct an {     int a;     int d;     bool operator<(const an &t) const { return d < t.d; }   };   int main() {     int i, j, k, n, a[200];     int miniind, maxiind, maxi, mini;     while (scanf( %d , &n) != EOF) {       maxi = 0;       mini = 200;       for (i = 0; i < n; i++) {         scanf( %d , &a[i]);         if (a[i] > maxi) {           maxi = a[i];           maxiind = i;         }         if (a[i] < mini) {           mini = a[i];           miniind = i;         }       }       printf( %d n ,              max(n - maxiind - 1, max(maxiind, max(n - miniind - 1, miniind))));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Q, m, n, a[10001], c[100001], ans, f[5001][101], d[1001];   char b[500001][13];   void dfs(int x, int now, int zong, int he) {     if (x > n) {       if (zong <= 100) f[he][zong] += c[now];       return;     }     dfs(x + 1, now * 2 + 1, zong + (d[x] == 1 ? a[x] : 0), he);     dfs(x + 1, now * 2, zong + (d[x] == 0 ? a[x] : 0), he);   }   int main() {     int i, j, now, t, ha;     char s[10001];     scanf( %d%d%d , &n, &m, &Q);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     for (i = 1; i <= m; i++) {       now = 0;       scanf( %s , b[i] + 1);       for (j = 1; j <= n; j++) {         now = now * 2;         if (b[i][j] ==  1 ) now++;       }       c[now]++;     }     for (i = 0; i < (1 << n); i++) {       now = i;       ha = 0;       for (j = 1; j <= n; j++) {         d[j] = now % 2;         ha = ha * 2 + d[j];         now /= 2;       }       dfs(1, 0, 0, ha);     }     for (i = 0; i < (1 << n); i++)       for (j = 1; j <= 100; j++) f[i][j] += f[i][j - 1];     while (Q--) {       scanf( %s%d , s + 1, &t);       now = 0;       for (i = 1; i <= n; i++) now = now * 2 + (s[i] ==  1 );       printf( %d n , f[now][t]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t;     cin >> t;     while (t--) {       long long n, g, b;       cin >> n >> g >> b;       if (g >= b) {         cout << n << endl;         continue;       }       long long good_need = n / 2;       if (n % 2 == 1) good_need += 1;       good_need -= g;       long long bad_poss = n / 2;       long long periods = bad_poss / b;       if (good_need - periods * g <= 0) {         cout << n << endl;         continue;       }       good_need -= periods * g;       long long restperiods = good_need / g;       long long rest = 0;       if (good_need % g != 0) {         rest = good_need % g + b;       }       cout << g + (periods + restperiods) * (g + b) + rest << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, c, d;     while (scanf( %d , &n) != EOF) {       int j, x, y, flag = 0;       for (int i = 1; i <= 4; i++) {         scanf( %d%d%d%d , &a, &b, &c, &d);         a = min(a, b);         b = min(c, d);         if (a + b <= n) {           x = a;           y = n - x;           j = i;           flag = 1;         }       }       if (flag)         printf( %d %d %d n , j, x, y);       else         printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int c0, c1, c2, c3;     cin >> c0 >> c1 >> c2 >> c3;     if (c1 - c0 == c2 - c1 && c2 - c1 == c3 - c2) {       cout << c3 + c1 - c0 << endl;     } else if (c1 * c1 == c0 * c2 && c2 * c2 == c1 * c3 && !((c3 * c3) % c2)) {       cout << c3 * c1 / c0 << endl;     } else {       cout << 42 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int w[1501000], cnt[1501000];   int main() {     int N, i;     int po, ans;     scanf( %d , &N);     for (int i = (0); i < (N); i++) scanf( %d , w + i);     sort(w, w + N);     memset(cnt, 0, sizeof(cnt));     for (int i = (0); i < (N); i++) cnt[w[i]]++;     po = 0;     ans = 0;     for (int po = (0); po < (1501000); po++) {       if (cnt[po] == 0) continue;       cnt[po + 1] += cnt[po] / 2;       if (cnt[po] % 2) ans++;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[510][510];   int d[1010][510];   int d2[1010][510];   int x, y, nr[1010], nr2[1010];   int n, m, i, j, ok;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) scanf( %d , &a[i][j]);     for (i = 1; i <= n; i++) {       x = i;       y = 1;       nr[i] = 0;       while (x > 0 && y <= m) {         d[i][++nr[i]] = a[x][y];         x--;         y++;       }       sort(d[i] + 1, d[i] + nr[i] + 1);     }     for (i = 2; i <= m; i++) {       x = n;       y = i;       nr[i + n - 1] = 0;       while (x > 0 && y <= m) {         d[i + n - 1][++nr[i + n - 1]] = a[x][y];         x--;         y++;       }       sort(d[i + n - 1] + 1, d[i + n - 1] + nr[i + n - 1] + 1);     }     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) scanf( %d , &a[i][j]);     for (i = 1; i <= n; i++) {       x = i;       y = 1;       nr2[i] = 0;       while (x > 0 && y <= m) {         d2[i][++nr2[i]] = a[x][y];         x--;         y++;       }       sort(d2[i] + 1, d2[i] + nr2[i] + 1);     }     for (i = 2; i <= m; i++) {       x = n;       y = i;       nr2[i + n - 1] = 0;       while (x > 0 && y <= m) {         d2[i + n - 1][++nr2[i + n - 1]] = a[x][y];         x--;         y++;       }       sort(d2[i + n - 1] + 1, d2[i + n - 1] + nr2[i + n - 1] + 1);     }     ok = 1;     for (i = 1; i <= n + m - 1 && ok; i++) {       for (j = 1; j <= nr[i] && ok; j++)         if (d[i][j] != d2[i][j]) ok = 0;     }     if (ok)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int h, m, n, vn;   map<int, pair<int, int> > M;   int group[222222], pos[222222], host[222222];   vector<int> v[222222], first[222222];   inline void add(int i, int x, int d) {     int m = first[i].size();     while (x < m) {       first[i][x] += d;       x = x | (x + 1);     }   }   inline int sum(int i, int x) {     int m = first[i].size(), res = 0;     while (x >= 0) {       res += first[i][x];       x = (x & (x + 1)) - 1;     }     return res;   }   int main() {     memset(host, -1, sizeof(host));     scanf( %d%d%d n , &h, &m, &n);     memset(group, -1, sizeof(group));     for (int i = 0; i < h; ++i)       if (group[i] == -1) {         for (int j = i; group[j] == -1; j = (j + m) % h) {           pos[j] = v[vn].size();           group[j] = vn;           v[vn].push_back(j);         }         ++vn;       }     for (int i = 0; i < vn; ++i) {       first[i].resize(int(v[i].size()));       for (int j = 0; j < v[i].size(); ++j) add(i, j, 1);     }     long long res = 0;     for (int i = 0; i < n; ++i) {       char ch;       int id, hash;       scanf( %c %d , &ch, &id);       if (ch ==  + ) {         scanf( %d , &hash);         int j = group[hash];         int k = pos[hash];         int l = k - 1, r = v[j].size();         int base = sum(j, k - 1);         while (r - l > 1) {           int mid = (l + r) / 2;           if (sum(j, mid) > base)             r = mid;           else             l = mid;         }         if (r < v[j].size()) {           M[id] = make_pair(j, r);           add(j, r, -1);           res += r - k;         } else {           l = -1, r = k;           while (r - l > 1) {             int mid = (l + r) / 2;             if (sum(j, mid) > 0)               r = mid;             else               l = mid;           }           M[id] = make_pair(j, r);           add(j, r, -1);           res += v[j].size() - k + r;         }       } else if (ch ==  - ) {         int j = M[id].first;         int k = M[id].second;         add(j, k, 1);       }       scanf(  n );     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, Max, reg;   int TIME = 0;   vector<int> T, W;   bool used[1010];   int p[1010], dmg[1010];   int main() {     int i, j, k, l, x, y;     cin >> n >> Max >> reg;     for (i = 0; i < n; ++i) cin >> p[i] >> dmg[i];     int ch = Max, cd = 0;     while (1) {       ch -= cd;       ch = min(Max, ch + reg);       if (ch <= 0) break;       j = -1;       for (i = 0; i < n; ++i) {         if (used[i] || p[i] * Max < 100 * ch) continue;         if (j == -1 || dmg[j] < dmg[i]) j = i;       }       if (j != -1 && dmg[j] >= 0) {         if (dmg[j] > cd || true) {           T.push_back(TIME);           W.push_back(j + 1);           used[j] = true;           cd += dmg[j];         }       }       ++TIME;       if (TIME >= 10000) break;     }     if (ch > 0)       cout <<  NO n ;     else {       cout <<  YES n ;       cout << TIME <<     << T.size() << endl;       for (i = 0; i < T.size(); ++i) cout << T[i] <<     << W[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 1e5 + 10;   const int N = 2e5;   using namespace std;   long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }   long long qmul(long long p, long long q, long long mo) {     long long f = 0;     while (q) {       if (q & 1) f = (f + p) % mo;       p = (p + p) % mo;       q >>= 1;     }     return f;   }   long long qpow(long long p, long long q) {     long long f = 1;     while (q) {       if (q & 1) f = f * p % 19260817;       p = p * p % 19260817;       q >>= 1;     }     return f;   }   int n, m, k, t;   int main() {     int i, j;     scanf( %d , &n);     for (i = n;; i--) {       if (n % i) continue;       j = i;       int cnta = 0, cntb = 0;       while (j && j % 2 == 0) cnta++, j /= 2;       while (j && j % 2 == 1) cntb++, j /= 2;       if (!j && cntb == cnta + 1) return 0 * printf( %d n , i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 65;   long long S, L, ans;   long long P[N] = {1};   long long f[N][N * 2][2];   int main() {     scanf( %lld , &S);     L = log2(S + 1);     for (int i = 1; i < N; ++i) P[i] = P[i - 1] << 1;     for (int h = 1; h <= L; ++h) {       long long x = S % (P[h] - 1);       for (int i = h; i; --i)         if (x >= P[i] - 1) x -= P[i] - 1;       ans += (!x);     }     for (int h0 = 1; h0 < L; ++h0)       for (int h1 = 1; S + 1 - P[h1] >= P[h0 + 1] + P[h1 + 1] - 3; ++h1) {         long long x = (S + 1 - P[h1]) / (P[h0 + 1] + P[h1 + 1] - 3);         long long r = (S + 1 - P[h1]) % (P[h0 + 1] + P[h1 + 1] - 3);         if (!r) {           ans++;           continue;         }         if (h0 == 1 && h1 == 1) {           ans += (S == x * 5 + 1);           continue;         }         for (int n = 1; n <= h0 + h1; ++n) {           long long C = r + n, L = log2(C) + 1;           if (C & 1) continue;           memset(f[0], 0, sizeof f[0]);           f[0][0][0] = 1;           for (int i = 1; i <= L; ++i) {             int d = (C >> i) & 1;             memset(f[i], 0, sizeof f[i]);             for (int j = 0; j <= i + i - 2 && j <= n; ++j)               for (int k = 0; k < 2; ++k)                 if (f[i - 1][j][k])                   for (int x = 0; x < 2; ++x)                     if (!x || i < h0)                       for (int y = 0; y < 2; ++y)                         if (!y || i < h1)                           if (((k + x + y) & 1) == d)                             f[i][j + x + y][(k + x + y) >> 1] += f[i - 1][j][k];           }           ans += f[L][n][0];         }       }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n & 1) {       cout << -1;       return 0;     }     if (n < 3) {       cout <<  bb nww n nbb nww ;       return 0;     }     string s1, s2;     for (int i = 0; i < 110; i++) s1 += (i % 4 < 2) ?  w  :  b ;     s2 = s1.substr(2);     s1 = s1.substr(0, n);     s2 = s2.substr(0, n);     for (int i = 0; i < n; i++) {       int x = i & 1;       for (int j = 0; j < n; j++) {         int y = (j % 4) < 2 ? 1 : 0;         if (x ^ y)           cout << s1 <<   n ;         else           cout << s2 <<   n ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[4], i, j, s;   int main() {     for (i = 0; i < 4; i++) {       scanf( %d , &a[i]);       s += a[i];     }     for (i = 0; i < 4; i++) {       if (a[i] == s - a[i]) {         puts( YES );         return 0;       }       for (j = i + 1; j < 4; j++)         if (a[i] + a[j] == s - a[i] - a[j]) {           puts( YES );           return 0;         }     }     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static inline void amin(int &a, int b) {     if (a > b) a = b;   }   int main() {     int N, M;     scanf( %d%d , &N, &M);     int A[N];     for (int i = 0; i < N; ++i) {       scanf( %d , &A[i]);     }     pair<int, int> Q[M];     for (int i = 0; i < M; ++i) {       scanf( %d%d , &Q[i].first, &Q[i].second);       Q[i].first--;       Q[i].second--;     }     int res = *max_element(A, A + N) - *min_element(A, A + N);     list<int> res_q;     int changes[N];     for (int mx = 0; mx < N; ++mx) {       list<int> q;       memset(changes, 0, sizeof changes);       for (int i = 0; i < M; ++i)         if (mx < Q[i].first || Q[i].second < mx) {           q.push_back(i);           for (int j = Q[i].first; j < Q[i].second + 1; ++j) changes[j]--;         }       int mn = numeric_limits<int>::max();       for (int i = 0; i < N; ++i) amin(mn, A[i] + changes[i]);       if (res < A[mx] - mn) {         res = A[mx] - mn;         res_q = q;       }     }     printf( %d n%d n , res, (int)res_q.size());     for (auto it : res_q) printf( %d  , it + 1);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   template <class T, class U>   istream &operator>>(istream &in, pair<T, U> &p) {     in >> p.first >> p.second;     return in;   }   template <class T, class U>   ostream &operator<<(ostream &out, const pair<T, U> &p) {     out << p.first <<     << p.second;     return out;   }   template <class T>   istream &operator>>(istream &in, vector<T> &v) {     for (auto &i : v) {       in >> i;     }     return in;   }   template <class T>   ostream &operator<<(ostream &out, const vector<T> &v) {     for (auto &i : v) {       out << i <<    ;     }     return out;   }   inline void io(int x = 15) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     srand(time(0));     cout << fixed << setprecision(x);   }   vector<int> prefix_function(string s) {     int n = s.length();     vector<int> pi(n);     for (int i = 1; i < n; ++i) {       int j = pi[i - 1];       while (j > 0 && s[i] != s[j]) {         j = pi[j - 1];       }       if (s[i] == s[j]) ++j;       pi[i] = j;     }     return pi;   }   bool prime_test(long long n) {     for (long long i = 2; i * i <= n; ++i)       if ((n >= 0 && n < 2) || n % i == 0) return false;     return true;   }   void prime_nums(int n, vector<char> &prime) {     prime[0] = prime[1] = false;     for (long long i = 2; i * i <= n; ++i) {       if (prime[i]) {         for (int j = i * i; j <= n; j += i) {           prime[j] = false;         }       }     }   }   long long bin_pow(long long a, long long b, long long m = 0) {     if (m == 0)       return b == 0 ? 1 : (b % 2 ? bin_pow(a, b - 1) * a : bin_pow(a * a, b / 2));     if (b == 0) return 1;     long long temp = bin_pow(a, b / 2, m);     if (b % 2 == 0)       return (temp * temp) % m;     else       return (a * temp * temp) % m;   }   bool nextperm(vector<char> &a) {     int n = a.size();     for (int i = n - 2; i >= 0; --i) {       if (a[i] < a[i + 1]) {         int mnv = a[i + 1], mni = i + 1;         for (int j = i + 2; j < n; ++j) {           if (a[j] < mnv && a[j] > a[i]) {             mni = j;             mnv = a[j];           }         }         swap(a[i], a[mni]);         reverse(a.begin() + i + 1, a.end());         return true;       }     }     return false;   }   int main() {     io();     int n, s;     cin >> n >> s;     vector<int> used(n);     for (int i = 0; i < n - 1; ++i) {       int l, r;       cin >> l >> r;       ++used[--l];       ++used[--r];     }     int x = 0;     for (int i = 0; i < n; ++i) {       if (used[i] == 1) {         ++x;       }     }     cout << (long double)s / x * 2;     return 0;   }