malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int limN = 1e5 + 5;   vector<pair<long long, int> > adj[limN];   bool usd[limN];   long long minP[limN];   int main() {     int ans = 0;     int N, E1, E2;     priority_queue<tuple<long long, int, int> > Q;     scanf( %d%d%d , &N, &E1, &E2);     for (int a, b, c; E1; E1--) {       scanf( %d%d%d , &a, &b, &c);       a--, b--;       adj[a].push_back({c, b});       adj[b].push_back({c, a});     }     for (int b, c; E2; E2--) {       scanf( %d%d , &b, &c);       b--;       Q.push({-c, 0, b});     }     Q.push({0, 1, 0});     while (!Q.empty()) {       long long dst;       int tip, pos;       tie(dst, tip, pos) = Q.top();       Q.pop();       if (usd[pos]) {         ans += 1 - tip;         continue;       }       dst *= -1;       usd[pos] = true;       for (const auto &second : adj[pos]) {         if (!usd[second.second] || minP[second.second] > dst + second.first) {           minP[second.second] = dst + second.first;           Q.push({-minP[second.second], 1, second.second});         }       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int len = s.size();     bool flag = false;     for (int i = 0; i < len - 1; i++) {       if ((s[i] !=  a  && s[i] !=  e  && s[i] !=  i  && s[i] !=  o  &&            s[i] !=  u )) {         if (s[i] ==  n )           continue;         else {           if ((s[i + 1] ==  a  || s[i + 1] ==  e  || s[i + 1] ==  i  ||                s[i + 1] ==  o  || s[i + 1] ==  u )) {             continue;           } else {             flag = true;             break;           }         }       }     }     if ((s[len - 1] !=  a  && s[len - 1] !=  e  && s[len - 1] !=  i  &&          s[len - 1] !=  o  && s[len - 1] !=  u  && s[len - 1] !=  n ))       flag = true;     if (!flag) {       cout <<  YES n ;     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1007;   bool ans[MAXN];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     int n = s.size();     int l = 0;     for (int i = 0; i < n; ++i) {       if (s[i] ==  a  && (i == n - 1 || s[i + 1] ==  b )) {         ans[l] = 1;         ans[i] = 1;       }       if (s[i] ==  b ) l = i;     }     for (int i = 0; i < n; ++i) cout << ans[i] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_MEM = (int)1e8;   int mpos = 0;   char mem[MAX_MEM];   inline void *operator new(size_t n) {     char *res = mem + mpos;     mpos += n;     return (void *)res;   }   inline void operator delete(void *) {}   struct __io_dev {     __io_dev(const bool &__fastio = false) {       if (__fastio) ios_base::sync_with_stdio(false), cin.tie(nullptr);       srand(time(nullptr));       if (!string(  ).empty())         freopen(                             .in ,              r , stdin),             freopen(                                     .out ,                  w , stdout);     }     ~__io_dev() { fprintf(stderr,  %.6f ms n , 1e3 * clock() / CLOCKS_PER_SEC); }   } __io(false);   const long long inf = (long long)1e+9 + 7ll;   const long long linf = (long long)1e+18 + 7ll;   const long double eps = (long double)1e-9;   const long double pi = acosl((long double)-1.0);   const int alph = 26;   const int maxs = 512l;   static char buff[(int)2e6 + 17];   long long __p[3] = {29ll, 31ll, 33ll};   long long __mod[3] = {inf, inf + 2ll, 14881337ll};   const int maxn = (int)2e5 + 17;   int n;   string s;   long long R, K;   void print(int R, int K) {     string r;     int cnt = 0;     for (; R > 0; R /= 10) {       r.push_back(char( 0  + R % 10));       ++cnt;       if (cnt % 3 == 0) r.push_back( . );     }     if (r.back() ==  . ) r.pop_back();     if (((int)(r.size())) == 0) r.push_back( 0 );     reverse(r.begin(), r.end());     printf( %s , r.c_str());     if (K != 0) printf( .%.2d , K);   }   int main() {     scanf( %s , buff);     s = string(buff);     n = ((int)(s.size()));     for (int i = 0; i < n; ++i)       if (!( a  <= s[i] && s[i] <=  z )) {         int r = i;         string t =   ;         for (; r < n && !( a  <= s[r] && s[r] <=  z ); ++r) t += s[r];         if (((int)(t.size())) >= 3 && t[((int)(t.size())) - 3] ==  . ) {           K += 10 * (t[((int)(t.size())) - 2] -  0 ) + t[((int)(t.size())) - 1] -                 0 ;           int cursize = ((int)(t.size()));           t.resize(cursize - 3);         }         long long cur = 0;         for (auto c : t)           if ( 0  <= c && c <=  9 ) cur = cur * 10ll + c -  0 ;         R += cur;         i = r - 1;       }     R += K / 100;     K %= 100;     print(R, K);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, p[100002];   bool id[100002];   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       for (int i = 1; i <= n; i++) {         int a;         scanf( %d , &a);         p[a] = i;         id[i] = true;       }       id[n + 1] = 0;       bool succeed = true;       int num = 1;       int tp = p[1];       p[1] = 0;       id[tp] = 0;       for (int i = 2; i <= n; i++) {         if (id[tp + 1] == false) {           id[p[i]] = false;           tp = p[i];         } else {           if (tp + 1 != p[i]) {             succeed = false;             break;           } else {             id[tp + 1] = false;             tp = tp + 1;           }         }       }       if (succeed)         printf( Yes n );       else         printf( No n );     }   }
#include <bits/stdc++.h>   using namespace std;   long long q, dp[105][100005], a[555555], b[555555], k, l, m, n, o, p;   map<long long, long long> mp;   vector<long long> adj[555555];   const long long mod = 1e9 + 7;   void solve() {     cin >> n;     for (long long i = 1; i <= n; i++) {       string s =   ;       cin >> s;       long long op[26], po = 0;       memset(op, 0, sizeof op);       for (auto u : s) {         op[u -  a ]++;       }       for (long long i = 0; i < 26; i++) {         po += (1 << i) * (op[i] % 2);       }       mp[po]++;       a[i] = po;     }     for (long long i = 1; i <= n; i++) {       mp[a[i]]--;       k += mp[a[i]];       for (long long j = 0; j < 26; j++) {         k += mp[a[i] ^ (1 << j)];       }     }     cout << k;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     q = 1;     while (q--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const bool debug = false;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     string s[8];     for (int i = 0; i < 8; i++) {       cin >> s[i];     }     int r = 0, col = 0;     for (int i = 0; i < 8; i++) {       int c = 0;       for (int j = 0; j < 8; j++) {         if (s[i][j] ==  B ) c++;       }       if (c == 8) r++;     }     for (int i = 0; i < 8; i++) {       int c = 0;       for (int j = 0; j < 8; j++) {         if (s[j][i] ==  B ) c++;       }       if (c == 8) col++;     }     if (r == 0 and col == 0) {       cout << 0;       return 0;     }     if (r == 8 or col == 8) {       cout << 8;       return 0;     }     cout << r + col;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2010;   const int mod = 1000000007;   long long dp[maxn][maxn];   long long s[maxn][maxn], ss[maxn][maxn];   void upd(long long &t, long long k) {     t += k;     t %= mod;   }   int main() {     int n, i, j, m;     long long t;     cin >> n >> m;     for (i = 1; i <= n; i++) {       for (j = 0; j + 1 < m; j++) {         long long t = 1 + s[i - 1][j] * (j + 1) - ss[i - 1][j];         upd(dp[i][j], t);       }       s[i][0] = dp[i][0];       for (j = 1; j + 1 < m; j++) {         s[i][j] = s[i][j - 1] + dp[i][j], ss[i][j] = ss[i][j - 1] + dp[i][j] * j;         s[i][j] %= mod;         ss[i][j] %= mod;       }     }     long long ans = 0;     for (i = 1; i <= n; i++) {       for (j = 0; j + 1 < m; j++) {         long long t1 = dp[i][j] - dp[i - 1][j];         long long t2 = dp[n - i + 1][j];         ans += t1 * t2 % mod * (m - j - 1);         ans %= mod;       }     }     cout << (ans + mod) % mod << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, w, x, c, ans;   int main() {     cin >> a >> b >> w >> x >> c;     if (c <= a) {       cout << 0 << endl;     } else {       ans = ceil(1.0 * (x * (c - a) - b) / (w - x));       cout << ans + c - a << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, d, b, l, r, need, ans1, ans2;   long long a[500011], n1[500011], n2[500011];   int main() {     scanf( %lld%lld%lld , &n, &d, &b);     long long re = (n >> 1) * b;     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (int i = 1; i <= n; i++)       n1[i] = min(a[i], re) + n1[i - 1], re -= min(a[i], re);     re = (n >> 1) * b;     for (int i = n; i; i--)       n2[i] = min(a[i], re) + n2[i + 1], re -= min(a[i], re);     for (int i = 1; i <= n / 2; i++) {       r = min(r + d + 1, n);       if (need + b <= n1[r])         need += b;       else         ans1++;     }     l = n + 1;     need = 0;     for (int i = n; i >= ((n + 1) / 2) + 1; i--) {       l = max(1LL, l - d - 1);       if (need + b <= n2[l])         need += b;       else         ans2++;     }     printf( %lld n , max(ans1, ans2));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s, ans;     cin >> s;     ans = s;     s += s;     for (int k = 0; k < 10; k++) {       for (int i = 0; i < s.length(); i++) {         s[i]++;         if (s[i] >  9 ) s[i] =  0 ;       }       for (int i = 0; i < n; i++) {         ans = min(ans, s.substr(i, n));       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int inf = 1e9;   int mod = 1e9 + 7;   const int M = 20;   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     int n = (int)s.length();     int dp[(1 << M)];     memset(dp, 0, sizeof(dp));     int maxi = 0;     for (int i = 0; i < n; i++) {       int mask = 0;       int cnt = 0;       for (int j = i; j < n; j++) {         int x = s[j] -  a ;         if ((mask >> x) & 1) {           break;         }         mask ^= (1 << x);         cnt++;         dp[mask] = cnt;       }       maxi = max(maxi, cnt);     }     for (int i = 0; i < M; i++) {       for (int j = 0; j < (1 << M); j++) {         if (j & (1 << i)) {           dp[j] = max(dp[j], dp[j ^ (1 << i)]);         }       }     }     for (int i = 0; i < (1 << M); i++) {       int comp = (1 << M) - 1 - i;       maxi = max(maxi, dp[i] + dp[comp]);     }     cout << maxi <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxm = 2e6 + 5;   struct task {     int t, k, d;   } tasks[maxm];   int times[110];   int main() {     for (int i = 0; i < 110; ++i) {       times[i] = 0;     }     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       scanf( %d%d%d , &tasks[i].t, &tasks[i].k, &tasks[i].d);     }     for (int i = 0; i < m; ++i) {       int num = 0, j = 1, res = 0;       if (tasks[i].k > n) {         printf( -1 n );         continue;       }       while (j <= n) {         if (times[j] <= tasks[i].t) {           num++;         }         if (num == tasks[i].k) break;         j++;       }       j = 1;       if (num == tasks[i].k) {         int cnt = 0;         while (j <= n) {           if (times[j] <= tasks[i].t) {             res += j;             times[j] = tasks[i].t + tasks[i].d;             cnt++;           }           if (cnt == tasks[i].k) break;           j++;         }         printf( %d n , res);       } else {         printf( -1 n );         continue;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 510;   int t, n, m, a, b, c;   vector<pair<int, int> > g[N];   int dp[N][N], inDegree[N][N], source, ans[N][N];   bool vis[N];   void dfs(int u) {     if (vis[u]) return;     vis[u] = 1;     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i].first;       int newCost = g[u][i].second + dp[source][u];       if (dp[source][v] == newCost) {         inDegree[source][v]++;         dfs(v);       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         dp[i][j] = 1e9;       }       dp[i][i] = 0;     }     for (int i = 0; i < m; ++i) {       scanf( %d%d%d , &a, &b, &c);       g[a].push_back(make_pair(b, c));       g[b].push_back(make_pair(a, c));       dp[a][b] = min(dp[a][b], c);       dp[b][a] = min(dp[b][a], c);     }     for (int k = 1; k <= n; k++) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);         }       }     }     for (source = 1; source <= n; source++) {       memset(vis, 0, sizeof vis);       dfs(source);     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         for (int k = 1; k <= n; k++) {           if (dp[i][k] + dp[k][j] == dp[i][j]) {             ans[i][j] += inDegree[i][k];           }         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         printf( %d  , ans[i][j]);       }     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200005];   bool got[200004], gave[200004];   queue<int> q;   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       got[a[i]] = 1;       if (a[i] != 0) {         gave[i] = 1;       }     }     for (int i = 1; i <= n; i++) {       if (!got[i]) {         q.push(i);       }     }     for (int i = 1; i <= n; i++) {       if (!got[i] && !gave[i]) {         int x = q.front();         q.pop();         if (x == i) {           q.push(x);           x = q.front();           q.pop();         }         a[i] = x;         gave[i] = 1;         got[x] = 1;       }     }     for (int i = 1; i <= n; i++) {       if (!gave[i]) {         int x = q.front();         q.pop();         a[i] = x;         gave[i] = 1;         got[x] = 1;       }     }     for (int i = 0; i < n; i++) {       cout << a[i + 1] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   bool check(string pattern, string text) {     int j = 0;     int i = 0;     while (i < text.size()) {       if (pattern[j] == text[i]) {         j++;       }       i++;     }     return j == pattern.size();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int d;     cin >> d;     while (d--) {       string s, t, p;       cin >> s >> t >> p;       string k = s;       s = s + p;       map<char, long long int> m_s;       map<char, long long int> m_t;       for (int i = 0; i < s.size(); ++i) {         m_s[s[i]]++;       }       for (int i = 0; i < t.size(); ++i) {         m_t[t[i]]++;       }       bool checks = true;       for (auto i : m_t) {         if (m_s[i.first] < i.second) {           checks = false;         }       }       if (checks && check(k, t)) {         cout <<  YES               <<   n ;       } else {         cout <<  NO               <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   vector<string> split(const string& s, char c) {     vector<string> v;     stringstream ss(s);     string x;     while (getline(ss, x, c)) v.emplace_back(x);     return move(v);   }   void err(vector<string>::iterator it) {}   template <typename T, typename... Args>   void err(vector<string>::iterator it, T a, Args... args) {     cerr << it->substr((*it)[0] ==    , it->length()) <<   =   << a <<   t ;     err(++it, args...);   }   const long double eps = 1e-9;   const long long mod = 1e9 + 7;   pair<long long, long long> dir[8] = {{-1, 0}, {1, 0},   {0, -1}, {0, 1},                                        {1, 1},  {-1, -1}, {-1, 1}, {1, -1}};   const long long nn = 3e5 + 5;   vector<long long> g[nn];   long long par[nn];   long long sz[nn];   long long centroid[nn];   void dfs(long long v) {     sz[v] = 1;     for (long long to : g[v]) {       dfs(to);       sz[v] += sz[to];     }     long long bad = -1;     for (long long to : g[v]) {       if (sz[to] * 2 > sz[v]) bad = to;     }     if (bad == -1) {       centroid[v] = v;     } else {       centroid[v] = centroid[bad];       while (sz[centroid[v]] * 2 <= sz[v]) {         centroid[v] = par[centroid[v]];       }     }   }   void robin() {     long long n, q;     cin >> n >> q;     for (long long i = 2; i <= n; i++) {       long long v;       cin >> v;       par[i] = v;       g[v].push_back(i);     }     dfs(1);     while (q--) {       long long v;       cin >> v;       cout << centroid[v] <<   n ;     }   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long T = 1;     for (long long tc = 1; tc <= T; tc++) {       robin();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int k;     cin >> k;     int sum = (1 << 18) - 1;     cout <<  3 3 n ;     cout << sum <<     << (1 << 17) <<     << 0 <<   n ;     cout << k <<     << sum <<     << 0 <<   n ;     cout << 0 <<     << k <<     << k <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int arr[n + 1];     for (int i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     for (int i = n - 1; i >= 0; i--) {       if (k % arr[i] == 0) {         cout << (k / arr[i]) << endl;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200000];   int b[200001];   int br[200001];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 1; i <= m; i++) cin >> b[i];     int minimum = 0;     for (int i = 1; i <= m; i++) minimum += b[i];     int ok = 0;     for (int i = 1; i <= m; i++) ok += !b[i];     int left = 0;     int ans = n + 1;     for (int right = 0; right < n; right++) {       br[a[right]]++;       if (br[a[right]] == b[a[right]]) ok++;       while (ok == m) {         ans = min(ans, right - left + 1);         if (br[a[left]] == b[a[left]]) ok--;         br[a[left]]--;         left++;       }     }     if (ans == n + 1)       cout << -1 << endl;     else       cout << ans - minimum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 10;   vector<pair<string, int> > ch[MAXN];   int nxt[MAXN][27], n, gp, ans;   string t;   void adds(string &tmp) {     for (int i = 0; i < tmp.size(); i++) {       gp = nxt[gp][tmp[i] -  a ];       if (gp == t.size()) ans++;     }   }   void dfs(int v, int p) {     for (int i = 0; i < ch[v].size(); i++) {       gp = p;       adds(ch[v][i].first);       dfs(ch[v][i].second, gp);     }   }   int main() {     cin >> n;     for (int i = 2; i <= n; i++) {       string tmp;       int r;       cin >> r >> tmp;       ch[r].push_back({tmp, i});     }     cin >> t;     nxt[0][t[0] -  a ] = 1;     int cp = 0;     for (int i = 1; i <= t.size(); i++) {       for (char c =  a ; c <=  z ; c++) {         if (t[cp] == c)           nxt[i][c -  a ] = cp + 1;         else           nxt[i][c -  a ] = nxt[cp][c -  a ];       }       if (i < t.size()) {         nxt[i][t[i] -  a ] = i + 1;         if (t[cp] == t[i])           cp++;         else           cp = nxt[cp][t[i] -  a ];       }     }     dfs(1, 0);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       string s;       cin >> s;       long long int x = 0, y = 0, p, q, sum = 0;       set<pair<int, int> > ma;       for (long long int i = 0; i < s.size(); i++) {         p = x;         q = y;         if (s[i] ==  N )           y++;         else if (s[i] ==  S )           y--;         else if (s[i] ==  W )           x++;         else           x--;         if (!ma.count({x + p, q + y})) {           sum = sum + 5;           ma.insert({x + p, q + y});         } else           ++sum;       }       cout << sum << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxN = 1e6 + 100;   const long long maxM = 1e3 + 100;   const long long mod = 1e9 + 7;   const long long hmod = 1e16 + 7;   const long double PI = 3.141592653;   const long double eps = 1e-8;   const long long D = 1379;   const long long INF = 1e18 + 20;   const long long Inf = 1e9 + 140;   void NO() {     cout <<  NO  << endl;     exit(0);   }   void YES() {     cout <<  YES  << endl;     exit(0);   }   long long n, k;   bool mrk[2][maxN], mark[2][maxN];   void dfs(long long v, long long x = 0, long long W = 0) {     if (v > n) YES();     if (v <= 0 || mrk[x][v] || mark[x][v] || v <= W) return;     mark[x][v] = true;     W++;     dfs(v + k, x ^ 1, W);     dfs(v + 1, x, W);     dfs(v - 1, x, W);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (long long i = 1; i <= n; i++) {       char c;       cin >> c;       if (c ==  X ) mrk[0][i] = true;     }     for (long long i = 1; i <= n; i++) {       char c;       cin >> c;       if (c ==  X ) mrk[1][i] = true;     }     dfs(1);     NO();   }
#include <bits/stdc++.h>   using namespace std;   double prb[(1 << 21)], p[25], ans[25];   int vis[(1 << 21)];   bool eq(double a, double b) { return (abs(a - b) < 1e-12); }   int main() {     int i, n, k, tmp;     scanf( %d , &n);     scanf( %d , &k);     tmp = n;     for (i = 0; i < n; i++) {       scanf( %lf , &p[i]);       if (eq(p[i], 0)) tmp--;     }     k = min(k, tmp);     prb[0] = 1;     queue<int> all;     all.push(0);     while (!all.empty()) {       int now = all.front();       all.pop();       if (__builtin_popcount(now) == k)         for (i = 0; i < n; i++)           if (now & (1 << i)) ans[i] += prb[now];       double gun = 0;       for (i = 0; i < n; i++)         if (!(now & (1 << i))) gun += p[i];       gun = 1 / gun;       if (__builtin_popcount(now) < k)         for (i = 0; i < n; i++) {           if ((now & (1 << i)) || eq(p[i], 0)) continue;           tmp = now ^ (1 << i);           prb[tmp] += (p[i] * gun * prb[now]);           if (!vis[tmp]) {             vis[tmp] = 1;             all.push(tmp);           }         }     }     for (i = 0; i < n; i++) printf( %.15f  , ans[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e5 + 100;   vector<int> v[MAX_N];   int dp[MAX_N], ans, deep[MAX_N];   void dfs(int x, int fa, int dep) {     int i;     deep[x] = dep;     for (i = 0; i < v[x].size(); i++) {       int y = v[x][i];       if (y == fa) continue;       dfs(y, x, dep + 1);     }   }   void dfs(int x, int fa) {     int i;     dp[x] = 0;     for (i = 0; i < v[x].size(); i++) {       int y = v[x][i];       if (y == fa) continue;       dfs(y, x);       ans = max(ans, dp[x] + dp[y] + 1);       dp[x] = max(dp[x], dp[y] + 1);     }   }   int main(void) {     int T, n, a, b, da, db, i, x, y;     cin >> T;     while (T--) {       scanf( %d%d%d%d%d , &n, &a, &b, &da, &db);       for (i = 1; i <= n; i++) v[i].clear();       for (i = 1; i < n; i++) {         scanf( %d%d , &x, &y);         v[x].push_back(y);         v[y].push_back(x);       }       dfs(a, -1, 0);       if (deep[b] <= da) {         puts( Alice );         continue;       }       if (da * 2 >= db) {         puts( Alice );         continue;       }       ans = 0;       dfs(1, -1);       if (da * 2 >= ans)         puts( Alice );       else         puts( Bob );     }     return 0;   }