I am unable to figure out why i am getting WA although my solution seems to be correct.

Here is the problem link:https://www.codechef.com/ENOC2019/problems/SS4

And this is my solution:

#include <bits/stdc++.h>

#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;

using namespace std;

#define int long long

#define ld long double

#define nl ‘\n’

#define pb push_back

#define f(i,n) for(int i=0;i<n;i++)

#define Fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int M =1e9+7;

void solve()

{

int n;

cin>>n;

vector<vector> v(n+1);

for(int i=1;i<=n-1;i++)

{

int x,y;

cin>>x>>y;

v[x].pb(y);

}

/*for(int i=1;i<=n;i++)
{
for(int j=0;j<v[i].size();j++)
{
cout<<v[i][j]<<" ";
}
cout<<nl;
}*/

int max=1,d=1,s=0,x=1,j=0,k=1;

```
for(int i=1;i<=n;i++)
{
s+=v[i].size();
j++;
if(j==x)
{ //cout<<max<<" ";
d++;
if(s>max)
{
max=s;
k=d;
}
x=s;
s=0;
j=0;
}
}
cout<<k<<nl;
```

}

signed main()

{

Fast;

solve();

return 0;

}

PLEASE look into it.