malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     {       long long int r, n, c, m, i, j, count = 0, x, a, b, y, sum = 0;       long long int mn = 1e18, mx = 0, ans = 0, k, ind;       long long int br = 0, T, rz = 0;       string s =   ;       cin >> n;       long long int a1, a2, a3, b1, b2, b3;       cin >> a1 >> a2 >> a3;       cin >> b1 >> b2 >> b3;       mx = max(mx, a1 - b1 - b3);       mx = max(mx, a2 - b1 - b2);       mx = max(mx, a3 - b2 - b3);       mn = 0;       mn += min(a1, b2);       mn += min(a2, b3);       mn += min(a3, b1);       cout << mx <<     << mn << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ntest = 0, test = 0;   inline void init();   inline void run();   inline void stop() { ntest = test - 1; }   int main() {     init();     while (++test <= ntest) {       run();     }     return 0;   }   const int INF = (int)1E9 + 5;   const double EPS = 1E-11;   const long long MOD = (long long)1E9 + 7;   const int dx[] = {-1, 0, 0, 1};   const int dy[] = {0, -1, 1, 0};   inline void init() { ntest = 1; }   long long mu(long long a, long long n) {     long long rs = 1;     for (; n; n >>= 1) {       if (n & 1) rs = (rs * a) % MOD;       a = (a * a) % MOD;     }     return rs;   }   vector<int> a;   inline void run() {     int n, k;     cin >> n >> k;     a.resize(n);     for (int i = 0; i < (n); i++) cin >> a[i];     if (k == 0) {       for (int i = 0; i < (n); i++) cout << a[i] <<    ;       return;     }     for (int i = 0; i < (n); i++) {       long long total = a[i];       long long cur = 1;       for (int j = (1); j <= (i); j++) {         cur = (cur * (k + j - 1)) % MOD;         cur = (cur * mu(j, MOD - 2)) % MOD;         total = (total + (cur * a[i - j]) % MOD) % MOD;       }       cout << total <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const long long LL_INF = (long long)9.22e18;   string s;   int main() {     cin >> s;     bool isFirst = true;     int cnt = 0;     for (char ch : s) {       if (ch ==  1  && isFirst) {         isFirst = false;         continue;       }       if (ch ==  0  && !isFirst) {         cnt++;       }     }     if (cnt >= 6 && !isFirst) {       cout <<  yes  << endl;     } else {       cout <<  no  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int ans, pre, cnt;   int main() {     cin >> s;     for (int i = 0; i < s.size(); i++) {       pre += s[i] -  0 ;       cnt++;       if (cnt == 3 || (s[i] -  0 ) % 3 == 0 || pre % 3 == 0)         ans++, pre = 0, cnt = 0;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using pii = pair<int, int>;   using UI = unsigned int;   const int mod = 1e9 + 7;   const int inf = 0x3f3f3f3f;   const double EPS = 1e-8;   const double PI = acos(-1.0);   const int N = 5e5 + 10;   const int M = N + (1 << 20);   int n, a[N][2];   int deg[1 << 20];   bool vis[N << 1];   vector<pii> G[M];   vector<int> ans;   void dfs(int x, int idx) {     pii p;     while (G[x].size()) {       p = G[x].back();       G[x].pop_back();       if (!vis[p.second]) {         vis[p.second] = 1;         dfs(p.first, p.second);       }     }     if (idx != -1) {       ans.emplace_back(idx);     }   }   void add_edge(int x, int y, int idx) {     G[x].emplace_back(y, idx);     G[y].emplace_back(x, idx);   }   bool ok(int k) {     int mask = (1 << k) - 1;     for (int i = (0); i < ((1 << k)); ++i) {       deg[i] = 0;     }     for (int i = (0); i < ((1 << k) + n); ++i) {       G[i].clear();     }     int x, y, z;     int offset = 1 << k;     for (int i = (0); i < (n); ++i) {       x = a[i][0] & mask;       y = a[i][1] & mask;       deg[x] += 1;       deg[y] += 1;       add_edge(x, i + offset, i << 1);       add_edge(y, i + offset, i << 1 | 1);     }     for (int i = (0); i < (1 << k); ++i) {       if (deg[i] & 1) return 0;     }     for (int i = (0); i < (n << 1); ++i) {       vis[i] = 0;     }     ans.clear();     for (int i = (0); i < (n + (1 << k)); ++i) {       if (G[i].size()) {         dfs(i, -1);         break;       }     }     if (ans.size() < n * 2) {       return 0;     }     printf( %d n , k);     for (int i = (0); i < (ans.size()); ++i) {       printf( %d  , ans[i] + 1);     }     puts(  );     return 1;   }   int main() {     scanf( %d , &n);     for (int i = (0); i < (n); ++i) {       scanf( %d %d , &a[i][0], &a[i][1]);     }     for (int i = (20); i > (0); --i) {       if (ok(i)) {         return 0;       }     }     puts( 0 );     for (int i = (1); i < (n + 1); ++i) {       printf( %d %d  , i * 2 - 1, i * 2);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int tinf = (int)1e9 + 7;   const long long inf = (long long)1e18 + 7;   const int N = 1e5 + 5;   long long n, x[10000], y[10000], ans;   int main() {     {       ios ::sync_with_stdio(false);       cin.tie(0);     }     cin >> n;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     for (int i = 1; i < n - 1; i++)       if (y[i] > y[i - 1] && x[i + 1] < x[i])         ans++;       else if (y[i] < y[i - 1] && x[i + 1] > x[i])         ans++;       else if (x[i] > x[i - 1] && y[i + 1] > y[i])         ans++;       else if (x[i] < x[i - 1] && y[i + 1] < y[i])         ans++;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long second = 0;     int r, m;     cin >> m >> r;     long long koef = 0, koef2 = 0;     for (int i = 1; i <= m; ++i) {       long long lef = i - 2, rig = m - i - 1;       if (lef < 0) lef = 0;       if (rig < 0) rig = 0;       koef2 += i != 1;       koef2 += i != m;       koef += lef + rig;       second += 2;       if (i != 1) second += 2;       if (i != m) second += 2;       second += (lef + 1) * lef;       second += (rig + 1) * rig;     }     long double ans = second + (2 * koef + koef2) * sqrt(2.0);     printf( %.10f n , double(ans / (1LL * m * m) * r));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long spf[100001];   long long fac[100001];   void sieve() {     spf[1] = 1;     for (long long i = 2; i < 100001; i++) spf[i] = i;     for (long long i = 4; i < 100001; i += 2) spf[i] = 2;     for (long long i = 3; i * i < 100001; i++) {       if (spf[i] == i) {         for (long long j = i * i; j < 100001; j += i)           if (spf[j] == j) spf[j] = i;       }     }   }   map<long long, long long> getfactor(long long a) {     map<long long, long long> m;     while (a > 1) {       m[spf[a]]++;       a /= spf[a];     }     return m;   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long inverse(long long a, long long p) { return power(a, p - 2, p); }   long long ncr(long long n, long long r, long long p) {     if (r == 0) return 1;     return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;   }   void solve() {     long long n;     cin >> n;     long long a[n];     long long hah[100001] = {0}, ans[100001] = {0};     for (long long i = 0; i < n; i++) {       cin >> a[i];       hah[a[i]]++;     }     for (long long i = 100000; i >= 1; i--) {       long long sum = 0;       for (long long j = i; j <= 100000; j += i) {         sum += hah[j];         ans[i] = (ans[i] - ans[j] + 1000000007) % 1000000007;         if (ans[i] < 0) ans[i] = (ans[i] + 1000000007) % 1000000007;       }       ans[i] = (ans[i] % 1000000007 + power(2, sum, 1000000007) - 1 + 1000000007 +                 1000000007) %                1000000007;     }     cout << ans[1] <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e6 + 100;   const long long INF = 9 * (long long)(1e18);   const long double PI = 3.14159265358979323846;   long long int modexp(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     if (y == 0)       return 1;     else if (x == 0)       return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res % p;   }   vector<long long int> is_prime(N + 1, 1);   void sieve(long long int n) {     for (long long int i = 1; i <= n; i++) is_prime[i] = i;     for (long long int i = 2; i * i <= n; i++) {       if (is_prime[i] == i) {         for (long long int j = i * i; j <= n; j += i)           is_prime[j] = min(i, is_prime[j]);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int foo;     cin >> foo;     while (foo--) {       long long int n;       cin >> n;       long long int x = (n + 3) / 4;       string s = string(x,  8 );       n -= x;       string s2 = string(n,  9 );       cout << s2 + s <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50 + 10, dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};   int main() {     int n, m, x, y;     while (~scanf( %d%d , &n, &m)) {       getchar();       char a[N][N];       for (int i = 0; i < n; i++) {         scanf( %s , a[i]);         for (int j = 0; j < m; j++) {           if (a[i][j] ==  S ) {             x = i;             y = j;           }         }       }       string str;       cin >> str;       int sum = 0, mmp[5], sz[5];       memset(sz, 0, sizeof(sz));       for (int i = 0; i < 4; i++) {         mmp[0] = i;         sz[i] = 1;         for (int j = 0; j < 4; j++) {           if (!sz[j]) {             sz[j] = 1;             mmp[1] = j;             for (int k = 0; k < 4; k++) {               if (!sz[k]) {                 mmp[2] = k;                 sz[k] = 1;                 for (int l = 0; l < 4; l++) {                   if (!sz[l]) {                     mmp[3] = l;                     int nx = x, ny = y;                     for (int zz = 0; zz < str.size(); zz++) {                       nx += dx[mmp[str[zz] -  0 ]];                       ny += dy[mmp[str[zz] -  0 ]];                       if (a[nx][ny] ==  #  ||                           !(nx >= 0 && nx < n && ny >= 0 && ny < m))                         break;                       if (a[nx][ny] ==  E ) {                         sum++;                         break;                       }                     }                   }                 }                 sz[k] = 0;               }             }             sz[j] = 0;           }         }         sz[i] = 0;       }       printf( %d n , sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct MyStruct {     long long val;     long long under;     long long scorev;     long long scoreu;     MyStruct(long long v, long long u, long long sv, long long su)         : val(v), under(u), scorev(sv), scoreu(su) {}     bool operator<(const MyStruct& m) const { return val < m.val; }   };   int main() {     ios_base::sync_with_stdio(false);     long long n;     cin >> n;     long long a1[n], a2[n], b1[n], b2[n];     for (long long i = 0; i < n; ++i) cin >> a1[i] >> b1[i] >> a2[i] >> b2[i];     long long ans = 0;     priority_queue<MyStruct> pq;     for (long long i = 0; i < n; ++i) {       long long cnum = a1[i] + b1[i], dnum = a2[i] + b2[i];       if (cnum < dnum) {         if (a1[i] > b2[i]) {           ans += a1[i] - b2[i];         } else if (b1[i] > a2[i]) {           ans -= b1[i] - a2[i];         }         continue;       }       if (cnum == dnum) {         ans += (a1[i] - b2[i]);         continue;       }       pq.push(MyStruct(cnum, dnum, a1[i], a2[i]));     }     bool first = true;     while (!pq.empty()) {       MyStruct top = pq.top();       pq.pop();       if (first)         ans += top.scorev;       else         ans += (top.scorev - top.val);       if (top.under != -1) pq.push(MyStruct(top.under, -1, top.scoreu, -1));       first = !first;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 9e18;   const int mod = 4e4 + 7;   vector<int> prime;   bool p[100005];   void init() {     p[1] = true;     for (int i = 2; i <= 100005; i++) {       if (!p[i]) {         prime.push_back(i);         for (int j = i + i; j < 100005; j += i) p[j] = true;       }     }   }   bool isp(int n) {     for (int i = 2; i <= sqrt(n); i++)       if (n % i == 0) return false;     return true;   }   int main() {     init();     int n;     cin >> n;     int s[100005];     int mx = 0;     for (int i = 0; i < n; i++) scanf( %d , &s[i]), mx = max(mx, s[i]);     sort(s, s + n);     int ans = 1;     int num[100005];     for (int i = 2; i <= mx; i++)       num[i] = upper_bound(s, s + n, i) - lower_bound(s, s + n, i);     for (int i = 0; i < prime.size(); i++) {       int sum = 0;       int x = prime[i];       for (int j = x; j <= mx; j++) {         if (j % x == 0) sum += num[j];       }       ans = max(ans, sum);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v(n);     int sum = 0;     for (int i = 0; i < n; i++) {       cin >> v[i];       sum += v[i];     }     int req = sum / 2 - v[0] + 1;     vector<pair<int, int> > v1;     for (int i = 1; i < n; i++) {       if (v[i] <= v[0] / 2) v1.push_back(make_pair(v[i], i));     }     vector<int> v2;     if (req > 0)       for (int j = 0; j < v1.size(); j++) {         req -= v1[j].first;         v2.push_back(v1[j].second + 1);         if (req <= 0) break;       }     if (req > 0)       cout << 0 << endl;     else {       cout << v2.size() + 1 << endl;       cout <<  1  ;       for (int i = 0; i < v2.size(); i++) cout << v2[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long int t, n, i, j, k, sum = 0, res = 0, maxi = -1, mini = 1000000100;     cin >> n;     long long int a[n + 1];     for (i = 0; i < n; i++) cin >> a[i];     long long int idx = 0;     for (i = 31; i >= 0; i--) {       long long int cnt = 0;       for (j = 0; j < n; j++) {         if ((a[j] >> i) & 1) {           cnt++;           idx = j;         }         if (cnt == 2) break;       }       if (cnt == 1) break;     }     swap(a[idx], a[0]);     for (i = 0; i < n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   const int MOD = 1E9 + 7;   const int N = 150000 + 5;   const int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};   const int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};   using namespace std;   struct Edge {     int nex, to;     int w;     Edge() {}     Edge(int nex, int to, int w) : nex(nex), to(to), w(w) {}   } edge[5151111];   int head[N];   int cnt;   void addEdge(int from, int to, int w) {     edge[++cnt].nex = head[from];     edge[cnt].to = to;     edge[cnt].w = w;     head[from] = cnt++;   }   vector<int> G[N];   vector<int> nex[N];   int dis[N];   bool vis[N];   int Find(int y, int w) {     int left = 0, right = G[y].size() - 1;     while (left <= right) {       int mid = (left + right) / 2;       if (G[y][mid] > w)         right = mid - 1;       else if (G[y][mid] < w)         left = mid + 1;       else         return nex[y][mid];     }     return w;   }   int SPFA(int s, int n) {     memset(dis, 0x3f3f3f3f, sizeof(dis));     memset(vis, false, sizeof(vis));     vis[s] = true;     dis[s] = Find(1, 0);     queue<int> Q;     Q.push(s);     while (!Q.empty()) {       int x = Q.front();       Q.pop();       vis[x] = false;       for (int i = head[x]; i != -1; i = edge[i].nex) {         int y = edge[i].to;         int w = edge[i].w;         int times = dis[x] + w;         if (y != n) times = Find(y, times);         if (dis[y] > times) {           dis[y] = times;           if (!vis[y]) {             vis[y] = true;             Q.push(y);           }         }       }     }     return dis[n];   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     memset(head, -1, sizeof(head));     for (int i = 1; i <= m; i++) {       int x, y, w;       scanf( %d%d%d , &x, &y, &w);       addEdge(x, y, w);       addEdge(y, x, w);     }     for (int i = 1; i <= n; i++) {       int t;       scanf( %d , &t);       while (t--) {         int x;         scanf( %d , &x);         G[i].push_back(x);       }     }     for (int i = 1; i <= n; i++) {       for (int j = G[i].size() - 1; j >= 0; j--) {         int before;         if (j == G[i].size() - 1 || G[i][j] != G[i][j + 1] - 1)           before = G[i][j] + 1;         nex[i].push_back(before);       }       reverse(nex[i].begin(), nex[i].end());     }     int res = SPFA(1, n);     if (res == 0x3f3f3f3f) res = -1;     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 100011, log_n = 32, max_m = 111, mod = 1000000007,             inf = 1011111111, p = 997;   long long n, pp[22], dp[max_n][22][2];   bool a[max_n][22];   long long ans;   vector<int> v[max_n];   void dfs(int x, int p) {     for (int i = 0; i < v[x].size(); ++i) {       if (v[x][i] == p) continue;       dfs(v[x][i], x);       for (int q = 0; q < 22; ++q) {         dp[x][q][a[x][q]] += dp[v[x][i]][q][0];         dp[x][q][1 - a[x][q]] += dp[v[x][i]][q][1];       }     }     long long ans1 = 0;     for (int i = 0; i < v[x].size(); ++i) {       if (v[x][i] == p) continue;       for (int q = 0; q < 22; ++q) {         dp[x][q][a[x][q]] -= dp[v[x][i]][q][0];         dp[x][q][1 - a[x][q]] -= dp[v[x][i]][q][1];         ans1 += pp[q] * dp[v[x][i]][q][0] * dp[x][q][1];         ans1 += pp[q] * dp[v[x][i]][q][1] * dp[x][q][0];         dp[x][q][a[x][q]] += dp[v[x][i]][q][0];         dp[x][q][1 - a[x][q]] += dp[v[x][i]][q][1];       }     }     ans1 /= 2;     ans += ans1;     for (int i = 0; i < 22; ++i) {       dp[x][i][a[x][i]]++;       ans += pp[i] * dp[x][i][1];     }   }   int main() {     pp[0] = 1;     for (int i = 1; i < 22; ++i) {       pp[i] = pp[i - 1] * 2;     }     cin >> n;     for (int i = 0; i < n; ++i) {       int g;       cin >> g;       for (int q = 0; g; g /= 2, ++q) {         a[i][q] = g % 2;       }     }     for (int i = 1; i < n; ++i) {       int g, h;       cin >> g >> h;       g--;       h--;       v[g].push_back(h);       v[h].push_back(g);     }     dfs(0, -1);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 105;   const int INF = 0x3f3f3f3f;   const double pi = acos(-1.0);   const double eps = 1e-9;   int a[maxn];   int n;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     sort(a, a + n);     int now = 10;     int ans = 0;     int anscnt = 0;     bool flag = true;     for (int i = 0; i < n; ++i) {       if (flag) {         now += a[i];         if (now == 360) {           anscnt += i + 1;           flag = false;         } else if (now > 360) {           anscnt += i;           if (now <= 720) {             flag = false;             anscnt++;             ans += now - 360;           } else             break;         }       } else {         now += a[i];         if (now <= 720) {           anscnt++;           ans += now - 360;         } else           break;       }     }     if (now <= 360) {       anscnt = n;       ans = 0;     }     cout << anscnt <<     << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long x, r, r1, s, s1, pos, pos1, nx = 0;     int digits[19], index = 0;     cin >> x;     pos = 1;     do {       pos1 = pos;       pos *= 10;       r = x % pos;       s = (x - r) / pos;       r1 = r % pos1;       s1 = (r - r1) / pos1;       digits[index] = s1;       index++;     } while (s != 0);     for (int i = index - 1; i >= 0; i--) {       if (!(i == index - 1) || !(digits[i] == 9)) {         if (digits[i] > 4) digits[i] = 9 - digits[i];         nx = nx + digits[i] * pos1;       } else {         nx = nx + digits[i] * pos1;       }       pos1 /= 10;     }     cout << nx << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int val[105];     memset(val, 0, sizeof val);     char arr[105];     scanf( %s , arr);     int n = strlen(arr);     for (int i = 0; i < n; i++) {       if (arr[i] ==  A ) {         if (i > 0) {           val[i - 1] |= 1;         }         val[i] |= 1;         if (i < n - 1) {           val[i + 1] |= 1;         }       } else if (arr[i] ==  B ) {         if (i > 0) {           val[i - 1] |= (1 << 1);         }         val[i] |= (1 << 1);         if (i < n - 1) {           val[i + 1] |= (1 << 1);         }       } else if (arr[i] ==  C ) {         if (i > 0) {           val[i - 1] |= (1 << 2);         }         val[i] |= (1 << 2);         if (i < n - 1) {           val[i + 1] |= (1 << 2);         }       }     }     bool flag = false;     for (int i = 0; i < n; i++) {       if (val[i] == 7) {         flag = true;         break;       }     }     if (flag) {       printf( Yes n );     } else {       printf( No n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long lcm(long long a, long long b) {     long long g = gcd(a, b);     long long ans = (a * b) / g;     return ans;   }   vector<long long> primes;   bool prime[10005];   void seive() {     memset(prime, 1, sizeof(prime));     prime[0] = 0;     prime[1] = 0;     for (long long i = 2; i <= 10000; i++) {       if (prime[i] == 1) {         for (long long j = i * i; j <= 10000; j += i) prime[j] = 0;       }     }   }   long long power(long long a, long long b) {     long long ans = 1;     while (b > 0) {       if (b % 2 == 1) ans = (ans % 1000000007 * a % 1000000007) % 1000000007;       a = (a * a) % 1000000007;       b = b / 2;     }     return ans;   }   template <typename T>   std::string NumberToString(T Number) {     std::ostringstream ss;     ss << Number;     return ss.str();   }   long long gcdExtended(long long a, long long b, long long *x, long long *y);   long long modInverse(long long b, long long m) {     long long x, y;     long long g = gcdExtended(b, m, &x, &y);     if (g != 1) return -1;     return (x % m + m) % m;   }   long long modDivide(long long a, long long b, long long m) {     a = a % m;     long long inv = modInverse(b, m);     return (inv * a) % m;   }   long long gcdExtended(long long a, long long b, long long *x, long long *y) {     if (a == 0) {       *x = 0, *y = 1;       return b;     }     long long x1, y1;     long long gcd = gcdExtended(b % a, a, &x1, &y1);     *x = y1 - (b / a) * x1;     *y = x1;     return gcd;   }   long long n;   vector<long long> v[100005];   vector<long long> ans;   void dfs(long long u, long long p) {     if (v[u].size() == 1 and p != 0) {       ans.push_back(u);       return;     }     for (auto x : v[u]) {       if (x != p) {         dfs(x, u);       }     }   }   void solve() {     cin >> n;     long long i, j;     for (i = 0; i < n - 1; i++) {       long long x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     long long ct = 0, root = 1;     for (long long i = 1; i <= n; i++) {       if (v[i].size() > 2) {         root = i;         ct++;       }     }     if (ct > 1) {       cout <<  No ;       return;     }     cout <<  Yes  <<   n ;     dfs(root, 0);     cout << ans.size() <<   n ;     for (i = 0; i < ans.size(); i++) {       cout << root <<     << ans[i] <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     bool codechef = 0;     long long t = 1;     if (codechef) {       cin >> t;     }     while (t--) {       solve();     }     return 0;   }