// #include using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define lch (o << 1) #define rch (o << 1 | 1) typedef double db; typedef long long ll; typedef unsigned int ui; typedef pair pint; typedef tuple tint; const int N = 2e5 + 5; const int INF = 0x3f3f3f3f; const ll INF_LL = 0x3f3f3f3f3f3f3f3f; int vst[N]; vector a[N]; int main() { ios::sync_with_stdio(0); queue q; int n; cin >> n; for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } for (int i = 1; i <= n; i++) { if (a[i].size() == 1) { q.push(make_pair(i, 0)); vst[i] = 1; } } int siz = q.size(); if (siz == 2) { cout << "Yes" << endl; return 0; } while (!q.empty()) { queue nq; while (!q.empty()) { pint p = q.front(); q.pop(); if (vst[p.fi] > 1) continue; for (auto v: a[p.fi]) { if (!vst[v] && v != p.se) { nq.push(make_pair(v, p.fi)); } } } q = nq; while (!nq.empty()) { pint p = nq.front(); nq.pop(); vst[p.fi]++; } } static int cnt[N]; for (int i = 1; i <= n; i++) cnt[vst[i]]++; bool flag = (cnt[1] == n - 1) && (cnt[siz] == 1); cout << (flag ? "Yes" : "No") << endl; return 0; }