#include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; struct edge{ int from; int to; int co; }; int main() { int n; cin >> n; vector> g(n); vector cost(n, 1001001001); vector stamp(n, false); 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); } int tar; for(int i = 0; i < n; i++){ if(g[i].size() == 1){ tar = i; break; } } queue q; q.push(tar); cost[tar] = 0; vector ans; stamp[tar] = true; while(!q.empty()){ int u = q.front(); q.pop(); for(int v: g[u]){ if(stamp[v] == true) continue; else stamp[v] = true; cost[v] = cost[u]+1; if(g[v].size() == 1) ans.push_back(cost[v]); else q.push(v); } } ll tmp = ans[0]; for(ll now : ans){ if(tmp != now){ cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }