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

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

#define DEBUG_ON 1  // 0 = off, 1 = on

namespace {
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define LEN(x) (int)((x).size())
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define OP minmax

#define FOR(i, begin, end)  \
  for (__typeof(end) i = (begin) - ((begin) > (end));  \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#ifndef ONLINE_JUDGE
#include "debug.h"
#endif  // ONLINE_JUDGE
  
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
}

const int MAX_N = 200000;
const ll MODD = 1000000009LL;
const ld EPS = 1e-9;



ll a, b, c;
ll ba, bb, bc;

ll solve(ll N, ll X) {
	if (N % 2 == 0 && X == N / 2) return 3 * X;
	if (2*X > N) X = N - X;
	
	ll ans = 2 * X + N;
	
	ll rem = (N - 2*X);
	ll x = X;
	while (rem != 0) {
		DEBUG(ans, rem, x);
		if (rem % x == 0) {
			ans += 2 * rem - x;
			return ans;
		}
		ans += (rem / x) * 2*x;
		ll temp = x;
		x = rem % x;
		rem = temp;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll N, X;
	cin >> N >> X;
	
	cout << solve(N, X) << endl;
}


Compiler output:
a.cc:21:10: fatal error: debug.h: No such file or directory
   21 | #include "debug.h"
      |          ^~~~~~~~~
compilation terminated.
Language: C++

#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
int main() {
	unsigned long long n, x;
	cin >> n >> x;
	if (n / 2.0  != x) {
		int a = (n - x) / x;
		int b = (n - x) % x;
		cout << x * 3 * ( b + a);
	}	}else {
		cout << x * 3;
	}
	return 0;
}

Compiler output:
a.cc:15:18: error: expected unqualified-id before 'else'
   15 |         }       }else {
      |                  ^~~~
a.cc:18:9: error: expected unqualified-id before 'return'
   18 |         return 0;
      |         ^~~~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: C++

#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
int main() {
	unsigned long long n, x;
	cin >> n >> x;
	if (n / 2.0  != x) {
		int a = (n - x) / x;
		int b = (n - x) % x;
		cout << x * 3 * ( b + a);
	}	}else {
		cout << x * 3;
	}
	return 0;
 

Compiler output:
a.cc:15:18: error: expected unqualified-id before 'else'
   15 |         }       }else {
      |                  ^~~~
a.cc:18:9: error: expected unqualified-id before 'return'
   18 |         return 0;
      |         ^~~~~~
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main {
	static int count = 0;
	
	public static int[] func(int[] ar) {
		//System.out.println(Arrays.toString(ar));
		Arrays.sort(ar);
		if (ar[0] == 0) {
			//int[] result = {count, 0};
			//return result;
			return ar;
		}
		//System.out.println(Arrays.toString(ar));
		//count = count + ar[0] * 3 * (ar[1] / ar[0]);
		int[] next = {ar[0], (ar[1] % ar[0])};
		return func(next);
	}
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().trim().split(" ");
		int[] ar = Stream.of(line).mapToInt(Integer::parseInt).toArray();
		Arrays.sort(ar);
		ar[1] = ar[1] - ar[0];
		//System.out.println(Arrays.toString(ar));
		//int[] ar = {3, 2};
		//System.out.println(func(ar)[0]);
		int poi = func(ar[1]);
		int result = poi * 3 * ((ar[0] * ar[1]) / poi);
		System.out.println(result);
	}
}

Compiler output:
Main.java:32: error: incompatible types: int cannot be converted to int[]
		int poi = func(ar[1]);
		                 ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C++

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define dump(o) { cerr << #o << " " << o << endl; }
#define dumpc(o) { cerr << #o; for (auto &e : (o)) cerr << " " << e; cerr << endl; }
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

vector<long long> a;
vector<long long> b;

long long cnt = 0;

//最大公約数
long long gcd(long long x, long long y) {
	if (y) {
		cnt++;
		a.push_back(y);
		b.push_back(x / y);
		return gcd(y, x%y);
	}
	else {
		return x;
	}
}

long long main() {
	long long N, K; cin >> N >> K;
	K = max(N - K, K);
	gcd(N, K);
	long long ans;
	if (cnt == 1) {
		ans = a[0] * 3;
	}
	else if (cnt == 2) {
		ans = 1 * a[0];
		ans += (2 * b[1])*a[1];
	}
	else {
		ans = 1 * a[0];
		ans += (2 * b[1] + 1)*a[1];
		for (long long i = 2; i < a.size() - 1; i++) {
			ans += 2 * b[i] * a[i];
			//dump(ans);
		}
		ans += (2 * b[a.size() - 1] - 1)*a[a.size() - 1];
		//dumpc(a);
		//dumpc(b);
	}
	//cout << cnt << endl;
	cout << ans << endl;

	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

include <iostream>

using namespace std;

int mod_gcd(int a, int b, int &l){
	if(a%b!=0){
		l=l+2*( a - (a % b));
		return mod_gcd(b,a%b,l);
	}
	else {
		l=l+b*(a/b+1);
	} 
}
int main(int argc, char *argv[]) {
	int n,x,l=0;
	cin >> n >> x;
	mod_gcd(n-x,x,l);
	cout << l+n;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int main(int, char**)':
a.cc:16:9: error: 'cin' was not declared in this scope
   16 |         cin >> n >> x;
      |         ^~~
a.cc:18:9: error: 'cout' was not declared in this scope
   18 |         cout << l+n;
      |         ^~~~
a.cc: In function 'int mod_gcd(int, int, int&)':
a.cc:11:18: warning: control reaches end of non-void function [-Wreturn-type]
   11 |                 l=l+b*(a/b+1);
      |                 ~^~~~~~~~~~~~
Language: Java

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int X = sc.nextInt();
        
        int ans = X + (N - X);
        if(N % 2 == 0) {
            ans += (X - (N / 2) + 1) * 3;
        } else {
            ans += ((N - 3) / 2) * 4 + 3;
        }
        System.out.println(ans);
    }

}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++


#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long

using namespace std;

int dx[] ={0,1,0,-1};
int dy[]= {1,0,-1,0};

int c=0;

long long solve(long long N,long long X){
  if(c==1){
  c++;
  if(2*N%X==0){
    return X*(2*N/X);
  }
  int ans = X*(2*N/X);
  return ans + solve(X,N%X);
  }else if(c%2==0){
  c++;
    if(N%X==0){
       return (N/X)*2*X-X;
    }
    int an = (N/X)*2*X;
    return an+solve(X,N%X); 
  }else if(c%2==1){
      c++;
  if(2*N%X==0){
    return X*(2*N/X)-X;
  }
  int ans = X*(2*N/X);
  return ans + solve(X,N%X);
}
}

int main(){
  long long N,X;
  cin>>N>>X;
  long long ans=X;
  c++;
  ans = ans + solve(X,N-X);
  c++;
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:3: error: 'cin' was not declared in this scope
   39 |   cin>>N>>X;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:44:3: error: 'cout' was not declared in this scope
   44 |   cout<<ans<<endl;
      |   ^~~~
a.cc:44:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:14: error: 'endl' was not declared in this scope
   44 |   cout<<ans<<endl;
      |              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | 
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
Language: C++


int dx[] ={0,1,0,-1};
int dy[]= {1,0,-1,0};

int c=0;

long long solve(long long N,long long X){
  if(c==1){
  c++;
  if(2*N%X==0){
    return X*(2*N/X);
  }
  int ans = X*(2*N/X);
  return ans + solve(X,N%X);
  }else if(c%2==0){
  c++;
    if(N%X==0){
       return (N/X)*2*X-X;
    }
    int an = (N/X)*2*X;
    return an+solve(X,N%X); 
  }else if(c%2==1){
      c++;
  if(2*N%X==0){
    return X*(2*N/X)-X;
  }
  int ans = X*(2*N/X);
  return ans + solve(X,N%X);
}
}

int main(){
  long long N,X;
  cin>>N>>X;
  long long ans=X;
  c++;
  ans = ans + solve(X,N-X);
  c++;
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:3: error: 'cin' was not declared in this scope
   34 |   cin>>N>>X;
      |   ^~~
a.cc:39:3: error: 'cout' was not declared in this scope
   39 |   cout<<ans<<endl;
      |   ^~~~
a.cc:39:14: error: 'endl' was not declared in this scope
   39 |   cout<<ans<<endl;
      |              ^~~~
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
Language: C++

#include <iostream>
using namespace std;
 
int main() {
	int n,x,length;
	int a[2];
	cin>>n>>x;
	a[0]=n-x;
	a[1]=x;
	length=x;
	while(a[0]!=a[1]){
		if(a[0]>a[1]){
		length=length+((a[0]-1)/a[1])*a1;
		a[0]=(a[0]-1)%a[1]+1;
		}
		if(a[0]<a[1]){
		a[1]=(a[1]-1)%a[0]+1;
		}
	}
	cout<<length*3;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:47: error: 'a1' was not declared in this scope; did you mean 'a'?
   13 |                 length=length+((a[0]-1)/a[1])*a1;
      |                                               ^~
      |                                               a
Language: C++

#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<math.h>
using namespace std;
int main() {
	unsigned long long n, x;
	cin >> n >> x;
	if (n / 2 < x) {
		cout << 6 * x;
	}
	else {
		cout << 3 * x;
	}
	return 0;
 

Compiler output:
a.cc: In function 'int main()':
a.cc:17:18: error: expected '}' at end of input
   17 |         return 0;
      |                  ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: C++

// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>

#include <functional>


using namespace std;


typedef long long ll;


int main() {

	ll N, X;
	scanf("%lld %lld\n", &N, &X);

	ll result = 0;


	// 明らかな場合を分けておく
	if (N % 2 == 0) {
		if (X == N / 2) {
			printf("%lld\n", X*3);
			return;
		}
		else if (X % 2 == 0) {
			// 3手目まで
			result += (X + (N - X) + X);
			int left = N - 2 * X;
			result += left * 2;

			printf("%lld", result);
			return;
		}
	}


	// 3手目まで
	result += (X + (N - X) + X);

	// 4手目
	result += X;

	// ...
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
   39 |                         return;
      |                         ^~~~~~
a.cc:48:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
   48 |                         return;
      |                         ^~~~~~
Language: C++

#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define MOD 1000000007

#define MAX_N 2000

typedef long long ll;
typedef unsigned long long ull;

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> g[MAX_N];
    REP(i, N) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        g[A].pb(B);
        g[B].pb(A);
    }
    int ret = MAX_N;
    REP(k, N) {
        if (true) {
            int d[MAX_N];
            fill(d, d + N, MAX_N);
            queue<int> q;
            q.pb(k);
            d[k] = 0;
            while (!q.empty()) {
                int x = q.front();
                q.pop();
                if (d[x] == K) {
                    continue;
                }
                for (int i = 0; g[x].size(); i++) {
                    int to = g[x][i];
                    if (d[to] > d[x] + 1) {
                        d[to] = d[x] + 1;
                        q.pb(to);
                    }
                }
            }
            for (int i = 0; g[k].size(); i++) {
                int to = g[k][i];
                
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:12: error: 'class std::queue<int>' has no member named 'push_back'
   24 | #define pb push_back
      |            ^~~~~~~~~
a.cc:54:15: note: in expansion of macro 'pb'
   54 |             q.pb(k);
      |               ^~
a.cc:24:12: error: 'class std::queue<int>' has no member named 'push_back'
   24 | #define pb push_back
      |            ^~~~~~~~~
a.cc:66:27: note: in expansion of macro 'pb'
   66 |                         q.pb(to);
      |                           ^~
a.cc:76:2: error: expected '}' at end of input
   76 | }
      |  ^
a.cc:36:1: note: to match this '{'
   36 | {
      | ^
Language: C++

#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

void swarp(long long *a,long long *b){
  long long c;
  c = *a;
  *a = *b;
  *b = c;
}

long long solve(long long l,long long s){
  if (l == (l/s)*s) return 2*(l-s);
  else return ((l/s) * 2-1)*s + l % s + solve(s,l%s);
}

int main(){
  long long n,x,sum=0;
  cin >> n >> x;
  sum += n+2*x;
  if (n==2*x) {
    cout << x*3 << endl;
    return 0;
  } else if (n>2*x && (n-2*x>=x) && n%x == 0){
    sum += 2*n-5*x;
    cout << sum << endl;
    return 0;
  } else if (n>2*x &&(x>n-2*x) x % (n-2*x)==0){
    sum += 2*x-(n-2*x);
    cout << sum << endl;
    return 0;
  } else if (n>2*x) {
      long long l=n-2*x;
      if(x>l) swarp(&l,&x);
      sum += 2*(n-2*x);
      sum += solve(x,(n-2*x)%x);
      cout << sum << endl;
      return 0;
  } else {
    sum += solve(n,n-x);
    cout << sum << endl;
    return 0;
  }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:31: error: expected ')' before 'x'
   33 |   } else if (n>2*x &&(x>n-2*x) x % (n-2*x)==0){
      |             ~                 ^~
      |                               )
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	long long n,x,a,res;
	cin >> n >> x;
	a = max(n-x,x)
	if(n%x == 0)cout << a*3 <<endl;
	else cout << a*4 <<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:23: error: expected ';' before 'if'
   10 |         a = max(n-x,x)
      |                       ^
      |                       ;
   11 |         if(n%x == 0)cout << a*3 <<endl;
      |         ~~             
a.cc:12:9: error: 'else' without a previous 'if'
   12 |         else cout << a*4 <<endl;
      |         ^~~~
Language: C

#include<stdio.h>

long long gcd(long long a,long long b){
    while(b ^= a ^= b ^= a%=b);
    return a;
}

long long main(){
	long long n,x;
	long long i,j,g;

	scanf("%lld%lld",&n,&x);

	g = gcd(n,x);
	n /= g;
	x /= g;

	prlong longf("%lld\n",(n-1)*3*g);

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:9: error: unknown type name 'prlong'; did you mean 'long'?
   18 |         prlong longf("%lld\n",(n-1)*3*g);
      |         ^~~~~~
      |         long
main.c:18:22: error: expected declaration specifiers or '...' before string constant
   18 |         prlong longf("%lld\n",(n-1)*3*g);
      |                      ^~~~~~~~
main.c:18:31: error: expected declaration specifiers or '...' before '(' token
   18 |         prlong longf("%lld\n",(n-1)*3*g);
      |                               ^
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

int main()
{
    ios::sync_with_stdio(false);
    uint64_t n, x;
    cin >> n >> x;
        cout << 6 * x << '\n';
    else if( 2 * x == n)
        cout << 3 * n / 2 << '\n';
    else
        cout << 3 * x << '\n';
}



Compiler output:
a.cc: In function 'int main()':
a.cc:31:5: error: 'else' without a previous 'if'
   31 |     else if( 2 * x == n)
      |     ^~~~
Language: Java

import java.util.Scanner;

public class main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long x = sc.nextLong();
		System.out.println(x*3 + (n-x-1)*3);
	}

}

Compiler output:
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main {
       ^
1 error
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i,n) for(int i=0; i<n; ++i)
using namespace std;
typedef long long int ll;
int main(){
    ll n, x;
    cin >> n >> x;
    x = min(x, n-x);
    if(n%x){ cout << 3*(n-1) << endl; }
    else   { cout << 3*(n/x-1)*x << endl; }

    return 0;
}
[yuri] 16-07-16 21:37:43> ~/agc


Compiler output:
a.cc:17:1: error: expected unqualified-id before '[' token
   17 | [yuri] 16-07-16 21:37:43> ~/agc
      | ^
Language: C++

#include<vector>
#include<algorithm>

int main() {
	std::size_t N,X;
	std::cin >> N >> X;
	auto res{0};
	if (2 * X < N) {
		res = X * 6;
	}
	else {
		res = X * 3;
	}
	std::cout << res<<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:14: error: 'cin' is not a member of 'std'
    6 |         std::cin >> N >> X;
      |              ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | 
a.cc:14:14: error: 'cout' is not a member of 'std'
   14 |         std::cout << res<<"\n";
      |              ^~~~
a.cc:14:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<cstdio>
#define ll long long
using namespace std;
int main()
{
    ll n,x;
    while(~scanf("%I64d%I64d",&n,&x))
    {
        if(x*2==n)printf("%I64d\n",3*(n/2));
        else printf("%I64d\n",3*(n-1));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:2: error: expected '}' at end of input
   11 | }
      |  ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, x;

int main() {
    GLL(n); GLL(x);

    LL res = n;

    LL a = x; LL b = n-x; if (a > b) swap(a, b);

    while (a > 0) {
        LL q = b / a;
        LL r = b % a;
        
        if (r > 0) {
            res += 2 * q * a;
        }
        else {
            res += (2 * q - 1) * a;
        }

        b = a;
        a = r;
    }

    cout << res << "\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:9: error: cannot bind non-const lvalue reference of type 'LL&' {aka 'long long int&'} to a value of type 'int'
   47 |     GLL(n); GLL(x);
      |         ^
a.cc:36:13: note:   initializing argument 1 of 'int GLL(LL&)'
   36 | int GLL(LL& x) {
      |         ~~~~^
a.cc:47:17: error: cannot bind non-const lvalue reference of type 'LL&' {aka 'long long int&'} to a value of type 'int'
   47 |     GLL(n); GLL(x);
      |                 ^
a.cc:36:13: note:   initializing argument 1 of 'int GLL(LL&)'
   36 | int GLL(LL& x) {
      |         ~~~~^
Language: C++

// It works until it doesn't
#ifndef NOBITS
#include <bits/stdc++.h>
#endif
using namespace std;
// pre
#include "debug/deb.cpp"
#include "io/ion.cpp"
// ctvl, ctvl2, read, write, writeln, ~, div_ceil, div_floor, min_heap, max_heap, d+=d, +-d, --d--, lbi, ubi, 
// vecnd, vec1, vec2, vec3, log2_floor, log2_ceil
#include "misc/util.cpp"
// all, rall, forn, ford, for1, forr, trav, eb, pub, pob, fi, se, endl, mp, mt, if0, timit, Fn, pct, ctz, clz, binrep 
#include "misc/macros.cpp"


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> using vv = vector<vector<T>>;
// #define int long long


const int N = 200'010;

auto dfs_tree(int root, const vector<vector<int>>& g) {
    stack<int> h;
    h.push(root);
    int n = g.size();
    vector<int> dist(n), pi(n, -1);
    while(!h.empty()) {
        int u = h.top();
        h.pop();
        for(auto v : g[u]) {
            if(pi[u] != v) {
                pi[v] = u;
                h.push(v);
                assert(dist[v] == 0);
                dist[v] = dist[u] + 1;
            }
        }
    }
    return make_tuple(dist, pi);
}
auto soln() {
    auto [n, k] = scan<int, int>();
    vpii edge(n - 1);
    vvi g(n + 1);
    forn(i, n - 1) {
        auto [u, v] = scan<int, int>();
        edge[i] = make_pair(u, v);
        g[u].pub(v);
        g[v].pub(u);
    }

    int res = N;
    if (k % 2) {
        for (auto &[u, v] : edge) {
            int count = 0;
            auto [distu, _1] = dfs_tree(u, g);
            auto [distv, _2] = dfs_tree(v, g);
            for (int i = 1; i <= n; ++i) {
                ckmin(distu[i], distv[i]);
                count += (distu[i] > k / 2);
            }
            ckmin(res, count);
        }
    }
    else {
        for (int i = 1; i <= n; ++i) {
            int count = 0;
            auto [dist, _3] = dfs_tree(i, g);
            echo(i, dist);
            for (int j = 1; j <= n; ++j) {
                count += (dist[j] > k / 2);
            }
            ckmin(res, count);
        }
    }
    cout << res << endl;
}
signed main() {
    int t = 1;
#ifndef LOCAL 
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#endif
    // t = scan<int>();
    while (t--)
        soln();
    return 0;
}







Compiler output:
a.cc:7:10: fatal error: debug/deb.cpp: No such file or directory
    7 | #include "debug/deb.cpp"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;

int n, k;
vector<int> g[4000];

int cnt(int cur, int prev)
{
    // cout << cur << ", " << prev << endl;

    int ret = 1;
    for (auto &n: g[cur]) {
        if (n == prev) continue;
        ret += cnt(n, cur);
    }
    return ret;
}

int solve(int cur, int prev, int dep)
{
    // cout << cur << ", " << prev << ", " << dep << endl;

    if (dep <= 0) {
        return cnt(cur, prev);
    }

    int ans = 0;

    for (int i = 0; i < g[cur].size(); i++) {
        if (g[cur][i] == prev) continue;
        ans += solve(g[cur][i], cur, dep - 1);
    }

    return ans;
}

int main()
{
    cin >> n >> k;
    g.resize(n);

    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 + 1;

    for (int center = 0; center < n; center++) {
        for (auto lng: g[center]) {
            int tmp = 0;
            for (auto root: g[center]) {
                tmp += solve(root, center, k / 2 + ((k % 2 == 1 && lng == root) ? 1 : 0));
            }
            // cout << center + 1 << " -> " << lng + 1 << ": " << tmp << endl;
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:7: error: request for member 'resize' in 'g', which is of non-class type 'std::vector<int> [4000]'
   49 |     g.resize(n);
      |       ^~~~~~
Language: C++

#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
int dp[4000][4000],g[4000],head[4000];
int n,k,ans;
bool visited[4000];
vector<int> graph[4000];
void dfs(int x)
{
	dp[x][0]=1;
	for (int j=1;j<=k+1;j++)
	{
		dp[x][j]=0;
	}
	visited[x]=1;
	for(int second : graph[x])
	{
		if(!visited[second])
		{
			dfs(second);
			g[0]=dp[x][0];
			for (int j=1;j<=k+1;j++)
            {
            	g[j]=min(g[j-1],dp[x][j]);
            }
			for (int j=1;j<=k+1;j++)
            {
            	dp[x][j]=n;
            }
			for (int j=1;j<=min(k+1,dp[x][0]);j++)
            {
				for (int w=0;w<=min(k,dp[second][0]);w++)
                {
					if (j-1+w<=k)
                    {
                    	dp[x][max(j,w+1)]=min(dp[x][max(j,w+1)],g[j]+dp[second][w]);
                    }
                }
            }
			dp[x][0]+=dp[second][0];
		}
	}
	for (int j=1;j<=k+1;j++)
    {
    	dp[x][j]=min(dp[x][j],dp[x][j-1]);
    }
	ans=min(ans,n-dp[x][0]+dp[x][k+1]);
}

int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		//push(2*i-1,x,y);push(2*i,y,x);
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	memset(v,0,sizeof(v));
	ans=n;
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:77:16: error: 'v' was not declared in this scope; did you mean 'vi'?
   77 |         memset(v,0,sizeof(v));
      |                ^
      |                vi
Language: C++

// In the name of god
#include <bits/stdC++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=2e3+5,inf=1e18;
ll  n,m=inf,k,x,y,h[maxn],num[2][maxn];
bool mark[maxn];
vector <ll> adj[maxn];
pair <ll,ll> p[maxn];
void dfs(int u,int v){
	mark[u]=1;
	for(int j:adj[u]){
		if(!mark[j]&&j!=v){
			h[j]=h[u]+1;
			num[0][h[u]+1]++;
			dfs(j,v);
		}
	}
}
void dfs2(int u,int v){
	mark[u]=1;
	for(int j:adj[u]){
		if(!mark[j]&&j!=v){
			h[j]=h[u]+1;
			num[1][h[u]+1]++;
			dfs2(j,v);
		}
	}
}
void dfs3(int u){
	mark[u]=1;
	for(int j:adj[u]){
		if(!mark[j]){
			h[j]=h[u]+1;
			num[0][h[j]]++;
			dfs3(j);
		}
	}
}
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		x--;
		y--;
		p[i]={x,y};
		adj[y].push_back(x);
		adj[x].push_back(y);
	}
	if(k%2==1){
		for(int i=1;i<n;i++){
			dfs(p[i].first,p[i].second);
			dfs2(p[i].second,p[i].first);
			x=0;
			for(int j=(k+1)/2;j<=n;j++){
				x+=num[0][j];
				x+=num[1][j];
			}
			m=min(m,x);
			for(int j=0;j<=n;j++){
				h[j]=0;
				num[0][j]=0;
				num[1][j]=0;
				mark[j]=0;
			}
		}
	}
	else{
		for(int i=0;i<n;i++){
			dfs3(i);
			x=0;
			for(int j=(k/2)+1;j<=n;j++){
				x+=num[0][j];
			}
			m=min(m,x);
			for(int j=0;j<=n;j++){
				h[j]=0;
				num[0][j]=0;
				num[1][j]=0;
				mark[j]=0;
			}
		}
	}
	cout<<m;
	
}


Compiler output:
a.cc:2:10: fatal error: bits/stdC++.h: No such file or directory
    2 | #include <bits/stdC++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
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: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>>
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
namespace io
{
#define SIZ (1 << 21 | 1)
#define gc() (io::iS == io::iT ? (io::iT= (io::iS= io::ibuff) + fread(io::ibuff, 1, SIZ, stdin), (io::iS == io::iT ? EOF : *io::iS++)) : *io::iS++)
#define putc(x) (io::oS == io::oT ? (fwrite(io::obuff, 1, io::oS - io::obuff, stdout), io::oS= io::obuff, (*io::oS++= x)) : *io::oS++= x)
#define exit                                          \
	fwrite(io::obuff, 1, io::oS - io::obuff, stdout); \
	return 0;
	char *iS, *iT, ibuff[SIZ], obuff[SIZ], *oS= obuff, *oT= oS + SIZ - 1, fu[110], c;
	int fr;
	template <class Type>
	inline void read(Type &x)
	{
		x= 0;
		Type y= 1;
		for(c= gc(); (c > '9' || c < '0') && c != '-'; c= gc())
			;
		c == '-' ? y= -1 : x= (c & 15);
		for(c= gc(); c >= '0' && c <= '9'; c= gc()) x= x * 10 + (c & 15);
		x*= y;
	}
	inline void reads(char *x)
	{
		for(c= gc(); c == ' ' || c == '\n'; c= gc())
			;
		for(; c != ' ' && c != '\n' && c != EOF; *x= c, c= gc(), ++x)
			;
	}
	template <class Type>
	inline void print(Type x, char text= '\n')
	{
		if(x < 0) putc('-'), x*= -1;
		if(x == 0) putc('0');
		while(x) fu[++fr]= x % 10 + '0', x/= 10;
		while(fr) putc(fu[fr--]);
		putc(text);
	}
	inline void prints(char *x, char *y= NULL, char text= '\n')
	{
		for(; *x && x != y; ++x) putc(*x);
		putc(text);
	}
}  // namespace io
using io::print;
using io::prints;
using io::read;
using io::reads;
#define N 2001
int n, k, head[N], cnt, dis[N], ans= 2147483647;
struct Edge
{
	int a, b;
} e[N << 1];
inline void add(int a, int b) { e[++cnt].a= head[a], e[cnt].b= b, head[a]= cnt; }
inline void dfs(int x, int y, int z)
{
	dis[x]= dis[y] + 1;
	for(int i= head[x]; i; i= e[i].a)
	{
		if(e[i].b == y || e[i].b == z) continue;
		dfs(e[i].b, x);
	}
}
signed main()
{
	read(n), read(k);
	for(int i= 1, a, b; i < n; i++) read(a), read(b), add(a, b), add(b, a);
	dis[0]= -1;
	if(k & 1)
	{
		for(int i= 1; i < n; i++)
		{
			int a= e[(i << 1) - 1].b, b= e[i << 1].b;
			dfs(a, 0, b), dfs(b, 0, a);
			int x= 0;
			for(int j= 1; j <= n; j++)
				if(dis[j] >= (k >> 1)) ++x;
			ans= min(ans, x);
		}
	}
	else
	{
		for(int i= 1; i <= n; i++)
		{
			dfs(i, 0, 0);
			int x= 0;
			for(int j= 1; j <= n; j++)
				if(dis[j] > (k >> 1)) ++x;
			ans= min(ans, x);
		}
	}
	print(ans);
	exit;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:75:20: error: too few arguments to function 'void dfs(int, int, int)'
   75 |                 dfs(e[i].b, x);
      |                 ~~~^~~~~~~~~~~
a.cc:69:13: note: declared here
   69 | inline void dfs(int x, int y, int z)
      |             ^~~
Language: C++

#include <iostream>
//#include <bits/stdc++.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;
const int N=2000;
vector<int> g[N];
int n;
int ok;
//int lvl[N];
//int parent[N];
bool used[N];
int k;
dfs(int u,int level){
//	lvl[u]=level;
//	parent[u]=p;
	if(level>k/2){
		ok++;
	}
	used[u]=true;
	for(auto x:g[u]){
		if(used[x]==false){
			dfs(x,level+1);
		}
	}
}
void solve(){
	scanf("%d%d",&n,&k);
		int x,y;
		loop(i,1,n){
			scanf("%d%d",&x,&y);
			x--;
			y--;
			g[y].pb(x);
			g[x].pb(y);
		}
	//distance kitna hai k/2
	vector<int> ans;
	loop(i,0,n){
		ok=0;
		memset(used,0,sizeof(used));
		dfs(i,0);
		ans.pb(ok);
	}
	cout<<*min_element(ans.begin(),ans.end());
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}




Compiler output:
a.cc:22:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   22 | dfs(int u,int level){
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
#define maxn 5000010

void read(int &x) {
  int f = 1;
  x = 0;
  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();
  }
  x *= f;
}
struct node {
  int to;
  int nxt;
} edge[maxn];
int tot, head[maxn], maxx, vis[maxn], ans, cnt;
void add(int x, int y) {
  edge[cnt].to = y;
  edge[cnt].nxt = head[x];
  head[x] = cnt++;
}
void dfs(int now, int fa, int stp) {
  tot++;
  if (stp == 0) return;
  for (int i = head[now]; ~i; i = edge[i].nxt) {
    if (edge[i].to == fa) {
      continue;
    }
    dfs(edge[i].to, now, stp - 1);
  }
}
int n, k;
int main() {
  read(n), read(k);
  int u, v, del;
  for (int i = 0; i <= n; i++) head[i] = -1;
  for (int i = 0; i < n - 1; i++) {
    read(u), read(v);
    add(u, v);
    add(v, u);
  }
  ans = 0;
  if (k % 2 == 0) {  // k为偶数，枚举点，跑k/2的边
    for (int i = 1; i <= n; i++) {
      tot = 0;
      dfs(i, 0, k / 2);
      ans = max(tot, ans);
    }
  } else {  // k为奇数，枚举边，跑k/2的点for (u = 1; u <= n; u++) {
    for (int j = head[u]; ~j; j = edge[j].nxt) {
      tot = 0;
      int t = edge[j].to;
      dfs(t, u, k / 2);
      dfs(u, t, k / 2);
      ans = max(tot, ans);
    }
  }
}
cout << n - ans << endl;
}


Compiler output:
a.cc:73:1: error: 'cout' does not name a type
   73 | cout << n - ans << endl;
      | ^~~~
a.cc:74:1: error: expected declaration before '}' token
   74 | }
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N = 2000 + 7;
int n, k, mindel[N][N], dep[N][N];
vector<int> g[N];
bool vis[N];

void dfs(int a) {
  mindel[a][0] = 1;
  vector<int> kids;
  vis[a] = 1;
  for (auto &b : g[a]) {
    if (vis[b] == 0) {
      dfs(b);
      mindel[a][0] += mindel[b][0];
      kids.push_back(b);
    }
  }
  if (kids.empty()) {
    for (int i = 1; i <= k; i++) {
      mindel[a][i] = 0;
    }
    return;
  }
  for (int len = 1; len <= k; len++) {
    mindel[a][len] = mindel[a][i - 1];
    int other = k - len;
    other = min(other, len - 1);
    for (auto &power : kids) {
      int cur = mindel[power][len - 1];
      for (auto &b : kids) {
        if (b != power) {
          cur += mindel[b][other];
        }
      }
      mindel[a][len] = min(mindel[a][len], cur);
    }
  }
}

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

  cin >> n >> k;
  k++;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  int ans = (int) 1e9;

  for (int i = 1; i <= n; i++) {
    ans = min(ans, mindel[i][k] + n - mindel[i][0]);
  }
  cout << ans << "\n";
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:28:32: error: 'i' was not declared in this scope
   28 |     mindel[a][len] = mindel[a][i - 1];
      |                                ^
Language: C++

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k);
	std::vector<int> a(n - 1), b(n - 1);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;

		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}

	int ans = n;
	for(int i = 0; i < n; i++) {
		int v = a[id] ^ b[id] ^ i;

		auto dfs = [&](auto&& dfs, int v, int par, int d) -> int {
			if(d > k / 2) return 0;
			int ret = 1;
			for(auto id: g[v]) {
				int to = a[id] ^ b[id] ^ v;
				ret += dfs(dfs, to, v, d + 1);
			}
			return ret;
		};

		if(k & 1) {
			// 中心が二つ
			for(auto id: g[i]) {
				int to = a[id] ^ b[id] ^ i;
				int ret = dfs(dfs, to, i, 0) + dfs(dfs, i, to, 0);

				ans = std::min(ans, n - ret);
			}
		} else {
			int ret = dfs(dfs, i, -1, 0);
			ans = std::min(ans, n - ret);
		}
	}

	printf("%d\n", ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:27: error: 'id' was not declared in this scope; did you mean 'i'?
   31 |                 int v = a[id] ^ b[id] ^ i;
      |                           ^~
      |                           i
Language: C++

#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 2010;
bool bye[maxn];
vector<int> edge[maxn];
int n, k;
vector<int> dp[maxn];
int sz[maxn];
void dfs1(int now, int last = -1){
	sz[now] = 1;
	for(int u : edge[now])if(u != last)
		dfs1(u, now), sz[now] += sz[u];
}
//
//void dfs2(int now, int last = -1){
//	for(int u : edge[now])if(u != last){
//		dfs2(u, now);
//		if(dp[u].size() > dp[now].size())
//			swap(dp[u], dp[now]);
//		for(int i = (int)dp[now].size()-1;i > 0;--i){
//			auto get = [&](const vector<int> &a, const vector<int> &b){
//				if(a.size() <= i)return maxn;
//				int p = min({max(k-i, 0), i});
//				return a[i] + (p >= b.size() ? 0 : b[p]);
//			};
//			dp[now][i] = min( get(dp[u], dp[now]), get(dp[now], dp[u]) );
//		}
//		for(int i = 1;i < dp[now].size();++i)
//			dp[now][i] = min(dp[now][i-1], dp[now][i]);
//	}
//	auto tmp = dp[now];
//	vector<int> &dp = ::dp[now];
//	dp.resize( max(2, (int)tmp.size()+1) );
//	dp[0] = sz[now];
//	for(int i = 0;i < tmp.size();++i)
//		dp[i+1] = tmp[i];
//	//for(int i= 1;i < dp.size();++i)
//		//assert(dp[i] <= dp[i-1]);
//	//cerr << "now " << now << ' ' << dp.size() << '\n';
//}
void dfs2(int now, int last = -1){
	dp[now] = {0};
	for(int u : edge[now])if(u != last){
		dfs2(u, now)
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for(int i = 1, a, b;i < n;++i){
		cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	dfs1(1);
	dfs2(1);
	cout << (dp[1].size() <= k+1 ? dp[1].back() : dp[1][k+1]) << '\n';
}



Compiler output:
a.cc: In function 'void dfs2(int, int)':
a.cc:46:29: error: expected ';' before 'signed'
   46 |                 dfs2(u, now)
      |                             ^
      |                             ;
   47 | signed main(){
      | ~~~~~~                       
a.cc:58:2: error: expected '}' at end of input
   58 | }
      |  ^
a.cc:45:44: note: to match this '{'
   45 |         for(int u : edge[now])if(u != last){
      |                                            ^
a.cc:58:2: error: expected '}' at end of input
   58 | }
      |  ^
a.cc:43:34: note: to match this '{'
   43 | void dfs2(int now, int last = -1){
      |                                  ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
	ll ans=0;ll a=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')a=-1;
	for(;c>='0'&&c<='9';c=getchar())ans=ans*10+c-48;
	return ans*a;
}
ll a[2001][2001],maxx;
vector<ll> p[2001];
ll se[2001],fi[2001],n,k,cnt;
void dfs(ll root,ll fa,ll poi,ll s)
{
	a[root][poi]=s;
	for(ll i=0;i<p[poi].size();i++) 
	{
		ll x=p[poi][i];
		if(x==fa)
		{
			continue ;
		}
		dfs(root,poi,x,s+1);
	}
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	maxx=ll_MAX;
	n=read();
	k=read();
	for(ll i=1;i<n;i++)
	{
		ll x=read();
		ll y=read();
		p[x].push_back(y);
		p[y].push_back(x);
		fi[i]=y;
		se[i]=x;
	}
	for(ll i=1;i<=n;i++)
	{
		dfs(i,0,i,0);
	}
	for(ll i=1;i<=n;i++)
	{
		ll cnt=0;
		for(ll j=1;j<=n;j++)
		{
			if(2*a[i][j]>k)cnt++;
		}
		maxx=min(maxx,cnt);
	}
	for(ll i=1;i<n;i++)
	{
		cnt=0;
		for(ll j=1;j<=n;j++)
		{
			if(2*(min(a[j][fi[i]],a[j][se[i]])+1)>k)
			cnt++;
		}
		maxx=min(maxx,cnt);
	}
	cout<<maxx<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:14: error: 'll_MAX' was not declared in this scope
   31 |         maxx=ll_MAX;
      |              ^~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
vvi graph(100);
vvi lineDistances(100, vi(100));
vvb visited(100, vb(100, false));
vi vertexA, vertexB;
int number, diameter;
void dfs(int root, int start, int distanceInLines)
{
	//preVisitRecursion.
	visited[root][start]=true;
	lineDistances[root][start]=distanceInLines;
	for(int next : graph[start])
	{
		if(!visited[root][next])
		{
			dfs(root, next, distanceInLines+1);
		}
	}
	//postVisitRecursion.
	return;
}
void usingDFS()
{
	cin>>number>>diameter;
	int vertex0, vertex1;
	for(int i=1; i<number; ++i)
	{
		cin>>vertex0>>vertex1;
		graph[vertex0].push_back(vertex1);
		graph[vertex1].push_back(vertex0);
		vertexA.push_back(vertex0);
		vertexB.push_back(vertex1);
	}
	for(int vertex=1; vertex<=number; ++vertex)
	{
		dfs(vertex, vertex, 0);
	}
	int minimum=40000;
	for(int i=1; i<=number; ++i)
	{
		int counter=0;
		for(int j=1; j<=number; ++j)
		{
			if(lineDistances[i][j]>diameter/2)
			{
				++counter;
			}
		}
		minimum=min(minimum, counter);
	}
	int dotA, dotB, tempMaxDist;
	for(int i=0; i<vertexA.size(); ++i)
	{
		int counter=0;
		dotA=vertexA[i];
		dotB=vertexB[i];
		for(int j=1; j<=number; ++j)
		{
			tempMaxDist=min(lineDistances[j][dotA], lineDistances[j][dotB]);
			if(tempMaxDist>(diameter-1)/2)
			{
				++counter;
			}
		}
		minimum=min(minimum, counter);
	}
	cout<<endl<<minimum<<endl;
	return;
}
/*
template<typename Type>
void showContent(Type inputVector)
{
	for(int i=1; i<=number; ++i)
	{
		for(int j=1; j<=number; ++j)
		{
			cout<<"["<<i<<"]["<<j<<"] <- "<<inputVector[i][j]<<endl;
		}
	}
	return;
}
*/
int main()
{
        ios :: sync_with_stdio(false);
	cout << fixed << setprecision(16);
	usingDFS();
	//cout<<endl;
	//showContent(visited);
	//cout<<endl;
	//showContent(lineDistances);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:26: error: 'setprecision' was not declared in this scope
   93 |         cout << fixed << setprecision(16);
      |                          ^~~~~~~~~~~~
a.cc:3:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    2 | #include <vector>
  +++ |+#include <iomanip>
    3 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
  int V, K; cin >> V >> K;
  vector<vector<int>> g(n);
  for (int i = 0; i < V-1; i++) {
    int u, v; cin >> u >> v; u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int res = 0;
  auto dfs = [&](auto f, int n, int p, int d) -> int {
    if (d == 0) return 0;
    int cnt = 1;
    for (auto x : g[n]) {
      if (x == p) continue;
      cnt += f(f, x, n, d-1);
    }
    return cnt;
  };
  for (int i = 0; i < V; i++) {
    for (auto x : g[i]) {
      res = max(res, V - dfs(dfs, i, x, K) + 1);
    }
  }
  cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:25: error: 'n' was not declared in this scope
    5 |   vector<vector<int>> g(n);
      |                         ^