Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stdlib.h>
#include <queue>
#include <set> 
#include <string>
#include <string.h>
#include <cstring>
#include <stdio.h>
#include <fstream>
#include <stack>
#include <iomanip>
//#include <conio.h>
//#include <windows.h>
//#include <time.h>
#define rep(N) for(int i=0;i<N;i++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define rep(N) for(int i=0;i<N;i++)
using namespace std;
vector <int> vec[2005];
vector <pair<int,int> >num[2005];
bool visit[2005];
int leaf[2005];
int dist[2005][2005];
int n,k;
vector <int> leave;

void bfs(int x)
{
	fill(visit,visit+n,0);
	queue <pair<int,int> >que;
	int t=x;
	que.push(make_pair<int,int>(t,0));
	while(!que.empty())
	{
		int nx=que.front().first;
		int s=que.front().second;
		que.pop();
		for(int i=0;i<vec[nx].size();i++)
		{
			if(visit[vec[nx][i]]) continue;
			visit[vec[nx][i]]=true;
			dist[t][vec[nx][i]]=s+1;
			que.push(make_pair<int,int>(vec[nx][i],s+1));
		}
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>k;
	int x,y;
	rep(n-1)
	{
		cin>>x>>y;
		vec[--x].push_back(--y);
		vec[y].push_back(x);
		leaf[x]++;
		leaf[y]++;
	}
	rep(n)
	{
		bfs(i);
	}
//	rep(n)
//	{
//		dist[i][i]=0;
//		for(int j=0;j<n;j++)
//		{
//			cout<<dist[i][j]<<"  ";
//		}
//		cout<<endl;
//	}
	int s=0,mini=0;
	bool ok[n];
	fill(ok,ok+n,0);
	rep(n)
	{
		dist[i][i]=0;
		if(ok[i]) continue;
		for(int j=0;j<n;j++)
		{
			if(ok[j]==1) continue;
			if(dist[i][j]>k) ok[j]=1;
		}
	}
	rep(n)
	{
		s+=ok[i];
	}
	cout<<s<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:37:37: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   37 |         que.push(make_pair<int,int>(t,0));
      |                                     ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~
a.cc:48:52: error: cannot bind rvalue reference of type 'int&&' to lvalue of type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   48 |                         que.push(make_pair<int,int>(vec[nx][i],s+1));
      |                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~