func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const long long maxn = (long long)2 * 1e5 + 10;   const double EPS = 1e-9;   const long long INF = 1e18 + 18;   const long long mod = (long long)10;   long long n, done[maxn], level[maxn], cnt = 0, parent[maxn];   vector<long long> graph[maxn];   set<pair<long long, long long> > seti;   void bfs(long long root) {     queue<long long> Q;     Q.push(root);     done[root] = 1, level[root] = 0;     while (!Q.empty()) {       long long top = Q.front();       Q.pop();       for (long long nb : graph[top]) {         if (done[nb]) continue;         done[nb] = 1;         level[nb] = 1 + level[top];         if (level[nb] > 2) seti.insert({-level[nb], nb});         parent[nb] = top;         Q.push(nb);       }     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (long long i = 1; i < n; i++) {       long long u, v;       cin >> u >> v;       graph[u].push_back(v);       graph[v].push_back(u);     }     bfs(1);     while (!seti.empty()) {       pair<long long, long long> top = *seti.begin();       long long tlevel = -top.first, tv = top.second;       for (long long nb : graph[parent[tv]]) {         auto it = seti.find({-level[nb], nb});         if (it != seti.end()) seti.erase(seti.find({-level[nb], nb}));       }       auto it = seti.find({-level[parent[tv]], parent[tv]});       if (it != seti.end())         seti.erase(seti.find({-level[parent[tv]], parent[tv]}));       cnt++;     }     cout << cnt << endl;     return 0;   }   