Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// Name-Anshu Raj Jaiswal
// Scholar id-2212172
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define mpq priority_queue<ll,vector<ll>,greater<ll>>
#define mpqp priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> 
#define Mpq priority_queue<ll>
#define Mpqp priority_queue<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
const ll MOD=998244353;
const ll N=200000;
ll ceil(ll a,ll b){return (a+b-1)/b;} 
ll pi=0; 
void dfs(ll node,vector<ll>&vis,vector<ll>&temp2,vector<vector<ll>>&adj)
{
  vis[node]=1;
  for(auto it:adj[node])
  {
    if(!vis[it])
    {
      temp2[node]++;
      temp2[it]++;
      dfs(it,vis,temp2,adj);
    }
  }
  return;
}
void solve()
{         
 ll n;
 cin>>n;
 vector<vector<ll>>adj(n+1);
 vector<ll>temp(n+1,0);
 vector<pair<ll,ll>>arr(n-1);
 for(ll i=0;i<n-1;i++)
 {
  ll u,v;
  cin>>u>>v;
  temp[u]++;temp[v]++;
  arr[i]={u,v};
 } 
 ll ans=0;
 ll in=-1;
 for(int i=0;i<n;i++)
 {
   if(temp[i]>ans)
   {
    ans=temp[i];
    in=i;
   }
 }
 ans--;
 for(ll i=0;i<n-1;i++)
 {
  ll u=arr[i].ff,v=arr[i].ss;
  if(u==in || v==in)continue;
  adj[u].pb(v);adj[v].pb(u);
 }
 vector<ll>vis(n+1,0);
 vector<ll>temp2(n+1,0);
 for(ll i=0;i<n;i++)
 {
   if(!vis[i])
   {
      dfs(i,vis,temp2,adj);
   }
 }
 ll pi=0;
 for(ll i=0;i<n;i++)
 {
   pi=max(pi,temp2[i]);
 }
 ans+=pi;
 cout<<ans<<endl;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {        
	  solve();
  }
  return 0;
} 

Submission (verdict: Wrong answer on test 2):
// Name-Anshu Raj Jaiswal
// Scholar id-2212172
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define mpq priority_queue<ll,vector<ll>,greater<ll>>
#define mpqp priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> 
#define Mpq priority_queue<ll>
#define Mpqp priority_queue<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
const ll MOD=998244353;
const ll N=200000;
ll ceil(ll a,ll b){return (a+b-1)/b;} 
ll pi=0; 
void dfs(ll node,vector<ll>&vis,vector<ll>&temp2,vector<vector<ll>>&adj)
{
  vis[node]=1;
  for(auto it:adj[node])
  {
    if(!vis[it])
    {
      temp2[node]++;
      temp2[it]++;
      dfs(it,vis,temp2,adj);
    }
  }
  return;
}
void solve()
{         
 ll n;
 cin>>n;
 vector<vector<ll>>adj(n+1);
 vector<ll>temp(n+1,0);
 vector<pair<ll,ll>>arr(n-1);
 for(ll i=0;i<n-1;i++)
 {
  ll u,v;
  cin>>u>>v;
  temp[u]++;temp[v]++;
  arr[i]={u,v};
 } 
 ll ans=0;
 ll in=-1;
 for(ll i=0;i<=n;i++)
 {
   if(temp[i]>ans)
   {
    ans=temp[i];
    in=i;
   }
 }
 ans--;
 for(ll i=0;i<n-1;i++)
 {
  ll u=arr[i].ff,v=arr[i].ss;
  if(u==in || v==in)
  continue;
  adj[u].pb(v);adj[v].pb(u);
 }
 vector<ll>vis(n+1,0);
 vector<ll>temp2(n+1,0);
 for(ll i=0;i<=n;i++)
 {
   if(!vis[i])
   {
      dfs(i,vis,temp2,adj);
   }
 }
 ll pi=0;
 for(ll i=0;i<=n;i++)
 {
   pi=max(pi,temp2[i]);
 }
 ans+=pi;
 cout<<ans<<endl;
} 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {        
	  solve();
  }
  return 0;
}