#include #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const int INF = 1 << 30; const ll LLINF = 1LL << 60; int mod = 1000000007; set st; vector nodes[100100]; void dfs(int p, int s, int depth){ bool is_leaf = true; for(auto to: nodes[s]){ if(to == p) continue; is_leaf = false; dfs(s, to, depth+1); } if(is_leaf) st.insert(depth); return; } int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; rep(i, N-1){ int a, b; cin >> a >> b; a--; b--; nodes[a].push_back(b); nodes[b].push_back(a); } vector jisuu_cnt(N, 0); int root = -1; rep(i, N){ jisuu_cnt[nodes[i].size()]++; if(nodes[i].size() >= 3) root = i; } if(jisuu_cnt[1]+jisuu_cnt[2] < N-1) cout << "No" << endl; else if(jisuu_cnt[1]+jisuu_cnt[2] == N) cout << "Yes" << endl; else{ dfs(-1, root, 0); if(st.size() == 1) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }