#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include using namespace std; vector Graph[200010]; int checked[200010]; vector vec[200010]; int dfs(int i,int parent){ checked[i]=1; for(int to:Graph[i]){ if(!checked[to]){ int p=dfs(to,i); vec[i].push_back(p); } } int res=1; sort(vec[i].rbegin(),vec[i].rend()); if(vec[i].size()<=2){ for(int j:vec[i]){ res+=j; } }else{ for(int j=0;j<2;j++){ res+=vec[i][j]; } if(parent!=-1){ for(int j=2;j>N; for(int i=0; i>x>>y; Graph[x-1].push_back(y-1); Graph[y-1].push_back(x-1); } ans=dfs(0,-1); cout<