malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void solve(priority_queue<pair<long long, int>, vector<pair<long long, int> >,                             greater<pair<long long, int> > > &P,              priority_queue<pair<long long, int> > &N, vector<long long> &ans,              int k, int x) {     while (k > 0) {       int ps = P.size(), pn = N.size();       if (ps && pn) {         pair<long long, int> pt = P.top();         P.pop();         pair<long long, int> nt = N.top();         N.pop();         int sign = (pn & 1) ? -1 : 1;         if (nt.first * -1 <= pt.first) {           nt.first += sign * x;           if (nt.first >= 0) {             P.push(nt);             P.push(pt);           } else {             N.push(nt);             P.push(pt);           }         } else {           pt.first -= sign * x;           if (pt.first < 0) {             N.push(nt);             N.push(pt);           } else {             N.push(nt);             P.push(pt);           }         }       } else if (ps) {         pair<long long, int> pt = P.top();         P.pop();         pt.first -= x;         if (pt.first < 0) {           N.push(pt);         } else {           P.push(pt);         }       } else {         pair<long long, int> nt = N.top();         N.pop();         int sign = (pn & 1) ? -1 : 1;         nt.first += sign * x;         if (nt.first >= 0) {           P.push(nt);         } else {           N.push(nt);         }       }       k--;     }     while (!P.empty()) {       pair<long long, int> it = P.top();       P.pop();       ans[it.second] = it.first;     }     while (!N.empty()) {       pair<long long, int> it = N.top();       N.pop();       ans[it.second] = it.first;     }   }   int main() {     int n, k, x, t;     while (cin >> n >> k >> x) {       priority_queue<pair<long long, int>, vector<pair<long long, int> >,                      greater<pair<long long, int> > >           Qp;       priority_queue<pair<long long, int> > Qn;       for (int i = 0; i < n; i++) {         cin >> t;         if (t >= 0)           Qp.push(make_pair(t, i));         else           Qn.push(make_pair(t, i));       }       vector<long long> ans(n);       solve(Qp, Qn, ans, k, x);       for (int i = 0; i < n; i++) cout << ans[i] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   char ch[200000];   int main() {     scanf( %s , ch + 1);     int n = strlen(ch + 1);     int flag = 0;     for (int i = 1; i <= n; i++) {       if (ch[i] != ch[n - i + 1]) flag++;     }     if (flag == 2 || n % 2 == 1 && flag == 0)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> globmap;   int optwin[32000];   int optptsc[32000];   int optptso[32000];   int pts[32000];   map<string, int> hashid;   string hashinv[32000];   void findit(int s) {     if (optwin[s] != -1) {       return;     }     string S = hashinv[s];     string append =  z ;     optwin[s] = 0;     optptsc[s] = 0;     optptso[s] = 1000000000;     bool can = 0;     for (int c =  a ; c <=  z ; c++) {       append[0] = c;       string Snext;       for (int b = 0; b < 2; b++) {         if (b)           Snext = S + append;         else           Snext = append + S;         if (hashid.find(Snext) == hashid.end()) continue;         can = 1;         int snext = hashid[Snext];         findit(snext);         int candwin = !optwin[snext];         int candptsc = pts[snext] + optptso[snext];         int candptso = optptsc[snext];         if (candwin < optwin[s]) continue;         if (candwin > optwin[s]) {           optwin[s] = candwin;           optptsc[s] = candptsc;           optptso[s] = candptso;           continue;         }         if (candptsc < optptsc[s]) continue;         if (candptsc > optptsc[s]) {           optwin[s] = candwin;           optptsc[s] = candptsc;           optptso[s] = candptso;           continue;         }         if (candptso > optptso[s]) continue;         if (candptso < optptso[s]) {           optwin[s] = candwin;           optptsc[s] = candptsc;           optptso[s] = candptso;           continue;         }       }     }     if (!can) {       optwin[s] = 0;       optptsc[s] = 0;       optptso[s] = 0;     }   }   int main() {     int n;     scanf( %d , &n);     map<string, int> globmap;     for (int i = 0; i < n; i++) {       string word;       cin >> word;       map<string, bool> allsubs;       int L = word.size();       for (int i = 0; i < L; i++)         for (int j = i; j < L; j++) allsubs[word.substr(i, j - i + 1)] = 1;       for (map<string, bool>::iterator it = allsubs.begin(); it != allsubs.end();            it++) {         string S = (*it).first;         if (globmap.find(S) == globmap.end())           globmap[S] = 1;         else           globmap[S]++;       }     }     int ct = 0;     for (map<string, int>::iterator it = globmap.begin(); it != globmap.end();          it++) {       string S = (*it).first;       int L = S.size();       int maxx = 0;       int summ = 0;       for (int i = 0; i < L; i++) {         summ += S[i] -  a  + 1;         if (S[i] -  a  + 1 > maxx) maxx = S[i] -  a  + 1;       }       (*it).second += summ * maxx;       hashid[S] = ct + 1;       hashinv[ct + 1] = S;       pts[ct + 1] = (*it).second;       ct++;     }     hashid[  ] = 0;     hashinv[0] =   ;     pts[0] = 0;     ct++;     for (int i = 0; i < ct; i++) {       optwin[i] = -1;       optptsc[i] = -1;       optptso[i] = -1;     }     findit(0);     if (optwin[0])       printf( First n );     else       printf( Second n );     printf( %d %d n , optptsc[0], optptso[0]);   }
#include <bits/stdc++.h>   using namespace std;   int longestIncreasingSubsequenceDP(int a[], int n) {     int dp[n], ans = 0;     for (int k = 0; k < n; k++) {       dp[k] = 1;       for (int i = 0; i < k; i++) {         if (a[i] <= a[k]) {           dp[k] = max(dp[k], dp[i] + 1);           ans = max(dp[k], ans);         }       }     }     return ans;   }   int gcd(int a, int b) {     if (a == 0) return b;     if (b == 0) return a;     if (a == b) return a;     if (a > b) return gcd(a - b, b);     return gcd(a, b - a);   }   void scanArray(int arr[], int n) {     for (int i = 0; i < n; i++) {       cin >> arr[i];     }   }   int highestFromThree(int n1, int n2, int n3) { return max(max(n1, n2), n3); }   int highestFromFour(int n1, int n2, int n3, int n4) {     return max(max(n1, n2), max(n3, n4));   }   int result[1000] = {0};   int factDP(int n) {     if (n >= 0) {       result[0] = 1;       for (int i = 1; i <= n; ++i) {         result[i] = i * result[i - 1];       }       return result[n];     }   }   int main() {     int n, m;     cin >> n >> m;     int l[n], r[n];     vector<pair<int, int>> v;     int points[m];     for (int i = 0; i < m; i++) {       points[i] = i + 1;     }     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i];       v.push_back(make_pair(l[i], r[i]));     }     int count = m;     for (int i = 0; i < m; i++) {       for (int j = 0; j < v.size(); j++) {         if (points[i] >= v[j].first && points[i] <= v[j].second) {           count--;           points[i] = 0;           break;         }       }     }     cout << count <<   n ;     for (int i = 0; i < m; i++) {       if (points[i] != 0) {         cout << points[i] <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n, a[4];   char s[N];   int main() {     cin >> n >> s;     for (int i = 0; i < n; ++i) {       if (s[i] ==  A )         a[0]++;       else if (s[i] ==  C )         a[1]++;       else if (s[i] ==  G )         a[2]++;       else if (s[i] ==  T )         a[3]++;     }     sort(a, a + 4);     int mx = a[3];     long long m = 0;     for (int i = 0; i < 4; ++i)       if (a[i] == mx) m++;     long long ans = 1;     for (int i = 0; i < n; ++i) ans = (ans * m) % (1000000007);     cout << ans << endl;   }
#include <bits/stdc++.h>   using std::abs;   using std::bitset;   using std::cerr;   using std::cin;   using std::copy;   using std::cout;   using std::deque;   using std::endl;   using std::fill;   using std::fixed;   using std::greater;   using std::iota;   using std::istream;   using std::lower_bound;   using std::make_pair;   using std::make_tuple;   using std::map;   using std::max;   using std::max_element;   using std::min;   using std::min_element;   using std::multiset;   using std::next_permutation;   using std::nth_element;   using std::ostream;   using std::pair;   using std::priority_queue;   using std::queue;   using std::reverse;   using std::rotate;   using std::set;   using std::sort;   using std::string;   using std::swap;   using std::tie;   using std::tuple;   using std::unique;   using std::unordered_map;   using std::unordered_set;   using std::upper_bound;   using std::vector;   long long rnd(long long x, long long y) {     static auto gen = std::bind(std::uniform_int_distribution<long long>(),                                 std::mt19937(960172));     return gen() % (y - x + 1) + x;   }   long long gcd(long long a, long long b) {     while (b > 0) {       long long t = a % b;       a = b;       b = t;     }     return a;   }   template <typename T>   T sqr(T const& a) {     return a * a;   }   int const INF = 100 + (int)1e9;   long long const INFL = 100 + (long long)1e18;   long double const PI = 3.1415926535897932384626433832795028;   void solve() {     vector<string> const hs = { Anka ,    Chapay ,  Cleo ,        Troll ,                                 Dracul ,  Snowy ,   Hexadecimal };     int qq;     cin >> qq;     int n = hs.size();     vector<vector<int>> z(n, vector<int>(n));     while (qq--) {       string a, b, c;       cin >> a >> b >> c;       int i = 0;       while (hs[i] != a) ++i;       int j = 0;       while (hs[j] != c) ++j;       ++z[i][j];     }     int A, B, C;     cin >> A >> B >> C;     int three = 1;     for (int i = 0; i < n; ++i) three *= 3;     int diff = 2 * INF;     int sym = 0;     for (int mask = 0; mask < three; ++mask) {       int val = mask;       vector<int> who(n), cnt(3);       for (int i = 0; i < n; ++i) {         int x = val % 3;         val /= 3;         who[i] = x;         ++cnt[x];       }       if (!cnt[0] || !cnt[1] || !cnt[2]) continue;       int a = A / cnt[0], b = B / cnt[1], c = C / cnt[2];       int cdiff = max({a, b, c}) - min({a, b, c});       int csym = 0;       for (int x = 0; x < n; ++x)         for (int y = 0; y < n; ++y) csym += z[x][y] * (who[x] == who[y]);       if (cdiff < diff || (cdiff == diff && csym > sym)) {         diff = cdiff;         sym = csym;       }     }     cout << diff <<     << sym << endl;   }   int main() {     cout.precision(15);     cout << fixed;     cerr.precision(6);     cerr << fixed;     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100 * 1000 + 5;   int xs, ys, xt, yt, n, a[N], b[N], r[N];   map<pair<int, int>, int> mark;   map<pair<int, int>, int> dist;   int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};   int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};   void bfs(int x, int y) {     queue<pair<int, int> > q;     dist[{x, y}] = 0;     q.push({x, y});     while (!q.empty()) {       pair<int, int> p = q.front();       q.pop();       x = p.first, y = p.second;       for (int i = 0; i < 8; i++) {         int nx = x + dx[i], ny = y + dy[i];         if (!mark[{nx, ny}])           continue;         else if (dist[{nx, ny}] > dist[{x, y}] + 1) {           dist[{nx, ny}] = dist[{x, y}] + 1;           q.push({nx, ny});         }       }     }   }   void input() {     cin >> xs >> ys >> xt >> yt >> n;     for (int i = 0; i < n; i++) cin >> r[i] >> a[i] >> b[i];   }   void solve() {     for (int i = 0; i < n; i++) {       for (int j = a[i]; j <= b[i]; j++) {         mark[{r[i], j}] = true;         dist[{r[i], j}] = 1e9;       }     }     bfs(xs, ys);   }   void output() {     int ans = dist[{xt, yt}];     if (ans == 1e9)       cout << -1 <<   n ;     else       cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     input();     solve();     output();   }
#include<bits/stdc++.h>   #define ll long long   using namespace std;   ll T,n,k;   void work(){    scanf( %lld%lld ,&n,&k);    if(n<=k){printf( %lld n ,(long long)ceil((double)k*1.0/(double)n));return;}    else{     if(n%k==0){      printf( %lld n ,1LL);      return;     }     else printf( %lld n ,2LL);    }    return;   }   int main(){    scanf( %d ,&T);    while(T--)work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int INF = 1000 * 1000 * 1000 + 7;   const long long LINF = INF * (long long)INF;   const int MAX = 3000 + 47;   vector<int> g[MAX];   vector<int> S;   int L[MAX];   int U[MAX];   queue<int> q;   int D[MAX];   int n;   void dfs(int v, int p) {     if (U[v] == 1) {       int sz = (int)S.size() - 1;       L[v] = 1;       while (S[sz] != v) {         L[S[sz]] = 1;         sz--;       }       return;     }     U[v] = 1;     S.push_back(v);     for (int i = (0); i < ((int)g[v].size()); i++) {       int to = g[v][i];       if (to == p) continue;       dfs(to, v);     }     S.pop_back();     U[v] = 2;   }   void bfs() {     for (int i = (0); i < (n); i++) D[i] = INF;     for (int i = (0); i < (n); i++) {       if (!L[i]) continue;       q.push(i);       D[i] = 0;     }     while (!q.empty()) {       int v = q.front();       q.pop();       for (int i = (0); i < ((int)g[v].size()); i++) {         int to = g[v][i];         if (D[to] != INF) continue;         D[to] = D[v] + 1;         q.push(to);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = (0); i < (n); i++) {       int x, y;       cin >> x >> y;       x--;       y--;       g[x].push_back(y);       g[y].push_back(x);     }     dfs(0, 0);     bfs();     for (int i = (0); i < (n); i++) {       cout << D[i] <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, l, r, cnt;   int a[105];   int main() {     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> l >> r;       for (int i = l; i <= r; ++i) {         a[i] = 1;       }     }     for (int i = 1; i <= m; ++i) {       if (!a[i]) cnt++;     }     cout << cnt << endl;     for (int i = 1; i <= m; ++i) {       if (!a[i]) cout << i <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, ser = 0, dim = 0;     vector<int> v;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     for (int i = 0; i < n; i++) {       if (i % 2 == 0) {         ser += max(v.front(), v.back());         if (v.front() > v.back())           v.erase(v.begin());         else           v.pop_back();       } else {         dim += max(v.front(), v.back());         if (v.front() > v.back())           v.erase(v.begin());         else           v.pop_back();       }     }     cout << ser <<     << dim << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, b, t[32], c[32], s[1 << 11], cnt[1 << 11];   bool dp[12][25][1 << 11];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , t + i);       if (t[i] > 1) c[++b] = t[i];     }     if (n == 1) {       puts( YES );       return 0;     }     if (b * 2 > n - 1) {       puts( NO );       return 0;     }     sort(c + 1, c + b + 1);     if (c[b] < n) {       puts( NO );       return 0;     }     dp[0][n - b][0] = 1;     for (int S = 1; S < (1 << b); S++) {       s[S] = s[S & (S - 1)] + c[__builtin_ctz(S) + 1];       cnt[S] = cnt[S & (S - 1)] + 1;     }     for (int i = 1; i <= b; ++i)       for (int j = 0; j <= n - b; ++j) {         for (int S = 0; S < (1 << (i - 1)); S++) {           bool z = 0;           int cS = ((1 << (i - 1)) - 1) ^ S;           for (int T = cS; !z; T = (T - 1) & cS) {             for (int k = j; k <= n - b; ++k) {               if (dp[i - 1][k][S ^ T] && s[T] + k - j == c[i] - 1 &&                   k - j + cnt[T] >= 2) {                 z = 1;                 break;               }             }             if (!T) break;           }           if (z) dp[i][j][S ^ (1 << (i - 1))] = 1;         }       }     puts(dp[b][0][1 << (b - 1)] ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long MOD = 1e9 + 7;   long long dp[4000][4000];   long long mn[4000][4000];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     set<long long> uss;     long long a[n];     long long b[n];     long long sm = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       a[i] = a[i] - i;       uss.insert(a[i]);     }     vector<long long> us;     for (auto i : uss) {       us.push_back(i);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < us.size(); j++) {         dp[i + 1][j] = mn[i][j] + abs(us[j] - a[i]);         mn[i + 1][j] = dp[i + 1][j];         if (j) mn[i + 1][j] = min(mn[i + 1][j], mn[i + 1][j - 1]);       }     }     cout << mn[n][us.size() - 1];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     int n;     cin >> n;     int t;     int speed = 0;     int ans = 0;     int c = 0;     int bs;     stack<int> s;     cin >> t >> speed;     for (int i = 1; i < n; i++) {       cin >> t;       if (t == 1) {         cin >> speed;         while (!s.empty() && speed > s.top()) {           s.pop();           ans++;         }       } else if (t == 2) {         ans += c;         c = 0;       } else if (t == 3) {         cin >> bs;         s.push(bs);         if (bs < speed) {           s.pop();           ans++;         }       } else if (t == 4) {         c = 0;       } else if (t == 5) {         while (!s.empty()) s.pop();       } else {         c++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps(1e-8);   const long long inf = -99999999999999999;   long long row, col, k, p;   long long sumr[1001];   long long sumc[1001];   long long answerR[1000001];   long long answerC[1000001];   priority_queue<long long> Rtmp, Ctmp;   int main() {     scanf( %I64d %I64d %I64d %I64d , &row, &col, &k, &p);     memset(sumr, 0, sizeof(sumr));     memset(sumc, 0, sizeof(sumc));     long long tmp;     for (int i = 1; i <= row; i++) {       for (int j = 1; j <= col; j++) {         scanf( %I64d , &tmp);         sumr[i] += tmp;         sumc[j] += tmp;       }     }     for (int i = 1; i <= row; i++) {       Rtmp.push(sumr[i]);     }     for (int i = 1; i <= col; i++) {       Ctmp.push(sumc[i]);     }     memset(answerR, 0, sizeof(answerR));     memset(answerC, 0, sizeof(answerC));     long long ans = 0;     for (int j = 1; j <= k; j++) {       ans += Rtmp.top();       tmp = Rtmp.top();       tmp -= col * p;       Rtmp.pop();       Rtmp.push(tmp);       answerR[j] = ans;     }     ans = 0;     for (int j = 1; j <= k; j++) {       ans += Ctmp.top();       tmp = Ctmp.top();       tmp -= row * p;       Ctmp.pop();       Ctmp.push(tmp);       answerC[j] = ans;     }     long long answer = inf;     for (int i = 0; i <= k; i++) {       answer = max(answer, answerR[i] + answerC[k - i] - i * (k - i) * p);     }     printf( %I64d n , answer);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000000 + 7;   const long long int N = 10000000 + 6;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     char matrix[4][n];     for (int i = 0; i < 4; i++)       for (int j = 0; j < n; j++) matrix[i][j] =  . ;     bool bo = true;     if (k & 1) {       if (k > n - 2) {         int g = n - 2;         for (int i = 1; i <= g; i++) matrix[1][i] =  # ;         int l = k - n;         matrix[2][1] =  # ;         matrix[2][n - 2] =  # ;         for (int i = 2; i <= l + 1; i++) matrix[2][i] =  # ;       } else {         int i = n / 2 - k / 2;         int c = 1;         for (int j = i; c <= k; c++, j++) matrix[1][j] =  # ;       }     } else {       int g = k / 2;       for (int i = 1; i <= g; i++) matrix[1][i] =  # ;       for (int i = 1; i <= g; i++) matrix[2][i] =  # ;     }     if (bo) {       cout <<  YES n ;       for (int i = 0; i < 4; i++) {         for (int j = 0; j < n; j++) cout << matrix[i][j];         cout <<   n ;       }     } else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   template <typename T>   void read(T& val) {     std::string tmp = typeid(val).name();     if (strcmp(tmp.c_str(),  i ) == 0)       scanf( %d , &val);     else if (strcmp(tmp.c_str(),  x ) == 0)       scanf( %I64d , &val);     else if (strcmp(tmp.c_str(),  d ) == 0)       scanf( %lf , &val);     else if (tmp.length() > 2 && tmp.back() ==  c )       scanf( %s , val);     else if (strcmp(tmp.c_str(),  c ) == 0)       scanf( %c , &val);   }   template <typename T, typename... Targs>   void read(T& val, Targs&... Fargs) {     read(val);     read(Fargs...);   }   template <typename T>   void print(T val) {     std::string tmp = typeid(val).name();     if (strcmp(tmp.c_str(),  i ) == 0)       printf( %d , val);     else if (strcmp(tmp.c_str(),  x ) == 0)       printf( %I64d , val);     else if (strcmp(tmp.c_str(),  d ) == 0)       printf( %.15f , val);     else if (strcmp(tmp.c_str(),  c ) == 0)       printf( %c , val);     else if (tmp.length() > 2 && tmp.back() ==  c )       printf( %s , val);   }   template <typename T, typename... Targs>   void print(T val, Targs... Fargs) {     print(val);     print(Fargs...);   }   const double pi = acos(-1);   const int MOD = 1e9 + 7;   const int INF = 1e9 + 7;   const int MAXN = 1e6 + 5;   const double eps = 1e-9;   using namespace std;   int a = 1, b, c, n, x, y, z;   int main() {     read(n, x, y, c);     while (a < c) {       b++;       z = min(x - 1, b);       a += max(z - max((y + b - n), 0) + 1, 0) +            max(z - max((b - y + 1), 0) + 1, 0) - (z == b);       z = min(n - x, b);       a += max(z - max((y + b - n), 1) + 1, 0) +            max(z - max((b - y + 1), 1) + 1, 0) - (z == b);     }     print(b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pll = pair<ll, ll>;   using pii = pair<int, int>;   struct Node {     vector<ll> con;     ll h1, h2;   } g[100010];   ll dfs(ll n, ll p) {     g[n].h1 = g[n].h2 = 0;     for (auto &i : g[n].con) {       if (i == p) continue;       ll k = dfs(i, n) + 1;       if (k >= g[n].h1) {         g[n].h2 = g[n].h1;         g[n].h1 = k;       } else if (k >= g[n].h2) {         g[n].h2 = k;       }     }     return g[n].h1;   }   ll dist(ll n, ll p, ll t) {     if (n == t) return 0;     ll ans = (ll)(1e17);     for (auto &i : g[n].con) {       if (i == p) continue;       ans = min(ans, dist(i, n, t) + 1);     }     return ans;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     ll N;     cin >> N;     while (N--) {       ll n, a, b, da, db;       cin >> n >> a >> b >> da >> db;       for (ll i = 0; i <= n - 1; i++) g[i].con.clear();       a--;       b--;       ll s, t;       for (ll i = 0; i <= n - 2; i++) {         cin >> s >> t;         s--;         t--;         g[s].con.emplace_back(t);         g[t].con.emplace_back(s);       }       dfs(0, 0);       ll height = 0;       for (ll i = 0; i <= n - 1; i++) height = max(height, g[i].h1 + g[i].h2);       ll dis = dist(a, a, b);       if (da * 2 < db && da * 2 < height && dis > da)         cout <<  Bob n ;       else         cout <<  Alice n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 0; i < t; i++) {       int n, m;       cin >> n;       vector<int> v(2 * n), v2;       for (int i = 0; i < 2 * n; i++) {         cin >> v[i];       }       for (int i = 0; i < 2 * n; i++) {         int d = 1;         for (int j = 0; j < i; j++) {           if (v[j] == v[i]) {             d = 0;             break;           }         }         if (d) {           v2.push_back(v[i]);         }       }       for (int i = 0; i < v2.size(); i++) {         cout << v2[i] <<    ;       }       cout << endl;     }     return 0;   }