func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, k;   vector<int> adj[(int)1e5 + 7];   int vis[(int)1e5 + 7];   int deg[(int)1e5 + 7];   int cnt[(int)1e5 + 7];   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     scanf( %d %d , &n, &k);     for (int i = 1; i <= n - 1; i++) {       int u, v;       scanf( %d %d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);       deg[v]++;       deg[u]++;     }     int lvl = 0;     queue<int> q;     for (int i = 1; i <= n; i++)       if (deg[i] == 1) q.push(i);     while (q.size()) {       set<int> kroots;       int sz = q.size();       while (sz--) {         int root = q.front();         q.pop();         vis[root] = 1;         for (auto neighbour : adj[root]) {           if (vis[neighbour]) {             continue;           }           deg[neighbour]--;           cnt[neighbour]++;           kroots.insert(neighbour);         }       }       for (auto val : kroots) {         if (vis[val] || deg[val] > 1 || cnt[val] < 3) {           puts( No );           return 0;         }         q.push(val);       }       if (kroots.size())         lvl++;       else         break;     }     if (lvl == k)       puts( Yes );     else       puts( No );     return 0;   }   