func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, k;     cin >> n >> k;     vector<int> adj[n];     int deg[n];     for (int i = 0; i < n; i++) {       deg[i] = 0;     }     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       adj[a].push_back(b);       adj[b].push_back(a);       deg[a]++;       deg[b]++;     }     vector<int> li;     for (int i = 0; i < n; i++) {       if (deg[i] == 1) {         li.push_back(i);       }     }     for (int i = 0; i < li.size(); i++) {       int now = li[i];       for (int j = 0; j < adj[now].size(); j++) {         int to = adj[now][j];         deg[to]--;         if (deg[to] == 1) {           li.push_back(to);         }       }     }     if (li.size() != n) {       cout <<  No  << endl;       return 0;     }     bool v[n];     int deep[n];     for (int i = 0; i < n; i++) {       v[i] = false;       deep[i] = -1;     }     v[li[n - 1]] = true;     deep[li[n - 1]] = 0;     bool ok = true;     for (int i = n - 1; i >= 0; i--) {       int now = li[i];       if (!v[now] || deep[now] > k) {         ok = false;         break;       }       int red = adj[now].size();       if (i < n - 1) {         red--;       }       if (red < 3 && deep[now] != k) {         ok = false;         break;       }       for (int j = 0; j < adj[now].size(); j++) {         int to = adj[now][j];         if (!v[to]) {           v[to] = true;           deep[to] = deep[now] + 1;         }       }     }     cout << (ok ?  Yes  :  No ) << endl;   }   