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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, q, k, a, b, c;
vector<P> es[100000];
ll d[100000];

void dfs(int v, int pa, ll x) {
	d[v] = x;
	REP(i, es[v].size()) if (es[v][i].F != pa) dfs(es[v][i].F, v, x + es[v][i].S);
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) {
		cin >> a >> b >> c;
		--a; --b;
		es[a].push_back(MP(b, c));
		es[b].push_back(MP(a, c));
	}
	cin >> q >> k;
	dfs(k, -1, 0);
	REP(i, q) {
		cin >> x >> y;
		--x; --y;
		cout << (d[x] + d[y]) << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:45:24: error: 'x' was not declared in this scope
   45 |                 cin >> x >> y;
      |                        ^
a.cc:45:29: error: 'y' was not declared in this scope
   45 |                 cin >> x >> y;
      |                             ^
Language: C++

#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<int, ll> pil;
typedef vector<pil> vpil;

vector<vpil> adj;
vector<ll> d;

void dfs(int x) {
	for(auto e:adj[x]) if(d[e.first]==-1) {
		d[e.first]=d[x]+e.second;
		dfs(e.first);
	}
}

int main() {
	int i, k, q, n, u, v;
	ll w;
	scanf("%d", &n);
	adj.assign(n+1, vpil(0));
	for(i=0; i<n-1; i++) {
		scanf("%d%d%lld", &u, &v, &w);
		adj[u].push_back(pil(v, w));
		adj[v].push_back(pil(u, w));
	}
	d.assign(n+1, -1);
	scanf("%d%d", &q, &k);
	d[k]=0;
	dfs(k);
	for(; q; q--) {
		scanf("%d%d", &u, &v);
		printf("%lld\n", d[u]+d[v]);
	}
	return 0;
}

Compiler output:
a.cc:7:9: error: 'vector' does not name a type
    7 | typedef vector<pil> vpil;
      |         ^~~~~~
a.cc:9:1: error: 'vector' does not name a type
    9 | vector<vpil> adj;
      | ^~~~~~
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<ll> d;
      | ^~~~~~
a.cc: In function 'void dfs(int)':
a.cc:13:20: error: 'adj' was not declared in this scope
   13 |         for(auto e:adj[x]) if(d[e.first]==-1) {
      |                    ^~~
a.cc:13:31: error: 'd' was not declared in this scope
   13 |         for(auto e:adj[x]) if(d[e.first]==-1) {
      |                               ^
a.cc: In function 'int main()':
a.cc:23:9: error: 'adj' was not declared in this scope
   23 |         adj.assign(n+1, vpil(0));
      |         ^~~
a.cc:23:25: error: 'vpil' was not declared in this scope; did you mean 'pil'?
   23 |         adj.assign(n+1, vpil(0));
      |                         ^~~~
      |                         pil
a.cc:29:9: error: 'd' was not declared in this scope
   29 |         d.assign(n+1, -1);
      |         ^
Language: C++

10
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
5 6 1000000000
6 7 1000000000
7 8 1000000000
8 9 1000000000
9 10 1000000000
1 1
9 10

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 10
      | ^~
Language: C

#define _CRT_SECURE_NO_WARNINGS
#include <iostream> 
#include <stdio.h> 
#include <string>
#include <string.h>
#include <stdlib.h> 
#include <math.h> 
#include <queue> 
#include <stack> 
#include <map> 
#include <vector> 
#include <algorithm>
#define inf 1000000000000000000
#define MAX 100010
#define M 1010
#define ll long long
using namespace std;
ll mp[M][M];
ll dist[M];
int p[M];
int c[MAX];
int main()
{
    int n,m,o,x,y,z;
    scanf("%d",&n);
    memset(p,0,sizeof(p));
	memset(c,0,sizeof(c));
    for (int i = 0; i < M; i++)
    {
        dist[i]=inf;
        for (int j = 0; j < M; j++)
        {
            mp[i][j]=inf;
        }
    }
	int ic=1;
    for (int i = 1; i < n; i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        if(c[x]==0)c[x]=ic++;
		if(c[y]==0)c[y]=ic++;
		if(mp[c[x]][c[y]]>z)mp[c[x]][c[y]]=mp[c[y]][c[x]]=z;
    }
    scanf("%d%d",&m,&o);
    int point=c[o],iMIN;
	ll MIN;
    dist[c[o]]=0;
    for (int i = 1; i < ic; i++)
    {
		if(i==c[o])continue;
        MIN=inf+1;iMIN=0;
        for (int j = 1; j < ic; j++)
        {
			if(j==c[o])continue;
            if(p[j]==0)
            {
				dist[j]=min(dist[point]+mp[point][j],dist[j]);
                if(MIN>dist[j]){MIN=dist[j];iMIN=j;}
            }
        }
        point=iMIN;
        p[point]=1;
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d",&x,&y);
        if(x==o&&y==o)printf("0\n");
        else if(x==o)printf("%lld\n",dist[c[y]]);
        else if(y==o)printf("%lld\n",dist[c[x]]);
        else printf("%lld\n",dist[c[x]]+dist[c[y]]);
    }
    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Edge {
  int to, cost;
};

int N, Q, K;
vector<Edge> d[100000];
ll v[100000];

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

  cin >> N;
  for (int i = 1; i < N; i++) {
    int a, b, c;
    --a, --b;
    d[a].emplace_back((edge) {b, c});
    d[b].emplace_back((edge) {a, c});
  }
  cin >> Q >> K;
  dfs(--N);
  while (Q--) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    cout << v[x] + v[y] << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: 'edge' was not declared in this scope; did you mean 'Edge'?
   23 |     d[a].emplace_back((edge) {b, c});
      |                        ^~~~
      |                        Edge
a.cc:24:29: error: expected ')' before '{' token
   24 |     d[b].emplace_back((edge) {a, c});
      |                      ~      ^~
      |                             )
a.cc:27:3: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   27 |   dfs(--N);
      |   ^~~
      |   ffs
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Edge {
  int to, cost;
}

int N, Q, K;
vector<Edge> d[100000];
ll v[100000];

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

  cin >> N;
  for (int i = 1; i < N; i++) {
    int a, b, c;
    --a, --b;
    d[a].emplace_back((edge) {b, c});
    d[b].emplace_back((edge) {a, c});
  }
  cin >> Q >> K;
  dfs(--N);
  while (Q--) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    cout << v[x] + v[y] << endl;
  }
  
  return 0;
}


Compiler output:
a.cc:9:2: error: expected ';' after struct definition
    9 | }
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:23:24: error: 'edge' was not declared in this scope; did you mean 'Edge'?
   23 |     d[a].emplace_back((edge) {b, c});
      |                        ^~~~
      |                        Edge
a.cc:24:29: error: expected ')' before '{' token
   24 |     d[b].emplace_back((edge) {a, c});
      |                      ~      ^~
      |                             )
a.cc:27:3: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   27 |   dfs(--N);
      |   ^~~
      |   ffs
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define REP(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,q,k;
vector<P>edge[100005];
ll cheat[100005];
void dfs(int v,int u,ll sum){
	cheat[v] = sum;
	REP(i,edge[v].size()){
		if(edge[v][i].fi == u) continue;
		dfs(edge[v][i].fi,v,sum+edge[v][i].sc);
	}	
}
int main(){
	cin >> n
	REP(i,n-1){
		int a,b,c; scanf("%d%d%d",&a,&b,&c);
		edge[a].pb(mp(b,c));
		edge[b].pb(mp(a,c));
	}
	cin >> q >> k;
	dfs(k,-1,0LL)
	REP(i,q){
		cin >> a >> b;
		cout << cheat[a]+cheat[b];
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: expected ';' before 'for'
   30 |         cin >> n
      |                 ^
      |                 ;
a.cc:31:13: error: 'i' was not declared in this scope
   31 |         REP(i,n-1){
      |             ^
a.cc:14:30: note: in definition of macro 'REP'
   14 | #define REP(i,x) for(int i=0;i<x;i++)
      |                              ^
a.cc:37:22: error: expected ';' before 'for'
   37 |         dfs(k,-1,0LL)
      |                      ^
      |                      ;
Language: C++

import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static List <Edge>G[];
    static int n, q, k, x[], y[];
    static long path[];
    static boolean used[];

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        G = new List[n];
        used = new boolean[n];
        path = new long[n];
        for(int i = 0;i < n;i++)G[i] = new LinkedList<>();
        for(int i = 0;i < n-1;i++){
            int a, b, c;
            a = scan.nextInt();
            b = scan.nextInt();
            c = scan.nextInt();
            G[a-1].add(new Edge(b-1, c));
            G[b-1].add(new Edge(a-1, c));
        }
        q = scan.nextInt();
        k = scan.nextInt();
        x = new int[q];  y = new int[q];
        for(int i = 0;i < q;i++){
            x[i] = scan.nextInt();
            y[i] = scan.nextInt();
        }
        used[k-1] = true;
        search(k-1);

        /*for(int i = 0;i < n;i++){
            System.out.println(k+"番目から"+(i+1)+"番目までのコストは"+path[i]+"である");
        }*/
        for(int i = 0;i < q;i++){
            long ans = path[x[i]-1]+path[y[i]-1];
            System.out.println(ans);
        }
    }

    static void search(int v){
        for(int i = 0;i < G[v].size();i++){
            Edge e = G[v].get(i);
            if(!used[e.to]){
                path[e.to] = path[v] + e.cost;
                used[e.to] = true;
                search(e.to);
            }
        }
        return;
    }
}

class Edge{
    int to;
    int cost;

    Edge(int to, int cost){
        this.to = to;
        this.cost = cost;
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.LinkedList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.List;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
a.cc:66:2: error: expected ';' after class definition
   66 | }
      |  ^
      |  ;
a.cc: In constructor 'Edge::Edge(int, int)':
a.cc:63:14: error: request for member 'to' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
   63 |         this.to = to;
      |              ^~
a.cc:64:14: error: request for member 'cost' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
   64 |         this.cost = cost;
      |              ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

bool gone[100010];
ll iku[100010];

void dfs(int s)
{
	rep(i, e[s].size())
	{
		int t=e[s][i].first;
		ll w=(ll) e[s][i].second;
		if(gone[t]==0)
		{
			gone[t]=1;
			iku[t]=iku[s]+w;
			dfs(t);
		}
	}
}

int main()
{
	int n;
	cin >> n;
	vector<pai> e[100010];
	int a, b, c;
	rep(i, n-1)
	{
		cin >> a >> b >> c;
		e[a].push_back(pai(b, c));
		e[b].push_back(pai(a, c));
	}
	int q, k;
	cin >> q >> k;
	gone[k]=1;
	dfs(k);
	int x, y;
	rep(i, q)
	{
		cin >> x >> y;
		cout << (iku[x]+iku[y]) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:18:16: error: 'e' was not declared in this scope
   18 |         rep(i, e[s].size())
      |                ^
a.cc:2:37: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i = 0; i < n; i++)
      |                                     ^
Language: C++

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

const int N   = 3e5+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

int fre(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}

inline int read(){
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||'9'<ch;ch=getchar())if(ch=='-') f=-1;
	for(;'0'<=ch&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}

#define lal puts("****");
#define pb  push_back
#define mp  make_pair
#define x   first
#define y   second

/*****************************************************************/

struct edge{
    int to,next,w;
}G[N<<1];
int head[N],tot;
void add(int u,int v,int w){
    G[tot].w=w,G[tot].to=v,G[tot].next=head[u],head[u]=tot++;
    G[tot].w=w,G[tot].to=u,G[tot].next=head[v],head[v]=tot++;
}

LL dp[N];

void dfs(int u,int f,LL w){
    dp[u]=w;
    for(int i=head[u],to;i!=-1;i=G[i].next){
        to = G[i].to;
        if(to == f) continue;
        dfs(to,u,w+G[i].w);
    }
}

int n,q,k;

int main(){
    memset(head,-1,sizeof(head));tot=0;
    scanf("%d",&n);
    for(int i=2,u,v,w;i<=n;i++){
        scanf("%d %d %d",&u,&v,&w);
        add(u,v,w);
    }
    // lal
    scanf("%d%d",&q,&k)
    dfs(k,0,0);
    for(int i=1;i<=n;i++)
        printf("%d <--\n", dp[i]);
    
    for(int x,y;q--;){
        scanf("%d%d",&x,&y);
        printf("%lld\n", dp[x]+dp[y]);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int fre()':
a.cc:12:1: warning: no return statement in function returning non-void [-Wreturn-type]
   12 | }
      | ^
a.cc: In function 'int main()':
a.cc:59:24: error: expected ';' before 'dfs'
   59 |     scanf("%d%d",&q,&k)
      |                        ^
      |                        ;
   60 |     dfs(k,0,0);
      |     ~~~
Language: C++

#include <bits/stdc++.h>
#define mem(a) memset(a,0,sizeof(a))
#define N 100010
#define ll long long int
using namespace std;
ll an[N];
struct Node{
  int to;
  ll cost;
};
vector<Node> v[N];
void dfs(int x,int fa){
  for(int i=0;i<v[x].size();i++){
    if(v[x][i].to==fa)
      continue;
    an[v[x][i].to]=an[x]+v[x][i].cost;
    dfs(v[x][i].to,x);
  }
}
int main(){
  int n;
  scanf("%d", &n);
  int x,y;
  ll z;
  for(int i=1;i<n;i++){
    scanf("%d%d%lld",&x,&y,&z);
    v[x].push_back(pair<y,z>);
    v[y].push_back(pair<x,z>);
  }
  int q,t;
  scanf("%d%d",&q,&t);
  dfs(t,-1);
  while(q--){
    scanf("%d%d",&x,&y);
    printf("%lld\n",an[x]+an[y]);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:28: error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
   27 |     v[x].push_back(pair<y,z>);
      |                            ^
a.cc:27:28: note:   expected a type, got 'y'
a.cc:27:28: error: type/value mismatch at argument 2 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
a.cc:27:28: note:   expected a type, got 'z'
a.cc:28:28: error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
   28 |     v[y].push_back(pair<x,z>);
      |                            ^
a.cc:28:28: note:   expected a type, got 'x'
a.cc:28:28: error: type/value mismatch at argument 2 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
a.cc:28:28: note:   expected a type, got 'z'
Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;

const int N = 1e5 + 1;

struct edge
{
	int to, w;
};

vector<edge> G[N];
LL d[N];

void dfs(int v, int p)
{
	for (edge id : G[v])
    	if (id.to != p)
        {
        	d[id.to] = d[v] + id.w;
          	dfs(id.to, v);
        }
}

int main()
{
	int n, a, b, c, q, k;
  	cin >> n;
  	for (int i = 1; i < n; ++i)
    {
    	cin >> a >> b >> c;
      	G[a].push_bach({b, c});
      	G[b].push_bach({a, c});
    }
  	cin >> q >> k;
  	dfs(k, 0);
  	for (int i = 0; i < q; ++i)
    {
    	cin >> a >> b;
     	cout << d[a] + d[b] << '\n';
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: 'class std::vector<edge>' has no member named 'push_bach'; did you mean 'push_back'?
   33 |         G[a].push_bach({b, c});
      |              ^~~~~~~~~
      |              push_back
a.cc:34:14: error: 'class std::vector<edge>' has no member named 'push_bach'; did you mean 'push_back'?
   34 |         G[b].push_bach({a, c});
      |              ^~~~~~~~~
      |              push_back
Language: Java

import java.util.*;

public class Main {
  static long[] depth;
  static ArrayList[] edge;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    edge = new ArrayList[n];
    for(int i = 0; i < n; i++) {
      edge[i] = new ArrayList<Edge>();
    }
    for(int i = 0; i < n - 1; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      long c = sc.nextLong();
      Edge e1 = new Edge(b, c);
      Edge e2 = new Edge(a, c);
      edge[a].add(e1);
      edge[b].add(e2); 
    }
    int Q = sc.nextInt();
    int K = sc.nextInt() - 1;
    dfs(K, -1, 0);
    for(int i = 0; i < Q; i++) {
      int x = sc.nextInt() - 1;
      int y = sc.nextInt() - 1;
      System.out.println(depth[x] + depth[y]);
    }
  }

  public static void dfs(int v, int parent, long depth) {
    depth[v] = depth;
    ArrayList<Edge> elist = edge[v];
    for(int i = 0; i < elist.size(); i++) {
      Edge e = elist.get(i);
      if(e.to != parent) dfs(e.to, v, e.cost + depth[v]); 
    } 
  }
}

class Edge {
  int to;
  long cost;
  Edge(int to, long cost) {
    this.to = to;
    this.cost = cost;
  }
}

Compiler output:
Main.java:34: error: array required, but long found
    depth[v] = depth;
         ^
Main.java:38: error: array required, but long found
      if(e.to != parent) dfs(e.to, v, e.cost + depth[v]); 
                                                    ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: C++

#include<iostream>
#include<vector>

using ll = long long;
const int limit = 100010;
using edge = struct{int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

int main(void) {
	int n;
	cin >> n;

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

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		cout << depth[x] + depth[y] << endl;
	}
	return 0;
}


Compiler output:
a.cc:7:1: error: 'vector' does not name a type
    7 | vector<edge> tree[limit];
      | ^~~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:12:24: error: 'tree' was not declared in this scope; did you mean 'free'?
   12 |         for (auto &e : tree[v]) {
      |                        ^~~~
      |                        free
a.cc: In function 'int main()':
a.cc:20:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   20 |         cin >> n;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:26:17: error: 'tree' was not declared in this scope; did you mean 'free'?
   26 |                 tree[a].push_back({b, c});
      |                 ^~~~
      |                 free
a.cc:39:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   39 |                 cout << depth[x] + depth[y] << endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:39:48: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   39 |                 cout << depth[x] + depth[y] << endl;
      |                                                ^~~~
      |                                                std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

using ll = long long;
const int limit = 100010;
using edge = struct{int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

int main(void) {
	int n;
	cin >> n;

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

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		cout << depth[x] + depth[y] << endl;
	}
	return 0;
}


Compiler output:
a.cc:4:1: error: 'vector' does not name a type
    4 | vector<edge> tree[limit];
      | ^~~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:9:24: error: 'tree' was not declared in this scope
    9 |         for (auto &e : tree[v]) {
      |                        ^~~~
a.cc: In function 'int main()':
a.cc:17:9: error: 'cin' was not declared in this scope
   17 |         cin >> n;
      |         ^~~
a.cc:23:17: error: 'tree' was not declared in this scope
   23 |                 tree[a].push_back({b, c});
      |                 ^~~~
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout << depth[x] + depth[y] << endl;
      |                 ^~~~
a.cc:36:48: error: 'endl' was not declared in this scope
   36 |                 cout << depth[x] + depth[y] << endl;
      |                                                ^~~~
Language: C++

using ll = long long;
cons int limit = 100010;
using edge = struct{int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

int main(void) {
	int n;
	cin >> n;

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

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		cout << depth[x] + depth[y] << endl;
	}
	return 0;
}


Compiler output:
a.cc:2:1: error: 'cons' does not name a type; did you mean 'const'?
    2 | cons int limit = 100010;
      | ^~~~
      | const
a.cc:4:1: error: 'vector' does not name a type
    4 | vector<edge> tree[limit];
      | ^~~~~~
a.cc:5:10: error: 'limit' was not declared in this scope
    5 | ll depth[limit];
      |          ^~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:8:9: error: 'depth' was not declared in this scope
    8 |         depth[v] = d;
      |         ^~~~~
a.cc:9:24: error: 'tree' was not declared in this scope
    9 |         for (auto &e : tree[v]) {
      |                        ^~~~
a.cc: In function 'int main()':
a.cc:17:9: error: 'cin' was not declared in this scope
   17 |         cin >> n;
      |         ^~~
a.cc:23:17: error: 'tree' was not declared in this scope
   23 |                 tree[a].push_back({b, c});
      |                 ^~~~
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout << depth[x] + depth[y] << endl;
      |                 ^~~~
a.cc:36:25: error: 'depth' was not declared in this scope
   36 |                 cout << depth[x] + depth[y] << endl;
      |                         ^~~~~
a.cc:36:48: error: 'endl' was not declared in this scope
   36 |                 cout << depth[x] + depth[y] << endl;
      |                                                ^~~~
Language: Java

import java.io.*;
import java.util.*;

class A {
    static class Pair {
        int to;
        long w;
        Pair(int t, long wt) {
            to = t;
            w = wt;
        }
    }
    static long[] depth;
    static ArrayList<Pair>[] v;
    static boolean[] visited;
    public static void main(String[] args) {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        depth = new long[n];
        v = new ArrayList[n];
        visited = new boolean[n];
        for (int i = 0; i < n; i++) v[i] = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            long w = in.nextLong();
            v[x].add(new Pair(y, w));
            v[y].add(new Pair(x, w));
        }
        int q = in.nextInt();
        int k = in.nextInt() - 1;
        dfs(k, -1, 0);
        for (int i = 0; i < q; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            out.println(depth[x] + depth[y]);
        }
        out.close();
    }

    static void dfs(int source, int parent, long d) {
        visited[source] = true;
        depth[source] = d;
        for (Pair a : v[source]) {
            if (!visited[a.to]) {
                dfs(a.to, source, d + a.w);
            }
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}



Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

class A {
    static class Pair {
        int to;
        long w;
        Pair(int t, long wt) {
            to = t;
            w = wt;
        }
    }
    static long[] depth;
    static ArrayList<Pair>[] v;
    static boolean[] visited;
    public static void main(String[] args) {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        depth = new long[n];
        v = new ArrayList[n];
        visited = new boolean[n];
        for (int i = 0; i < n; i++) v[i] = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            long w = in.nextLong();
            v[x].add(new Pair(y, w));
            v[y].add(new Pair(x, w));
        }
        int q = in.nextInt();
        int k = in.nextInt() - 1;
        dfs(k, -1, 0);
        for (int i = 0; i < q; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            out.println(depth[x] + depth[y]);
        }
        out.close();
    }

    private static void dfs(int source, int parent, long d) {
        visited[source] = true;
        depth[source] = d;
        for (Pair a : v[source]) {
            if (!visited[a.to]) {
                dfs(a.to, source, d + a.w);
            }
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}



Compiler output:
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class A {
    static class Pair {
        int to;
        long w;
        Pair(int t, long wt) {
            to = t;
            w = wt;
        }
    }
    static long[] depth;
    static ArrayList<Pair>[] v;
    static boolean[] visited;
    public static void main(String[] args) {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        depth = new long[n];
        v = new ArrayList[n];
        visited = new boolean[n];
        for (int i = 0; i < n; i++) v[i] = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            long w = in.nextLong();
            v[x].add(new Pair(y, w));
            v[y].add(new Pair(x, w));
        }
        int q = in.nextInt();
        int k = in.nextInt() - 1;
        dfs(k, -1, 0);
        for (int i = 0; i < q; i++) {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            out.println(depth[x] + depth[y]);
        }
        out.close();
    }

    private static void dfs(int source, int parent, long d) {
        visited[source] = true;
        depth[source] = d;
        for (Pair a : v[source]) {
            if (!visited[a.to]) {
                dfs(a.to, source, d + a.w);
            }
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}



Compiler output:
Main.java:8: error: class A is public, should be declared in a file named A.java
public class A {
       ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++

#include<iostream>

using namespace std;
 


//long long fa[10005],w[10000];

struct edge{
	long long to;
	long long next;
	long long w;
	//edge():to(-1),next(-1),w(-1){	};
	 
}e[10005];

long long v[10005],tote=1;
long long fa[10005],depth[10005],s[10005];
long long addedge(long long from,long long to,long long weight){
	e[tote].next=v[from];
	e[tote].to=to;
	e[tote].w=weight;
	v[from]=tote;
	tote++;
	
}
long long init(long long root,long long dep){
	long long t=v[root];
	depth[root]=dep;
	while(e[t].to==fa[root]) t=e[t].next;
	while(t){
		if(e[t].to!=fa[root]){
			fa[e[t].to]=root;
			s[e[t].to]=s[root]+e[t].w;
			init(e[t].to,dep+1);	
		}
		t=e[t].next; 
	}
}
long long lca(long long a,long long b){
	long long p1=a,p2=b;
	long long j1,j2;
	if(depth[a]>depth[b]){
		j1=a;j2=b;
	}else j1=b,j2=a;
			
			//get to the same depth
			while(depth[j1]!=depth[j2]){
				j1=fa[j1];
			}
			while(j1!=j2){
				j1=fa[j1];
				j2=fa[j2];
			}
			long long lca=j1;
			return s[p1]-s[lca]+s[p2]-s[lca];
}


long long main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long n;
	cin>>n;
	n--;
	while(n--){
		long long a,b,c;
		cin>>a>>b>>c;
		addedge(a,b,c); 
		addedge(b,a,c);
	}

	init(1,0);//root,depth

	
	long long k;
	cin>>n>>k;
	while(n--){
		long long a,b;
		cin>>a>>b;
		cout<<lca(a,k)+lca(b,k)<<endl;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'long long int addedge(long long int, long long int, long long int)':
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
a.cc: In function 'long long int init(long long int, long long int)':
a.cc:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | }
      | ^
At global scope:
cc1plus: error: '::main' must return 'int'
Language: Java

import java.util.*;
public class Main {

    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int a[] = new int[N-1];
	int b[] = new int[N-1];
	int c[] = new int[N-1];
	int Q, K;
	int i;
	int s, t;
	long ans;
	
	for(i=0;i<N-1; i++){
	    a[i] = sc.nextInt()-1;
	    b[i] = sc.nextInt()-1;
	    c[i] = sc.nextInt();
	}
	Q = sc.nextInt();
	K = sc.nextInt();
	K -= 1;

        long d[] = new long[N];
	int prev[] = new int[N];
	Set<Integer> vert = new HashSet<>();
	for(i=0;i<N;i++){
	    vert.add(i);
	    d[i] = -1;
	    prev[i] = -1;
	}
	d[K] = 0;
	while(!(vert.isEmpty())){
	    long min = -1;
	    int j = -1;
	    for(int v : vert){
		if(min == -1 || d[v] < min){
		    min = d[v];
		    j = v;
		}
	    }
	    vert.remove(j);
	    for(i = 0; i<N-1; i++){
		if(a[i] == j){
		    if(d[b[i]] == -1 || d[b[i]] > d[j] + c[i]){
			d[b[i]] = d[j] + c[i];
			prev[b[i]] = j;
		    }
		}else if(b[i] == j){
		    if(d[a[i]] == -1 || d[a[i]] > d[j] + c[i]){
			d[a[i]] = d[j] + c[i];
			prev[a[i]] = j;
		    }
		}
	    }

Compiler output:
Main.java:55: error: reached end of file while parsing
	    }
	     ^
1 error
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool _check[n+1];
ll dp[n+1][n+1];


int main()
{
	ll n;
	cin >> n;
	
	
	REP(i,n+1)
	{
		_check[i] = false;
	}
	
	iiv v(n+1);
	
	
	REP(i,n-1)
	{
		int a,b,c;
		cin >> a >> b >> c;
		v[a].PB(b);
		v[b].PB(a);
		dp[a][b] = dp[b][a] = c;
	}
	
	int qq,kk;
	
	cin >> qq >> kk;
	
	queue<int> q;
	int now = kk;
	REP(i,v[kk].size())
	{
		q.push(v[kk][i]);
		_check[v[kk][i]] = true;
	}
	
	while(!q.empty())
	{
		int tmp = q.front();q.pop();
		REP(i,v[tmp].size())
		{
			int ww = v[tmp][i];
			if(_check[ww] == false)
			{
				dp[now][ww] = dp[ww][now] = dp[now][tmp] + dp[tmp][ww];
				q.push(ww);
				_check[ww] = true;
				//DBG
			}
		}
	}
	
		
	REP(i,qq)
	{
		int aa,bb;
		cin >> aa >> bb;
		cout << dp[aa][kk] + dp[kk][bb] << endl;
	}
		
	
	return 0;
}

Compiler output:
a.cc:29:13: error: 'n' was not declared in this scope; did you mean 'yn'?
   29 | bool _check[n+1];
      |             ^
      |             yn
a.cc:30:7: error: 'n' was not declared in this scope; did you mean 'yn'?
   30 | ll dp[n+1][n+1];
      |       ^
      |       yn
a.cc:30:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   30 | ll dp[n+1][n+1];
      |            ^
      |            yn
a.cc: In function 'int main()':
a.cc:41:17: error: '_check' was not declared in this scope
   41 |                 _check[i] = false;
      |                 ^~~~~~
a.cc:53:17: error: 'dp' was not declared in this scope
   53 |                 dp[a][b] = dp[b][a] = c;
      |                 ^~
a.cc:65:17: error: '_check' was not declared in this scope
   65 |                 _check[v[kk][i]] = true;
      |                 ^~~~~~
a.cc:74:28: error: '_check' was not declared in this scope
   74 |                         if(_check[ww] == false)
      |                            ^~~~~~
a.cc:76:33: error: 'dp' was not declared in this scope
   76 |                                 dp[now][ww] = dp[ww][now] = dp[now][tmp] + dp[tmp][ww];
      |                                 ^~
a.cc:89:25: error: 'dp' was not declared in this scope
   89 |                 cout << dp[aa][kk] + dp[kk][bb] << endl;
      |                         ^~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <xfunctional>
typedef long long ll;
using namespace std;

vector<ll> nodes[100005];
vector<ll> len[100005];
ll di[100005];
ll n, q, k;
ll xs[100005];
ll ys[100005];
bool vi[100005];

int main() {
	cin >> n;
	for (ll i = 1; i < n; i++) {
		ll t1, t2, t3;
		cin >> t1 >> t2 >> t3;
		nodes[t1].push_back(t2);
		len[t1].push_back(t3);
		nodes[t2].push_back(t1);
		len[t2].push_back(t3);
	}
	cin >> q >> k;
	priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater < pair<ll, ll> > > que;
	que.push(pair<ll, ll>(0, k));
	for (int i = 1; i <= n; i++) {
		di[i] = INT64_MAX;
	}
	di[k] = 0;
	while (que.size()) {
		pair<ll, ll> p = que.top(); que.pop();
		ll v = p.second;
		ll d = p.first;
		vi[v] = true;
		for (int i = 0; i < nodes[v].size(); i++) {
			di[nodes[v][i]] = min(di[nodes[v][i]], d + len[v][i]);
			if (vi[nodes[v][i]] == false)
				que.push(pair<ll, ll>(di[nodes[v][i]], nodes[v][i]));
		}
	}
	for (ll i = 1; i <= q; i++) {
		cin >> xs[i] >> ys[i];
	}
	for (ll i = 1; i <= q; i++) {
		cout << 1ll * di[xs[i]] + 1ll * di[ys[i]] << endl;
	}
}

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

#include<iostream>
#include<vector>
#include<memory.h>
using namespace std;
struct s
{
    int u;//记录边的起点
    int v;//记录边的终点
   long long  int w;//记录边的权值
    int next;//指向上一条边的编号
}edge[100010];
int head[100100];//表头，head[i]代表起点是i的边的编号
int cnt=0;
void add(int u,int v,int w)//向所要连接的表中加入边
{
    edge[cnt].u=u;
    edge[cnt].v=v;
    edge[cnt].w=w;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
// long int dis[100001][100001];
int n;
long  long int dist[100001];
void dijestra(int uu){
	bool s[100001];
	memset(s,0,sizeof(s));
	memset(dist,-1,sizeof(dist));
	for(int i=head[uu];i!=-1;i=edge[i].next){
	dist[edge[i].v]=edge[i].w;
	}
	dist[uu]=0;
	s[uu]=1;
	 for(int i=2; i<=n; i++){
	 //	cout<<"test"<<endl; 
        long long  int mindist = 100000000000000;
		 int u = uu;
         for(int j=1; j<=n; ++j)
         if((!s[j]) &&dist[j]!=-1&&dist[j]<mindist)
        {u = j; 
        mindist = dist[j];
       }
       s[u] = true; 
          for(int j=head[u];j!=-1;j=edge[j].next)
         if((!s[edge[j].v]) )
         {
                 if(dist[u] + edge[j].w<dist[edge[j].v]||dist[edge[j].v]==-1)     //在通过新加入的u点路径找到离v0点更短的路径  
                {
                       dist[edge[j].v] = dist[u] + edge[j].w;    
                 }
           //      cout<<"test"<<endl;
            }
    }
    return ;
}
int main(){
	while(cin>>n){
		memset(head,-1,sizeof(head));

		for(int k=0;k<n-1;k++){
			int i,j
			long long int kk;
			cin>>i>>j>>kk;
            add(i,j,kk);
            add(j,i,kk);
		//	dis[i][j]=dis[j][i]=kk;
		}
		int mm,nn;
		cin>>mm>>nn;
		dijestra(nn);
		for(int i=0;i<mm;i++){
			int a,b;
			cin>>a>>b;
			cout<<dist[a]+dist[b]<<endl;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:25: error: expected initializer before 'long'
   62 |                         long long int kk;
      |                         ^~~~
a.cc:63:33: error: 'j' was not declared in this scope
   63 |                         cin>>i>>j>>kk;
      |                                 ^
a.cc:63:36: error: 'kk' was not declared in this scope; did you mean 'k'?
   63 |                         cin>>i>>j>>kk;
      |                                    ^~
      |                                    k
Language: C++

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

typedef long long ll;

#define MAX_V 100005

#define int long long
#define INF int(1e18-1)

struct Edge {
    int v, cost;
    Edge() {}
    Edge(int v, int cost) : v(v), cost(cost) {}
};

// g[] : 重み付き有向グラフの隣接リスト, V : 頂点数, s : 始点となる頂点, d[] : sからの最短経路を格納する配列
// 適宜、終点となる頂点(tとする)を引数に入れて、sからtまでの最短コストd[t]を返しても良い
void Dijkstra (vector<Edge> g[], int V, int s, int d[]) {
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(make_pair(0, s)); // pair(cost, vertex)
    bool used[MAX_V + 1] = {false};

    while (!que.empty()) {
        pair<int, int> p = que.top();
        que.pop();
        int v = p.second, size_ = g[v].size();

        if (d[v] < p.first) continue;

        for (int i = 0; i < size_; ++i) {
            Edge e = g[v][i];
            if (d[e.v] > d[v] + e.cost) {
                d[e.v] = d[v] + e.cost;
                que.push(make_pair(d[e.v], e.v));
            }
        }
    }

}

ll n, u, k, v, l[MAX_V + 1], dk[MAX_V], a, b, c;
vector<Edge> g[MAX_V + 1]; // 有向グラフ

signed main() {
    cin >> n;
    for (int i = 0; i < n-1; ++i) {
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back(Edge(b, c));
        g[b].push_back(Edge(a, c));        
    }
    int q, k, x, y;
    cin >> q >> k;
    k--;
    Dijkstra(g, n, k, dk);
    for (int i = 0; i < q; ++i) {
        cin >> x >> y;
        x--, y--;
        Dijkstra(g, n, x, l);
        cout << l[k] + dk[y] << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void Dijkstra(std::vector<Edge>*, long long int, long long int, long long int*)':
a.cc:8:13: error: expected primary-expression before 'long'
    8 | #define int long long
      |             ^~~~
a.cc:9:13: note: in expansion of macro 'int'
    9 | #define INF int(1e18-1)
      |             ^~~
a.cc:21:20: note: in expansion of macro 'INF'
   21 |     fill(d, d + V, INF);
      |                    ^~~
Language: C++

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

typedef long long ll;

#define MAX_V 100005
#define INF int(1e18-1)

#define int long long

struct Edge {
    int v, cost;
    Edge() {}
    Edge(int v, int cost) : v(v), cost(cost) {}
};

// g[] : 重み付き有向グラフの隣接リスト, V : 頂点数, s : 始点となる頂点, d[] : sからの最短経路を格納する配列
// 適宜、終点となる頂点(tとする)を引数に入れて、sからtまでの最短コストd[t]を返しても良い
void Dijkstra (vector<Edge> g[], int V, int s, int d[]) {
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(make_pair(0, s)); // pair(cost, vertex)
    bool used[MAX_V + 1] = {false};

    while (!que.empty()) {
        pair<int, int> p = que.top();
        que.pop();
        int v = p.second, size_ = g[v].size();

        if (d[v] < p.first) continue;

        for (int i = 0; i < size_; ++i) {
            Edge e = g[v][i];
            if (d[e.v] > d[v] + e.cost) {
                d[e.v] = d[v] + e.cost;
                que.push(make_pair(d[e.v], e.v));
            }
        }
    }

}

ll n, u, k, v, l[MAX_V + 1], dk[MAX_V], a, b, c;
vector<Edge> g[MAX_V + 1]; // 有向グラフ

signed main() {
    cin >> n;
    for (int i = 0; i < n-1; ++i) {
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back(Edge(b, c));
        g[b].push_back(Edge(a, c));        
    }
    int q, k, x, y;
    cin >> q >> k;
    k--;
    Dijkstra(g, n, k, dk);
    for (int i = 0; i < q; ++i) {
        cin >> x >> y;
        x--, y--;
        Dijkstra(g, n, x, l);
        cout << l[k] + dk[y] << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void Dijkstra(std::vector<Edge>*, long long int, long long int, long long int*)':
a.cc:9:13: error: expected primary-expression before 'long'
    9 | #define int long long
      |             ^~~~
a.cc:7:13: note: in expansion of macro 'int'
    7 | #define INF int(1e18-1)
      |             ^~~
a.cc:21:20: note: in expansion of macro 'INF'
   21 |     fill(d, d + V, INF);
      |                    ^~~
Language: C++

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

typedef long long ll;

#define MAX_V 100005
#define INF int(1e18)

#define int long long

struct Edge {
    int v, cost;
    Edge() {}
    Edge(int v, int cost) : v(v), cost(cost) {}
};

// g[] : 重み付き有向グラフの隣接リスト, V : 頂点数, s : 始点となる頂点, d[] : sからの最短経路を格納する配列
// 適宜、終点となる頂点(tとする)を引数に入れて、sからtまでの最短コストd[t]を返しても良い
void Dijkstra (vector<Edge> g[], int V, int s, int d[]) {
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(make_pair(0, s)); // pair(cost, vertex)
    bool used[MAX_V + 1] = {false};

    while (!que.empty()) {
        pair<int, int> p = que.top();
        que.pop();
        int v = p.second, size_ = g[v].size();

        if (d[v] < p.first) continue;

        for (int i = 0; i < size_; ++i) {
            Edge e = g[v][i];
            if (d[e.v] > d[v] + e.cost) {
                d[e.v] = d[v] + e.cost;
                que.push(make_pair(d[e.v], e.v));
            }
        }
    }

}

ll n, u, k, v, l[MAX_V + 1], dk[MAX_V], a, b, c;
vector<Edge> g[MAX_V + 1]; // 有向グラフ

signed main() {
    cin >> n;
    for (int i = 0; i < n-1; ++i) {
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back(Edge(b, c));
        g[b].push_back(Edge(a, c));        
    }
    int q, k, x, y;
    cin >> q >> k;
    k--;
    Dijkstra(g, n, k, dk);
    for (int i = 0; i < q; ++i) {
        cin >> x >> y;
        x--, y--;
        Dijkstra(g, n, x, l);
        cout << l[k] + dk[y] << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void Dijkstra(std::vector<Edge>*, long long int, long long int, long long int*)':
a.cc:9:13: error: expected primary-expression before 'long'
    9 | #define int long long
      |             ^~~~
a.cc:7:13: note: in expansion of macro 'int'
    7 | #define INF int(1e18)
      |             ^~~
a.cc:21:20: note: in expansion of macro 'INF'
   21 |     fill(d, d + V, INF);
      |                    ^~~