#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); } queue q; q.push(0); cost[0] = 0; vector ans; stamp[0] = true; while(!q.empty()){ int u = q.front(); q.pop(); for(int v: g[u]){ if(stamp[v]) continue; else stamp[v] = true; if(cost[v] >= cost[u]+1){ cost[v] = cost[u]+1; } if(g[v].size() == 1) ans.push_back(cost[v]); q.push(v); } } int tmp = ans[0]; for(int now : ans){ if(tmp != now){ cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }