/** * author: shu8Cream * created: 13.03.2021 11:04:54 **/ #include using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair; using vi = vector; using vvi = vector; int n; vi to[200005]; vi dist; void dfs(int v, int p=-1){ for(auto nv : to[v]){ //if(dist[nv]!=-1) continue; if(nv == p) continue; dist[nv]=dist[v]+1; dfs(nv,v); } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> n; rep(i,n-1){ int a,b; cin >> a >> b; a--; b--; to[a].push_back(b); to[b].push_back(a); } dist.resize(n); rep(i,n){ if(to[i].size()==1){ dist[i]=0; dfs(i); break; } } set s; rep(i,n){ if(dist[i] && to[i].size()==1) s.insert(dist[i]); } if(s.size()==1) cout << "Yes" << endl; else cout << "No" << endl; }