Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define trill pair<ll,pill> 
#define F f
#define S s.f
#define T s.s;


using namespace std;

const ll N = 2011;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n, k;

bool del[N];

vector<ll> g[N];

trill bfs(ll s) {
	queue<pill> x;
	x.push({s, 0});
	trill rstM = {0, {0, 0}};
	bool w[N] = {0};
	w[s] = 1;
	while(x.size()) {
		ll v = x.front().f, rst = x.front().s;
		if(rstM.F < rst)
			rstM = {rst, {0, 0}};
		if(rstM.F == rst)
			rstM.T++;
		x.pop();
		for(auto u : g[v]){
 			if(!w[u] && !del[u])
				w[u] = 1,x.push({u, rst + 1});
		}
	}
	return rstM;
}

pill dia() {
	trill g1 = bfs(1);
	trill g2 = bfs(g1.s);
	trill g3 = bfs(g2.s);
	if(g3.T > g2.T)
		return g3;
	else
		return g2;
	
}

int main() {
    speed;
    cin >> n >> k;
    rep(1, n, 1){
    	ll a,b;
		cin >> a >> b;
		g[a].pb(b), g[b].pb(a);
	}
	rep(0, n, 1) {
		pill g1 = dia();
		if(g1.f <= k)
			cout << i,ex;
		del[g1.s] = 1;
	}
}

/*
	Code written by
	Codeforces : I_Love_Trott
	mail : dzhon.snoudin@mail.ru
*/



Compiler output:
a.cc: In function 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)':
a.cc:45:33: error: expected primary-expression before ';' token
   45 |                         rstM.T++;
      |                                 ^
a.cc: In function 'std::pair<long long int, long long int> dia()':
a.cc:8:11: error: cannot convert 'std::pair<long long int, long long int>' to 'long long int'
    8 | #define s second
      |           ^
      |           |
      |           std::pair<long long int, long long int>
a.cc:57:27: note: in expansion of macro 's'
   57 |         trill g2 = bfs(g1.s);
      |                           ^
a.cc:8:11: note:   initializing argument 1 of 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)'
    8 | #define s second
      |           ^
a.cc:34:14: note: in expansion of macro 's'
   34 | trill bfs(ll s) {
      |              ^
a.cc:8:11: error: cannot convert 'std::pair<long long int, long long int>' to 'long long int'
    8 | #define s second
      |           ^
      |           |
      |           std::pair<long long int, long long int>
a.cc:58:27: note: in expansion of macro 's'
   58 |         trill g3 = bfs(g2.s);
      |                           ^
a.cc:8:11: note:   initializing argument 1 of 'std::pair<long long int, std::pair<long long int, long long int> > bfs(long long int)'
    8 | #define s second
      |           ^
a.cc:34:14: note: in expansion of macro 's'
   34 | trill bfs(ll s) {
      |              ^
a.cc:59:17: error: expected primary-expression before '>' token
   59 |         if(g3.T > g2.T)
      |                 ^
a.cc:18:14: error: expected ')' before ';' token
   18 | #define T s.s;
      |              ^
a.cc:59:22: note: in expansion of macro 'T'
   59 |         if(g3.T > g2.T)
      |                      ^
a.cc:59:11: note: to match this '('
   59 |         if(g3.T > g2.T)
      |           ^
a.cc:59:23: error: expected primary-expression before ')' token
   59 |         if(g3.T > g2.T)
      |                       ^
a.cc:61:9: error: 'else' without a previous 'if'
   61 |         else
      |         ^~~~
a.cc:62:24: error: could not convert 'g2' from 'pair<[...],std::pair<long long int, long long int>>' to 'pair<[...],long long int>'
   62 |                 return g2;
      |                        ^~
      |                        |
      |                        pair<[...],std::pair<long long int, long long int>>