malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool flag = false;   int n, m, K;   int up[2005][2005], down[2005][2005];   int Find(int p[], int x) { return p[x] != x ? p[x] = Find(p, p[x]) : x; }   void check(int x, int y, int i, int &g, int &h, int &L) {     if (i < 1 || i > n) return;     int j;     j = Find(up[i], y);     if (j != 0) {       int d = abs(x - i) + abs(y - j);       if (d < L || d == L && (!flag && (i < g || i == g && j < h) ||                               flag && (j < h || j == h && i < g)))         L = d, g = i, h = j;     }     j = Find(down[i], y);     if (j != m + 1) {       int d = abs(x - i) + abs(y - j);       if (d < L || d == L && (!flag && (i < g || i == g && j < h) ||                               flag && (j < h || j == h && i < g)))         L = d, g = i, h = j;     }   }   int main() {     scanf( %d%d%d , &n, &m, &K);     if (n > m) {       swap(n, m);       flag = true;     }     for (int i = 1; i <= n; i++)       for (int j = 0; j <= m + 1; j++) up[i][j] = down[i][j] = j;     while (K--) {       int x, y;       scanf( %d%d , &x, &y);       if (flag) swap(x, y);       int g = -1, h = -1, L = 0x7fffffff;       for (int i = 0; i <= L; i++) {         check(x, y, x - i, g, h, L);         check(x, y, x + i, g, h, L);       }       up[g][h] = h - 1;       down[g][h] = h + 1;       if (flag) swap(g, h);       printf( %d %d n , g, h);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int32_t MOD = 1000000007;   struct WEdge {     int32_t u, v;     int w;     bool operator<(const WEdge& other) { return w < other.w; }     WEdge(int32_t u, int32_t v, int w) : u(u), v(v), w(w) {}     WEdge() {}     void in() { cin >> u >> v >> w; }     void trace() {       if (0) cout << u <<     << v <<     << w <<   n ;     }   };   struct Edge {     int32_t u, v;     Edge(int32_t u, int32_t v) : u(u), v(v) {}     void in() { cin >> u >> v; }   };   struct UnionSet {     map<int32_t, pair<int32_t, int32_t> > sets;     void makeSet(int32_t x) { sets.emplace(x, make_pair(x, 0)); }     void init(int32_t a, int32_t b) {       for (int x = (a); x < (b); ++x) makeSet(x);     }     int find(int32_t x) {       if (sets[x].first == x)         return x;       else         return sets[x].first = find(sets[x].first);     }     void union_both(int32_t x, int32_t y) {       int32_t parentX = find(x), parentY = find(y);       int32_t rankX = sets[parentX].second, rankY = sets[parentY].second;       if (parentX == parentY)         return;       else if (rankX < rankY)         sets[parentX].first = parentY;       else         sets[parentY].first = parentX;       if (rankX == rankY) sets[parentX].second++;     }   };   int32_t add(int32_t a, int32_t b) {     int32_t r = a + b;     if (r >= MOD) r -= MOD;     return r;   }   int32_t sub(int32_t a, int32_t b) {     int32_t r = a - b;     if (r < 0) r += MOD;     return r;   }   int32_t mul(int32_t a, int32_t b) { return (a * 1ll * b) % MOD; }   int32_t pow_mod(int32_t a, int64_t n) {     if (n == 0)       return 1;     else {       int32_t tmp = pow_mod(a, n / 2);       tmp = mul(tmp, tmp);       if (n % 2 == 0)         return tmp;       else         return mul(tmp, a);     }   }   int32_t fact_mod(int32_t n) {     int32_t r = 1;     for (int32_t k = 1; k <= n; k++) r = mul(r, k);     return r;   }   vector<int> children[200001];   int a[200001];   int64_t S[200001];   int64_t T[200001];   void dfs_init(int u, int pred) {     S[u] = a[u];     T[u] = 0;     for (auto v : children[u]) {       if (v != pred) {         dfs_init(v, u);         S[u] += S[v];         T[u] += T[v] + S[v];       }     }   }   int64_t M = -1;   void dfs_maxt(int u, int pred, int64_t sa, int64_t ta) {     M = max(M, ta + T[u]);     sa += a[u];     ta += sa;     int64_t ts = 0, tt = 0;     for (auto v : children[u]) {       if (v != pred) {         ts += S[v];         tt += 2ll * S[v] + T[v];       }     }     for (auto v : children[u]) {       if (v != pred) {         dfs_maxt(v, u, sa + ts - S[v], ta + tt - T[v] - 2ll * S[v]);       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     for (int i = (0); i < (n); ++i) cin >> (a + 1)[i];     int u, v;     for (int i = (0); i < (n - 1); ++i) {       cin >> u >> v;       children[u].push_back(v);       children[v].push_back(u);     }     dfs_init(1, -1);     dfs_maxt(1, -1, 0, 0);     cout << M <<   n ;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   template <class T>   T gcd(T a, T b) {     return ((b == 0) ? a : gcd(b, a % b));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, x;     cin >> n >> x;     n %= 6;     for (int i = 0; i < (int)(3); i++) {       vector<int> a(3, 0);       a[i] = 1;       for (int j = 0; j < (int)(n); j++) {         if (j % 2 == 0)           swap(a[0], a[1]);         else           swap(a[1], a[2]);       }       if (a[x]) {         cout << i << endl;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int t, l, r, d, m, n, i;     scanf( %d , &t);     for (i = 0; i < t; i++) {       scanf( %d %d %d , &l, &r, &d);       if (l > d || r < d) {         printf( %d n , d);       } else {         m = (r / d) + 1;         n = d * m;         printf( %d n , n);       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast ,  unroll-loops ,  no-stack-protector )   using namespace std;   template <class T>   using minheap = priority_queue<T, vector<T>, greater<T>>;   template <typename T>   void setmax(T& a, T b) {     a = max(a, b);   };   template <typename T>   void setmin(T& a, T b) {     a = min(a, b);   };   const int N = 3010;   int n;   vector<int> g[N];   long long sz[N][N];   int par[N][N];   long long dp[N][N];   void dfs(int root, int x, int p = 0) {     sz[root][x]++;     par[root][x] = p;     for (int y : g[x]) {       if (y == p) continue;       dfs(root, y, x);       sz[root][x] += sz[root][y];     }   }   long long solve(int u, int v) {     if (dp[u][v] != -1) return dp[u][v];     if (u > v) return dp[u][v] = solve(v, u);     if (u == v) return dp[u][v] = 0;     return dp[u][v] = sz[u][v] * sz[v][u] +                       max(solve(par[v][u], v), solve(u, par[u][v]));   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       g[u].push_back(v);       g[v].push_back(u);     }     for (int i = 1; i <= n; i++) {       dfs(i, i);     }     memset(dp, -1, sizeof dp);     long long ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         setmax(ans, solve(i, j));       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s, x, y, a, b;     cin >> s >> x >> y >> a >> b;     if ((x * s) + (2 * a) < (y * s) + (2 * b)) {       cout <<  First ;       return 0;     }     if ((x * s) + (2 * a) > (y * s) + (2 * b)) {       cout <<  Second ;       return 0;     }     if ((x * s) + (2 * a) == (y * s) + (2 * b)) {       cout <<  Friendship ;       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[1111];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long n, ans = 0;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + 1 + n);     for (long long i = 1; i < n; i++) {       ans = ans + (a[i + 1] - a[i] - 1);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n;   string s;   int main() {     cin >> t;     for (int x = 1; x <= t; x++) {       cin >> n;       cin >> s;       string ans;       long long v = 0;       for (int i = 0; i < s.length(); i++) {         ans += s[i + (v++)];         if (i == n - 1) break;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std::chrono;   bool prime[2000005];   vector<int> myarr;   void myprime(int n) {     for (long int i = 0; i < n; i++) prime[i] = true;     for (int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (int i = p * p; i <= n; i += p) prime[i] = false;       }     }     for (int p = 2; p <= n; p++)       if (prime[p]) myarr.push_back(p);   }   int gcd(int a, int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   void swap(int &a, int &b) {     int temp = a;     a = b;     b = temp;   }   int max(int a, int b) { return (a > b ? a : b); }   vector<long long> a(15);   void moj(long long n) {}   bool cmp(pair<string, int> p1, pair<string, int> p2) {     if (p2.second < p1.second) return true;     return false;   }   void solve() {     int n;     cin >> n;     map<string, int> ms;     vector<string> vs(n);     for (long int i = 0; i < n; i++) cin >> vs[i];     int rr = 1;     for (long int i = 0; i < n; i++) {       string s;       s = vs[i];       ms[s] = rr;       rr++;     }     vector<pair<string, int> > sss;     for (auto &i : ms) {       sss.push_back(i);     }     sort(sss.begin(), sss.end(), cmp);     for (auto i : sss) {       cout << i.first <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000005;   struct ky {     int u, val;     bool operator<(const ky &p) const { return val < p.val; }   } a[N], b[N];   int n, ca, cb, ci, vali;   bool tg[N];   inline void fr(int &num) {     num = 0;     char c = getchar();     int p = 1;     while (c <  0  || c >  9 ) c ==  -  ? p = -1, c = getchar() : c = getchar();     while (c >=  0  && c <=  9 ) num = num * 10 + c -  0 , c = getchar();     num *= p;   }   int main() {     fr(n);     for (register int i = 1; i <= n; ++i)       fr(ci), fr(vali), ci ? a[++ca] = (ky){i, vali} : b[++cb] = (ky){i, vali};     sort(a + 1, a + 1 + ca), sort(b + 1, b + 1 + cb);     register int i = 1, j = 1, minn;     while (i <= ca && j <= cb)       minn = (a[i].val < b[j].val ? a[i].val : b[j].val),       printf( %d %d %d n , a[i].u, b[j].u, minn), a[i].val -= minn,       b[j].val -= minn, tg[a[i].u] = tg[b[j].u] = true, !a[i].val ? ++i : ++j;     while (i <= ca) {       if (!tg[a[i].u]) printf( %d %d 0 n , a[i].u, b[1].u), tg[a[i].u] = 1;       ++i;     }     while (j <= cb) {       if (!tg[b[j].u]) printf( %d %d 0 n , a[1].u, b[j].u), tg[b[j].u] = 1;       ++j;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     struct node* left;     struct node* right;     int vl;     node() {       vl = 0;       left = NULL;       right = NULL;     }   };   int a[300005];   int ans = 0;   void query(node* n, int v, int i, int j) {     if (n == NULL || j == 0) return;     int no = (1 << (j - 1));     node* l2 = n->left;     node* r2 = n->right;     int l1 = 0, r1 = 0;     if (l2 != NULL) l1 = l2->vl;     if (r2 != NULL) r1 = r2->vl;     j--;     if ((v & (1 << j)) == 0) {       if (l1 == no) {         ans += (1 << (j));         query(n->right, v, i / 2, j);         return;       }       query(n->left, v, i / 2, j);       return;     }     if (r1 == no) {       ans += (1 << (j));       query(n->left, v, i / 2, j);       return;     }     query(n->right, v, i / 2, j);     return;   }   void insert(node* n, int val, int i, int j) {     if (j == 0) return;     j--;     if ((val & (1 << j)) == 0) {       if (n->left == NULL) {         node* cur = new node();         n->left = cur;       }       insert(n->left, val, i / 2, j);       return;     }     if (n->right == NULL) {       node* cur = new node();       n->right = cur;     }     insert(n->right, val, i / 2, j);     return;   }   int dfs(node* n) {     if (n->left == NULL && n->right == NULL) {       n->vl = 1;       return 1;     }     int w = 0;     int u = 0;     if (n->left != NULL) {       w += dfs(n->left);       u++;     }     if (n->right != NULL) {       w += dfs(n->right);       u++;     }     n->vl = w;     return w;   }   int main() {     int n, m;     cin >> n >> m;     node* h = new node();     node* w1 = h;     for (int i = 1; i <= n; i++) {       cin >> a[i];       h = w1;       insert(h, a[i], (1 << 20) - 1, 19);     }     int x = 0;     h = w1;     dfs(h);     for (int i = 1; i <= m; i++) {       int x1;       cin >> x1;       x = x ^ x1;       ans = 0;       h = w1;       query(h, x, (1 << 20) - 1, 19);       cout << ans <<   n ;     }   }
#include <iostream>   #include <set>   #include <vector>   #include <algorithm>   using namespace std;   typedef long long ll;      vector<int> res;   vector<pair<int, int>> edges;   vector<vector<int>> v;   int n, k;      int buildTree(set<int> idx, int rootSalary) {    if (idx.size() == 1) { return *idx.begin(); }    int curRoot = k++; res.push_back(rootSalary);       while (!idx.empty()) {     int cur = *idx.begin(), nextRootSalary = 0;     set<int> newIDX; newIDX.insert(cur);        for (auto& x : idx) if(cur != x && v[cur][x] < rootSalary) {      nextRootSalary = max(nextRootSalary, v[cur][x]);      newIDX.insert(x);     }     for (auto& x : newIDX) { idx.erase(x); }        int child = buildTree(newIDX, nextRootSalary);     edges.push_back({ child, curRoot });    }       return curRoot;   }      int main() {    ios::sync_with_stdio(0);    cin.tie(0), cout.tie(0);       cin >> n; k = n; v.resize(n, vector<int>(n)); res.resize(n); int ma = 0;    for (auto& x : v) for (auto& y : x) { cin >> y; ma = max(ma, y); }    for (int i = 0; i < n; i++) res[i] = v[i][i];       set<int> idx; for (int i = 0; i < n; i++) idx.insert(i);    int head = buildTree(idx, ma);       cout << res.size() <<   n ; for (auto& x : res)      cout << x <<    ; cout <<   n ;    cout << head + 1 <<   n ; for (auto& e : edges)      cout << ++e.first <<     << ++e.second <<   n ;       cin.ignore(2); return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200200;   int n;   int a[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int cnt_0 = 0, cnt_neg = 0, pos = -1;     vector<int> used(n);     for (int i = 0; i < n; i++) {       if (a[i] == 0) {         used[i] = 1;         cnt_0++;       }       if (a[i] < 0) {         cnt_neg++;         if (pos == -1 || abs(a[pos]) > abs(a[i])) {           pos = i;         }       }     }     if (cnt_neg & 1) {       used[pos] = 1;     }     if (cnt_0 == n || (cnt_0 == n - 1 && cnt_neg == 1)) {       for (int i = 0; i < n - 1; i++) {         cout << 1 <<     << i + 1 <<     << i + 2 <<   n ;       }       return 0;     }     int lst = -1;     for (int i = 0; i < n; i++) {       if (!used[i]) continue;       if (lst != -1) {         cout << 1 <<     << lst + 1 <<     << i + 1 <<   n ;       }       lst = i;     }     if (lst != -1) cout << 2 <<     << lst + 1 <<   n ;     lst = -1;     for (int i = 0; i < n; i++) {       if (used[i]) continue;       if (lst != -1) {         cout << 1 <<     << lst + 1 <<     << i + 1 <<   n ;       }       lst = i;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     string s;     int n, x = 0, ans;     cin >> s;     n = s.length();     for (int i = 0; i < n; i++) {       x = x * 10 + (s[i] -  0 );       x = x % 4;     }     ans = (1 + (int)pow(2, x) + (int)pow(3, x) + (int)pow(4, x)) % 5;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     int N, ans = 0;     string s;     cin >> N >> s;     for (int i = 0, j; i < N;) {       if (s[i] ==  ? ) {         for (j = i; j < N && s[j] ==  ? ; j++)           ;         if (j - i > 1 || !i || j == N || s[i - 1] == s[j]) ans = 1;         i = j;       } else {         if (i && s[i - 1] == s[i]) {           cout <<  No n ;           return 0;         }         i++;       }     }     if (ans)       cout <<  Yes n ;     else       cout <<  No n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using lint = long long int;   constexpr int MOD = 1000000007;   int main() {     int T;     cin >> T;     for (int t = (0), t_end_ = (T); t < t_end_; t++) {       int r, c, k;       cin >> r >> c >> k;       vector<string> map(r);       for (int i = (0), i_end_ = (r); i < i_end_; i++) {         cin >> map[i];       }       int rice = 0;       for (int i = (0), i_end_ = (r); i < i_end_; i++) {         for (int j = (0), j_end_ = (c); j < j_end_; j++) {           if (map[i][j] ==  R ) {             rice++;           }         }       }       int a = rice / k;       int b = rice % k;       vector<int> ricelist(k, a);       for (int i = (0), i_end_ = (b); i < i_end_; i++) {         ricelist[i]++;       }       vector<vector<char>> ans(r, vector<char>(c));       int nowk = 0;       for (int i = (0), i_end_ = (r); i < i_end_; i++) {         if (i % 2 == 0) {           for (int j = (0), j_end_ = (c); j < j_end_; j++) {             if (nowk >= 36) {               ans[i][j] =  a  + (nowk - 36);             } else if (nowk >= 10) {               ans[i][j] =  A  + (nowk - 10);             } else {               ans[i][j] =  0  + nowk;             }             if (map[i][j] ==  R ) {               ricelist[nowk]--;             }             if (ricelist[nowk] == 0 && nowk != k - 1) {               nowk++;             }           }         } else {           for (int j = (c)-1, j_begin_ = (0); j >= j_begin_; j--) {             if (nowk >= 36) {               ans[i][j] =  a  + (nowk - 36);             } else if (nowk >= 10) {               ans[i][j] =  A  + (nowk - 10);             } else {               ans[i][j] =  0  + nowk;             }             if (map[i][j] ==  R ) {               ricelist[nowk]--;             }             if (ricelist[nowk] == 0 && nowk != k - 1) {               nowk++;             }           }         }       }       for (int i = (0), i_end_ = (r); i < i_end_; i++) {         for (int j = (0), j_end_ = (c); j < j_end_; j++) {           cout << ans[i][j];         }         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   inline void boost() {     ios_base::sync_with_stdio();     cin.tie(0);     cout.tie(0);   }   const long long maxn = 1e5 + 123;   const long long inf = 1e9 + 123;   const long long mod = 1e9 + 7;   const double infm = 1e-9;   const double pi = acos(-1);   int a[maxn];   bool used[maxn];   int main() {     boost();     int n, k;     cin >> n >> k;     int p = 0, m = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     int mx = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (abs(j - i) % k == 0) {           used[j] = 1;         }       }       int sum = 0, sum1 = 0;       for (int j = 1; j <= n; j++) {         if (used[j] == 0) {           if (a[j] == 1) {             sum++;           } else {             sum1++;           }         }         used[j] = 0;       }       mx = max(mx, abs(sum - sum1));     }     cout << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   double ans = 0;   map<double, double> F;   void insert(double dist, double s) {     double need = dist / (s + 1);     F[s] += need;     if (s > 1) F[s] += dist / (s - 1);     ans += need;     while (need > 1e-9) {       map<double, double>::iterator it = --F.end();       double y = it->first;       double dlt = min(need, F[y]);       F[y] -= dlt;       need -= dlt;       ans += dlt / y;       if (F[y] < 1e-9) {         F.erase(it);       }     }   }   int n, L, ls;   int main() {     scanf( %d%d , &n, &L);     int l, r;     double s;     while (n--) {       scanf( %d%d%lf , &l, &r, &s);       insert(l - ls, 1);       insert(r - l, s + 1);       ls = r;     }     insert(L - ls, 1);     printf( %.10lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> arr[100100];   int dist[100100];   map<int, int> m1;   void dfs(int curr, int par) {     dist[curr] = dist[par] + 1;     if (curr == par) {       dist[curr] = 0;     }     for (auto x : arr[curr]) {       if (x != par) {         dfs(x, curr);       }     }   }   int main() {     int n;     cin >> n;     for (int i = 2; i <= n; i++) {       int x;       cin >> x;       arr[i].push_back(x);       arr[x].push_back(i);     }     dfs(1, 1);     int ans = 0;     for (int i = 1; i <= n; i++) {       m1[dist[i]]++;     }     for (auto it = m1.begin(); it != m1.end(); it++) {       ans += (it->second) % 2;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int i, k, b, n, m, r = 0, x = 0, y = 0, z = 0, h = 0, l;     string s;     cin >> s;     n = s.size();     int a[n];     for (i = 0; i < n; i++) {       if (s[i] ==  ( )         x++;       else if (s[i] ==  )  && x > 0)         x--;       else if (s[i] ==  ) )         z = 1;       else if (s[i] ==  #  && x > 0) {         a[y] = 1;         y++;         x--;         k = i;         l = x;       } else if (s[i] ==  # )         z = 1;     }     x = l;     if (y > 0) {       r = 0;       for (i = k + 1; i < n; i++) {         if (s[i] ==  ( ) {           x++;           r++;         } else if (s[i] ==  )  && x > 0)           x--;         else           h = 1;         if (s[i] ==  )  && r > 0) r--;       }       a[y - 1] = x + 1;     }     if (z == 1 || h == 1 || r != 0)       cout <<  -1 ;     else {       for (i = 0; i < y; i++) {         cout << a[i] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int a[n];       for (int i = 0; i < n; i++) {         cin >> a[i];       }       long long s = 0;       for (int i = 0; i < n; i++) {         s = s + a[i];         if (s < 0) s = 0;       }       cout << s <<   n ;     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   vector<int> gr[N];   long long int edges, z, o;   int col[N], vis[N];   void color(int n) {     for (int i = 0; i < gr[n].size(); i++) {       if (col[gr[n][i]] == -1) {         if (col[n] == 0) {           o++;           col[gr[n][i]] = 1;         } else {           z++;           col[gr[n][i]] = 0;         }         edges++;         color(gr[n][i]);       }     }   }   int main() {     int n, a, b;     cin >> n;     for (int i = 0; i < n - 1; i++) {       col[i] = -1;       cin >> a >> b;       gr[a].push_back(b);       gr[b].push_back(a);     }     col[n - 1] = -1;     col[n] = -1;     col[1] = 0;     z++;     color(1);     if (n == 1) {       cout << 0 << endl;     } else {       cout << z * o - edges << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, y;     cin >> n >> x >> y;     int arr[n];     int countx = 0;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] <= x) {         countx++;       }     }     if (y < x) {       cout << n << endl;       return 0;     }     if (y >= x) {       if (countx % 2 == 0) {         countx = countx / 2;       } else {         countx = countx / 2 + 1;       }       cout << countx << endl;       return 0;     }   }