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

#include<bits/stdc++.h>
using namespace std;
int N;
int a, b;
long long c;
long long tree[100005][100005];
long long dist[100005];
int main(){
    cin>>N;
    for(int i=0; i<N-1; i++){
        cout<<i<<endl;
        cin>>a>>b>>c;
        a--;b--;
        tree[a][b] = c;
        tree[b][a] = c;
    }
    int Q, K; 
	cin >> Q >> K;
    K--;
    dist[K] = 0;
    queue<int> que;
    que.push(K);
    while(!que.empty()){
        int v;
		v = que.front(); que.pop();
		for(int i=0;i<N-1;i++){
			if(tree[v][i]) dist[i] = dist[v] + tree[v][i];
			que.push(i);
		}
    }
    long long ans;
    for(long long i = 0; i < Q; i++){
        int x, y; cin >> x >> y;
        x--;y--;
        cout << dist[x]+dist[y] << endl;
    }
    
}

Compiler output:
/tmp/ccjP7J4c.o: in function `main':
a.cc:(.text+0x17b): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o
a.cc:(.text+0x217): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o
a.cc:(.text+0x260): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o
a.cc:(.text+0x327): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o
a.cc:(.text+0x342): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    for (ll i = 0; i < V;i++) {
        d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
      for (ll i = 0; i < V;i++) {
          d[i] = INF;
      }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
    ll n;
    cin >> n;
    graph g(n);
    for (ll i = 0; i < n - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        g.add_edge(a, b, c);
    }
	ll q,k;
    cin >> q >> k;
    k--;
    g.dijkstra(k);
    for (ll i = 0; i < q;i++){
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << g.d[x] + g.d[y] << endl;
    }
}

Compiler output:
a.cc:6:1: error: expected ',' or ';' before 'const'
    6 | const long double PI = acosl(-1.0);
      | ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};

int main(){
  ll n;
  cin >> n;
  graph g(n);
  rep(i, n-1){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    g.add_edge(a,b,c);
  }
  ll q, k;
  cin >> q >> k;
  k--;
  g.dijkstra(k);
  rep(i, q){
    ll x, y;
    cin >> x >> y;
    x--; y--;
    cout << g.d[x]+g.d[y] << endl;
  }
  return 0;
}
  


Compiler output:
a.cc: In member function 'void graph::init(ll)':
a.cc:24:14: error: 'INF' was not declared in this scope
   24 |       d[i] = INF;
      |              ^~~
a.cc: In member function 'void graph::dijkstra(ll)':
a.cc:36:14: error: 'INF' was not declared in this scope
   36 |       d[i] = INF;
      |              ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    REP(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    REP(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};

int main(){
  ll n;
  cin >> n;
  graph g(n);
  rep(i, n-1){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    g.add_edge(a,b,c);
  }
  ll q, k;
  cin >> q >> k;
  k--;
  g.dijkstra(k);
  rep(i, q){
    ll x, y;
    cin >> x >> y;
    x--; y--;
    cout << g.d[x]+g.d[y] << endl;
  }
  return 0;
}
  

Compiler output:
a.cc: In member function 'void graph::init(ll)':
a.cc:23:9: error: 'i' was not declared in this scope
   23 |     REP(i,V){
      |         ^
a.cc:23:5: error: 'REP' was not declared in this scope
   23 |     REP(i,V){
      |     ^~~
a.cc: In member function 'void graph::dijkstra(ll)':
a.cc:35:9: error: 'i' was not declared in this scope
   35 |     REP(i,V){
      |         ^
a.cc:35:5: error: 'REP' was not declared in this scope
   35 |     REP(i,V){
      |     ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
map<pair<int,int>,long long int> mp;
vector<int> v[100005];
long long int d[100005];
void solve(int now,int before,long long int dis){
    if(now==before){
        for(auto u:v[now]){
            d[u]=mp[make_pair(min(now,u),max(now,u))];
            solve(u,now,mp[make_pair(min(now,u),max(now,u))]);
        }
    }
    else{
        for(auto u:v[now]){
            if(u!=before){
                if(d[u]>dis+mp[make_pair(min(now,u),max(now,u))]){
                    d[u]=dis+mp[make_pair(min(now,u),max(now,u))];
                    solve(u,now,dis+mp[make_pair(min(tmp,u),max(tmp,u))]);
            }}
        }
    }
}

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

Compiler output:
a.cc: In function 'void solve(int, int, long long int)':
a.cc:19:54: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   19 |                     solve(u,now,dis+mp[make_pair(min(tmp,u),max(tmp,u))]);
      |                                                      ^~~
      |                                                      tm
Language: C++

#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;
using ll = long long;
using P = pair<ll, ll>;
double PI = acos(-1);

int n;
int a, b, c;
vector<vector<P>> to(MX);
int q,k;
int x[MX], y[MX];
int visit[MX];
int dep[MX];

void dfs(int v, int depth) {
    if(visit[v]==1) return;
    visit[v] = 1;
    dep[v] = depth;
    for(auto u: to[v]) {
        dfs(u.first, depth+u.second);
    }
}

signed main(){
    cin >> n;
    rep(i,n-1) {
        cin >> a >> b >> c;
        to[a].push_back({b,c});
        to[b].push_back({a,c});
    }
    cin >> q >> k;
    dfs(k,0);
    
    rep(i, q) {
        cin >> x[i] >> y[i];
        cout << dep[x[i]]+dep[y[i]] << endl;
    }
    return 0;
}



Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:27:8: error: reference to 'visit' is ambiguous
   27 |     if(visit[v]==1) return;
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:23:5: note:                 'long long int visit [1000000]'
   23 | int visit[MX];
      |     ^~~~~
a.cc:28:5: error: reference to 'visit' is ambiguous
   28 |     visit[v] = 1;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:23:5: note:                 'long long int visit [1000000]'
   23 | int visit[MX];
      |     ^~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

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

const long long INF = 1000000000000000007;
// -------------------------------------------------------

// 少し多めに確保すること
// ぴったりだと正しく動かないので注意
const long long MAX_V = 1010101;

struct edge {
  long long to, cost;
};

using Pll = pair<long long, long long>;

long long V;
vector<edge> Graph[MAX_V];
long long dist[MAX_V];

void dijkstra(long long s) {
  priority_queue<Pll, vector<Pll>, greater<Pll>> que;

  // 0-indexedと1-indexedの両方に対応
  fill(dist, dist + MAX_V, INF);

  dist[s] = 0;
  que.push(Pll(0, s));

  while (!que.empty()) {
    auto elem = que.top();
    que.pop();

    auto cv = elem.second;

    if (elem.first > dist[cv]) {
      continue;
    }

    for (auto e : Graph[cv]) {
      if (dist[e.to] > dist[cv] + e.cost) {
        dist[e.to] = dist[cv] + e.cost;
        que.push(Pll(dist[e.to], e.to));
      }
    }
  }
}

ll N;
ll Q, K;

int main() {
  cin >> N;
  V = N;

  rep(i, 1, N) {
    ll a, b, c;
    cin >> a >> b >> c;
    Graph[a].push_back(edge{b, c});
    Graph[b].push_back(edge{a, c});
  }

  cin >> Q >> K;
  dijkstra(K);
  vector<ll> ans;
  rep(i, 0, Q) {
    ll x, y;
    cin >> x >> y;
    ans.push_back(dist[x] + dist[y]);
  }

  for (auto e : ans) {
    cout << e << "\n";
  }
}


Compiler output:
a.cc:38:17: error: redefinition of 'const long long int INF'
   38 | const long long INF = 1000000000000000007;
      |                 ^~~
a.cc:31:17: note: 'const long long int INF' previously defined here
   31 | const long long INF = 1000000000000000007;
      |                 ^~~
Language: C++

#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;

	vector<map<ll, ll>> dic(N+1);
	rep(i, 1, N) {
		ll a, b, c;
		std::cin >> a >> b >> c;
		dic[a][b] = c;
		dic[b][a] = c;
	}

	ll Q, K;
	std::cin >> Q >> K;

	vll cost(N+1, LLONG_MAX);
	cost[K] = 0;
	vector<bool> isVisited(N + 1, false);
	priority_queue<pair<ll, ll>> pq;
	pq.push({ 0,K });
	while (!pq.empty()) {
		if (!isVisited[pq.top().second]) {
			isVisited[pq.top().second] = true;
			ll c = pq.top().first;
			ll pos = pq.top().second;
			pq.pop();

			for (auto itr = dic[pos].begin(); itr != dic[pos].end(); itr++) {
				if (c + itr->second < cost[itr->first]) {
					cost[itr->first] = c + itr->second;
					pq.push({ cost[itr->first],itr->first });
				}
			}
		}
	}

	rep(i, 0, Q) {
		ll x, y;
		std::cin >> x >> y;
		std::cout << cost[x] + cost[y] << endl;
	}


	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:90:23: error: 'LLONG_MAX' was not declared in this scope
   90 |         vll cost(N+1, LLONG_MAX);
      |                       ^~~~~~~~~
a.cc:16:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   15 | #include<stack>
  +++ |+#include <climits>
   16 |
Language: C++

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

struct edge{
    ll v,cost;
};

int main(){
    ll n;
    cin>>n;
    vector<vector<edge>> adj(n);
    ll a,b,c;
    rep(i,n-1){
        cin>>a>>b>>c;
        a--,b--;
        adj[a].push_back((edge){b,c});
        adj[b].push_back((edge){a,c});
    }
    ll q,k;
    cin>>q>>k;
    k--;
    vector<ll> dist(n,-1);
    queue<ll> q;
    q.push(k);
    dist[k]=0;
    while(!q.empty()){
        ll now=q.front();
        q.pop();
        rep(i,adj[now].size()){
            if(dist[adj[now][i].v]==-1){
                dist[adj[now][i].v]=dist[now]+adj[now][i].cost;
                q.push(adj[now][i].v);
            }
        }
    }
    ll x,y;
    rep(i,q){
        cin>>x>>y;
        cout<<dist[x]+dist[y]<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:15: error: conflicting declaration 'std::queue<long long int> q'
   26 |     queue<ll> q;
      |               ^
a.cc:22:8: note: previous declaration as 'll q'
   22 |     ll q,k;
      |        ^
a.cc:27:7: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'}
   27 |     q.push(k);
      |       ^~~~
a.cc:29:14: error: request for member 'empty' in 'q', which is of non-class type 'll' {aka 'long long int'}
   29 |     while(!q.empty()){
      |              ^~~~~
a.cc:30:18: error: request for member 'front' in 'q', which is of non-class type 'll' {aka 'long long int'}
   30 |         ll now=q.front();
      |                  ^~~~~
a.cc:31:11: error: request for member 'pop' in 'q', which is of non-class type 'll' {aka 'long long int'}
   31 |         q.pop();
      |           ^~~
a.cc:35:19: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'}
   35 |                 q.push(adj[now][i].v);
      |                   ^~~~
Language: Java

import java.util.*;

public class Main {
    static List<int[]>[] to;
    static long[] dist;
    static int n;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        
        // to: 隣接リスト(無向)
        to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<long[]>();
        }
        for (int i = 0; i < n - 1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            int dis = sc.nextInt();
            to[p].add(new int[]{q, dis});
            to[q].add(new int[]{p, dis});
        }
        
        // 点kから各点までの距離を計算 
        int query = sc.nextInt();
        int k = sc.nextInt() - 1;
        long[] distK = calcDist(k);
        
        // p→k→qの最短距離を出力
        while (query-- > 0) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            
            System.out.println(distK[p] + distK[q]);
        }
    }
    
    public static long[] calcDist(int p) {
        dist = new long[n];
        dfs(p, 0, -1);
        return dist;
    }
    
    // 頂点pと隣接する点に自分の値+距離を配る
    public static void dfs(int p, long d, int par) {
        dist[p] = d;
        
        for (int[] q : to[p]) {
            if (q[0] == par) continue;
            dfs(q[0], d + q[1], p);
        }
    }
}


Compiler output:
Main.java:16: error: incompatible types: ArrayList<long[]> cannot be converted to List<int[]>
            to[i] = new ArrayList<long[]>();
                    ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Language: C++


vector<int> dist;

void dfs( int now, int ago, int depth ){
  dist[now] = depth;
  for( int i = 0; i < G[now].size(); i++ ){
    int next = G[now][i].to;
    if( next == ago ) continue;
    dfs( next, now, depth + G[now][i].cost );
  }
}

int main(){
  cin >> N;
  G.resize(N); dist.resize(N, -1);
  for(int i = 1; i < N; i++){
    int a, b, c; scanf("%d%d%d", &a, &b, &c); --a; --b; 
    G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c});
  }
  int Q; cin >> Q;
  cin >> K; --K;
  dfs(K, -1, 0);
  for( int i = 0; i < Q; i++ ){
    int x, y; scanf("%d%d", &x, &y); --x; --y;
    cout << dist[x] + dist[y] << '\n';
  }
}

Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<int> dist;
      | ^~~~~~
a.cc: In function 'void dfs(int, int, int)':
a.cc:5:3: error: 'dist' was not declared in this scope
    5 |   dist[now] = depth;
      |   ^~~~
a.cc:6:23: error: 'G' was not declared in this scope
    6 |   for( int i = 0; i < G[now].size(); i++ ){
      |                       ^
a.cc: In function 'int main()':
a.cc:14:3: error: 'cin' was not declared in this scope
   14 |   cin >> N;
      |   ^~~
a.cc:14:10: error: 'N' was not declared in this scope
   14 |   cin >> N;
      |          ^
a.cc:15:3: error: 'G' was not declared in this scope
   15 |   G.resize(N); dist.resize(N, -1);
      |   ^
a.cc:15:16: error: 'dist' was not declared in this scope
   15 |   G.resize(N); dist.resize(N, -1);
      |                ^~~~
a.cc:17:18: error: 'scanf' was not declared in this scope
   17 |     int a, b, c; scanf("%d%d%d", &a, &b, &c); --a; --b;
      |                  ^~~~~
a.cc:18:20: error: 'edge' was not declared in this scope
   18 |     G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c});
      |                    ^~~~
a.cc:18:52: error: expected ')' before '{' token
   18 |     G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c});
      |                                               ~    ^
      |                                                    )
a.cc:21:10: error: 'K' was not declared in this scope
   21 |   cin >> K; --K;
      |          ^
a.cc:24:15: error: 'scanf' was not declared in this scope
   24 |     int x, y; scanf("%d%d", &x, &y); --x; --y;
      |               ^~~~~
a.cc:25:5: error: 'cout' was not declared in this scope
   25 |     cout << dist[x] + dist[y] << '\n';
      |     ^~~~
Language: C++

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

vector<lint> dist;
const lint INF = 1e18;
struct  edge{lint to, cost;};
vector<edge> G[100010];

void dfs(lint now, lint ago, lint depth){
  dist[now] = depth;
  for(lint i = 0; i < G[now].size(); i++){
    lint next = G[now][i].to;
    if(next == ago) continue;
    dfs(next, now, depth + G[now][i].cost);
  }
}

signed main(){
  lint N; cin >> N;
  for(lint i = 1; i < N; i++){
    lint a, b, c; scanf("%d%d", &a, &b, &c) --a; --b;
    G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c});
  }
  dist.resize(N, 0);
  lint Q, K; cin >> Q >> K;
  dfs(K - 1, -1, 0);
  for(lint i = 0; i < Q; i++){
    lint x, y; scanf("%d%d", &x, &y);
    lint ans = dist[x - 1] + dist[y - 1];
    cout << ans << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:24: error: lvalue required as decrement operand
   22 |     lint a, b, c; scanf("%d%d", &a, &b, &c) --a; --b;
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n,q,k,dx[100010];
vector<pair<ll,ll>>a[100010];
void dep(ll now){
	if(now!=k&&a[now].size()==1){
		return ;
	}
	for(ll i=0;i<a[i].size();i++){
		ll next=a[i].first;
		
	}
}
int main() {
	cin>>n;
	for(ll i=0;i<n-1;i++){
		ll x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		a[x].push_back(make_pair(y,c));
		a[y].push_back(make_pair(x,c));
	}
	cin>>q>>k;
	k--;
	dep(k);
	// your code goes here
	return 0;
}

Compiler output:
a.cc: In function 'void dep(ll)':
a.cc:13:30: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   13 |                 ll next=a[i].first;
      |                              ^~~~~
Language: C++

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

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

void dfs(const Graph &G, int v, int p, long long sum, vector<long long> &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(){
  int N; cin >> N;
  Graph G(N);
  for(int i=0; i<N-1; i++){
    int a, b; long long c;
    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;
  vector<long long> dist(N, 0);
  rec(G, K, -1, 0, dist);
  
  for(int i=0; i<Q; i++){
    int x, y; cin >> x >> y; --x, --y;
    cout << dist[x] + dist[y] <<endl;
  }
}
    
  
    

Compiler output:
a.cc: In function 'void dfs(const Graph&, int, int, long long int, std::vector<long long int>&)':
a.cc:12:5: error: 'rec' was not declared in this scope
   12 |     rec(G, e.first, v, sum+e.second, dist);
      |     ^~~
a.cc: In function 'int main()':
a.cc:29:3: error: 'rec' was not declared in this scope
   29 |   rec(G, K, -1, 0, dist);
      |   ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

struct edge { ll to, cost; };

ll N;
vector<vector<edge>> G;
ll dp[100100]; 

void dfs(ll v, ll par = -1) {
    for (ll i = 0; i < G[v].size(); i++) {
        ll next = G[v][i].to, next_cost = G[v][i].cost;

        if (next != par) {
            dp[next] = dp[v] + next_cost;
            dfs(next, v, d + next_cost);
        }
    }
}

int main() {
    cin >> N;
    G.resize(N);
    rep(i, N - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    ll Q, K;
    cin >> Q >> K;

    K--;
    dfs(K);

    // rep(i, N) {
    //     cout << i << " " << dp[i] << endl;
    // }
    // return 0;

    // x -> K -> y の最短路
    rep(i, Q) {
        ll x, y;
        cin >> x >> y;
        x--; y--;

        cout << dp[x] + dp[y] << endl;
    }
}

Compiler output:
a.cc: In function 'void dfs(ll, ll)':
a.cc:23:26: error: 'd' was not declared in this scope
   23 |             dfs(next, v, d + next_cost);
      |                          ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
static const int64_t INF = numeric_limits<int>::max();
int main() {
    int64_t N, Q, K;
    cin >> N;
    vector<vector<int64_t>> cost(N, vector<int64_t>(N, INF));
    for (int64_t i = 0, a, b, c; i < N - 1; i++) {
        cin >> a >> b >> c;
        cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
    }
    cin >> Q >> K;
    vector<bool> visited(N, false);
    vector<int64_t> dis(N, 0);
    queue<int64_t> q;
    visited[K - 1] = true;
    q.push(K - 1);
    while (!q.empty()) {
        int64_t t = q.front();
        q.pop();
        visited[t] = true;
        for (int64_t i = 0; i < N; i++) {
            if (cost[t][i] == INF || visited[i]) continue;
            q.push(i);
            dis[i] = dis[t] + cost[t][i];
        }
    }
    for (int64_t i = 0, x, y; i < Q; i++) {
        cin >> x >> y;
        cout << dis[x - 1] + dis[y - 1] << endl;
    }
}

Compiler output:
a.cc:5:28: error: 'numeric_limits' was not declared in this scope
    5 | static const int64_t INF = numeric_limits<int>::max();
      |                            ^~~~~~~~~~~~~~
a.cc:5:43: error: expected primary-expression before 'int'
    5 | static const int64_t INF = numeric_limits<int>::max();
      |                                           ^~~
Language: C++

#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
vector<vector<pair<ll,ll>>> v(N);
vector<ll> dist(N);
void dfs(ll cur, ll par,ll point=0){
    dist[cur] = point;
    // cout<<"cur:"<<cur<<", par:"<<par<<endl;
    for(ll i=0;i<v[cur].size();i++){
        ll next = v[cur][i].first;
        ll next_point = v[cur][i].second+point;
        // cout<<"next:"<<next<<endl;
        if(next!=par){
            dfs(next,cur,next_point);
        }
    }
    return;
}

int main(){
    long N;
    cin>>N;
    
    for(ll i=0;i<N-1;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
    
    ll Q,K;
    cin>>Q>>K;
    K--;
    ll x[Q],y[Q];
    for(ll i=0;i<Q;i++){
        ll _x,_y;
        cin>>_x>>_y;
        _x--;_y--;
        x[i] = _x;
        y[i] = _y;
    }
    dfs(K,-1);
    for(ll i=0;i<Q;i++){
        cout<<dist[x[i]]+dist[y[i]]<<"\n";
    }




}


Compiler output:
a.cc:11:31: error: 'N' was not declared in this scope
   11 | vector<vector<pair<ll,ll>>> v(N);
      |                               ^
a.cc:12:17: error: 'N' was not declared in this scope
   12 | vector<ll> dist(N);
      |                 ^
Language: C++

#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
vector<vector<pair<ll,ll>>> v;
vector<ll> dist;
void dfs(ll cur, ll par,ll point=0){
    dist[cur] = point;
    // cout<<"cur:"<<cur<<", par:"<<par<<endl;
    for(ll i=0;i<v[cur].size();i++){
        ll next = v[cur][i].first;
        ll next_point = v[cur][i].second+point;
        // cout<<"next:"<<next<<endl;
        if(next!=par){
            dfs(next,cur,next_point);
        }
    }
    return;
}

int main(){
    long N;
    cin>>N;
    v(N);
    dist(N);
    for(ll i=0;i<N-1;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
    
    ll Q,K;
    cin>>Q>>K;
    K--;
    ll x[Q],y[Q];
    for(ll i=0;i<Q;i++){
        ll _x,_y;
        cin>>_x>>_y;
        _x--;_y--;
        x[i] = _x;
        y[i] = _y;
    }
    dfs(K,-1);
    for(ll i=0;i<Q;i++){
        cout<<dist[x[i]]+dist[y[i]]<<"\n";
    }




}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:6: error: no match for call to '(std::vector<std::vector<std::pair<long long int, long long int> > >) (long int&)'
   30 |     v(N);
      |     ~^~~
a.cc:31:9: error: no match for call to '(std::vector<long long int>) (long int&)'
   31 |     dist(N);
      |     ~~~~^~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
struct edge{ ll to,cost;};
int main(){
  ll n;
  cin>>n;
  vector<vector<edge>> e(n,vector<edge>(0));
  rep(i,n-1){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    edge k;
    k.to=b;
    k.cost=c;
    e[a].pb(k);
    k.to=a;
    e[b].pb(k);
  }
  ll q,k;
  cin>>q>>k;
  vll l(n,INF);
  queue<ll> que;
  k--;
  l[k]=0;
  que.pu(k);
  while(sz(que)){
    ll h=que.front();
    que.pop();
    for(auto y:e[h]){
      if(l[y.F]!=INF) continue;
      l[y.F]=y.S+l[h];
      que.pu(y.F);
    }
  }
  rep(i,q){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    COUT(l[a]+l[b]);
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: 'struct edge' has no member named 'first'
   15 | #define F first
      |           ^~~~~
a.cc:70:14: note: in expansion of macro 'F'
   70 |       if(l[y.F]!=INF) continue;
      |              ^
a.cc:15:11: error: 'struct edge' has no member named 'first'
   15 | #define F first
      |           ^~~~~
a.cc:71:11: note: in expansion of macro 'F'
   71 |       l[y.F]=y.S+l[h];
      |           ^
a.cc:16:11: error: 'struct edge' has no member named 'second'
   16 | #define S second
      |           ^~~~~~
a.cc:71:16: note: in expansion of macro 'S'
   71 |       l[y.F]=y.S+l[h];
      |                ^
a.cc:15:11: error: 'struct edge' has no member named 'first'
   15 | #define F first
      |           ^~~~~
a.cc:72:16: note: in expansion of macro 'F'
   72 |       que.pu(y.F);
      |                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//幅優先探索
//全て添字で扱うこと
vll bfs(ll n, vector<vector<vll>> &next, ll start) {
  vll ans(n, 0);

  queue<vll> task;
  task.push({0, start});

  vll seen(n, 0);
  seen[start] = 1;

  ll depth = 0;
  while (task.size() > 0) {
      for (ll j = 0; j < next[task.front()[1]].size(); j++) {
        if (seen[next[task.front()[1]][j][1]] == 0) {
          ans[next[task.front()[1]][j][1]] = ans[task.front()[1]] + next[task.front()[1]][j][0];

          task.push(next[task.front()[1]][j]);
          seen[next[task.front()[1]][j][1]] = 1;
        }
      }
      task.pop();
    }
  }
  return ans
}

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

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

  ll q, k;
  cin >> q >> k;

  vll ans = bfs(n, next, k - 1);

  for (ll i = 0; i < q; i++) {
    ll x, y;
    cin >> x >> y;
    cout << ans[x - 1] + ans[y - 1] << endl;
  }
}


Compiler output:
a.cc: In function 'vll bfs(ll, std::vector<std::vector<std::vector<long long int> > >&, ll)':
a.cc:36:3: warning: no return statement in function returning non-void [-Wreturn-type]
   36 |   }
      |   ^
a.cc: At global scope:
a.cc:37:3: error: expected unqualified-id before 'return'
   37 |   return ans
      |   ^~~~~~
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//幅優先探索
//全て添字で扱うこと
vll bfs(ll n, vector<vector<vll>> &next, ll start) {
  vll ans(n, 0);

  queue<vll> task;
  task.push({0, start});

  vll seen(n, 0);
  seen[start] = 1;

  ll depth = 0;
  while (task.size() > 0) {
      for (ll j = 0; j < next[task.front()[1]].size(); j++) {
        if (seen[next[task.front()[1]][j][1]] == 0) {
          ans[next[task.front()[1]][j][1]] = ans[task.front()[1]] + next[task.front()[1]][j][0];

          task.push(next[task.front()[1]][j]);
          seen[next[task.front()[1]][j][1]] = 1;
        }
      }
      task.pop();
    }
  }
  return; ans
}

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

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

  ll q, k;
  cin >> q >> k;

  vll ans = bfs(n, next, k - 1);

  for (ll i = 0; i < q; i++) {
    ll x, y;
    cin >> x >> y;
    cout << ans[x - 1] + ans[y - 1] << endl;
  }
}

Compiler output:
a.cc: In function 'vll bfs(ll, std::vector<std::vector<std::vector<long long int> > >&, ll)':
a.cc:36:3: warning: no return statement in function returning non-void [-Wreturn-type]
   36 |   }
      |   ^
a.cc: At global scope:
a.cc:37:3: error: expected unqualified-id before 'return'
   37 |   return; ans
      |   ^~~~~~
a.cc:37:11: error: 'ans' does not name a type
   37 |   return; ans
      |           ^~~
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int N,Q,K;
vector<vector<pair<int>>> G; // グラフ
vector<ll> Dis; // 頂点Kからの距離
vector<bool> seen;

void dfs(int v){
  seen.at(v) = true;
  for (auto p : G.at(v)){
    auto nv = p.first;
    auto distance = p.second;
    if (seen.at(nv)) continue; // 既に訪れていればスキップ
    Dis.at(nv) = Dis.at(v) + distance;
    dfs(nv);
  }
}

int main() {
  cin >>N;
  G.assign(N, vector<int>());
  rep(i,N-1){
    int a,b,c; cin >>a >>b >>c;
    a--; b--;
    G.at(a).push_back(make_pair(b,c));
    G.at(b).push_back(make_pair(a,c));
  }
  cin >>Q >>K;

  seen.assign(N, false);
  Dis.assign(N, -1);
  K--;
  Dis.at(K) = 0;
  dfs(K);

  rep(i, Q){
    int a,b; cin >>a >>b;
    a--; b--;
    cout <<Dis.at(a) + Dis.at(b) <<endl;
  }
}

Compiler output:
a.cc:15:20: error: wrong number of template arguments (1, should be 2)
   15 | vector<vector<pair<int>>> G; // グラフ
      |                    ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:15:23: error: template argument 1 is invalid
   15 | vector<vector<pair<int>>> G; // グラフ
      |                       ^~
a.cc:15:23: error: template argument 2 is invalid
a.cc:15:25: error: template argument 1 is invalid
   15 | vector<vector<pair<int>>> G; // グラフ
      |                         ^
a.cc:15:25: error: template argument 2 is invalid
a.cc: In function 'void dfs(int)':
a.cc:21:19: error: request for member 'at' in 'G', which is of non-class type 'int'
   21 |   for (auto p : G.at(v)){
      |                   ^~
a.cc: In function 'int main()':
a.cc:32:5: error: request for member 'assign' in 'G', which is of non-class type 'int'
   32 |   G.assign(N, vector<int>());
      |     ^~~~~~
a.cc:36:7: error: request for member 'at' in 'G', which is of non-class type 'int'
   36 |     G.at(a).push_back(make_pair(b,c));
      |       ^~
a.cc:37:7: error: request for member 'at' in 'G', which is of non-class type 'int'
   37 |     G.at(b).push_back(make_pair(a,c));
      |       ^~
Language: Java

import java.util.*;

public class Main {
  private static final long INF = 1_000_000_000_000_000_000L;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    List<List<Dst>> from = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      from.add(new ArrayList<>());
    }
    for (int i = 0; i < N-1; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      a--;
      b--;
      int c = sc.nextInt();
      from.get(a).add(new Dst(b,c));
      from.get(b).add(new Dst(a,c));
    }

    int Q = sc.nextInt();
    int K = sc.nextInt();
    K--;
    
    PriorityQueue<Dst> pq = new PriorityQueue<>((a,b)->{
      if (a.cost == b.cost) {
        return 0;
      }
      return a.cost > b.cost ? 1 : -1;
    });
    long[] cost = new long[N];
    Arrays.fill(cost, INF);
    
    pq.offer(new Dst(K,0));
    while (!pq.isEmpty()) {
      now = pq.poll();
      if (cost[now.to] <= 0) continue;
      cost[now.to] = -now.cost;
      
      for (Dst p : from.get(now.to)) {
        long newCost = now.cost+p.cost;
        if (cost[p.to] > 0 && newCost < cost[p.to]) {
          cost[p.to] = newCost;
          pq.offer(new Dst(p.to,newCost));
        }
      }
    }
      
    StringBuilder ans = new StringBuilder();
    for (int i = 0; i < Q; i++) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      x--;
      y--;
      ans.append(-(cost[x]+cost[y])).append('\n');
    }
    System.out.print(ans.toString());
  }
  private static class Dst {
    private final int to;
    private final long cost;
    Dst(int to, long cost) {
      this.to = to;
      this.cost = cost;
    }
  }
}

Compiler output:
Main.java:37: error: cannot find symbol
      now = pq.poll();
      ^
  symbol:   variable now
  location: class Main
Main.java:38: error: cannot find symbol
      if (cost[now.to] <= 0) continue;
               ^
  symbol:   variable now
  location: class Main
Main.java:39: error: cannot find symbol
      cost[now.to] = -now.cost;
           ^
  symbol:   variable now
  location: class Main
Main.java:39: error: cannot find symbol
      cost[now.to] = -now.cost;
                      ^
  symbol:   variable now
  location: class Main
Main.java:41: error: cannot find symbol
      for (Dst p : from.get(now.to)) {
                            ^
  symbol:   variable now
  location: class Main
Main.java:42: error: cannot find symbol
        long newCost = now.cost+p.cost;
                       ^
  symbol:   variable now
  location: class Main
6 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main() {
  ll n;cin>>n;
  vector<ll> a(n-1),b(n-1),c(n-1);
  rep(i,n-1) cin>>a[i]>>b[i]>>c[i],a[i]--,b[i]--;
  ll q,k;cin>>q>>k;k--;
  vector<ll> x(q),y(q);
  vector<ll> g[n];
  rep(i,n-1){
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  vector<ll> to_k(n,-1);
  ll value[10000000000][100000000000];
  rep(i,n-1) value[a[i]][b[i]]=value[b[i]][a[i]]=c[i];
  rep(i,n) value[i][i]=0;
  queue<ll> que;
  que.push(k);
  to_k[k]=0;
  while(!que.empty()){
    auto tmp=que.front();
    que.pop();
    for(auto c:g[tmp]){
      if(to_k[c]==-1){
        to_k[c]=to_k[tmp]+value[tmp][c];
        que.push(c);
      }
    }
  }
  rep(i,q){
    ll x,y;cin>>x>>y;x--;y--;
    cout<<to_k[x]+to_k[y]<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:6: error: size of array 'value' exceeds maximum object size '9223372036854775807'
   17 |   ll value[10000000000][100000000000];
      |      ^~~~~
a.cc:18:14: error: 'value' was not declared in this scope
   18 |   rep(i,n-1) value[a[i]][b[i]]=value[b[i]][a[i]]=c[i];
      |              ^~~~~
a.cc:19:12: error: 'value' was not declared in this scope
   19 |   rep(i,n) value[i][i]=0;
      |            ^~~~~
a.cc:28:27: error: 'value' was not declared in this scope
   28 |         to_k[c]=to_k[tmp]+value[tmp][c];
      |                           ^~~~~
Language: C++

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

#define ll long long
#define limit 100002
struct edge2{
	int to;
  	int cost;
}edge;
void dfs(int v,int p,ll dist)
{
  depth[v]=dist;
  
  for(auto x:arr[v])
  {
    	if(x.to==p)
        {
         	continue; 
        }
    	else
        {
         	dfs(x.to,v,dist+x.cost); 
        }
  }
  
}
int main()
{
 	 
  vector<edge> arr[limit];
  ll depth[limit];
  int n;
  cin>>n;
  
  for(int i=0;i<n-1;i++)
  {
    
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    
    arr[a].push_back({b,c});
    arr[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;
    x--,y--;
    
    cout<<depth[x]+depth[y]<<endl;
    
  }
  
}


Compiler output:
a.cc: In function 'void dfs(int, int, long long int)':
a.cc:12:3: error: 'depth' was not declared in this scope
   12 |   depth[v]=dist;
      |   ^~~~~
a.cc:14:14: error: 'arr' was not declared in this scope
   14 |   for(auto x:arr[v])
      |              ^~~
a.cc: In function 'int main()':
a.cc:30:14: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   30 |   vector<edge> arr[limit];
      |              ^
a.cc:30:14: note:   expected a type, got 'edge'
a.cc:30:14: error: template argument 2 is invalid
a.cc:42:12: error: request for member 'push_back' in 'arr[a]', which is of non-class type 'int'
   42 |     arr[a].push_back({b,c});
      |            ^~~~~~~~~
a.cc:43:12: error: request for member 'push_back' in 'arr[b]', which is of non-class type 'int'
   43 |     arr[b].push_back({a,c});
      |            ^~~~~~~~~
Language: C++

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

#define limit 100002
struct edge2{
	int to;
  	int cost;
}edge;
void dfs(int v,int p,ll dist)
{
  depth[v]=dist;
  
  for(auto x:arr[v])
  {
    	if(x.to==p)
        {
         	continue; 
        }
    	else
        {
         	dfs(x.to,v,dist+x.cost); 
        }
  }
  
}
int main()
{
 	 
  vector<edge> arr[limit];
  ll depth[limit];
  int n;
  cin>>n;
  
  for(int i=0;i<n-1;i++)
  {
    
    int a,bc;
    cin>>a>>b>>c;
    a--;b--;
    
    arr[a].push_back({b,c});
    arr[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;
    x--,y--;
    
    cout<<depth[x]+depth[y]<<endl;
    
  }
  
}


Compiler output:
a.cc:9:22: error: 'll' has not been declared
    9 | void dfs(int v,int p,ll dist)
      |                      ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:11:3: error: 'depth' was not declared in this scope
   11 |   depth[v]=dist;
      |   ^~~~~
a.cc:13:14: error: 'arr' was not declared in this scope
   13 |   for(auto x:arr[v])
      |              ^~~
a.cc: In function 'int main()':
a.cc:29:14: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   29 |   vector<edge> arr[limit];
      |              ^
a.cc:29:14: note:   expected a type, got 'edge'
a.cc:29:14: error: template argument 2 is invalid
a.cc:30:3: error: 'll' was not declared in this scope
   30 |   ll depth[limit];
      |   ^~
a.cc:38:13: error: 'b' was not declared in this scope; did you mean 'bc'?
   38 |     cin>>a>>b>>c;
      |             ^
      |             bc
a.cc:38:16: error: 'c' was not declared in this scope; did you mean 'bc'?
   38 |     cin>>a>>b>>c;
      |                ^
      |                bc
a.cc:41:12: error: request for member 'push_back' in 'arr[a]', which is of non-class type 'int'
   41 |     arr[a].push_back({b,c});
      |            ^~~~~~~~~
a.cc:54:11: error: 'depth' was not declared in this scope
   54 |     cout<<depth[x]+depth[y]<<endl;
      |           ^~~~~
Language: C++

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

using namespace std;



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

long long int d[100010];
long long int n;

typedef pair<long long int, long long int> P;  

long long int V, d[100010];
vector<edge> G[100010]; 

void dijkstra(int s) {
    fill(d, d + V, 10000000009);
    d[s] = 0;  
    priority_queue<P, vector<P>, greater<P>> que;  
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;  
        if (d[v] < p.first) {
            continue;
        }
        for (auto e : G[v]) {  
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){

  long long int a[100010],b[100010],c[100010],q,k,x[100010],y[100010];
  
  cin >>n;
  
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
  }
  
   G[a[i]].push_back(edge{b[i],c[i]});
  
    G[b[i]].push_back(edge{a[i],c[i]});
  
  
  cin >> q >> k;
  
  k--;
  
  dijkstra(k);
  
  for(int i=0;i<q;i++){
    cin >> x[i] >> y[i];
    x[i]--,y[i]--;
  }
  
  for(int i=0;i<q;i++){
    cout << d[x[i]]+d[y[i]] << endl;
  }
}
  
  

Compiler output:
a.cc:18:18: error: redefinition of 'long long int d [100010]'
   18 | long long int V, d[100010];
      |                  ^
a.cc:13:15: note: 'long long int d [100010]' previously declared here
   13 | long long int d[100010];
      |               ^
a.cc: In function 'int main()':
a.cc:53:8: error: 'i' was not declared in this scope
   53 |    G[a[i]].push_back(edge{b[i],c[i]});
      |        ^