malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int k, t;   char n1[10005];   char n2[10005];   int swapindex[2];   bool same(char x[], char y[], int n) {     for (int i = 0; i < n; i++) {       if (x[i] != y[i]) {         return false;       }     }     return true;   }   int ham(char x[], char y[], int n) {     int temp = 0;     for (int i = 0; i < n; i++) {       if (x[i] != y[i]) {         temp++;       }     }     return temp;   }   int main() {     cin >> k;     for (int i = 0; i < k; i++) {       cin >> t;       for (int l = 0; l < t; l++) {         cin >> n1[l];       }       for (int l = 0; l < t; l++) {         cin >> n2[l];       }       if (ham(n1, n2, t) == 2) {         int temp = 0;         for (int i = 0; i < t; i++) {           if (n1[i] != n2[i]) {             swapindex[temp] = i;             temp++;           }         }         swap(n1[swapindex[0]], n2[swapindex[1]]);         if (same(n1, n2, t)) {           cout <<  Yes  << endl;         } else {           cout <<  No  << endl;         }       } else {         cout <<  No  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100005];   long long k;   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     long long sum = accumulate(a, a + n, 0LL);     if (sum < k)       cout << -1 << endl;     else {       long long L = 0, R = 1 << 30;       while (L < R) {         long long mid = (L + R + 1) / 2, cur = 0;         for (int i = 0; i < n; i++) cur += min(mid, (long long)a[i]);         if (cur > k)           R = mid - 1;         else           L = mid;       }       long long cur = k;       for (int i = 0; i < n; i++) cur -= min((long long)a[i], L);       queue<pair<int, int> > q;       for (int i = 0; i < n; i++)         if (a[i] - L > 0) q.push(make_pair(i, a[i] - L));       while (cur--) {         pair<int, int> p = q.front();         q.pop();         if (p.second - 1 > 0) q.push(make_pair(p.first, p.second - 1));       }       while (!q.empty()) {         pair<int, int> p = q.front();         q.pop();         cout << p.first + 1 <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long sum = 0, sum_mas;     cin >> n;     vector<int> mas;     for (int i = 0, temp = 0; i < n; i++) {       cin >> temp;       sum += temp;       mas.push_back(temp);     }     sum_mas = sum;     sort(mas.begin(), mas.end());     for (int i = 0; i < n; i++) {       sum += sum_mas;       sum_mas -= mas[i];     }     cout << sum - mas[mas.size() - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   template <class A, class B>   ostream& operator<<(ostream& os, const pair<A, B>& p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <class T>   auto operator<<(ostream& os, T&& x) -> decltype(x.begin(), os) {     os <<  { ;     for (auto it = x.begin(); it != x.end(); ++it)       os << *it << (it == prev(x.end()) ?    :  ,  );     return os <<  } ;   }   void dump() {}   template <class T, class... Args>   void dump(T&& x, Args... args) {     cerr << x <<  ;   ;     dump(args...);   }   int t, n, m;   void solve() {     cin >> n >> m;     bool ans = false;     for (int i = 0; i < n; ++i) {       int x, y, z, w;       cin >> x >> y >> z >> w;       if (y == z) ans = true;     }     if (m % 2 == 0 && ans)       cout <<  YES n ;     else       cout <<  NO n ;   }   int main() {     ios::sync_with_stdio(false);     for (cin >> t; t--;) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, yu, one, sum, cnt = 3;   long long ans[4];   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   int main() {     scanf( %I64d , &n);     if (!(n % 3))       printf( 1 1 %I64d , n - 2);     else       printf( 1 2 %I64d , n - 3);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[200], b[200], i, j, DP[3 * 10000];   int main() {     cin >> n >> k;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++) cin >> b[i], b[i] *= k;     for (j = 10000; j >= -10000; j--) DP[j + 10000] = -(10000 * 10000);     DP[10000] = 0;     for (i = 1; i <= n; i++)       if (a[i] - b[i] > 0) {         for (j = 10000; j >= -10000; j--)           if (j + 10000 + a[i] - b[i] >= 0 &&               j + 10000 + a[i] - b[i] <= 2 * 10000)             DP[j + 10000 + a[i] - b[i]] =                 max(DP[j + 10000] + a[i], DP[j + 10000 + a[i] - b[i]]);       } else {         for (j = -10000; j <= 10000; j++)           if (j + 10000 + a[i] - b[i] >= 0 &&               j + 10000 + a[i] - b[i] <= 2 * 10000)             DP[j + 10000 + a[i] - b[i]] =                 max(DP[j + 10000] + a[i], DP[j + 10000 + a[i] - b[i]]);       }     if (!DP[10000])       cout <<  -1  << endl;     else       cout << DP[10000] << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct tree {     int lf;     int rt;     int we;   } a[2000010];   int v[2000010];   int main() {     int n;     scanf( %d , &n);     for (int j = 0; j < n - 1; j++) {       scanf( %d%d , &a[j].lf, &a[j].rt);       a[j].we = -1;       v[a[j].lf]++;       v[a[j].rt]++;     }     int maxi = 0, ans = -1, p = 0;     for (int j = 0; j < 2000010; j++) {       if (maxi < v[j]) {         maxi = v[j];         ans = j;       }     }     for (int j = 0; j < n - 1; j++)       if ((a[j].lf == ans || a[j].rt == ans) && a[j].we == -1) a[j].we = p++;     for (int j = 0; j < n - 1; j++)       if (a[j].we == -1) a[j].we = p++;     for (int j = 0; j < n - 1; j++) printf( %d n , a[j].we);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 121;   int a[N], b[N], last[N], kol, ans, v, u, i, n;   inline void add(int v, int u) {     a[++kol] = u;     b[kol] = last[v];     last[v] = kol;   }   void dfs(int v, int p, int len) {     if (len == 2) {       ++ans;       return;     }     int x = last[v];     while (x) {       if (a[x] != p) dfs(a[x], v, len + 1);       x = b[x];     }   }   int main() {     cin >> n;     for (i = 1; i < n; ++i) {       cin >> v >> u;       add(v, u);       add(u, v);     }     for (i = 1; i <= n; ++i) dfs(i, 0, 0);     cout << ans / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       int v[1000];       cin >> n;       for (int i = 0; i < n; i++) {         cin >> v[i];         v[i] = abs(v[i]);       }       int signo = 1;       for (int i = 0; i < n - 1; i++) {         cout << v[i] * signo <<    ;         signo *= -1;       }       cout << v[n - 1] * signo << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long in() {     int32_t x;     scanf( %d , &x);     return x;   }   inline long long lin() {     long long x;     scanf( %lld , &x);     return x;   }   const long long maxn = 200 + 10;   const long long inf = 1e18 + 1;   long long a[maxn][maxn], mini[maxn], res[maxn], dp[maxn][maxn], id[maxn],       what[maxn];   long long N;   inline void calcDp() {     memset(dp, 0, sizeof dp);     dp[N][0] = 1;     for (long long i = N - 1; i >= 0; i--) {       for (long long j = 0; j <= i; j++) {         dp[i][j] = min(dp[i + 1][j + 1] * bool(what[i] != 1) +                            (j && what[i] != 0 ? dp[i + 1][j - 1] : 0),                        inf);       }     }   }   int32_t main() {     long long n = in(), m = in(), k = lin();     N = n + m - 1;     memset(mini, 63, sizeof mini);     memset(res, -1, sizeof res);     memset(what, -1, sizeof what);     for (long long i = 0; i < n; i++)       for (long long j = 0; j < m; j++) a[i][j] = in();     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) mini[i + j] = min(mini[i + j], a[i][j]);     }     iota(id, id + n + m - 1, 0);     sort(id, id + n + m - 1, [](const long long &a, const long long &b) {       return mini[a] < mini[b];     });     for (long long _ = 0; _ < n + m - 1; _++) {       long long i = id[_];       what[i] = 0;       calcDp();       if (dp[0][0] >= k) continue;       k -= dp[0][0];       what[i] = 1;     }     for (long long i = 0; i < n; i++, cout <<   n ) {       for (long long j = 0; j < m; j++) {         cout << (what[i + j] == 0 ?  (  :  ) );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> cnt(n);     for (int i = 0; i < n; ++i) cin >> cnt[i];     sort(cnt.begin(), cnt.end(), greater<int>());     long long ans = 0;     int prev = 1000000001;     for (int i = 0; i < n; ++i) {       if (cnt[i] >= prev) cnt[i] = prev - 1;       prev = max(cnt[i], 0);       ans += prev;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   void parseArray(long long* A, long long n) {     for (long long K = 0; K < n; K++) {       cin >> A[K];     }   }   long long modInverse(long long a, long long b) {     return 1 < a ? b - modInverse(b % a, a) * b / a : 1;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long double dist(long long x, long long y, long long a, long long b) {     return sqrt((x - a) * (x - a) + (y - b) * (y - b));   }   void debug(long long* a, long long n) {     for (int k = 0; k < n; k++) {       cout << a[k] <<    ;     }     cerr <<   n ;   }   long long mod = 1000000007;   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     long long n;     cin >> n;     long long ans[n + 1];     memset(ans, 0, sizeof ans);     long long id = 1;     for (int k = 2; k <= n; k++) {       if (ans[k] == 0) {         for (int j = k; j <= n; j += k) {           ans[j] = id;         }         id++;       }     }     for (int k = 2; k <= n; k++) {       cout << ans[k] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     int sum, c = 0;     cin >> n;     int arr[3];     for (int i = 0; i < n; i++) {       for (int i = 0; i < 3; i++) {         cin >> arr[i];       }       sum = arr[0] + arr[1] + arr[2];       if (sum > 1) c++;     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t0, t1, t2, x1, x2;   long long count(long long y1, long long y2) {     return t1 * y1 + t2 * y2 - t0 * (y1 + y2);   }   int main() {     cin >> t1 >> t2 >> x1 >> x2 >> t0;     if (t1 == t2) {       cout << x1 <<     << x2;       return 0;     }     long long by1 = 0, by2 = x2;     for (long long y1 = 0; y1 <= x1; y1++) {       long long l = (y1 == 0 ? 1 : 0), r = x2;       while (l <= r) {         long long m = (l + r) / 2;         long long c = count(y1, m);         if (c < 0)           l = m + 1;         else {           if ((t1 * y1 + t2 * m) * (by1 + by2) <                   (t1 * by1 + t2 * by2) * (y1 + m) ||               ((t1 * y1 + t2 * m) * (by1 + by2) ==                    (t1 * by1 + t2 * by2) * (y1 + m) &&                (by1 + by2) < (y1 + m))) {             by1 = y1;             by2 = m;           }           r = m - (r == m ? 1 : 0);         }       }     }     cout << by1 <<     << by2;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, b, a[22222], mx = 0;     cin >> n >> b;     mx = b;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       int k = b / a[i];       int s = b % a[i];       for (int j = i + 1; j < n; j++) {         int p = a[j] * k + s;         mx = max(mx, p);       }     }     cout << mx;     return 0;   }
#include <bits/stdc++.h>   int main() {     int i, j, n, max = -1, count, a;     char c1, c2;     scanf( %d , &n);     char s[n];     scanf( %s , s);     for (i = 0; i < n - 1; i++) {       count = 0;       for (j = i + 1; j < n - 1; j++) {         if (s[j] == s[i]) {           if (s[j + 1] == s[i + 1]) count++;         }       }       if (count > max) {         max = count;         c1 = s[i];         c2 = s[i + 1];       }     }     printf( %c%c n , c1, c2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     set<long long> a = {1, n};     for (long long d = 2; d <= min((long long)sqrt(n) + 10, n - 1); d++) {       if (n % d == 0) {         a.insert(d);         a.insert(n / d);       }     }     long long ans = -1;     if (a.size() >= k) {       auto it = next(a.begin(), k - 1);       ans = *it;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const int N = 405;   int x, y, n, d, a[25][2], memo[N][N];   bool check(int i, int j) { return i * i + j * j <= d * d; }   int solve(int i, int j) {     int &ans = memo[i + 200][j + 200];     if (~ans) return ans;     set<int> st;     for (int k = 0; k < n; k++)       if (check(i + a[k][0], j + a[k][1]))         st.insert(solve(i + a[k][0], j + a[k][1]));     int mex = 0;     while (st.count(mex)) mex++;     return ans = mex;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> x >> y >> n >> d;     for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];     memset(memo, -1, sizeof memo);     cout << (solve(x, y) ?  Anton  :  Dasha );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v, vv, vv2;   int main() {     long long t, n, a[1000], k, f = 0;     cin >> n;     string s;     cin >> s;     int cnt = 0;     for (int i = 0; i < s.size() && cnt >= -1; i++) {       if (s[i] ==  ( )         cnt++;       else         cnt--;     }     if (!cnt)       cout <<  Yes  << endl;     else       cout <<  No  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int a[n];     for (int i = 0; i < n; i++) a[i] = s[i] - 48;     int c1 = 0;     for (int i = 0; i < n; i++) {       if (n % 2 && i == n - 1) {         if (!a[i]) c1 += 1;       } else {         if (a[i] == a[i + 1])           c1 += 1;         else if (a[i] == 0 && a[i + 1] == 1)           c1 += 2;         i++;       }     }     int c2 = 0;     for (int i = 0; i < n; i++) {       if (n % 2 && i == n - 1) {         if (a[i]) c2 += 1;       } else {         if (a[i] == a[i + 1])           c2 += 1;         else if (a[i] == 1 && a[i + 1] == 0)           c2 += 2;         i++;       }     }     cout << min(c1, c2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<pair<int, int> > a(n);     for (int i = (0); i < ((n)); ++i) cin >> a[i].first >> a[i].second;     sort(a.begin(), a.end());     long long best = -1;     vector<long long> dp(n, 0);     for (int i = n - 1; i >= 0; --i) {       dp[i] = -1;       long long prev = 0;       for (int j = i; j < n; ++j) {         prev += a[j].first - a[i].first;         long long cost = a[i].second + prev + (j == n - 1 ? 0 : dp[j + 1]);         if (dp[i] == -1 || dp[i] > cost) {           dp[i] = cost;         }       }       if (dp[i] == -1) dp[i] = a[i].second;     }     cout << dp[0] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long re = 0, flag = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) flag = -1;       ch = getchar();     }     while (isdigit(ch)) re = (re << 1) + (re << 3) + ch -  0 , ch = getchar();     return re * flag;   }   long long n, mx, m, ans;   namespace seg {   long long seg[1000010];   inline void update(long long num) {     seg[num] = seg[num << 1] + seg[num << 1 | 1];   }   inline void add(long long l, long long r, long long num, long long pos) {     if (l == r) {       seg[num] = 1;       return;     }     long long mid = (l + r) >> 1;     if (mid >= pos)       add(l, mid, num << 1, pos);     else       add(mid + 1, r, num << 1 | 1, pos);     update(num);   }   inline long long query(long long l, long long r, long long ql, long long qr,                          long long num) {     if (l >= ql && r <= qr) return seg[num];     long long mid = (l + r) >> 1, re = 0;     if (mid >= ql) re += query(l, mid, ql, qr, num << 1);     if (mid < qr) re += query(mid + 1, r, ql, qr, num << 1 | 1);     return re;   }   }  // namespace seg   struct node {     long long x, y;   } a[200010];   inline bool cmp1(const node &a, const node &b) { return a.x < b.x; }   inline bool cmp2(const node &a, const node &b) {     if (a.y != b.y) return a.y < b.y;     return a.x > b.x;   }   int main() {     n = read();     long long i, j, k;     for (i = 1; i <= n; i++) a[i].x = read(), a[i].y = read();     sort(a + 1, a + n + 1, cmp1);     for (i = 1; i <= n; i = j + 1) {       m++;       j = i;       while (j < n && a[j + 1].x == a[i].x) a[++j].x = m;       a[i].x = m;     }     sort(a + 1, a + n + 1, cmp2);     for (i = 1; i <= n; i = j + 1) {       mx++;       j = i;       while (j < n && a[j + 1].y == a[i].y) a[++j].y = mx;       a[i].y = mx;     }     reverse(a + 1, a + n + 1);     for (i = 1; i <= n; i = j + 1) {       j = i;       while (j < n && a[j + 1].y == a[i].y) j++;       for (k = i; k <= j; k++) {         seg::add(1, m, 1, a[k].x);       }       for (k = i; k <= j; k++) {         ans += seg::query(1, m, ((k == i) ? 1 : a[k - 1].x + 1), a[k].x, 1) *                seg::query(1, m, a[k].x, m, 1);       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   void solve() {     cin >> n >> k;     if (n < k) {       cout << k - n <<   n ;       return;     }     if ((n % 2 == 0 and k % 2 == 0) or (n % 2 == 1 and k % 2 == 1))       cout << 0 <<   n ;     else       cout << 1 <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long t;     cin >> t;     for (long long i = 1; i <= t; i++) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, i;     int rs = 1;     int temp_rs = 1;     cin >> n >> k;     int mang[n];     for (i = 0; i < n; i++) {       cin >> mang[i];       if (i > 0) {         if (mang[i] != mang[i - 1]) {           rs += 1;         } else {           rs = 1;         }         if (rs > temp_rs) {           temp_rs = rs;         }       }     }     cout << temp_rs;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, t;   int l[200005], r[200005], last[200005];   int main() {     cin >> s >> t;     memset(last, -1, sizeof(last));     int j = 0, slen = s.size(), tlen = t.size();     for (int i = 0; i < slen; i++) {       l[i] = last[s[i] -  a ];       if (j < tlen && s[i] == t[j]) {         l[i] = j;         j++;       }       last[s[i] -  a ] = l[i];     }     memset(last, -1, sizeof(last));     j = tlen - 1;     for (int i = slen - 1; i >= 0; i--) {       r[i] = last[s[i] -  a ];       if (j >= 0 && s[i] == t[j]) {         r[i] = j;         j--;       }       last[s[i] -  a ] = r[i];     }     bool ok = true;     for (int i = 0; i < slen; i++) {       if (l[i] == -1 || r[i] == -1 || l[i] < r[i]) {         ok = false;         break;       }     }     if (ok)       cout <<  yes  << endl;     else       cout <<  no  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long mod1 = 998244353;   const double pie = 3.1415926535;   long long power(long long x, long long y) {     if (y == 0)       return 1;     else {       if (y % 2 == 0)         return power(x * x, y / 2);       else         return x * power(x * x, (y - 1) / 2);     }   }   long long mod_power(long long x, long long y, long long m) {     long long r = 1;     x = x % m;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) r = (r * x) % m;       y = y / 2;       x = (x * x) % m;     }     return r;   }   unsigned long long gcd(unsigned long long x, unsigned long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   vector<long long> extended_Euclid(long long a, long long b) {     vector<long long> v(3);     if (b == 0) {       v[0] = a;       v[1] = 1;       v[2] = 0;       return v;     } else {       vector<long long> v1 = extended_Euclid(b, a % b);       v[0] = v1[0];       v[1] = v1[2];       v[2] = v1[1] - (a / b) * v1[2];       return v;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int TESTS = 1;     while (TESTS--) {       int n, k;       cin >> n >> k;       vector<vector<int> > adj;       long long t = 0;       int flag = 0;       for (int i = 0; i < k; i++) {         int m;         cin >> m;         vector<int> v(m);         for (int i = 0; i < m; i++) cin >> v[i];         if (v[0] == 1) {           for (int i = 1; i < m; i++) {             if (v[i] == (v[i - 1] + 1))               flag++;             else               break;           }           t += m - 1 - flag;         } else           t += m - 1;       }       long long ans = t + n - flag - 1;       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-5;   const long double PI = acos(-1);   const int INF = (int)1e9;   const long long INFF = (long long)1e18;   const int mod = (int)1e9 + 7;   const int MXN = (int)3e5 + 7;   int main(void) {     int n;     cin >> n;     puts(n == 2 ?  2  :  1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[5];     int dp[350][350];     int n;     int i, j, k;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     if (n == 1) {       if (a[0] != 0)         printf( BitLGM n );       else         printf( BitAryo n );     }     if (n == 2) {       int mx = max(a[0], a[1]);       for (i = 1; i <= mx; i++) {         dp[i][0] = 1;         dp[0][i] = 1;       }       for (i = 1; i <= a[0]; i++) {         for (j = 1; j <= a[1]; j++) {           for (k = 1; k < i; k++) {             if (dp[i - k][j] == 0) {               dp[i][j] = 1;               break;             }           }           for (k = 1; k < j; k++) {             if (dp[i][j - k] == 0) {               dp[i][j] = 1;               break;             }           }           for (k = 1; k <= min(i, j); k++) {             if (dp[i - k][j - k] == 0) {               dp[i][j] = 1;               break;             }           }         }       }       if (dp[a[0]][a[1]] == 1)         printf( BitLGM n );       else         printf( BitAryo n );     }     if (n == 3) {       int g = 0;       g = g ^ a[0];       g = g ^ a[1];       g = g ^ a[2];       if (g != 0)         printf( BitLGM n );       else         printf( BitAryo n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, r1, r2, t1, t2, f1 = 1, f2 = 1, col[100010];   vector<vector<int>> graph;   bool dfs(const int &v, const int &from, const int &color) {     if (col[v] != color) return 0;     for (auto &i : graph[v])       if (i != from)         if (!dfs(i, v, color)) return 0;     return 1;   }   int main() {     scanf( %d , &n);     graph.resize(n + 1);     for (int i = 1; i < n; ++i) {       scanf( %d%d , &r1, &r2);       graph[r1].push_back(r2);       graph[r2].push_back(r1);     }     for (int i = 1; i <= n; ++i) scanf( %d , &col[i]);     for (int i = 1; i <= n; ++i)       for (auto &j : graph[i])         if (col[i] != col[j]) {           t1 = i;           t2 = j;           break;         }     if (!t1) {       printf( YES n1 );       return 0;     }     for (auto &i : graph[t1]) f1 &= dfs(i, t1, col[i]);     for (auto &i : graph[t2]) f2 &= dfs(i, t2, col[i]);     if (f1)       printf( YES n%d , t1);     else if (f2)       printf( YES n%d , t2);     else       printf( NO );   }