criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;}
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;}
    return false;
}

const int MAX_N=2010;

int N,K,ans=0,c=0;
vector<vector<int>> G(MAX_N);
vector<vector<int>> d(MAX_N,vector<int>(MAX_N));

void dfs(int v,int p,int r,int &cnt){
    for (auto nv:G[v]){
        if (nv==p) continue;
        d[r][nv]=d[r][v]+1;
        if (d[r][nv]<=K) ++c;
        dfs(nv,v,r,c);
    }
    if (p==r) chmax(ans,cnt),cnt=0;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,N) d[i][i]=0;
    rep(i,N) dfs(i,-1,i,c);
    cout << N-ans-1 << endl;
}

Compiler output:
a.cc:39:30: error: stray '\16' in program
   39 |     if (p==r) chmax(ans,cnt),<U+000E>cnt=0;
      |                              ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;
  
  vector<vector<int>> A(N);
  for(int i=0;i<N;i++){
    int a,b;cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  int diameter=0,best_s=-1;
  for(int s=0;s<N;s++){
    queue<int> q;
    vector<int> dist(N,-1);
    q.push(s);dist[s]=0;
    while(q.size()){
      int attend=q.front();q.pop();
      for(int next=0;next<A[attend].size();next++){
        if(dist[next]==-1){
          q.push(next);dist[next]=dist[attend]+1;
          if(diameter<dist[next]+1){
            diameter=dist[next]+1;best_s=s;
          }
        }
      }
    }
  }
  int centor[2]={-1,-1};
  queue<int> q;
  vector<int> dist(N,-1);
  q.push(best_s);dist[best_s]=0;
  while(q.size()){
    int attend=q.front();q.pop();
    for(int next=0;next<A[attend].size();next++){
      if(dist[next]==-1){
        q.push(next);dist[next]=dist[attend]+1;
        if(dist[next]==(diameter-1)/2)centor[0]=next;
        if(dist[next]==(diameter)/2)centor[1]=next;   
      }
    }
  }
  
  
  
  
  vector<int> dist2(2*N,-1);
  for(int i=0;i<2;i++){
    queue<int> q;q.push(centor[i]);
    dist2[centor[i]+N*i]=0;
    while(q.size()){
      int attend=q.front();q.pop();
      for(int next=0;next<A[attend].size();next++){
        if(dist2[next+N*i]==-1){
          q.push(next);dist2[next+N*i]=dist2[attend+N*i]+1;
        }
      } 
    }  
  }
  int ans=0;
  int t=K/2;
  for(int i=0;i<N;i++){
    if(dist2[i]>t||dist2[i+N]>t)ans++
  }
  if((K+diameter)%2=1)ans--;
  cout<<ans;
  


}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:38: error: expected ';' before '}' token
   63 |     if(dist2[i]>t||dist2[i+N]>t)ans++
      |                                      ^
      |                                      ;
   64 |   }
      |   ~                                   
a.cc:65:18: error: lvalue required as left operand of assignment
   65 |   if((K+diameter)%2=1)ans--;
      |      ~~~~~~~~~~~~^~
Language: C++

/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/

#include <bits/stdc++.h>
#include <windows.h>

#define ll long long
#define X first
#define Y second
#define MP make_pair

using namespace std;

    /*
const int MAX_MEM = 1e8;
int mpos=0;
char mem[MAX_MEM];
inline void * operator new(size_t n){
	char *res = mem + mpos;
	mpos += n;
	assert(mpos <= MAX_MEM);
	return (void *)res;
}

inline void operator delete(void *){}
    */
const int N = 2e3 + 1;

int n, k, ans[N], t;
vector<int> g[N];

void dfs(int v, int pr=0, int d=0){
	if(d > k / 2){
		ans[t] += 1;
	}
	for(int u: g[v]){
		if(pr == u)
			continue;
		dfs(u, v, d + 1);
	}		
}

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> k;
	for(int i = 1;i < n;i++){
		int x, y;
		cin >> x >> y;
		g[x].push_back(y), g[y].push_back(x);
	}

	for(int i = 1;i <= n;i++){
		t = i;
		dfs(i);
	}

	int res = n;
	for(int i = 1;i <= n;i++)
		res = min(res, ans[i]);
	cout << res;
}    


Compiler output:
a.cc:11:10: fatal error: windows.h: No such file or directory
   11 | #include <windows.h>
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
const int MAXN = 2e3 + 10;
int n , k , u , v , mn , h[MAXN];
pii edge[MAXN];
vector<int> adj[MAXN];
int dfs(int u)
{
	int ans = (k / 2 < h[u]);
	for(auto v : adj[u])
		if(h[v] == -1)
			h[v] = h[u] + 1 , ans += dfs(v);
	return ans;
}
void input()
{
	cin >> n >> k;
	for(int i = 0 ; i < n - 1 ; i ++)
		cin >> u >> v , u -- , v -- , adj[u].pb(v) , adj[v].pb(u) , edge[i] = mp(u , v);
	return;
}
int32_t main()
{
	input() , mn = INT_MAX;
	/*for(int i = 0 ; i < n - 1 ; i ++)
		cout << edge[i].f << " " << edge[i].s << "       ";
	cout << endl;*/
	/*for(int i = 0 ; i < n ; i ++)
	{
		for(auto j : adj[i])
			cout << "adj[i][j]: " << j << " "; 
		cout << endl;
	}*/
	if(!(k % 2))
		for(int i = 0 ; i < n ; i ++)
			mem(h , -1) , h[i] = 0 , mn = min(mn , dfs(i));
	else
		for(int i = 0 ; i < n - 1 ; i ++)
			mem(h , -1) , h[edge[i].f] = h[edge[i].s] = 0 , mn = min(mn , dfs(edge[i].f) + dfs(edge[i].s));
	return cout << mn << endl , 0;
}		


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:63:24: error: 'INT_MAX' was not declared in this scope
   63 |         input() , mn = INT_MAX;
      |                        ^~~~~~~
a.cc:23:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   22 | #include <complex>
  +++ |+#include <climits>
   23 | using namespace std;
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2005;
int n,m,t,p,ans;
int d[N],first[N],v[N],w[N],next[N];
struct Node{
    int u,v;
}e[N];
void add(int x,int y)
{
	t++;
	next[t]=first[x];
	first[x]=t;
	v[t]=y;
}
void dfs(int x,int father)
{
	int i,j;
	for(i=first[x];i;i=next[i])
	{
		j=v[i];
		if(j==father)
		  continue;
		d[j]=d[x]+1;
		dfs(j,x);
	}
}
int main()
{
	int x,y,z,i,k,u;
	scanf("%d%d",&n,&k);
	m=k/2;
	ans=0x3f3f3f3f;
	for(i=2;i<=n;++i)
	{
		scanf("%d%d",&x,&y);
		e[i].u=x;
		e[i].v=y;
		add(x,y);
		add(y,x);
	}
	if ((k&1)==0){
		int res=0;
		for (int i=1;i<=n;i++){
			res = d[i] = 0;
			dfs(i,i);
            for (int j=1;j<=n;j++) if(d[j]>m) ++res;
            ans = min(ans,res);
		}
	}
	else{
		int res = 0;
       	for (int i=2;i<=n;i++){
            d[e[i].u] = d[e[i].v] = res = 0;
            dfs(e[i].u,e[i].v);
			dfs(e[i].v,e[i].u);
            for (int j=1;j<=n;j++) if(d[j]>m) ++res;
            ans = min(ans,res);
        }
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:14:9: error: reference to 'next' is ambiguous
   14 |         next[t]=first[x];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:7:29: note:                 'int next [2005]'
    7 | int d[N],first[N],v[N],w[N],next[N];
      |                             ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:21:28: error: reference to 'next' is ambiguous
   21 |         for(i=first[x];i;i=next[i])
      |                            ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:7:29: note:                 'int next [2005]'
    7 | int d[N],first[N],v[N],w[N],next[N];
      |                             ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
typedef long long int ll;

int n,k;
vector<int> G[2100];

int dfs(int t,int f,int k,int depth=0){
	int cnt=0;
	if(depth>=k)cnt++;
	for(auto d:G[t]){
		if(d==f)continue;
		cnt+=dfs(d,t,k,depth+1);
	}
	return cnt;
}

int main(){
	cin >> n >> k;
	for(int i=0;i<n-1;i++){
		int a,b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans=n;
	for(int i=0;i<n;i++){
		int cnt=0;
		for(int t:G[i]){
			cnt+=dfs(t,i,k/2);
		}
		ans=min(ans,cnt);
	}
	for(int i=0;i<n;i++){
		for(int t:G[i]){
			int cnt=dfs(t,i,(k+1)/2)+dfs(t,s,(k+1)/2);
			ans=min(ans,cnt);
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:56: error: 's' was not declared in this scope
   40 |                         int cnt=dfs(t,i,(k+1)/2)+dfs(t,s,(k+1)/2);
      |                                                        ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

int N, K;
vector<vector<int>> tree;

void rec(int v, int p, int d, vector<int> &depth) {
    depth[v] = d;
    for(auto u : tree[v]) {
        if(u == p) continue;
        rec(u, v, d + 1, depth);
    }
}

void solve() {
    cin >> N >> K;
    tree.assign(N, vector<int>());
    rep(i, N - 1) {
        int a, b; cin >> a >> b; a --; b --;
        tree[a].push_back(b); tree[b].push_back(a);
    }
    vector<int> depth(N);
    if(K % 2 == 0) {
        int ans = N;
        rep(v, N) {
            rec(v, -1, 0, depth);
            int cnt = 0;
            rep(u, N) {
                if(depth[u] > K / 2) cnt ++;
            }
            ans = min(ans, res);
        }
        cout << ans << endl;
    } else {
        int ans = N;
        rep(v, N) {
            for(auto u : tree[v]) {
                rec(u, v, 0, depth); rec(v, u, 0, depth);
                int cnt = 0;
                rep(w, N) {
                    if(depth[w] > K / 2) cnt ++;
                }
                ans = min(ans, cnt);
            }
            cout << ans << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:76:28: error: 'res' was not declared in this scope; did you mean 'rec'?
   76 |             ans = min(ans, res);
      |                            ^~~
      |                            rec
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
 

using namespace std;

const int Maxn = 4000 + 100;
int Begin[Maxn], To[Maxn], Next[Maxn], e;
int sum[Maxn], dis[Maxn];
int n, K, maxi;
vector<int> graph[Maxn];

void add_edge(int x, int y)
{
    To[++e] = y;
    Next[e] = Begin[x];
    Begin[x] = e;
}
void dfs (int x, int fa)
{
    maxi = max(maxi, dis[x]);
    sum[dis[x]] ++;
    for (int i = 0; i < graph[x].size(); i++)
    {
        int y = graph[x][i];
        if (y == fa) 
        	continue;
        dis[y] = dis[x] + 1;
        dfs(y, x);
    }
}

int main()
{
    cin >> n >> K;
    for (int i = 1; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
        add_edge(x, y);
        add_edge(y, x);
    }
    int ans = 1000 * 1000 * 1000;
    for (int i = 1; i <= n; ++i)
    {
        memset(sum, 0, sizeof(sum));
        memset(dis, 0, sizeof(dis));
        maxi = 0;
        dfs(i, 0);
        int cnt = 0;
        for (int j = K / 2 + 1; j <= maxi; ++j)
            cnt += sum[j];
        if (!(K & 1))
        {
        	ans = min(ans, cnt);
        }
        else 
        {
            for (int j = Begin[i]; j; j = Next[j])
            {
                int y = To[j];
                int tmp = 0;
                memset(sum, 0, sizeof(sum));
                memset(dis, 0, sizeof(dis));
                maxi = 0;
                dfs(i, y);
                for (int k = K / 2 + 1; k <= maxi; ++k)
                {
                    tmp += sum[k];
                }
                memset(sum, 0, sizeof(sum));
                memset(dis, 0, sizeof(dis));
                maxi = 0;
                dfs(y, i);
                for (int k = K / 2 + 1; k <= maxi; k++)
                {
                    tmp += sum[k];
                }
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}
 

   


Compiler output:
a.cc: In function 'int main()':
a.cc:59:9: error: 'memset' was not declared in this scope
   59 |         memset(sum, 0, sizeof(sum));
      |         ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include<numeric>
  +++ |+#include <cstring>
   14 |
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
 
using namespace std;

using namespace std;
 
const int mod = 1000 * 1000 * 1000 + 7;
const int N = 5 * 1000 + 5;
int n, k;
int ans = 0;
vector<int> graph[N];
int dis[N];
bool mark[N];
int jvb = mod;
void input()
{
	cin >> n >> k;
	for (int i = 0 ; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[u - 1].push_back(v - 1);
		graph[v - 1].push_back(u -1 );
	}
}
void dfs(int v)
{
	mark[v] = true;
	for (int i = 0; i < graph[v].size(); i++)
	{
		if (!mark[graph[v][i]])
		{
			dfs(graph[v][i]);
			dis[i] = dis[v] + 1;
			if (dis[i] > k / 2)
			{
				ans++;
			}
		}
	}
}
int main() 
{
	input();
	for (int i = 0; i < n; i++)
	{
		memset(mark, 0, sizeof mark);
		ans = 0;
		dfs(i);
		jvb = min(jvb, ans);
	}
	cout << jvb << endl;


}
 

   


Compiler output:
a.cc: In function 'int main()':
a.cc:59:17: error: 'memset' was not declared in this scope
   59 |                 memset(mark, 0, sizeof mark);
      |                 ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include<numeric>
  +++ |+#include <cstring>
   14 |
Language: C

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e9;
vector<int> dist[2020];
vector<int> edge[2020];
int vis[2020];
int e[2020];
int N,K;
int dfs(int pos,int dis)
{
	int res = 0;
	vis[pos] = 1;
	if(dis>K/2) res++;
	for(int i = 0;i < dist[pos].size();i++){
		if(!vis[dist[pos][i]]){
			res += dfs(dist[pos][i],dis+1);
			//cout<<"res:"<<res<<endl;
		}
	}
	return res;
}
int main()
{
	cin>>m;
	scanf("%d%d",&N,&K);
	for(int i = 1;i <= N-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		dist[a].push_back(b);
		dist[b].push_back(a);
		edge[a].push_back(i);
		edge[b].push_back(i);
	}
	for(int i = 1;i <= N;i++){
		if(edge[i].size()>=2){
			for(int j = 0;j < edge[i].size();j++){
				for(int k = )
			}
		}
	}
	if(K%2==0){
		int ans = INF;
		for(int i = 1;i <= N;i++){
			memset(vis,0,sizeof(vis));
			ans = min(dfs(i,0),ans);
		}
		cout<<ans<<endl;
	}
	else{
		K = K + 1;
	}
	return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 2010;
vector<int> edge[N];
pair<int,int> e[N];
bool vis[N];
int cnt;
void dfs(int n,int k){
    vis[n]=1;cnt++;
    if(k==0) return ;
    for(int i=0;i<edge[n].size();i++){
        if(!vis[edge[n][i]]) dfs(edge[n][i],k-1);
    }
}
int main(){
    int n,k;cin>>n>>k;
    for(int i=1;i<=n-1;i++){
        int a,b;cin>>a>>b;
        e[i].first=a;e[i].second=b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int ans=n;
    if(k&1){
        for(int i=1;i<=n-1;i++){
            cnt=0;
            memset(vis,0,sizeof vis);
            vis[e[i].second]=1;
            dfs(e[i].first,k/2);
            dfs(e[i].second,k/2);
            int tmp=n-cnt;
            ans=min(tmp,ans);
        }
    }else{
        for(int i=1;i<=n;i++){
            cnt=0;
            memset(vis,0,sizeof vis);
            dfs(i,k/2);
            cout<<cnt<<endl;
            int tmp=n-cnt;
            ans=min(tmp,ans);
        }
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:13: error: 'memset' was not declared in this scope
   30 |             memset(vis,0,sizeof vis);
      |             ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <cmath>
  +++ |+#include <cstring>
    5 | using namespace std;
a.cc:40:13: error: 'memset' was not declared in this scope
   40 |             memset(vis,0,sizeof vis);
      |             ^~~~~~
a.cc:40:13: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <bits/stdc++.h>
using namespace std;

int n,d,hed[2010],cnt,k,fa[2010],dep[2010],ans=2e9,book[2010];
struct node
{
	int from,to,next;
}a[100010];
void add(int from,int to)
{
	a[cnt++].to=to;
	a[cnt].from=from;
	a[cnt].next=hed[from];
	hed[from]=cnt;
}
void dfs(int x)
{
	for(int i=hed[x];i;i=a[i].next)
	{
		int y=a[i].to;
		if(fa[x]==y||book[y])
		continue;
		dep[y]=dep[x]+1;
		fa[y]=x;
		dfs(y);
	}
}
int main()
{
	cin>>n>>k;
	cnt=1;
	for(int i=1;i<n;i++)
	{
		int ls,lss;
		cin>>ls>>lss;
		add(ls,lss);
		add(lss,ls);
	}
	if(k%2)
	{
		for(int i=2;i<=cnt;i++)
		{
			memset(fa,0,sizeof(fa));
			memset(dep,0,sizeof(dep));
			book[a[i].to]=1;
			dfs(a[i].from);
			int ji=0;
			for(int j=1;j<=n;j++)
			{
				if(dep[j]>k/2)
				j++i;
			}
			memset(fa,0,sizeof(fa));
			memset(dep,0,sizeof(dep));
			book[a[i].from]=1;
			book[a[i].to]=0;
			dfs(a[i].to);
			for(int j=1;j<=n;j++)
			{
				if(dep[j]>k/2)
				j++i;
			}
			book[a[i].from]=0;
			ans=min(ans,ji);
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			memset(fa,0,sizeof(fa));
			memset(dep,0,sizeof(dep));
			dfs(i);
			int ji=0;
			for(int j=1;j<=n;j++)
			{
				if(dep[j]>k/2)
					ji++;
			}
			ans=min(ans,ji);
		}
	}
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:36: error: expected ';' before 'i'
   51 |                                 j++i;
      |                                    ^
      |                                    ;
a.cc:61:36: error: expected ';' before 'i'
   61 |                                 j++i;
      |                                    ^
      |                                    ;
Language: C++

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,k,d[2005],m,sum[2005],ans,ans2;
pair<int,int> a[2005];
bool l[2005],u[2005];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		l[i]=true;
	while(cin>>a[++m].first>>a[m].second);
	for(int i=1;i<=m;i++)
	{
		l[a[i].first]=false;
		if(a[i].first==1)
			d[a[i].second]=2,sum[2]++;
		else
			d[a[i].second]=d[a[i].first]+1,sum[d[a[i].second]]++;
	}
	queue<int> q;
	while(!q.empty())
	{
		q.push(x);
		for()
	}
	for()
	ans=99999;
	k/=2;
	for(int i=1;i<=n;i++)
		if(d[i]>k)
			ans2++;
	cout<<ans2;
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:36:24: error: 'x' was not declared in this scope
   36 |                 q.push(x);
      |                        ^
a.cc:37:21: error: expected primary-expression before ')' token
   37 |                 for()
      |                     ^
a.cc:38:9: error: expected primary-expression before '}' token
   38 |         }
      |         ^
a.cc:37:22: error: expected ';' before '}' token
   37 |                 for()
      |                      ^
      |                      ;
   38 |         }
      |         ~             
a.cc:38:9: error: expected primary-expression before '}' token
   38 |         }
      |         ^
a.cc:37:22: error: expected ')' before '}' token
   37 |                 for()
      |                    ~ ^
      |                      )
   38 |         }
      |         ~             
a.cc:38:9: error: expected primary-expression before '}' token
   38 |         }
      |         ^
a.cc:39:13: error: expected primary-expression before ')' token
   39 |         for()
      |             ^
a.cc:42:9: error: expected primary-expression before 'for'
   42 |         for(int i=1;i<=n;i++)
      |         ^~~
a.cc:41:14: error: expected ')' before 'for'
   41 |         k/=2;
      |              ^
      |              )
   42 |         for(int i=1;i<=n;i++)
      |         ~~~   
a.cc:39:12: note: to match this '('
   39 |         for()
      |            ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
int n,k;
vector<int>g[2005];
int dfs(int x,int p,int deepth,int mx)
{
	int ans=1;
	if(deepth!=mx)
	{
		for(int i=0;i<g[x].size();i++)
		if(i!=p)
			ans+=dfs(i,x,deepth+1,mx);
	}
	return ans;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	int ans=0;
	if(k%2==0)
		for(int i=1;i<=n;i++)
			ans=max(ans,dfs(i,-1,0,k/2));
	else
	{
		for(int i=1;i<=n;i++)
			for(int j=0;j<g[i].size();j++)
				ans=max(ans,dfs(i,g[i][j],0,k/2)+dfs(g[i][j],i,0,k/2));
	}
	cout<<n-ans;
	return 0;
}

Compiler output:
a.cc:5:17: error: 'acos' was not declared in this scope
    5 | const double pi=acos(-1);
      |                 ^~~~
Language: C++

#include<iostream>
#include<algorithm> 
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
int n,k;
vector<int>g[2005];
int dfs(int x,int p,int deepth,int mx)
{
	int ans=1;
	if(deepth!=mx)
	{
		for(int i=0;i<g[x].size();i++)
		if(i!=p)
			ans+=dfs(i,x,deepth+1,mx);
	}
	return ans;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	int ans=0;
	if(k%2==0)
		for(int i=1;i<=n;i++)
			ans=max(ans,dfs(i,-1,0,k/2));
	else
	{
		for(int i=1;i<=n;i++)
			for(int j=0;j<g[i].size();j++)
				ans=max(ans,dfs(i,g[i][j],0,k/2)+dfs(g[i][j],i,0,k/2));
	}
	cout<<n-ans;
	return 0;
}

Compiler output:
a.cc:4:17: error: 'acos' was not declared in this scope
    4 | const double pi=acos(-1);
      |                 ^~~~
a.cc:12:1: error: 'vector' does not name a type
   12 | vector<int>g[2005];
      | ^~~~~~
a.cc: In function 'int dfs(int, int, int, int)':
a.cc:18:31: error: 'g' was not declared in this scope
   18 |                 for(int i=0;i<g[x].size();i++)
      |                               ^
a.cc: In function 'int main()':
a.cc:31:17: error: 'g' was not declared in this scope
   31 |                 g[x].pb(y);
      |                 ^
a.cc:41:39: error: 'g' was not declared in this scope
   41 |                         for(int j=0;j<g[i].size();j++)
      |                                       ^
Language: C


//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

using namespace std;

int m;
int come[2050];
vector<int> graph[2050];

void init(void){
	int i;
	for(i=0;i<2050;i++){
		come[i]=0;
	}
}

int evensearch(int a,int d){
	int i;
	int sum=1;
	if(come[a]==1) return 0;
	if(d==m/2) return 1;

	for(i=0;i<graph[a].size();i++){
		sum=sum+evensearch(graph[a][i],d+1);
	}

	return sum;
}

int oddsearch(int a,int b,int d){
	int i;
	int sum=1;
	if(come[a]==1||a==b) return 0;
	if(d==m/2) return 1;

	come[a]=1;

	for(i=0;i<graph[a].size();i++){
		sum=sum+oddsearch(graph[a][i],b,d+1);
	}

//	printf("%d->%d\n",a,sum);
	return sum;
}

int main(void)
{
	//変数の宣言
	int n;
//	int m;
	int a[2050];
	int b[2050];
//
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	for(i=0;i<n-1;i++){
		scanf("%d %d",&a[i],&b[i]);
//		scanf_s("%d %d",&a[i],&b[i]);
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	if(m%2==0){
		for(i=1;i<=n;i++){
			init();
			ans=max(ans,evensearch(i,0));
		}
	}else{
		for(i=0;i<n-1;i++){
			init();
//			ans=max(ans,oddsearch(a[i],b[i],0)+oddsearch(b[i],a[i],0));
			temp=oddsearch(a[i],b[i],0);
			temp=temp+oddsearch(b[i],a[i],0);
			ans=max(ans,temp);

//			printf("(%d,%d)-->left->%d,right->%d\n",a[i],b[i],oddsearch(a[i],b[i],0),oddsearch(b[i],a[i],0));
		}
	}



	//	printf("計算部分終了\n");

	//出力

	printf("%d",n-ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Compiler output:
main.c:8:10: fatal error: vector: No such file or directory
    8 | #include <vector>
      |          ^~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k, a[2010], b[2010];
    V g[2010];

    cin >> n >> k;
    REP(i, n - 1)
    {
        cin >> a[i] >> b[i];
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    int res = INT_MAX;

    for (int i = 1; i <= n; i++)
    {
        int cnt = 1;

        queue<int> q;

        q.push(i);

        int dis[2100];
        fill(dis, dis + n + 1, -1);

        dis[i] = 0;

        while (q.size())
        {
            int p = q.front();
            q.pop();
            for (int j : g[p])
            {
                if (dis[p] + 1 <= k / 2 && dis[j] == -1)
                {
                    cnt++;
                    dis[j] = dis[p] + 1;

                    if (dis[p] + 1 < k / 2)
                        q.push(j);
                }
            }
        }

        res = min(n - cnt, res);
    }

    if (k % 2 && res)
        res--;

    cout << res << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:15: error: 'INT_MAX' was not declared in this scope
   49 |     int res = INT_MAX;
      |               ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include <cstring>
  +++ |+#include <climits>
   15 |
Language: C++

#include<queue> #include<cstdio> #include<algorithm> using namespace std; const int MAXN = 2000; struct edge{ int to; edge *nxt; }edges[MAXN*2 + 5], *adj[MAXN + 5], *ecnt = &edges[0]; void addedge(int u, int v) { edge *p = (++ecnt); p->to = v, p->nxt = adj[u], adj[u] = p; p = (++ecnt); p->to = u, p->nxt = adj[v], adj[v] = p; } queue<int>que; int dis[MAXN + 5], vis[MAXN + 5], N, K; int solve() { int ret = 0; while( !que.empty() ) { int f = que.front(); que.pop(); if( dis[f] > K/2 ) ret++; for(edge *p=adj[f];p!=NULL;p=p->nxt) { if( !vis[p->to] ) { vis[p->to] = true; dis[p->to] = dis[f] + 1; que.push(p->to); } } } return ret; } int main() { scanf("%d%d", &N, &K); for(int i=1;i<N;i++) { int A, B; scanf("%d%d", &A, &B); addedge(A, B); } int ans = MAXN + 5; if( K % 2 == 0 ) { for(int i=1;i<=N;i++) { for(int j=1;j<=N;j++) { vis[j] = false; dis[j] = 0; } vis[i] = true; que.push(i); ans = min(ans, solve()); } } else { for(int i=1;i<=N;i++) { for(edge *p=adj[i];p!=NULL;p=p->nxt) { if( i > p->to ) continue; for(int j=1;j<=N;j++) { vis[j] = false; dis[j] = 0; } vis[i] = true; que.push(i); vis[p->to] = true; que.push(p->to); ans = min(ans, solve()); } } } printf("%d\n", ans); }


Compiler output:
a.cc:1:17: warning: extra tokens at end of #include directive
    1 | #include<queue> #include<cstdio> #include<algorithm> using namespace std; const int MAXN = 2000; struct edge{ int to; edge *nxt; }edges[MAXN*2 + 5], *adj[MAXN + 5], *ecnt = &edges[0]; void addedge(int u, int v) { edge *p = (++ecnt); p->to = v, p->nxt = adj[u], adj[u] = p; p = (++ecnt); p->to = u, p->nxt = adj[v], adj[v] = p; } queue<int>que; int dis[MAXN + 5], vis[MAXN + 5], N, K; int solve() { int ret = 0; while( !que.empty() ) { int f = que.front(); que.pop(); if( dis[f] > K/2 ) ret++; for(edge *p=adj[f];p!=NULL;p=p->nxt) { if( !vis[p->to] ) { vis[p->to] = true; dis[p->to] = dis[f] + 1; que.push(p->to); } } } return ret; } int main() { scanf("%d%d", &N, &K); for(int i=1;i<N;i++) { int A, B; scanf("%d%d", &A, &B); addedge(A, B); } int ans = MAXN + 5; if( K % 2 == 0 ) { for(int i=1;i<=N;i++) { for(int j=1;j<=N;j++) { vis[j] = false; dis[j] = 0; } vis[i] = true; que.push(i); ans = min(ans, solve()); } } else { for(int i=1;i<=N;i++) { for(edge *p=adj[i];p!=NULL;p=p->nxt) { if( i > p->to ) continue; for(int j=1;j<=N;j++) { vis[j] = false; dis[j] = 0; } vis[i] = true; que.push(i); vis[p->to] = true; que.push(p->to); ans = min(ans, solve()); } } } printf("%d\n", ans); }
      |                 ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=2005;
int n,k,Ans=MAXN;
int son[MAXN],vis[MAXN];
vector<int>T[MAXN];
void Dfs(int u,int fa,int dep,int gra){
	if(dep>k/2){
		if(k%2)son[gra]++;
		return ;
	}	
	vis[u]=1;
	int size=T[u].size();
	for(int i=0;i<size;i++){
		int v=T[u][i];
		if(v==fa)continue;
		Dfs(v,u,dep+1,gra);
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		T[x].push_back(y);
		T[y].push_back(x);
	}
	for(int i=1;i<=n;i++){
		memset(vis,0,sizeof(vis));
		memset(son,0,sizeof(son));
		int size=T[i].size(),ret=0;
		vis[i]=1;
		for(int j=0;j<size;j++){
			int v=T[i][j];
			Dfs(v,i,1,v);
			ret=min(ret,-son[v]);
		}
		for(int j=1;j<=n;j++)
			if(!vis[j])ret++;
		if(ret<Ans)Ans=ret;
	}
	printf("%d\n",Ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: 'memset' was not declared in this scope
   31 |                 memset(vis,0,sizeof(vis));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int head[N],ver[N*2],nxt[N*2],tot;
int n,k;
int dp[N];
int g[N];
void add(int x,int y)
{
	ver[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
void dfs(int rt,int fa,int dep)
{
	for(int i=head[rt]; i; i=nxt[i])
	{
		int y=ver[i];
		if(y!=fa)
		{
			dfs(y,rt,dep+1);
			g[rt]+=g[y]+1;
			dp[rt]+=dp[y];
		}
	}
	if(dep>k/2)
		dp[rt]=g[rt];
}
int main()
{
	scanf("%d%d",&n,&k);
	int x,y;
	for(int i=1; i<n; i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	int ans=1e9;
	if(k%2==0)
	{
		for(int i=1; i<=n; i++)
		{
			memset(dp,0,sizeof(dp));
			memset(g,0,sizeof(g));
			dfs(i,i,1);
			ans=min(ans,dp[i]);
			//cout<<dp[i]<<endl;
		}
	}
	else
	{
		for(int x=1;x<=n;x++)
		{
			for(int i=head[x];i;i=nxt[i])
			{
				memset(dp,0,sizeof(dp));
				memset(g,0,sizeof(g));
				int y=ver[i];
				b[y]=1;
				dfs(x,y,1);
				dfs(y,x,1);
				ans=min(ans,dp[x]+dp[y]);
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:33: error: 'b' was not declared in this scope
   60 |                                 b[y]=1;
      |                                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn=2010;
int n,k,tans,ans,x,y;
bool vis[maxn];
vector <int> e[maxn];
priority_queue <int> Qmax;
void dfs(int root,int node,int dep){
	//cout<<node<<endl;
	Qmax.push(dep);
	vis[node]=1;
	for(int i=0;i<e[node].size();++i)
		if(!vis[e[node][i]])dfs(root,e[node][i],dep+1);
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	ans=n-k-1;
	for(int i=1;i<=n;++i){
		for(;!Qmax.empty();Qmax.pop());
		if(e[i].size()<2)continue;
		tans=0;
		memset(vis,0,sizeof(vis));
		vis[i]=1;
		for(int j=0;j<e[i].size();++j){
			int t=e[i][j];
			for(;!Q[t].empty();Q[t].pop());
			dfs(t,t,1);
			Qmax.push(t);
		}
		int now=Qmax.top();
		Qmax.pop();
		int sec=Qmax.top();
		for(;now+sec>k;++tans){
			now=Qmax.top();
			sec=Qmax.top();
		}
		ans=min(ans,tans);
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:31: error: 'Q' was not declared in this scope
   31 |                         for(;!Q[t].empty();Q[t].pop());
      |                               ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POSSIBLE(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Possible(i) cout<<(i?"Possible":"Impossible")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
//
int N,K;
vector<int> V[2000];
int num[2000];
int m;
void DFS(int n,int ran){
	FOR(i,0,V[n].size()){
		if(num[V[n][i]]==INF){
			num[V[n][i]]=ran;
			if(ran==K/2){
				if(ran*2+1==K){
					m=max(m,(int)V[n][i].size()-1);
				}
				continue;
			}else{
				DFS(V[n][i],ran+1);
			}
		}
	}
}
int main(){
	cin>>N>>K;
	FOR(i,0,N-1){
		int A,B;
		cin>>A>>B;
		A--;B--;
		V[A].PB(B);
		V[B].PB(A);
	}
	int ans=INF;
	FOR(i,0,N){
		if(V[i].size()==1){
			continue;
		}
		fill(num,num+N,INF);
		num[i]=0;
		m=0;
		DFS(i,1);
		sort(num,num+N);
		if(K%2==0){
			ans=min(ans,N-(int)(upper_bound(num,num+N,K/2)-num));
		}else{
			ans=min(ans,N-(int)(upper_bound(num,num+N,K/2)-num)-m);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void DFS(int, int)':
a.cc:53:62: error: request for member 'size' in 'V[n].std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   53 |                                         m=max(m,(int)V[n][i].size()-1);
      |                                                              ^~~~
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define INF 1000000
#define MAX_V 2010
using namespace std;

struct edge{int to,cost; };
vector<edge> G[MAX_V];

bool used[MAX_V];
bool c[MAX_V][MAX_V];
int d[MAX_V],h[MAX_V],f[MAX_V][MAX_V];
int V;

void dfs(int s){
	used[s] = true;
	int i = 0;
	while(true){
		edge e = G[s][i];
		if(e.to==-1){
			break;
		}
		if(!used[e.to]){
			i++;
			used[e.to] = true;
			d[e.to] = d[s] + e.cost;
			dfs(e.to);
		}else{
			i++;
		}
	}
}

int main(){
	int i,j,k,mx,l,ans=0;
	cin >> V >> k;
	for(i=0;i<V-1;i++){
		int s,t;
		cin >> s >> t;
		s--; t--;
		edge e;
		e.to = t;
		e.cost = 1;
		G[s].push_back(e);
		e.to = s;
		e.cost = 1;
		G[t].push_back(e);
	}
	for(i=0;i<V;i++){
		edge e;
		e.to = -1; e.cost = 0;
		G[i].push_back(e);
	}
	for(i=0;i<V;i++){
		h[i] = 0;
		for(j=0;j<V;j++){
			c[i][j] = 0;
			used[j] = false;
		}
		d[i] = 0;
		dfs(i);
		for(j=0;j<V;j++){
			f[i][j] = d[j];
		}
	}
	
	for(i=0;i<V;i++){
		for(j=0;j<V;j++){
			if(f[i][j]>k){
				c[i][j] = false;
				h[i]++;
				h[j]++;
			}
		}
	}
	
	for(i=0;i<V;i++){
		mx = 0;
		for(j=0;j<V;j++){
			if(g[j]>mx){
				mx = h[j];
				l = j;
			}
		}
		if(mx==0){
			break;
		}
		for(j=0;j<V;j++){
			if(!c[j][l]){
				c[j][l] = true;
				h[l]--;
				h[j]--;
			}
			if(!c[l][j]){
				c[l][j] = true;
				h[l]--;
				h[j]--;
			}
		}
		ans++;
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:28: error: 'g' was not declared in this scope
   82 |                         if(g[j]>mx){
      |                            ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2000 + 10;
int N, K;
vector<int> A[MAXN];
int ans;

inline int Dfs( int x, int p, int t, int y ) {
	register int i;
	int res = 1;
	if(t != y)
		for( i = 0; i < (int) A[x].size(); ++i )
			if(A[x][i] != p)
				res += Dfs(A[x][i], x, t + 1, y);
	return res;
}

int main() {
	register int i, j; int x, y;
	scanf( "%d%d", &N, &K );
	for( i = 1; i < N; ++i )
		scanf( "%d%d", &x, &y ),
		A[--x].push_back(--y), A[y].push_back(x);
	if(K & 1)
		for( i = 0; i < N; ++i )
			for( j = 0; j < (int) A[i].size(); ++j )
				ans = max( ans, Dfs( i, A[i][j], 0, K >> 1 ) + Dfs( A[i][j], i, 0, K >> 1 ) );
	else
		for( i = 0; i < N; ++i )
			ans = max( ans, Dfs( i, -1, 0, K >> 1 ) );
	printf( "%d\n", N - ans );
	return 0;
}

Compiler output:
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<int> A[MAXN];
      | ^~~~~~
a.cc: In function 'int Dfs(int, int, int, int)':
a.cc:14:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |         register int i;
      |                      ^
a.cc:17:39: error: 'A' was not declared in this scope
   17 |                 for( i = 0; i < (int) A[x].size(); ++i )
      |                                       ^
a.cc: In function 'int main()':
a.cc:24:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register int i, j; int x, y;
      |                      ^
a.cc:24:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register int i, j; int x, y;
      |                         ^
a.cc:28:17: error: 'A' was not declared in this scope
   28 |                 A[--x].push_back(--y), A[y].push_back(x);
      |                 ^
a.cc:31:47: error: 'A' was not declared in this scope
   31 |                         for( j = 0; j < (int) A[i].size(); ++j )
      |                                               ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2000 + 10;
int N, K;
vector<int> A[MAXN];
int ans;

inline int Dfs( int x, int p, int t, int y ) {
	register int i;
	int res = 1;
	if(t != y)
		for( i = 0; i < (int) A[x].size(); ++i )
			if(A[i] != p)
				res += Dfs(A[i], x, t + 1, y);
	return res;
}

int main() {
	register int i, j; int x, y;
	scanf( "%d%d", &N, &K );
	for( i = 1; i < N; ++i )
		scanf( "%d%d", &x, &y ),
		A[--x].push_back(--y), A[y].push_back(x);
	if(K & 1)
		for( i = 0; i < N; ++i )
			for( j = 0; j < (int) A[i].size(); ++j )
				ans = max( ans, Dfs( i, A[j], 0, K >> 1 ) + Dfs( A[j], i, 0, K >> 1 ) );
	else
		for( i = 0; i < N; ++i )
			ans = max( ans, Dfs( i, -1, 0, K >> 1 ) );
	printf( "%d\n", N - ans );
	return 0;
}

Compiler output:
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<int> A[MAXN];
      | ^~~~~~
a.cc: In function 'int Dfs(int, int, int, int)':
a.cc:14:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |         register int i;
      |                      ^
a.cc:17:39: error: 'A' was not declared in this scope
   17 |                 for( i = 0; i < (int) A[x].size(); ++i )
      |                                       ^
a.cc: In function 'int main()':
a.cc:24:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register int i, j; int x, y;
      |                      ^
a.cc:24:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register int i, j; int x, y;
      |                         ^
a.cc:28:17: error: 'A' was not declared in this scope
   28 |                 A[--x].push_back(--y), A[y].push_back(x);
      |                 ^
a.cc:31:47: error: 'A' was not declared in this scope
   31 |                         for( j = 0; j < (int) A[i].size(); ++j )
      |                                               ^
Language: C++

#include<iostream>
#include<cstdio>
#define MN 2000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,K,head[MN+5],f[MN+5][MN+5],cnt,ans,F[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void Solve(int x,int fa)
{
    for(int i=0;i<=K;++i) f[x][i]=1;
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=fa)
        {
            Solve(e[i].to,x);
            memset(F,200,sizeof(F));
            for(int j=1;j<=K;++j)
                F[j]=max(f[e[i].to][j-1]+f[x][min(K-j,j)],j<K?(f[x][j]+f[e[i].to][min(K-j-1,j-1)]):0);
            for(int j=1;j<=K;++j) f[x][j]=max(F[j],f[x][j-1]);
        }
    ans=max(ans,f[x][K]);
    //for(int j=0;j<=K;++j) printf("f[%d][%d]=%d\n",x,j,f[x][j]);
}
int main()
{
    memset(f,200,sizeof(f));
    n=read();K=read();
    for(int i=1;i<n;++i) ins(read(),read());
    Solve(1,0);
    printf("%d\n",n-ans);
    return 0;
}


Compiler output:
a.cc: In function 'void Solve(int, int)':
a.cc:26:13: error: 'memset' was not declared in this scope
   26 |             memset(F,200,sizeof(F));
      |             ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<cstdio>
  +++ |+#include <cstring>
    3 | #define MN 2000
a.cc: In function 'int main()':
a.cc:36:5: error: 'memset' was not declared in this scope
   36 |     memset(f,200,sizeof(f));
      |     ^~~~~~
a.cc:36:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'