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

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

ll gcd(ll a, ll b){
	if(b==0)return a;

	return gcd(b, a%b);
}


ll lcm(ll a, ll b){
	return a /gcd(a, b) * b;
}

struct edge {
	int to; ll cost;
};

vector<edge> tree[114514];
ll depth[114514];
int q, k, x,y;

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(){
	cin >> n;
	rep(i, n-1) {
		int a,b,c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		tree[a].push_back({b,c});
		tree[b].push_back({a,c});
	}
	cin >> q >> k;
	k--;

	dfs(k, -1,0);

	rep(i, q) {
		scanf("%d %d", &x, &y);
		x--;y--;
		cout << depth[x] + depth[y] << endl;	
	}

}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |         cin >> n;
      |                ^
      |                yn
Language: C++

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }


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()
{
  int n;
  cin>>n;

  REP(i,n-1)
  {
    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);
    REP(i,q)
    {
      int x,y;
      cin>>x>>y;
      x--,y--;
      cout<<depth[x]+depth[y]<<endl;
    }
return 0;
}


Compiler output:
a.cc:38:29: error: expected ';' at end of member declaration
   38 | using edge =struct {int to, ll cost;};
      |                             ^~
      |                               ;
a.cc:38:32: error: 'cost' does not name a type; did you mean 'const'?
   38 | using edge =struct {int to, ll cost;};
      |                                ^~~~
      |                                const
a.cc: In function 'void dfs(int, int, ll)':
a.cc:46:20: error: 'struct<unnamed>' has no member named 'cost'
   46 |     dfs(e.to,v,d+e.cost);
      |                    ^~~~
Language: C

#include <stdio.h>

#define N 100000

int oo[1 + (N - 1) * 2], oj[1 + (N - 1) * 2], oc[1 + (N - 1) * 2];

int link(int o, int j, int c) {
	static int _ = 1;

	oo[_] = o, oj[_] = j, oc[_] = c;
	return _++;
}

int ae[N];

void dfs(int p, int i, int d) {
	int o;

	for (o = ae[i]; o; o = oo[o]) {
		int j;

		j = oj[o];
		if (j != p)
			dfs(i, j);
	}
}

int main() {
	int n, h, i, j, c;

	scanf("%d", &n);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d%d", &i, &j, &c), i--, j--;
		ae[i] = link(ae[i], j, c);
		ae[j] = link(ae[j], i, c);
	}
	dfs(-1, 0, 0);
	for (i = 0; i < n; i++) {
		int o;

		printf("%d:", i + 1);
		for (o = ae[i]; o; o = oo[o])
			printf(" %d", oj[o] + 1);
		printf("\n");
	}
	/*
	dfs(-1, 0);
	*/
	return 0;
}

Compiler output:
main.c: In function 'dfs':
main.c:24:25: error: too few arguments to function 'dfs'
   24 |                         dfs(i, j);
      |                         ^~~
main.c:16:6: note: declared here
   16 | void dfs(int p, int i, int d) {
      |      ^~~
Language: Java

import java.util.*;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        List<List<Edge>> edges = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            edges.add(new ArrayList<>());
        }
        for (int i = 0; i < N - 1; i++) {
            int[] e = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            edges.get(e[0] - 1).add(new Edge(e[1] - 1, e[2]));
            edges.get(e[1] - 1).add(new Edge(e[0] - 1, e[2]));
        }
        String[] qv = scanner.nextLine().split(" ");
        int Q = Integer.parseInt(qv[0]);
        int via = Integer.parseInt(qv[1]) - 1;
        dist = new long[N];
        es = edges;
        getDist(via, 0, new HashSet<>());
        for (int i = 0; i < Q; i++) {
            int[] q = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            int from = q[0] - 1;
            int to = q[1] - 1;
            System.out.println(dist[from] + dist[to]);
        }
    }

    static long[] dist;
    static List<List<Edge>> es;
    static Set<Integer> used = new HashSet<>();

    static void getDist(int s, long cost) {
        used.add(s);
        dist[s] = cost;
        for (Edge next : es.get(s)) {
            if (!used.contains(next.to)) {
                getDist(next.to, cost + (long) next.cost);
            }
        }
    }

    static class Edge {
        int to;
        int cost;

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

}

Compiler output:
Main.java:26: error: method getDist in class Main cannot be applied to given types;
        getDist(via, 0, new HashSet<>());
        ^
  required: int,long
  found:    int,int,HashSet<Object>
  reason: actual and formal argument lists differ in length
1 error
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> P;
const ll INF = 1001001001001001;

ll d[100000];
ll dist[100000][100000];
vector<vector<int>> to(100000);

void dfs(int v,int p,ll di){
    d[v]=di;
    for(auto u:to[v]){
        if(u==p) continue;
        dfs(u,v,di+dist[u][v]);
    }
}
int main(){
    int n;
    cin >> n;
    rep(i,n) d[i]=INF;
    rep(i,n)rep(j,n) dist[i][j]=0;
    rep(i,n-1){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b]=c;
        dist[b][a]=c;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int q,k;
    cin >> q >> k;
    k--;
    dfs(k,-1,0);
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--; y--;
        cout << d[x]+d[y] << endl;
    }
    return 0;
}


Compiler output:
/tmp/ccoQtAiY.o: in function `dfs(int, int, long long)':
a.cc:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
/tmp/ccoQtAiY.o: in function `main':
a.cc:(.text+0x254): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
/tmp/ccoQtAiY.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3c9): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
a.cc:(.text+0x3ef): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> P;
const ll INF = 1001001001001001;
ll d[100100];
ll dist[100100][100100];
vector<vector<int>> to(100100);

void dfs(int v,int a,ll di){
    d[v]=di;
    for(auto u:to[v]){
        if(a==u) continue;
        dfs(u,v,di+dist[u][v]);
    }
}
int main(){
    int n;
    cin >> n;
    rep(i,n) d[i]=INF;
    rep(i,n)rep(j,n) dist[i][j]=0;
    rep(i,n-1){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b]=c;
        dist[b][a]=c;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int q,k;
    cin >> q >> k;
    k--;
    dfs(k,-1,0);
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--; y--;
        ll ans = d[x]+d[y];
        cout << ans << endl;
    }
    return 0;
}


Compiler output:
/tmp/ccG4dcvX.o: in function `dfs(int, int, long long)':
a.cc:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
/tmp/ccG4dcvX.o: in function `main':
a.cc:(.text+0x254): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
/tmp/ccG4dcvX.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3d1): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
a.cc:(.text+0x3f7): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<ll,int> P;
const ll INF = 1001001001001;
int n;
ll d[100100];
ll dist[100100][100100];
vector<vector<int>> to(100100);
//単一始点最短路問題
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> pq;
    //pair(distance,vertex) to[vertex]を全探索
    rep(i,n) d[i]=INF;
    d[s]=0;
    pq.push(P(0,s));
    while(!pq.empty()){
        P p = pq.top();
        pq.pop();
        ll c = p.se;
        if(d[c]<p.fi) continue; //無駄
        for(auto u:to[c]){
            if(d[u]>d[c]+dist[c][u]){
                d[u]=d[c]+dist[c][u];
                pq.push(P(d[u],u));
            }
        }
    }
}
int main(){
    cin >> n;
    rep(i,n-1){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b]=c;
        dist[b][a]=c;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int q,k;
    cin >> q >> k;
    k--;
    //k始点での各頂点への最短距離
    dijkstra(k);
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--; y--;
        ll ans = d[x]+d[y];
        cout << ans << endl;
    }
}


Compiler output:
/tmp/cc7valJn.o: in function `dijkstra(int)':
a.cc:(.text+0x11a): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
/tmp/cc7valJn.o: in function `main':
a.cc:(.text+0x3cb): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
a.cc:(.text+0x3f4): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
/tmp/cc7valJn.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x541): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
a.cc:(.text+0x567): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<ll>>;
typedef long long ll;
const ll mod = 1000000007;

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

    Graph to(n), cost(n);
    rep(i, n-1) {
        ll a, b, w;
        cin >> a >> b >> w;
        a--;  b--;
        to[a].push_back(b);
        to[b].push_back(a);
        cost[a].push_back(w);
        cost[b].push_back(w);
    }

    int q, K;
    cin >> q >> K;
    K--;

    vector<ll> dist(n, -1);  // dist[i] : 頂点iの根からの距離
    queue<ll> Q;

    const int root = K;  // 根は頂点K
    dist[root] = 0;
    Q.push(root);
    while(!Q.empty()) {
        
        ll v = Q.front();
        Q.pop();

        rep(i, to[v].size()) {
            
            ll u = to[v][i];
            
            if(dist[u] != -1) {
                continue;
            }
            
            dist[u] = dist[v] + cost[v][i];
            Q.push(u);
        }
    }

    vector<ll> ans(q);
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        x--;  y--;
        ans[i] = dist[x] + dist[y];
    }

    rep(i, q) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Compiler output:
a.cc:13:29: error: 'll' was not declared in this scope
   13 | using Graph = vector<vector<ll>>;
      |                             ^~
a.cc:13:29: error: template argument 1 is invalid
a.cc:13:29: error: template argument 2 is invalid
a.cc:13:31: error: template argument 1 is invalid
   13 | using Graph = vector<vector<ll>>;
      |                               ^~
a.cc:13:31: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:21:5: error: 'Graph' was not declared in this scope; did you mean 'isgraph'?
   21 |     Graph to(n), cost(n);
      |     ^~~~~
      |     isgraph
a.cc:26:9: error: 'to' was not declared in this scope; did you mean 'tm'?
   26 |         to[a].push_back(b);
      |         ^~
      |         tm
a.cc:28:9: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   28 |         cost[a].push_back(w);
      |         ^~~~
      |         cosl
a.cc:47:16: error: 'to' was not declared in this scope; did you mean 'tm'?
   47 |         rep(i, to[v].size()) {
      |                ^~
a.cc:11:38: note: in definition of macro 'rep'
   11 | #define rep(i, n) for(int i = 0; i < n; i++)
      |                                      ^
a.cc:55:33: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   55 |             dist[u] = dist[v] + cost[v][i];
      |                                 ^~~~
      |                                 cosl
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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

using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;

void rec(const Graph &G, int v, int p, ll sum, vector<ll> &dist){
  dist[v] = sum;
  for(auto e : G[v]){
    if(e.first == p) continue;
    rec(G, e.first, v, sum+e.second, dist);
  }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
  	int N;
    cin >> N;
    Graph(N);
    rep(i,N-1){
      int a,b; ll c; cin >> a >> b >> c;
      --a,--b;
      G[a].push_back({b,c});
      G[b].push_back({a,c});
    }
    int Q, K; cin >> Q >> K; --K;
    vector<ll> dist(N, 0);
    rec(G,K,-1,0,dist);

    rep(q,Q){
      int x,y;
      cin >> x >> y;
      --x,--y;
      cout << dist[x] + dist[y] << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:11: error: conflicting declaration 'Graph N'
   39 |     Graph(N);
      |           ^
a.cc:37:13: note: previous declaration as 'int N'
   37 |         int N;
      |             ^
a.cc:43:7: error: 'G' was not declared in this scope
   43 |       G[a].push_back({b,c});
      |       ^
a.cc:48:9: error: 'G' was not declared in this scope
   48 |     rec(G,K,-1,0,dist);
      |         ^
Language: C++

#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define NMAX 100000
using namespace std;

ll ranges[NMAX] = {};
vector<pair<int,int>> graph[NMAX]; //first is ngh. second is ranges.
bool used[NMAX] = {};


void dfs(int v,ll range){
	ranges[v] = range;
	used[v] = true;
	rep(i,0,graph[v].size()){
		if(!used[graph[v][i].first]){
			dfs(graph[v][i].first,range+graph[v][i].second);
		}
	}
}

int main(){
	int N;
	cin >> N;
	int tmp1,tmp2,tmp3;
	rep(i,0,N-1){
		cin >> tmp1 >> tmp2 >> tmp3;
		graph[tmp1-1].push_back(make_pair(tmp2-1,tmp3));
		graph[tmp2-1].push_back(make_pair(tmp1-1,tmp3));
	}
	int Q,K;
	int x[Q],y[Q];
	cin >> Q >> K;
	rep(i,0,Q){
		cin >> x[i] >> y[i];
	}
	dfs(K-1,0);
	rep(i,0,Q){
		cout << ranges[x[i]-1] + ranges[y[i]-1] << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: 'cin' was not declared in this scope
   31 |         cin >> N;
      |         ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    6 | #include <utility>
  +++ |+#include <iostream>
    7 | #define ll long long int
a.cc:46:17: error: 'cout' was not declared in this scope
   46 |                 cout << ranges[x[i]-1] + ranges[y[i]-1] << endl;
      |                 ^~~~
a.cc:46:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#include <vector>
#include <queue>

struct edge{
    int to, cost;
};

using namespace std;

//ダイクストラで多用する型
typedef pair<int, int> P;//(その頂点までの距離,頂点)として使う。

vector<edge> G[100000];//頂点iから出る辺の配列G[i]の配列。
int dist[100000];//特定の頂点から各頂点への距離が格納される。
bool used[100000];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。

void dijkstra(int v){//vは始点。
    //以下のリンクでpriority_queueの使い方を参照
    //http://shirokurostone.hatenablog.com/entry/20110522/1306052844
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, v));
    while(!que.empty()){
        P top = que.top();
        que.pop();
        int u = top.second;
        int d = top.first;
        //cout << u << ' ' << d << endl;
        if(used[u]) continue;
        dist[u] = d;
        used[u] = true;
        for(int i = 0; i < G[u].size(); i++){
            if(!used[G[u][i].to]){
                que.push(P(d+G[u][i].cost, G[u][i].to));
                //cout << G[u][i].to << ' ' <<  d+G[u][i].cost << endl;
            }
        }
    }
}

int main(){
  int n;
  cin >> n;
  int a,b,c;
  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;
  cin>>q>>k;
  k--;
  dijkstra(k);
  int x,y;
  long long res;
  REP(i,q){
    cin>>x>>y;
    x--;y--;
    res = (long long)(dist[x]+dist[y]);
    cout<<res<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:7: error: 'i' was not declared in this scope
   57 |   REP(i,q){
      |       ^
a.cc:57:3: error: 'REP' was not declared in this scope
   57 |   REP(i,q){
      |   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
typedef pair<ll,ll> P;
const ll INF=10000000000000000;
const ll mod=1000000007;
#define F first
#define S second
#define all(a) (a.begin(),a.end())
struct node{int to,ll cost};
int main(void){
    ll n;cin>>n;
    vector<node>v(n);
    int x;
    rep(i,n-1){
        node d;
        cin>>x>>d.to>>d.cost;
        x--;d.to--;d.cost--;
        v[x].push_back(d);
        swap(x,d.to);
        v[x].push_back(d);
    }
    ll q,k;cin>>q>>k;
    k--;queue q<int>;
    q.push(k);
    vector<ll>dist(n);
    while(!q.empty()){
        
    }
}

Compiler output:
a.cc:11:20: error: expected ';' at end of member declaration
   11 | struct node{int to,ll cost};
      |                    ^~
      |                      ;
a.cc:11:23: error: 'cost' does not name a type; did you mean 'const'?
   11 | struct node{int to,ll cost};
      |                       ^~~~
      |                       const
a.cc: In function 'int main()':
a.cc:18:25: error: 'struct node' has no member named 'cost'
   18 |         cin>>x>>d.to>>d.cost;
      |                         ^~~~
a.cc:19:22: error: 'struct node' has no member named 'cost'
   19 |         x--;d.to--;d.cost--;
      |                      ^~~~
a.cc:20:14: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'push_back'
   20 |         v[x].push_back(d);
      |              ^~~~~~~~~
a.cc:22:14: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'push_back'
   22 |         v[x].push_back(d);
      |              ^~~~~~~~~
a.cc:25:16: error: expected initializer before '<' token
   25 |     k--;queue q<int>;
      |                ^
a.cc:26:7: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'}
   26 |     q.push(k);
      |       ^~~~
a.cc:28:14: error: request for member 'empty' in 'q', which is of non-class type 'll' {aka 'long long int'}
   28 |     while(!q.empty()){
      |              ^~~~~
Language: C++

#include <iostream>

const long long INF = 10000000000000000;
const int MAX_N = 100000;
int N;

int d[MAX_N+1][MAX_N+1];
bool visit[MAX_N+1];

long long dfs(int x, int y, long long distance){
   if(x==y) return distance;
   if(visit[x]) return INF;
   visit[x] = true;
   
   long long min;
   bool first = true;
   for(int i=1; i<=N; ++i){
      if(d[x][i]>0){
	 if(first){
	    min = dfs(i,y,distance+d[x][i]);
	    first = false;
	 }else min = std::min(min,dfs(i,y,distance+d[x][i]));
      }
   }
   return min;
}

int main(){
   std::cin >> N;
   int a, b, c;
   for(int i=1; i<N; ++i){
      std::cin >> a >> b >> c;
      d[a][b] = c;
      d[b][a] = c;
   }
   int Q, K;
   std::cin >> Q >> K;
   int x[Q], y[Q];
   for(int i=0; i<Q; ++i){
      std::cin >> x[i] >> y[i];
   }

   long long ans;
   for(int i=0; i<Q; ++i){
      for(int j=0; j<N; ++j) visit[j] = false;
      ans = dfs(x[i],K, 0);
      for(int j=0; j<N; ++j) visit[j] = false;
      ans += dfs(K,y[i], 0);
      std::cout << ans << std::endl;
   }

   return 0;
}


Compiler output:
/tmp/ccjEM1PP.o: in function `dfs(int, int, long long)':
a.cc:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
a.cc:(.text+0x4e): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
/tmp/ccjEM1PP.o: in function `main':
a.cc:(.text+0x36b): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
a.cc:(.text+0x3b5): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919
#define double long double
using namespace std;
typedef pair<ll, ll>P;
struct edge { int to, cost; };
ll n;
vector<edge> g[114514];
ll d[114514];
ll x[114514], y[114514];
void dijkstra(ll s) {
	prique<P, vector<P>, greater<P>>que;
	fill(d, d + n, inf);
	d[s] = 0;
	que.push(P(0, s));
	while (que.size()) {
		P p = que.top(); que.pop();
		ll nv = p.second;
		if (d[nv] < p.first)continue;
		for (int i = 0; i < g[nv].size(); i++) {
			edge e = g[nv][i];
			if (d[e.to] > d[nv] + e.cost) {
				d[e.to] = d[nv] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		g[a].push_back({b, c});
		q.to = a;
		g[b].push_back({a, c});
	}
	ll q, k;
	cin >> q >> k;
	rep(i, q) cin >> x[i] >> y[i];
	ll ans = 0;
	rep(i, q) {
		dijkstra(x[i]);
		ans += d[k];
		dijkstra(k);
		ans += d[y[i]];
		cout << ans << endl;
		ans = 0;
	}
	ggr
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:33: warning: narrowing conversion of 'b' from 'long long int' to 'int' [-Wnarrowing]
   47 |                 g[a].push_back({b, c});
      |                                 ^
a.cc:47:36: warning: narrowing conversion of 'c' from 'long long int' to 'int' [-Wnarrowing]
   47 |                 g[a].push_back({b, c});
      |                                    ^
a.cc:48:17: error: 'q' was not declared in this scope
   48 |                 q.to = a;
      |                 ^
a.cc:49:33: warning: narrowing conversion of 'a' from 'long long int' to 'int' [-Wnarrowing]
   49 |                 g[b].push_back({a, c});
      |                                 ^
a.cc:49:36: warning: narrowing conversion of 'c' from 'long long int' to 'int' [-Wnarrowing]
   49 |                 g[b].push_back({a, c});
      |                                    ^
Language: C++

#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;
ll cost[100000][100000];
ll dist[100000], used[100000];

int main() {
    int N;
    cin >> N;
    vector<int> vt[N];
    for(int i=0; i<N-1; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;
        b--;
        vt[a].push_back(b);
        vt[b].push_back(a);
        cost[a][b]=c;
        cost[b][a]=c;
    }
    queue<int> que;
    int Q,K;
    cin >> Q >> K;
    K--;
    que.push(K);
    
    used[K]=1;
    while(true){
        int s=que.size();
        for(int i=0; i<s; i++){
            int tmp = que.front(); que.pop();
            for(int next=0; next<vt[tmp].size(); next++){
                if(used[vt[tmp][next]]==1) continue;
                dist[vt[tmp][next]]=dist[tmp]+cost[tmp][vt[tmp][next]];
                que.push(vt[tmp][next]);
                used[vt[tmp][next]]=1;
            }
        }
        if(que.size()==0) break;
    }
    ll ans[Q];
    for(int i=0; i<Q; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        ans[i] = dist[x]+dist[y];
    }
    for(int i=0; i<Q; i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Compiler output:
/tmp/ccXEHHjr.o: in function `main':
a.cc:(.text+0x2c7): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x359): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x380): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x415): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x495): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x5c6): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x5e1): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
collect2: error: ld returned 1 exit status
Language: C

#include<bits/stdc++.h>
using namespace std;
 
long long n;
vector<long long> v(100005);
map<long long,vector<pair<long long,long long>>> mp;
bool used[100005];
 
void dfs(long long s,long long dist){
        used[s]=true;
        v[s]=dist;

        for(auto i:mp[s]){
            if(!used[i.first])
                dfs(i.first,dist+i.second);
        }

}
 
int main(){
    cin>>n;
    long long a,b,c;
    for(long long i=0;i<n-1;i++){
        cin>>a>>b>>c;
        a--,b--;
        mp[a].push_back(make_pair(b,c));
        mp[b].push_back(make_pair(a,c));
    }
    long long k,q;
    cin>>q>>k;
    k--;
    
 
    dfs(k,0);
 
    for(long long i=0;i<q;i++){
        long long x,y;
        cin>>x>>y;
        x--,y--;
      
        cout<<v[x]+v[y]<<endl;
    }
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

typedef long long ll;
struct edge{int to;ll cost;};

vector<edge> tree[100010];
ll dist[100010];

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

int main(){
  int N;cin>>N;
  for (int i=0;i<N-1;++i){
    int a, b;ll 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;
  dfs(K, -1, 0);

  for (int i=0;i<Q;++i){
    int x, y;cin>>x>>y;x--,y--;
    cout << dist[x]+dist[y] << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, ll)':
a.cc:14:15: error: cannot convert 'edge' to 'int'
   14 |     dfs(e.to, e, d+e.cost);
      |               ^
      |               |
      |               edge
a.cc:10:21: note:   initializing argument 2 of 'void dfs(int, int, ll)'
   10 | void dfs(int v, int p, ll d){
      |                 ~~~~^
Language: C++

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

typedef long long ll;
struct edge{int to;ll cost;};

vector<edge> tree[100010];
ll dist[100010];

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

int main(){
  int N;cin>>N;
  for (int i=0;i<N-1;++i){
    int a, b;ll 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;
  dfs(K, -1, 0);

  for (int i=0;i<Q;++i){
    int x, y;cin>.x>>y;x--,y--;
    cout << dist[x]+dist[y] << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, ll)':
a.cc:14:26: error: expected ')' before ';' token
   14 |     dfs(e.to, e, d+e.cost;)
      |        ~                 ^
      |                          )
a.cc:14:27: error: expected primary-expression before ')' token
   14 |     dfs(e.to, e, d+e.cost;)
      |                           ^
a.cc: In function 'int main()':
a.cc:29:18: error: expected primary-expression before '.' token
   29 |     int x, y;cin>.x>>y;x--,y--;
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof v)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r) {int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int a, b, c, n, m, x, y, z, w, h, res = 0, cnt = 0, mx = -INF, mn = INF;
str s, t;
bool flag = true;

signed main(){
    incant();
    
    print();
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:26: error: expected primary-expression before ')' token
   48 | #define out(x) cout << (x)
      |                          ^
a.cc:50:18: note: in expansion of macro 'out'
   50 | #define print(x) out(x), indent()
      |                  ^~~
a.cc:75:5: note: in expansion of macro 'print'
   75 |     print();
      |     ^~~~~
Language: C++

#include <cstdio>
#include <cstring>

#include <iostream>
#include <vector>
#include <queue>


#define MAX_V 100010
#define INF   10000000100

int  N, Q, K;
long d[MAX_V];
long cost[MAX_V][MAX_V];
bool used[MAX_V];

void dijkstra(int s) {
    std::fill(d, d+N, INF);
    std::fill(used, used+N, false);
    d[s] = 0;
    while (true) {
        int v = -1;
        for (int u=0; u<N; ++u) {
            if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        if (v == -1) break;
        used[v] = true;
        for (int u=0; u<N; ++u) {
            d[u] = std::min(d[u], d[v] + cost[v][u]);
        }
    }
    /*
    std::cout << "\nDebug : ";
    for (int i=0; i<N; ++i) std::cout << d[i] << ' ';
    std::cout << std::endl;
    */
}

long solve(int x, int y) {
    return d[x] + d[y];
}

int main() {
    std::cin >> N;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<N; ++j) {
            cost[i][j] = INF;
            if (i == j) cost[i][j] = 0;
        }
    }
    for (int i=0; i<N-1; ++i) {
        int  from, to;
        long w;
        std::cin >> from >> to >> w;
        --from; --to;
        cost[from][ to ] = w;
        cost[ to ][from] = w;
    }
    std::cin >> Q >> K;
    dijkstra(K-1);
    for (int i=0; i<Q; ++i) {
        int x, y;
        std::cin >> x >> y;
        --x; --y;
        std::cout << solve(x, y) << std::endl;
    }

    return 0;
}

Compiler output:
/tmp/cc0SDrcX.o: in function `dijkstra(int)':
a.cc:(.text+0x5c): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

//input sample
//5
//0 3 2 3 3 1 1 2
//1 2 0 2 3 4
//2 3 0 3 3 1 4 1
//3 4 2 1 0 1 1 4 4 3
//4 2 2 1 3 3

//output sample
//shortest cost of each node
//0 0
//1 2
//2 2
//3 1
//4 3
//parent id of each node
//0 - 1
//1 0
//2 3
//3 0
//4 2
static const int MAX = 100000;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
vector<pair<int, int>> adj[MAX];

ll pre[MAX];
ll p[MAX];
ll d[MAX];
ll color[MAX];
priority_queue<pair<int, int>>PQ;
ll n;
void dijkstra(int s) {
	repe(i, 1, n) {
		d[i] = INF;
		pre[i] = INF;
		color[i] = WHITE;
	}

	d[s] = 0;
	p[s] = -1;
	PQ.push(make_pair(s, s)); // ?reverse?
	color[s] = GRAY;

	while (!PQ.empty()) {
		pair<ll, ll> f = PQ.top(); PQ.pop();
		ll u = f.second;

		color[u] = BLACK;

		if (d[u] < f.first * (-1)) continue;

		rep(j, 0, adj[u].size()) {
			ll v = adj[u][j].first;
			if (color[v] == BLACK) continue;
			if (d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * (-1), v));
				p[v] = u;
				color[v] = GRAY;
			}
		}
	}
	//rep(i, 0, n) cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
	//rep(i, 0, n) cout << i << " " << (p[i] == INF ? -1 : p[i]) << endl;
}

vector<int> get_path(int t) {
	vector<int> path;
	for (; t != -1; t = p[t])path.push_back(t);
	reverse(path.begin(), path.end());
	return path;
}

int main()
{
	cin >> n;
	rep(i, 0, n - 1) {
		ll a, b, c; cin >> a >> b >> c;
		adj[a].push_back(make_pair(b, c));
		adj[b].push_back(make_pair(a, c));
	}
	ll q, k; cin >> q >> k;

	dijkstra(k);

	rep(i, 0, q) {
		ll x, y; cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}

	//int k, u, v, c;
	//cin >> n;
	//rep(i, 0, n) {
	//	cin >> u >> k;
	//	rep(j, 0, k) {
	//		cin >> v >> c;
	//		adj[u].push_back(make_pair(v, c));
	//	}
	//}
	//dijkstra(0);
	//pass start index;

	return 0;
}

Compiler output:
a.cc: In function 'std::vector<int> get_path(int)':
a.cc:82:9: error: 'reverse' was not declared in this scope
   82 |         reverse(path.begin(), path.end());
      |         ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int limit = 100010;
using edge = struct {
  int to;
  ll cost;
  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:8:3: error: 'depth' does not name a type
    8 |   depth[v] = d;
      |   ^~~~~
a.cc:9:3: error: expected unqualified-id before 'for'
    9 |   for (auto &e : tree[v]) {
      |   ^~~
a.cc:13:2: error: expected ';' after struct definition
   13 | }
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:21:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   21 |     tree[a].push_back({b, c});
      |     ^~~~
      |     free
a.cc:27:3: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   27 |   dfs(k, -1, 0);
      |   ^~~
      |   ffs
a.cc:32:13: error: 'depth' was not declared in this scope
   32 |     cout << depth[x] + depth[y] << endl;
      |             ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,q,k;
long long total=0;
int kyori[100001][100001];
long long cost[100001];
vector<int> node[100001];
bool edge[100001];
void dfs(int e){
  edge[e]=true;
  for(auto i:node[e]){
    if(!edge[i]){
      total+=kyori[e][i];
      cost[i]=total;
      dfs(i);
      total-=kyori[e][i];
    }
  }
}
int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    node[a].push_back(b);
    node[b].push_back(a);
    kyori[a][b]=c;
    kyori[b][a]=c;
  }
  cin>>q>>k;
  k--;
  cost[k]=0;
  dfs(k);
  for(int i=0;i<q;i++){
    int x,y;
    cin>>x>>y;
    x--,y--;
    cout<<cost[x]+cost[y]<<endl;
  }
}

Compiler output:
/tmp/cccofs0e.o: in function `dfs(int)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x7a): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
/tmp/cccofs0e.o: in function `main':
a.cc:(.text+0x1e6): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x212): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x2e4): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x353): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x36b): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
/tmp/cccofs0e.o: in function `__tcf_0':
a.cc:(.text+0x3c4): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x3cb): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,q,k;
ll total;
int kyori[100001][100001];
ll cost[100001];
vector<int> node[100001];
bool edge[100001];
void dfs(int e){
  edge[e]=true;
  for(auto i:node[e]){
    if(!edge[i]){
      total+=kyori[e][i];
      cost[i]=total;
      dfs(i);
      total-=kyori[e][i];
    }
  }
}
int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    node[a].push_back(b);
    node[b].push_back(a);
    kyori[a][b]=c;
    kyori[b][a]=c;
  }
  cin>>q>>k;
  k--;
  cost[k]=0;
  dfs(k);
  for(int i=0;i<k;i++){
    int x,y;
    cin>>x>>y;
    x--,y--;
    cout<<cost[x]+cost[y]<<endl;
  }
}

Compiler output:
/tmp/ccSPwqcw.o: in function `dfs(int)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x7a): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
/tmp/ccSPwqcw.o: in function `main':
a.cc:(.text+0x1e6): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x212): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x2e4): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x353): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x36b): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
/tmp/ccSPwqcw.o: in function `__tcf_0':
a.cc:(.text+0x3c4): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x3cb): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
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) { //v:行先,p:ひとつ前,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}); //aからbへの距離
    tree[b].push_back({a, c}); //bからaへの距離
  }
  int q, k;
  cin >> q >> k;
  k--;
  dfs(k, -1, 0); //kから各方面への距離
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x] + depth[y] << endl;
  }
  return 0;
}

/*
5
1 2 1
1 3 1
2 4 1
3 5 1
3 1
2 4
2 3
4 5

tree[0]=(1,1),(2,1)
tree[1]=(0,1),(3,1)
tree[2]=(0,1),(4,1)
tree[3]=(1,1)
tree[4]=(2,1)

dfs(0,-1,0){
  depth[0]=0
  dfs(1,0,0+1){
    depth[1]=1
    dfs(3,1,1+1){
      depth[3]=2
    }
  }
  dfs(2,0,0+1){
    depth[2]=1
    dfs(4,2,1+1){
      depth[4]=2
    }
  }
}
*/

Compiler output:
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<edge> tree[limit];
      | ^~~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:12:18: 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:19:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   19 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 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:24:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   24 |     tree[a].push_back({b, c}); //aからbへの距離
      |     ^~~~
      |     free
a.cc:35:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   35 |     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:35:36: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   35 |     cout << depth[x] + depth[y] << endl;
      |                                    ^~~~
      |                                    std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~