#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = 1000000007; int N; vectorG[100010]; int depth[100010]; void dfs(int v, int p, int d) { depth[v] = d; for (auto nv : G[v]) { if (nv == p)continue; dfs(nv, v, d + 1); } } signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i = 0; i < N - 1; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } for (int i = 0; i < N; i++) { if (G[i].size() == 1) { dfs(i, -1, 0); setst; for (int j = 0; j < N; j++) { if (G[j].size() == 1) { st.insert(depth[j]); } } if (st.size() <= 2) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; return 0; }