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

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int n;
vector<int> to(100005);
std::vector<int> dist;

void dfs(int V, int d = 0, int P= -1){
	dist[v] = d;
	for(int u: to[V]){
		if(u== v) continue;
		dfs(u,d+1,V);
	}
}


vector<int> calDistance(int P){
	vector<int> dist(n);
	dfs(P);
	return dist;
}



int main(){
	cin >> n;
	int T,A; cin >> T >> A;

	// buh tseguudee to array ruu hiine
	rep(i,n-1){
		int a,b; cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> distFromA = calDistance(A);
	vector<int> distFromT = calDistance(T);
	int ret = 0;
	rep(i,n){
		if(distFromA[i] < distFromT[i]){
			self_max(ret,distFromT[i]-1);
		}
	}

	cout << ret << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:19:14: error: 'v' was not declared in this scope
   19 |         dist[v] = d;
      |              ^
a.cc:20:24: error: 'begin' was not declared in this scope
   20 |         for(int u: to[V]){
      |                        ^
a.cc:20:24: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:20:24: error: 'end' was not declared in this scope
   20 |         for(int u: to[V]){
      |                        ^
a.cc:20:24: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc: In function 'int main()':
a.cc:42:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   42 |                 to[a].push_back(b);
      |                       ^~~~~~~~~
a.cc:43:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   43 |                 to[b].push_back(a);
      |                       ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int n;
vector<int> to(100005);
std::vector<int> dist;

void dfs(int V, int d = 0; int P= -1){
	dist[v] = d;
	for(int u: to[V]){
		if(u== v) continue;
		dfs(u,d+1,V);
	}
}


vector<int> calDistance(int P){
	vector<int> dist(n);
	dfs(P);
	return dist;
}



int main(){
	cin >> n;
	int T,A; cin >> T >> A;

	// buh tseguudee to array ruu hiine
	rep(i,n-1){
		int a,b; cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> distFromA = calDistance(A);
	vector<int> distFromT = calDistance(T);
	int ret = 0;
	rep(i,n){
		if(distFromA[i] < distFromT[i]){
			self_max(ret,distFromT[i]-1);
		}
	}

	cout << ret << endl;
	return 0;
}

Compiler output:
a.cc:18:26: error: expected ')' before ';' token
   18 | void dfs(int V, int d = 0; int P= -1){
      |         ~                ^
      |                          )
a.cc:18:37: error: expected ',' or ';' before ')' token
   18 | void dfs(int V, int d = 0; int P= -1){
      |                                     ^
a.cc: In function 'int main()':
a.cc:42:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   42 |                 to[a].push_back(b);
      |                       ^~~~~~~~~
a.cc:43:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   43 |                 to[b].push_back(a);
      |                       ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int n;
vector<int> to(100005);
vector<int> dist;
void dfs(int v,int d = 0 , int p = -1){
	dist[v] = d;
	for(int u: to[v]){
		if (u == v) continue;
		dfs(u,d+1,v);
	}
}

vector<int> distances(int p){
	vector<int> dist(n);
	dfs(p);
	return dist;
}



int main(){
	cin >> n;
	int T,A; cin >> T >> A;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> distA = distances(A);
	vector<int> distT = distances(T);

	int ret = 0;
	rep(i,n){
		if(distA[i] < distT[i]){
			self_max(ret, distT[i]);
		}
	}
	cout << ret -1 << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:19:24: error: 'begin' was not declared in this scope
   19 |         for(int u: to[v]){
      |                        ^
a.cc:19:24: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:19:24: error: 'end' was not declared in this scope
   19 |         for(int u: to[v]){
      |                        ^
a.cc:19:24: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc: In function 'int main()':
a.cc:38:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   38 |                 to[a].push_back(b);
      |                       ^~~~~~~~~
a.cc:39:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   39 |                 to[b].push_back(a);
      |                       ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}
vector<int> dist;
void dfs(int v,int d = 0 , int p = -1){
	dist[v] = d;
	for(int u: to[v]){
		if (u == v) continue;
		dfs(u,d+1,v);
	}
}

vector<int> distances(int p){
	vector<int> dist(n);
	dfs(p);
	return dist;
}

int n;
vector<int> to(100005);
int main(){
	cin >> n;
	int T,A; cin >> T >> A;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> distA = distances(A);
	vector<int> distT = distances(T);

	int ret = 0;
	rep(i,n){
		if(distA[i] < distT[i]){
			self_max(ret, distT[i]);
		}
	}
	cout << ret -1 << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:16:20: error: 'to' was not declared in this scope; did you mean 'tm'?
   16 |         for(int u: to[v]){
      |                    ^~
      |                    tm
a.cc: In function 'std::vector<int> distances(int)':
a.cc:23:26: error: 'n' was not declared in this scope
   23 |         vector<int> dist(n);
      |                          ^
a.cc: In function 'int main()':
a.cc:35:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   35 |                 to[a].push_back(b);
      |                       ^~~~~~~~~
a.cc:36:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   36 |                 to[b].push_back(a);
      |                       ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}
vector<int> dist;
void dfs(int v,int d = 0 , int p = -1){
	dist[v] = d;
	for(int u: v){
		if (u == v) continue;
		dfs(u,d+1,v);
	}
}

vector<int> distances(int p){
	vector<int> dist(n);
	dfs(p);
	return dist;
}

int n;
vector<int> to(100005);
int main(){
	cin >> n;
	int T,A; cin >> T >> A;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> distA = distances(A);
	vector<int> distT = distances(T);

	int ret = 0;
	rep(i,n){
		if(distA[i] < distT[i]){
			self_max(ret, distT[i]);
		}
	}
	cout << ret -1 << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:16:20: error: 'begin' was not declared in this scope
   16 |         for(int u: v){
      |                    ^
a.cc:16:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:16:20: error: 'end' was not declared in this scope
   16 |         for(int u: v){
      |                    ^
a.cc:16:20: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc: In function 'std::vector<int> distances(int)':
a.cc:23:26: error: 'n' was not declared in this scope
   23 |         vector<int> dist(n);
      |                          ^
a.cc: In function 'int main()':
a.cc:35:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   35 |                 to[a].push_back(b);
      |                       ^~~~~~~~~
a.cc:36:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   36 |                 to[b].push_back(a);
      |                       ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}
vector<int> dist;
void dfs(int v,int d = 0 ; int p = -1){
	dist[v] = d;
	for(int u: v){
		if (u == v) continue;
		dfs(u,d+1,v);
	}
}

vector<int> distances(int p){
	vector<int> dist(n);
	dfs(p);
	return dist;
}

int n;
vector<int> to(100005);
int main(){
	cin >> n;
	int T,A; cin >> T >> A;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<int> distA = distances(A);
	vector<int> distT = distances(T);

	int ret = 0;
	rep(i,n){
		if(distA[i] < distT[i]){
			self_max(ret, distT[i]);
		}
	}
	cout << ret -1 << endl;

	return 0;
}

Compiler output:
a.cc:14:25: error: expected ')' before ';' token
   14 | void dfs(int v,int d = 0 ; int p = -1){
      |         ~               ^~
      |                         )
a.cc:14:38: error: expected ',' or ';' before ')' token
   14 | void dfs(int v,int d = 0 ; int p = -1){
      |                                      ^
a.cc: In function 'std::vector<int> distances(int)':
a.cc:23:26: error: 'n' was not declared in this scope
   23 |         vector<int> dist(n);
      |                          ^
a.cc: In function 'int main()':
a.cc:35:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   35 |                 to[a].push_back(b);
      |                       ^~~~~~~~~
a.cc:36:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   36 |                 to[b].push_back(a);
      |                       ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

long long gcd(long long a, long long b) {
    for(;;) {
        if(a == 0)
            return b;
        b %= a;
        if(b == 0)
            return a;
        a %= b;
    }
}

long long lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

vector<int> E[101010];
int D[101010][2]; //互いの距離
void dfs(int current, int pre, int d, int id) {
    D[cur][id] = d;
    for(auto e : E[cur]) {
        if(e != pre) {
            dfs(e, cur, d + 1, id);
        }
    }
}
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    A--;
    B--;
    REP(i, N - 1) {
        int x, y;
        cin >> x >> y;
        E[x - 1].push_back(y - 1);
        E[y - 1].push_back(x - 1);
    }
    dfs(A, A, 0, 0);
    dfs(B, B, 0, 1);
    int ma = 0;
    REP(i, N) {
        if(D[i][0] < D[i][1]) {
            //後者のほうが遠い点
            ma = max(ma, D[i][1] - 1);
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int, int)':
a.cc:55:7: error: 'cur' was not declared in this scope
   55 |     D[cur][id] = d;
      |       ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

vector<vector<int> > nodes;

void dfs(int parent, int current, int distances[], int distance = 0){
    distances[current] = distance;
    for(int to : nodes[current]){
        if( to == parent ){
            continue;
        }
        dfs(current, to, nodes, distance+1);
    }
}

int main(){
    int N, u, v;
    cin >> N >> u >> v;
    u--;
    v--;
    nodes.resize(N);
    
    rep(i, N-1){
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        nodes[from].push_back(to);
        nodes[to].push_back(from);
    }
    int distance_from_aoki[N], distance_from_takahashi[N];
    dfs(-1, u, distance_from_takahashi);
    dfs(-1, v, distance_from_aoki);

    int ans = 0;
    rep(i,N){
        if( distance_from_takahashi[i] < distance_from_aoki[i] ){
            ans = max(ans, distance_from_aoki[i] - 1);
        }
    }

    cout << ans << endl;

}

Compiler output:
a.cc: In function 'void dfs(int, int, int*, int)':
a.cc:27:26: error: cannot convert 'std::vector<std::vector<int> >' to 'int*'
   27 |         dfs(current, to, nodes, distance+1);
      |                          ^~~~~
      |                          |
      |                          std::vector<std::vector<int> >
a.cc:21:39: note:   initializing argument 3 of 'void dfs(int, int, int*, int)'
   21 | void dfs(int parent, int current, int distances[], int distance = 0){
      |                                   ~~~~^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

vector<int> get_dis(vector<vector<int>> &E,int start){
	vector<int> dis(N,Inf);
	dis[start] = 0;
	queue<int> Q;
	Q.push(start);
	
	while(Q.size()!=0){
		int from = Q.front();
		Q.pop();
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i];
			if(dis[to]!=Inf)continue;
			dis[to] = dis[from] + 1;
			Q.push(to);
		}
	}
	
	return dis;
}


int main(){
	
	int N;
	cin>>N;
	
	int u,v;
	cin>>u>>v;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	vector<int> dis_u = get_dis(E,u),dis_v = get_dis(E,v);

	int ans = 0;
	for(int i=0;i<N;i++){
		if(dis_u[i] <= dis_v[i])continue;
		ans = max(ans,dis_v[i]-1);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'std::vector<int> get_dis(std::vector<std::vector<int> >&, int)':
a.cc:8:25: error: 'N' was not declared in this scope
    8 |         vector<int> dis(N,Inf);
      |                         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int n, u, v;

int dist[2][100002];
vector<int>G[100002];

void dfs (int nod, int p, int f) {
  dist[f][nod] = d;
  for (auto it : G[nod])
    if (it != p) {
      dist[f][it] = dist[f][nod] + 1;
      dfs(it, x, f);
    }
}

int main()
{
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(u, -1, 0);
  dfs(v, -1, 1);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (dist[0][i] < dist[1][i])
      ans = max(ans, dist[1][i] - 1);
  cout << ans;
  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:11:18: error: 'd' was not declared in this scope
   11 |   dist[f][nod] = d;
      |                  ^
a.cc:15:15: error: 'x' was not declared in this scope
   15 |       dfs(it, x, f);
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const ll INF = 2e9+10;

struct edge{
    int to, next;
}G[maxn << 1];
int tot, head[maxn];
void addEdge(int u, int v){G[tot] = {v, head[u]};head[u] = tot++;};
int n, s, t, vis[2][maxn];
void dfs(int u, int fa, int x){
    for(int i = head[u];i != -1;i = G[i].next)
        if(G[i].to != fa)
            vis[x][G[i].to] = vis[x][u] + 1, dfs(G[i].to, u, x);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    cin >> n >> s >> t;
    int u, v;
    for(int i = 1;i <= n;i++)head[i] = -1;
    for(int i = 1;i < n;i++){
        cin >> u >> v;
        addEdge(u, v);
        addEdge(v, u);
    }
    dfs(s, -1, 0);
    dfs(t, -1, 1);
    for(int i = 1;i <= n;i++)
        if(vis[0][i] < vis[1][i])
            ans = max(ans, vis[1][i] - 1);        
    cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |             ans = max(ans, vis[1][i] - 1);
      |             ^~~
      |             abs
a.cc:37:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     cout << ans << "\n";
      |             ^~~
      |             abs
Language: C++

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

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> e(n + 1);
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<int> dx(n + 1), dy(n + 1);
  function<void(int, int, int, vector<int>&)> dfs = [&](int cur, int par, int i, vector<int>& d) {
    for (int nex: e[cur]) {
      if (nex == par) continue;
      dfs(nex, cur, i + 1);
    }
    d[cur] = i;
  };
  dfs(x, -1, 0, dx);
  dfs(y, -1, 0, dy);
  int res = 0;
  for(int i = 1; i <= n; i++){
    if(dy[i] < dx[i]) continue;
    res=max(res, dy[i]);
  }
  cout << (res - 1) << "\n";
  return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:19:10: error: no match for call to '(std::function<void(int, int, int, std::vector<int>&)>) (int&, int&, int)'
   19 |       dfs(nex, cur, i + 1);
      |       ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/functional:59,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/std_function.h:587:7: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {int, int, int, std::vector<int, std::allocator<int> >&}]'
  587 |       operator()(_ArgTypes... __args) const
      |       ^~~~~~~~
/usr/include/c++/14/bits/std_function.h:587:7: note:   candidate expects 4 arguments, 3 provided
Language: C++

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(const vector<vector<Edge<T>>> &edges, const int st) {

	const int V = (int)edges.size();
	const T inf = numeric_limits<T>::max() / 2;
	vector<T> cost(V, inf);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> pq;
	pq.emplace(st, cost[st]);

	while (!pq.empty()) {

		Edge<T> now(pq.top().to, pq.top().cost);
		pq.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				pq.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min cost to vertex idx from st
}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	int t, a;
	cin >> t >> a;
	t--, a--;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v, 1);
		edges[v].emplace_back(u, 1);
	}

	auto d_t = Dijkstra(edges, t);
	auto d_a = Dijkstra(edges, a);

	DMP(d_t, d_a);

	int max_d = 0;
  for(int i=0; i<N; i++) if(d_t[i] < d_a[i]) chmax(max_d, d_a[i] - 1)

	cout << max_d << "\n";

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:105:70: error: expected ';' before 'cout'
  105 |   for(int i=0; i<N; i++) if(d_t[i] < d_a[i]) chmax(max_d, d_a[i] - 1)
      |                                                                      ^
      |                                                                      ;
  106 | 
  107 |         cout << max_d << "\n";
      |         ~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
// #define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }

const int sz = 2e5+1;

void dfs(int node,int curr,bool vis[],int dis[],map<int,vector<int>>& tree){
  if(vis[node]) return;
  else{
    vis[node] = true;
    dis[node] = curr;

    for(int i=0;i<tree[node].size();i++){
      if(!vis[tree[node][i]]){
        dfs(tree[node][i],curr+1,vis,dis,tree);
      }
    }
  }
}

int32_t main(){
    
  fast;
  int n,x,y; cin >> n >> x >> y;
  map<int,vector<int>> tree;

  for(int i=1;i<=n-1;i++){
    int a,b; cin >> a >> b;
    tree[a].pb(b);
    tree[b].pb(a);
  }

  bool vis1[sz] = {false},vis2[sz]={false};
  int dis1[sz]={0},dis2[sz]={0};
  
  dfs(x,0,vis1,dis1,tree);
  dfs(y,0,vis2,dis2,tree);

  int ans = -1;

  for(int i=1;i<=n;i++){
    if(dis1[i]<dis2[i]){
      ans = max(ans,dis2[i]-1);
    }
  }
  
  cout << ans << '\n';

  return 0;
}

Compiler output:
a.cc:8: error: unterminated #ifndef
    8 | #ifndef ONLINE_JUDGE
Language: C++

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

const int N = 1e5 + 100;

int vis[2][N] ;
vector<int> G[N];

void dfs(int s , int p , int t , int dis = 0){
	vis[t][s] = dis;
  	for(auto it : G[s]){
    	if(it == p) continue;
      	dfs(it , s , t , dis+1);
    }
  	
} 

int main(){
	int n ,a , b;
  	cin >> n >> a >> b;
  	for(int i = 0;i < n-1; ++i){
    	int u , v;
      	cin >> u >> v;
      	G[u].push_back(v);
      	G[v].push_back(u);
    }
  	dfs(u , -1 , 0);
  	dfs(v , -1 , 1);
  	int ans = 0;
  	for(int i = 1;i <= n; ++i)
      ans = max(ans , vis[0][i]-vis[1][i]);
  	cout << ans << endl;
  	return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: 'u' was not declared in this scope
   27 |         dfs(u , -1 , 0);
      |             ^
a.cc:28:13: error: 'v' was not declared in this scope
   28 |         dfs(v , -1 , 1);
      |             ^
Language: C++

#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

int DFS(int i, int p, std::vector<std::set<int>> const &edge, std::vector<int> const &depth, std::vector<boost::optional<int>> &next)
{
	int max = -1;
	for (auto n : edge[i])
	{
		if (n == p)
		{
			continue;
		}
		auto r = DFS(n, i, edge, depth, next);
		if (max < r)
		{
			next[i] = n;
			max = r;
		}
	}
	return max == -1 ? depth[i] : max;
}

void Main()
{
	int N, u, v;
	std::cin >> N >> u >> v;
	--u;
	--v;
	std::vector<std::set<int>> edge(N);
	for (auto _ : boost::irange(0, N - 1))
	{
		int a, b;
		std::cin >> a >> b;
		--a;
		--b;
		edge[a].emplace(b);
		edge[b].emplace(a);
	}
	std::vector<boost::optional<int>> parent(N);
	std::vector<int> depth(N);
	std::vector<boost::optional<int>> next(N);
	boost::dynamic_bitset<> flag(N);
	std::queue<std::pair<int, int>> queue;
	queue.emplace(-1, v);
	while (queue.size())
	{
		int p, i;
		std::tie(p, i) = queue.front();
		queue.pop();
		if (flag[i])
		{
			continue;
		}
		flag[i] = true;
		if (p == -1)
		{
			depth[i] = 0;
		}
		else
		{
			depth[i] = depth[p] + 1;
			parent[i] = p;
		}
		for (auto n : edge[i])
		{
			queue.emplace(i, n);
		}
	}
	DFS(v, -1, edge, depth, next);
	auto aoki = 0;
	auto result = 0;
	while (2 < depth[u] - aoki)
	{
		u = *parent[u];
		++result;
		++aoki;
	}
	while (aoki < depth[u])
	{
		if (!next[u])
		{
			u = *parent[u];
		}
		else
		{
			u = *next[u];
		}
		if (depth[u] == aoki)
		{
			break;
		}
		else
		{
			++result;
			++aoki;
		}
	}
	lib::print::debug_range(next);
	std::cout << result << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Compiler output:
a.cc:2:10: fatal error: boost/multi_array.hpp: No such file or directory
    2 | #include <boost/multi_array.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>

int edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;

void dfs (int arr[], int start, int step) {
    arr[start] = step;
    for (int i = 1; i <= n; i++) {
        if (edges[start][i] && !arr[i]) {
            dfs(arr, i, step + 1);
        }
    }
}

int main (void) {
    scanf("%d %d %d", &n, &u, &v);
    for (int i = 1; i < n; i++) {
        scanf("%d %d", &a, &b);
        edges[a][b] = edges[b][a] = 1;
    }
    dfs(td, u, 1);
    dfs(ad, v, 1);
    for (int i = 1; i <= n; i++) {
        if (ad[i] > td[i] && ad[i] > res)
            res = ad[i];
    }

    printf("%d\n", res - 2);

    return 0;
}


Compiler output:
/tmp/ccvbmx5T.o: in function `dfs':
main.c:(.text+0x96): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccvbmx5T.o
/tmp/ccvbmx5T.o: in function `main':
main.c:(.text+0xae): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0xec): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0xf6): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0x113): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0x145): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0x14b): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccvbmx5T.o
main.c:(.text+0x198): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C

int edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;

dfs (int arr[], int start, int step) {
    arr[start] = step;
    for (int i = 1; i <= n; i++) {
        if (edges[start][i] && !arr[i]) {
            dfs(arr, i, step + 1);
        }
    }
}

main () {
    scanf("%d %d %d", &n, &u, &v);
    for (int i = 1; i < n; i++) {
        scanf("%d %d", &a, &b);
        edges[a][b] = edges[b][a] = 1;
    }
    dfs(td, u, 1);
    dfs(ad, v, 1);
    for (int i = 1; i <= n; i++) {
        if (ad[i] > td[i] && ad[i] > res)
            res = ad[i];
    }

    printf("%d\n", res - 2);
}


Compiler output:
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | dfs (int arr[], int start, int step) {
      | ^~~
main.c:12:1: error: return type defaults to 'int' [-Wimplicit-int]
   12 | main () {
      | ^~~~
main.c: In function 'main':
main.c:13:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   13 |     scanf("%d %d %d", &n, &u, &v);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;
main.c:13:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   13 |     scanf("%d %d %d", &n, &u, &v);
      |     ^~~~~
main.c:13:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:25:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   25 |     printf("%d\n", res - 2);
      |     ^~~~~~
main.c:25:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:25:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:25:5: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C++

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

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  vector<vector<int>> t(n);
  for(int i = 0; i < n - 1; ++i){
    int a, b;
    cin >> a >> b;
    t[a-1].push_back(b-1);
    t[b-1].push_back(a-1);
  }
  
  vector<int> du(n, 100000000);
  du[u-1] = 0;
  queue<int> qu;
  qu.push(u-1);
  while(!qu.empty()){
    int tmp = qu.front();
    qu.pop();
    for(int i: t[tmp]){
      if(du[i] > du[tmp] + 1){
        du[i] = du[tmp] + 1;
        qu.push(i);
    }
  }

  vector<int> dv(n, 100000000);
  dv[v-1] = 0;
  queue<int> qv;
  qv.push(v-1);
  while(!qv.empty()){
    int tmp = qv.front();
    qv.pop();
    for(int i: t[tmp]){
      if(dv[i] > dv[tmp]){
        dv[i] = dv[tmp] + 1;
        qv.push(i);
    }
  }

  int r = 0;
  for(int i = 0; i < n; ++i){
    if(du[i] > dv[i]) continue;
    else r = max(r, du[i]);
  }
  cout << r << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:2: error: expected '}' at end of input
   49 | }
      |  ^
a.cc:19:21: note: to match this '{'
   19 |   while(!qu.empty()){
      |                     ^
a.cc:49:2: error: expected '}' at end of input
   49 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

vector<int> G[100'010];
vector<int> lat(100'010, -1);
vector<int> upre(100'010, -1);
vector<int> udist(100'010, -1);
vector<int> vpre(100'010, -1);
vector<int> vdist(100'010, -1);
void udfs(int v){
  for(int nv:G[v]){
    if(nv == upre[v]){
      continue;
    }
    udist[nv] = udist[v] + 1;
    upre[nv] = v;
    udfs(nv);
    lat[v] = nv; 
  }
  return;
}
void vdfs(int v){
  for(int nv:G[v]){
    if(nv == vpre[v]){
      continue;
    }
    vdist[nv] = vdist[v] + 1;
    vpre[nv] = v;
    vdfs(nv);
    //lat[v] = nv; 
  }
  return;
}
    
int main(){
  
  int n,u,v;
  cin>>n>>u>>v;
  u--;v--;
  int a[n-1],b[n-1];
  REP(i,n-1){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  udist[u] = 0;
  udfs(u);
  vdist[v] = 0;
  vdfs(v);
  
  vector<int> endn;
  REP(i,n){
    if(lat[i] < 0){
      endn.push_back(i);
    }
  }
  int m = endn.size();//ブランチの数
  int ans = 0;
  REP(i,m){
    if(udist[end[i]] >= vdist[endn[i]])continue;
    ans = max(ans, vdist[endn[i]]-1);
  }
  cout<<ans<<endl;
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:122:17: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  122 |     if(udist[end[i]] >= vdist[endn[i]])continue;
      |                 ^
Language: C++

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

class Dijkstra {
public:
    struct edge { long long v, dist; };

    struct state {
        long long v, cost;
        bool operator>(const state s) const { return cost > s.cost; }
    };

    const long long INF = (1LL << 60);
    long long N;
    vector< vector<edge> > E;

    Dijkstra(long long n): N(n), E(n) {}

    //有効グラフの時はこっち。u→vに距離dで結ぶ
    void add_directed_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
    }

    //無向グラフの時はこっち。uとvを双方向に距離dで結ぶ
    void add_undirected_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
        E[v].push_back((edge) { u, d });
    }

    //Sを始点として、他の頂点への最短経路を探す
    vector<long long> shortest_path(long long S) {
        vector<long long> dp(E.size(), INF);
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        while(!q.empty()) {
            long long v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v] <= cost) continue;
            dp[v] = cost;
            for(int i=0;i < E[v].size() ; i++) {
            long long nv = E[v][i].v, ncost = cost + E[v][i].dist;
            if(dp[nv] > ncost) q.push((state) { nv, ncost });
            }
        }
        return dp;
    }
};


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,s,t;
    cin>>n>>s>>t;
    s--,t--;
    Dijkstra dij(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        dij.add_undirected_edge(a,b,1);
    }

    vector<ll> sd = dij.shortest_path(s);
    vector<ll> td = dij.shortest_path(t);
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(sd[i] < td[i]){
            ans = max(ans, td[p]-1);
        }
    }
    cout << ans << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:31: error: 'p' was not declared in this scope
   72 |             ans = max(ans, td[p]-1);
      |                               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }
const int INF = 0x3fffffff;

vector<int> dist(const vector<vector<int>>& g, int s){
  vector<int> d(g.size(), INF);
  queue<int> q;
  d[s] = 0;
  q.push(s);
  while(q.size()){
    int at = q.front();
    q.pop();
    for(int i : at) if(chmin(d[i], d[at] + 1)) q.push(i);
  }
  return d;
}
int main(){
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  vector<vector<int>> g(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);
  }
  vector<int> d_taka = dist(g, u), d_aoki = dist(g, v);
  int ans = 0;
  for(int i = 0; i < n; i++) if(d_taka[i] < d_aoki[i]) chmax(ans, d_aoki[i] - 1);
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'std::vector<int> dist(const std::vector<std::vector<int> >&, int)':
a.cc:15:17: error: 'begin' was not declared in this scope
   15 |     for(int i : at) if(chmin(d[i], d[at] + 1)) q.push(i);
      |                 ^~
a.cc:15:17: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:15:17: error: 'end' was not declared in this scope
   15 |     for(int i : at) if(chmin(d[i], d[at] + 1)) q.push(i);
      |                 ^~
a.cc:15:17: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
template<class T> chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T> chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }
const int INF = 0x3fffffff;

vector<int> dist(const vector<vector<int>>& g, int s){
  vector<int> d(g.size(), INF);
  queue<int> q;
  d[s] = 0;
  q.push(s);
  while(q.size()){
    int at = q.front();
    q.pop();
    for(int i : at) if(chmin(d[i], d[at] + 1)) q.push(i);
  }
  return d;
}
int main(){
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  vector<vector<int>> g(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);
  }
  vector<int> d_taka = dist(g, u), d_aoki = dist(g, v);
  int ans = 0;
  for(int i = 0; i < n; i++) if(d_taka[i] < d_aoki[i]) chmax(ans, d_aoki[i] - 1);
  cout << ans << endl;
}

Compiler output:
a.cc:3:19: error: ISO C++ forbids declaration of 'chmin' with no type [-fpermissive]
    3 | template<class T> chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }
      |                   ^~~~~
a.cc:4:19: error: ISO C++ forbids declaration of 'chmax' with no type [-fpermissive]
    4 | template<class T> chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }
      |                   ^~~~~
a.cc: In function 'std::vector<int> dist(const std::vector<std::vector<int> >&, int)':
a.cc:15:17: error: 'begin' was not declared in this scope
   15 |     for(int i : at) if(chmin(d[i], d[at] + 1)) q.push(i);
      |                 ^~
a.cc:15:17: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:15:17: error: 'end' was not declared in this scope
   15 |     for(int i : at) if(chmin(d[i], d[at] + 1)) q.push(i);
      |                 ^~
a.cc:15:17: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool used[100005];
vector<ll> node[100005];
ll T_dis[100005]={0},A_dis[100005]={0};
void dfs_T(ll pos,ll dis){
  T_dis[pos]=dis;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs_T(to,dis+1);
    }
  }
}
void dfs_A(ll pos,ll dis){
  A_dis[pos]=dis;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs_A(to,dis+1);
    }
  }
}
int main(){
  ll n,u,v;
  cin>>n>>u>>v;
  for(int i=1;i<n;i++){
    ll a,b;
    cin>>a>>b;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  for(int i=0;i<=n;i++) used[i]=false;
  used[u]=true;
  dfs_T(u,0);
  for(int i=0;i<=n;i++) used[i]=false;
  used[v]=true;
  dfs_A(v,0);
  for(int i=0;i<=n;i++) used[i]=false;
  used[u]=true;
  dfs_G(u);
  ll ans=17441744;
  for(int i=1;i<=n;i++){
    if(T_dis[i]<A_dis[i]) ans=min(ans,A_dis[i]);
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:3: error: 'dfs_G' was not declared in this scope; did you mean 'dfs_T'?
   44 |   dfs_G(u);
      |   ^~~~~
      |   dfs_T
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool used[100005];
vector<ll> node[100005];
ll T_dis[100005]={0},A_dis[100005]={0};
void dfs_T(ll pos,ll dis){
  T_dis[pos]=dis;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs_T(to,dis+1);
    }
  }
}
void dfs_A(ll pos,ll dis){
  A_dis[pos]=dis;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs_A(to,dis+1);
    }
  }
}
int main(){
  ll n,u,v;
  cin>>n>>u>>v;
  for(int i=1;i<n;i++){
    ll a,b;
    cin>>a>>b;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  for(int i=0;i<=n;i++) used[i]=false;
  used[u]=true;
  dfs_T(u,0);
  for(int i=0;i<=n;i++) used[i]=false;
  used[v]=true;
  dfs_A(v,0);
  for(int i=0;i<=n;i++) used[i]=false;
  used[u]=true;
  dfs_G(u);
  ll ans=17441744;
  for(int i=1;i<=n;i++){
    if(T_dis[i]<A_dis[i]) ans=min(ans,A_dis[i]);
  }
  cout<<ans-1<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:3: error: 'dfs_G' was not declared in this scope; did you mean 'dfs_T'?
   44 |   dfs_G(u);
      |   ^~~~~
      |   dfs_T
Language: C++

int main() {
   int N,u,v;
   cin>>N>>u>>v;
   int A[N-1],B[N-1];
   for(int i=0;i<N-1;i++){
       cin>>A[i]>>B[i];
   }
  cout<<0<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:4: error: 'cin' was not declared in this scope
    3 |    cin>>N>>u>>v;
      |    ^~~
a.cc:8:3: error: 'cout' was not declared in this scope
    8 |   cout<<0<<endl;
      |   ^~~~
a.cc:8:12: error: 'endl' was not declared in this scope
    8 |   cout<<0<<endl;
      |            ^~~~