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

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

bool visited[100005];
ll c, graph[100005][100005], value[100005];

void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < 100005; i++) {
        if (graph[v][i] > 0 && visited[i] == false) {
            value[i] = graph[v][i] + value[v];
            dfs(i);
        }
    }
}

int main() {
    int n, a, b, q, k, x, y;
    cin >> n;
    fill(graph[0], graph[n], 0);
    fill(visited, visited+n, false);

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

    cin >> q >> k;
    value[k] = 0;
    dfs(k);

    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        cout << value[x] + value[y] << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccVgRM1N.o: in function `dfs(int)':
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
a.cc:(.text+0xbf): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
/tmp/ccVgRM1N.o: in function `main':
a.cc:(.text+0x25c): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
a.cc:(.text+0x2b6): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
a.cc:(.text+0x2ce): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
collect2: error: ld returned 1 exit status
Language: C

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

bool visited[100005];
ll c, graph[100005][100005], value[100005];

void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < 100005; i++) {
        if (graph[v][i] > 0 && visited[i] == false) {
            value[i] = graph[v][i] + value[v];
            dfs(i);
        }
    }
}

int main() {
    int n, a, b, q, k, x, y;
    cin >> n;
    fill(graph[0], graph[n], 0);
    fill(visited, visited+n, false);

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

    cin >> q >> k;
    value[k] = 0;
    dfs(k);

    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        cout << value[x] + value[y] << endl;
    }

    return 0;
}

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

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

bool visited[100005];
ll c, graph[100005][100005], value[100005];

void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < 100005; i++) {
        if (graph[v][i] > 0 && visited[i] == false) {
            value[i] = graph[v][i] + value[v];
            dfs(i);
        }
    }
}

int main() {
    int n, a, b, q, k, x, y;
    cin >> n;
    fill(graph[0], graph[n], 0);
    fill(visited, visited+n, false);

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

    cin >> q >> k;
    value[k] = 0;
    dfs(k);

    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        cout << value[x] + value[y] << endl;
    }

    return 0;
}

Compiler output:
/tmp/ccaGHiFU.o: in function `dfs(int)':
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
a.cc:(.text+0xbf): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
/tmp/ccaGHiFU.o: in function `main':
a.cc:(.text+0x25c): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
a.cc:(.text+0x2b6): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
a.cc:(.text+0x2ce): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
collect2: error: ld returned 1 exit status
Language: C++

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

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


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

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

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


int n;
int a,b；
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];


void dfs(int s,int p,long d){
    ans[s]=d;
	for(int i=0;i<(int)v[s].size();i++){
	    if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
	}
}
		
int main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	cin>>q>>k;
	for(int i=1;i<=n;i++)ans[i]=10000000000000000;
	dfs(k,0,0)
	rep(i,q){
		cin>>x>>y;
		cout<<ans[x]+ans[y]<<endl;
	}
	return 0;
}


Compiler output:
a.cc:8:1: error: expected initializer before 'long'
    8 | long c;
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:25: error: 'b' was not declared in this scope
   27 |                 cin>>a>>b>>c;
      |                         ^
a.cc:27:28: error: 'c' was not declared in this scope
   27 |                 cin>>a>>b>>c;
      |                            ^
a.cc:28:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
   28 |                 v[a].push_back({b,c});
      |                 ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Language: C++

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


int n;
int a;
int b;
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];


void dfs(int s,int p,long d){
    ans[s]=d;
	for(int i=0;i<v[s].size();i++){
	    if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
	}
}
		
int main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	cin>>q>>k;
	for(int i=1;i<=n;i++)ans[i]=10000000000000000;
	dfs(k,0,0)
	rep(i,q){
		cin>>x>>y;
		cout<<ans[x]+ans[y]<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:19: error: expected ';' before 'for'
   34 |         dfs(k,0,0)
      |                   ^
      |                   ;
a.cc:35:13: error: 'i' was not declared in this scope
   35 |         rep(i,q){
      |             ^
a.cc:3:30: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
Language: C++

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


int n;
int a;
int b；
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];


void dfs(int s,int p,long d){
    ans[s]=d;
	for(int i=0;i<v[s].size();i++){
	    if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
	}
}
		
int main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	cin>>q>>k;
	for(int i=1;i<=n;i++)ans[i]=10000000000000000;
	dfs(k,0,0)
	rep(i,q){
		cin>>x>>y;
		cout<<ans[x]+ans[y]<<endl;
	}
	return 0;
}


Compiler output:
a.cc:9:1: error: expected initializer before 'long'
    9 | long c;
      | ^~~~
a.cc: In function 'int main()':
a.cc:28:25: error: 'b' was not declared in this scope
   28 |                 cin>>a>>b>>c;
      |                         ^
a.cc:28:28: error: 'c' was not declared in this scope
   28 |                 cin>>a>>b>>c;
      |                            ^
a.cc:29:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
   29 |                 v[a].push_back({b,c});
      |                 ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:34:19: error: expected ';' before 'for'
   34 |         dfs(k,0,0)
      |                   ^
      |                   ;
a.cc:35:13: error: 'i' was not declared in this scope
   35 |         rep(i,q){
      |             ^
a.cc:3:30: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
Language: C++

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


int n;
int a,b；
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];


void dfs(int s,int p,long d){
    ans[s]=d;
	for(int i=0;i<v[s].size();i++){
	    if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
	}
}
		
int main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	cin>>q>>k;
	for(int i=1;i<=n;i++)ans[i]=10000000000000000;
	dfs(k,0,0)
	rep(i,q){
		cin>>x>>y;
		cout<<ans[x]+ans[y]<<endl;
	}
	return 0;
}


Compiler output:
a.cc:8:1: error: expected initializer before 'long'
    8 | long c;
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:25: error: 'b' was not declared in this scope
   27 |                 cin>>a>>b>>c;
      |                         ^
a.cc:27:28: error: 'c' was not declared in this scope
   27 |                 cin>>a>>b>>c;
      |                            ^
a.cc:28:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
   28 |                 v[a].push_back({b,c});
      |                 ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:33:19: error: expected ';' before 'for'
   33 |         dfs(k,0,0)
      |                   ^
      |                   ;
a.cc:34:13: error: 'i' was not declared in this scope
   34 |         rep(i,q){
      |             ^
a.cc:3:30: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
Language: C++

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


int n;
int a,b；
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];


void dfs(int s,int p,long d){
    ans[s]=d;
	for(int i=0;i<v[s].size();i++){
	    if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
	}
}
		
int main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	cin>>q>>k;
	for(int i=1;i<=n;i++)ans[i]=10000000000000000;
	dfs(k,0,0)
	rep(i,q){
		cin>>x>>y;
		cout<<ans[x]+ans[y]<<endl;
	}
	return 0;
}


Compiler output:
a.cc:8:1: error: expected initializer before 'long'
    8 | long c;
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:25: error: 'b' was not declared in this scope
   27 |                 cin>>a>>b>>c;
      |                         ^
a.cc:27:28: error: 'c' was not declared in this scope
   27 |                 cin>>a>>b>>c;
      |                            ^
a.cc:28:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
   28 |                 v[a].push_back({b,c});
      |                 ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Language: C++

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


int n;
int a,b,c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];


void dfs(int s,long d){
    ans[s]=d;
	for(int i=0;i<v[s].size();i++){
	    if(ans[v[s][i].second]==10000000000000000)continue;
		dfs(v[s][i].first,d+v[s][i].second);
	}
}
		
int main(){
	cin>>n;
	rep(i,n-1){
		cin>>a>>b>>c;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	cin>>q>>k;
	for(int i=1;i<=n;i++)ans[i]=10000000000000000;
	dfs(k,0)
	rep(i,q){
		cin>>x>>y;
		cout<<ans[x]+ans[y]<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:17: error: expected ';' before 'for'
   33 |         dfs(k,0)
      |                 ^
      |                 ;
a.cc:34:13: error: 'i' was not declared in this scope
   34 |         rep(i,q){
      |             ^
a.cc:3:30: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

using namespace std;


#define INF LONG_MAX
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);
    for(int 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(int 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(){
  int from,to,cost,N;
  cin >> N ;
  graph g(N);

  for(int i = 0; i < N-1; i++){
    cin >> from >> to >> cost;
    from --; to --;
    g.add_edge(from,to,cost);
    g.add_edge(to,from,cost);
  }
  int Q,K,x,y;
  cin >> Q >> K;

  K--;
  g.dijkstra(K);

  for(int i = 0; i < Q; i++){
    cin >> x >> y;
    x--; y--;
    long long ans = g.d[x] + g.d[y];
    cout << ans << endl;;
  }
  return 0;
}


Compiler output:
a.cc: In member function 'void graph::init(ll)':
a.cc:27:13: error: 'LONG_MAX' was not declared in this scope
   27 | #define INF LONG_MAX
      |             ^~~~~~~~
a.cc:46:14: note: in expansion of macro 'INF'
   46 |       d[i] = INF;
      |              ^~~
a.cc:23:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   22 | #include <queue>
  +++ |+#include <climits>
   23 | 
a.cc: In member function 'void graph::dijkstra(ll)':
a.cc:27:13: error: 'LONG_MAX' was not declared in this scope
   27 | #define INF LONG_MAX
      |             ^~~~~~~~
a.cc:58:14: note: in expansion of macro 'INF'
   58 |       d[i] = INF;
      |              ^~~
a.cc:27:13: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   27 | #define INF LONG_MAX
      |             ^~~~~~~~
a.cc:58:14: note: in expansion of macro 'INF'
   58 |       d[i] = INF;
      |              ^~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#include <map>

#define INF 2147483647
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

struct e { ll to, cost; };
typedef pair<ll, ll> P;
int main() {
	int N;
	cin >> N;
	vector<vector<e> > G(N,vector<e>());
	vector<ll> d(N, LLONG_MAX);
	for (int i = 0; i < N - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		G[a-1].push_back(e{ b-1, c });
		G[b-1].push_back(e{ a-1, c });
	}
	int Q, K;
	cin >> Q >> K; K--;
	priority_queue<P, vector<P>, greater<P>> que;
	d[K] = 0;
	que.push(P(0, K));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			e next = G[v][i];
			if (d[next.to] > d[v] + next.cost) {
				d[next.to] = d[v] + next.cost;
				que.push(P(d[next.to], next.to));
			}
		}
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:23:25: error: 'LLONG_MAX' was not declared in this scope
   23 |         vector<ll> d(N, LLONG_MAX);
      |                         ^~~~~~~~~
a.cc:11:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <map>
  +++ |+#include <climits>
   11 |
Language: C

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int n,q,k;
int m,head[300020],next[300020],to[300020];
long long len[300020],dis[300020];
bool visited[300020];

void dfs(int x,int y, long long d){
    dis[x]=d;
    visited[x]=true;
    for (int e=head[x]; e!=-1; e=next[e]){
        if (visited[to[e]]==false){
           if (to[e]==y) {
                continue;
            }
            dfs(to[e],x,len[e]+d);
            visited[to[e]]=false;
        }
    }
}

int main(void){
    scanf("%d",&n);
    for (int i=0, i<n; i++){
        head[i]=-1;
    }
    for (int i=0; i<n-1; i++){
        int a,b;
        long long c;
        scanf("%d%d%lld",&a,&b,&c);
        a--;
        b--;
        next[m]=head[a];
        head[a]=m;
        to[m]=b;
        len[m]=c;
        m++;
        next[m]=head[b];
        head[b]=m;
        to[m]=a;
        len[m]=c;
        m++;
    }
    scanf("%d%d",&q,&k);
    dfs(k-1,-1,0);
    for (int i=0; i<q; i++){
        int x,y;
        scanf("%d%d",&x,&y);
        printf("%lld\n",dis[x-1]+dis[y-1]);
    }
	return 0 ;
}

Compiler output:
main.c: In function 'main':
main.c:26:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   26 |     for (int i=0, i<n; i++){
      |                    ^
main.c:26:27: error: expected ';' before ')' token
   26 |     for (int i=0, i<n; i++){
      |                           ^
      |                           ;
Language: C

#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 1 << 58;

const int MOD = 1000000007;


int N, Q, K;
vector<pair<int, int> > ab[100010];
long saitankyori[100010];
bool tootta[100010];
int kyori(int genzaichi){
    tootta[genzaichi] = true;
    while(!ab[genzaichi].empty()){
        int tuginogenzaichi = ab[genzaichi][0].first;
        long tuginogenzaichimadenokyori = ab[genzaichi][0].second;
        ab[genzaichi].erase(ab[genzaichi].begin());
        if(!tootta[tuginogenzaichi]){
            saitankyori[tuginogenzaichi] = saitankyori[genzaichi] + tuginogenzaichimadenokyori;
            kyori(tuginogenzaichi);
        }
    }
    if(genzaichi == K)return 0;
    return 0;
}
int transittreepath(){
    cin >> N;
    REP(i, N - 1){
        int a, b, c;
        cin >> a >> b >> c;
        ab[a].push_back(pair<int, int>(b,c));
        ab[b].push_back(pair<int, int>(a,c));
    }
    
    cin >> Q >> K;
    int x, y;
    long answers[100010];
    REP(i, N + 1){
        saitankyori[i] = INF;
        saitankyori[i] *= 256;
    }
    
    saitankyori[K] = 0;
    kyori(K);
    
    REP(i, Q){
        cin >> x >> y;
        answers[i] = saitankyori[x] + saitankyori[y];
    }
    
    REP(i, Q){
        printf("%ld\n", answers[i]);
    }
    return 0;
}

/*
 vector<int> ab[100010];
 int konokazu[100100] = {0};
 ll dpf[100100] = {0};
 ll dpg[100100] = {0};
 bool tootta[100010] = {false};
 int N;
int kyori(int genzaichi){
    bool hasi = true;
    tootta[genzaichi] = true;
    while(!ab[genzaichi].empty()){
        int tuginogenzaichi = ab[genzaichi][0];
        ab[genzaichi].erase(ab[genzaichi].begin());
        if(!tootta[tuginogenzaichi]){
            kyori(tuginogenzaichi);
            dpf[genzaichi] = (dpg[tuginogenzaichi] * dpf[genzaichi]) % MOD;
            dpg[genzaichi] = (dpf[tuginogenzaichi] * dpg[genzaichi]) % MOD;
        }
    }
    dpf[genzaichi] += dpg[genzaichi];
    dpf[genzaichi] %= MOD;
    dpg[genzaichi] %= MOD;
    return 0;
}
int nurie(){
    //treeDP
    cin >> N;
    REP(i, N - 1){
        int a,b;
        cin >> a >> b;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }
    REP(i, N + 1){
        dpf[i] = 1;
        dpg[i] = 1;
    }
    
    tootta[1] = true;
    kyori(1);
    
    return dpf[1];
}
*/

int main(){
    transittreepath();
}


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

#include<cstdio>
#include <vector>
#include <map>
#define int long long int
using namespace std;

typedef pair<int,int> P;
vector<P> G[200000];
int d[200000];

void dfs(int prev, int now, int cost) {
    d[now] = cost;
    for(P p : G[now]) {
        int next = p.first;
        int ncost = p.second;
        if(next == prev) continue;
        dfs(now, next, cost + ncost);
    }
}

int main(void) {
    int n;
    scanf("%lld",&n);

    for(int i=0; i<n-1; i++) {
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a--, b--;
        G[a].push_back(P(b,c));
        G[b].push_back(P(a,c));
    }

    int q,k;
    scanf("%lld%lld",&q,&k);
    k--;
    dfs(-1, k, 0);

    for(int i=0; i<q; i++) {
        int x,y;
        scanf("%lld%lld",&x,&y);
        x--, y--;
        printf("%lld\n", d[x] + d[y]);
    }
}

Compiler output:
a.cc:4:23: error: '::main' must return 'int'
    4 | #define int long long int
      |                       ^~~
a.cc:21:1: note: in expansion of macro 'int'
   21 | int main(void) {
      | ^~~
Language: C++

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

ll cost[100100][100100];
ll d[100100];
bool used[100100];
ll V;

void dk(int s) {
  fill(d, d + V, 10000000000);
  fill(used, used + V, false);
  d[s] = 0;

  while (true) {
    int v = -1;
    rep(u, V){
      if (!used[u] && (v == -1 || d[u] < d[v])) {
        v = u;
      }
    }
    if (v == -1) break;
    used[v] = true;
    rep(u, V){
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
}

int main(){
  cin >> V;
  int a, b, c;
  rep(i, V){
    rep(j, V){
      cost[i][j] = 10000000000;
    }
  }
  rep(i, V-1){
    cin >> a >> b >> c;
    cost[a-1][b-1] = c;
    cost[b-1][a-1] = c;
  }

  int Q, K, x, y;
  cin >> Q >> K;
  dk(K-1); // 頂点1が配列番号の0と対応しているため

  rep(i, Q){
    cin >> x >> y;
    cout << d[x-1] + d[y-1] << endl;
  }

}


Compiler output:
/tmp/ccIRfkAn.o: in function `dk(int)':
a.cc:(.text+0x1c): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x5d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x72): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0xb2): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0xef): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x10f): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define MAX 100010
#define int long long
using namespace std;

struct edge {
  int to, cost;
};

typedef pair<int, int> P;

vector<edge> G[MAX];
int d[MAX];
int n;

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + n + 1, LLONG_MAX / 4);
  d[s] = 0;
  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 (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

signed main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge tmp;
    tmp.to = b;
    tmp.cost = c;
    G[a].push_back(tmp);
    tmp.to = a;
    G[b].push_back(tmp);
  }
  int q, k;
  cin >> q >> k;
  dijkstra(k);
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    cout << d[x] + d[y] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'void dijkstra(long long int)':
a.cc:21:22: error: 'LLONG_MAX' was not declared in this scope
   21 |   fill(d, d + n + 1, LLONG_MAX / 4);
      |                      ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <queue>
  +++ |+#include <climits>
    4 | #include <vector>
Language: C

#include<iostream>
#include<vector>
using namespace std;
int n,a,b,q,k,x,y,j,visit[100010]={},cnt[100010]={};
long c,dis[100010];
vector<vector<int>> v(100010);
vector<vector<int>> d(100010);

int dfs(int p){
  visit[p]=1;
  int i;
  for(i=0;i<cnt[p];i++){
    //cout<<p<<" "<<cnt[p]<<endl;
    if(visit[v[p][i]]==0){
      dis[v[p][i]]=dis[p]+d[p][i];
      dfs(v[p][i]);
    }
  }   
}

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

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

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long lint;
typedef pair<lint,lint> P;
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define MAX_V 100005
struct edge{lint to,cost;};
lint n;
vector<edge> vec[MAX_V];
lint d[MAX_V];
void dijkstra(lint k);
signed main(){
    cin>>n;
    rep(i,n-1){  
        lint a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        vec[a].push_back({b,c});
        vec[b].push_back({a,c});
    }          
    lint q,k;
    cin>>q>>k;
    k--;
    dijkstra(k);
    rep(i,q){
        lint x,y;
        cin>>x>>y; 
        x--;
        y--;
         cout<<d[x]+d[y]<<endl;
    }
    return 0;
}
void dijkstra(lint k){
    priority_queue<P, vector<P>,greater<P> >que;
    fill(d,d+n,INF);
    d[k]=0;
    que.push(P(0,k));
    while(!que.empty()){
        P p=que.top();
        que.pop();
        lint v= p.second;
        if(d[v]<p.first)continue;
        for(lint i=0;i<vec[v].size();i++){
            edge temp=vec[v][i];
            if(d[temp.to]>d[v]+temp.cost){
                d[temp.to]=d[v]+temp.cost;
                que.push(P(d[temp.to],temp.to));
            }
        }
    }
}


Compiler output:
a.cc: In function 'void dijkstra(lint)':
a.cc:14:13: error: 'LLONG_MAX' was not declared in this scope
   14 | #define INF LLONG_MAX
      |             ^~~~~~~~~
a.cc:46:16: note: in expansion of macro 'INF'
   46 |     fill(d,d+n,INF);
      |                ^~~
a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <utility>
  +++ |+#include <climits>
   10 | using namespace std;
Language: Java

import java.util.*;

public class Main {
    @lombok.ToString
    private class Edge {
        int to;
        long cost;

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

    @lombok.ToString
    private class Node {
        long minCost = Long.MAX_VALUE;
        List<Edge> childs = new ArrayList<>();
        boolean isFix = false;

        public void addEdge(Edge e) {
            childs.add(e);
        }

        public void fixed() {
            isFix = true;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        Node nodes[] = new Node[n + 1];
        for (int i = 1; i <= n; i++) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            long c = sc.nextLong();
            nodes[a].addEdge(new Edge(b, c));
            nodes[b].addEdge(new Edge(a, c));
        }

        int q = sc.nextInt();
        int k = sc.nextInt();
        dijkstra(k, n, nodes);

        for (int i = 0; i < q; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            System.out.println(nodes[x].minCost + nodes[y].minCost);
        }
    }

    public void dijkstra(int start, int n, Node nodes[]) {
        nodes[start].minCost = 0;

        Queue<Node> queue = new PriorityQueue<>((n1, n2) -> Long.compare(n1.minCost, n2.minCost));
        queue.add(nodes[start]);
        while (!queue.isEmpty()) {
            Node src = queue.poll();
            src.fixed();
            for (Edge e : src.childs) {
                Node dst = nodes[e.to];
                if (!dst.isFix) {
                    dst.minCost = Math.min(dst.minCost, src.minCost + e.cost);
                    queue.add(dst);
                }
            }
        }
    }

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


Compiler output:
Main.java:15: error: package lombok does not exist
    @lombok.ToString
           ^
Main.java:4: error: package lombok does not exist
    @lombok.ToString
           ^
2 errors
Language: C

#include <bits/stdc++.h>
using namespace std;
#define INF 100100100100100
#define NMAX 100000
typedef long long llong;

llong d[NMAX];
vector<pair<llong, int>> g[NMAX];

void dijkstra(int s) {
    priority_queue<pair<llong, int>, vector<pair<llong, int>>, greater<pair<llong, int>>> que;
    fill(d, d + NMAX, INF);
    d[s] = 0;
    que.push({0, s});
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < g[v].size(); i++) {
            auto e = g[v][i];
            if (d[e.second] > d[v] + e.first) {
                d[e.second] = d[v] + e.first;
                que.push({d[e.second], e.second});
            }
        }
    }
}

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--;
        g[a].push_back({c, b});
        g[b].push_back({c, a});
    }
    int q, k;
    cin >> q >> k;
    k--;
    dijkstra(k);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << d[x] + d[y] << endl;
    }
}


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

#include <bits/stdc++.h>
#define inf (1<<29)
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define MEMSET(a) memset(a,0,sizeof(a))
using namespace std;

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

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

int main(){
	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:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++


int n,a,b,q,k;
ll c;
ll depth[100000] ={0};

typedef struct{int to;ll cost;} edge;
vector<edge> tree[100000];

void dfs(int v,int p, ll d){
  depth[v] = d;
  for(int i = 0;i<tree[v].size();i++){
    if(tree[v][i].to == p) continue;
    dfs(tree[v][i].to, v, d + tree[v][i].cost);
  }
}

int main(){
  scanf("%d", &n);
  REP(i,n){
    scanf("%d %d %lld",&a,&b,&c);
    a--;b--;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }
  scanf("%d %d",&q,&k);
  k--;
  dfs(k,-1,0);
  REP(i,q){
    int x,y;
    scanf("%d %d",&x,&y);
    x--;y--;
    printf("%lld\n",depth[x]+depth[y]);
  }
}


Compiler output:
a.cc:3:1: error: 'll' does not name a type
    3 | ll c;
      | ^~
a.cc:4:1: error: 'll' does not name a type
    4 | ll depth[100000] ={0};
      | ^~
a.cc:6:23: error: 'll' does not name a type
    6 | typedef struct{int to;ll cost;} edge;
      |                       ^~
a.cc:7:1: error: 'vector' does not name a type
    7 | vector<edge> tree[100000];
      | ^~~~~~
a.cc:9:23: error: 'll' has not been declared
    9 | void dfs(int v,int p, ll d){
      |                       ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:10:3: error: 'depth' was not declared in this scope
   10 |   depth[v] = d;
      |   ^~~~~
a.cc:11:19: error: 'tree' was not declared in this scope
   11 |   for(int i = 0;i<tree[v].size();i++){
      |                   ^~~~
a.cc: In function 'int main()':
a.cc:18:3: error: 'scanf' was not declared in this scope
   18 |   scanf("%d", &n);
      |   ^~~~~
a.cc:19:7: error: 'i' was not declared in this scope
   19 |   REP(i,n){
      |       ^
a.cc:19:3: error: 'REP' was not declared in this scope
   19 |   REP(i,n){
      |   ^~~
Language: C

#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define  mem memset(a,0,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;

typedef long long ll;
using namespace std;

ll d[100005];
typedef pair<int,int>P;
vector<P>vec[100005];

void dfs(int x,int y)
{
    int n=vec[x].size();
    for(int i=0;i<n;i++)
    {
        if(vec[x][i].first!=y)
        {
            P s=vec[x][i];
            d[s.first]=d[x]+s.second;
            dfs(s.first,x);
        }
    }
}
int main()
{
    int n,m,k,q;
    int i;
    cin>>n;
    int a,b,c;
    for(i=0;i<n-1;i++)
    {
        cin>>a>>b>>c;
        vec[a].push_back(P(b,c));
        vec[b].push_back(P(a,c));
    }
    cin>>q>>k;
    d[k]=0;
    dfs(k,k);
    while(q--)
    {
        cin>>a>>b;

        cout<<d[a]+d[b]<<endl;
    }
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
using namespace  std;  
#define  ll long long  
static const ll INF=1e9;
static const ll MAX=1e5+7;
const    ll   len=1e5+5;
ll n;
ll m[len][len],d[len];
struct ss{
	ll y;
	ll w;
};
vector<ss>ve[len];
void dkstl(ll s)
{
	ll u,minm;
	ll flag[len];
	for(ll i=0;i<n;++i)
	{
		d[i]=INF;
		flag[i]=0;
	}
	d[s]=0;
	while(1)
	{
		minm=INF;u=-1;
		for(ll i=0;i<n;++i)
		{
			if(flag[i]==0&&d[i]<minm)
			{
				u=i;
				minm=d[i];
			}
		}
		if(u==-1)break;
		flag[u]=1;
		for(ll v=0;v<ve[u].size();++v)
		{
			if(flag[ve[u][v].y]==0)
			{
				if(d[ve[u][v].y]>ve[u][v].w+d[u])
					d[ve[u][v].y]=ve[u][v].w+d[u];
			}
		}
	}
	//for(ll i=0;i<n;++i)
	//	printf("%lld ",d[i]);
	//return d[z];
}
int main()
{	
	while(cin>>n)
	{
		ll i,j,t;
		//for(i=0;i<n;++i)
		{
			//for(j=0;j<n;++j)
				//m[i][j]=INF;
		}
		ss kkk;
		for(ll u=0;u<n-1;++u)
		{
			scanf("%lld%lld",&i,&j);
			i--;j--;
			cin>>t;
			kkk.y=j;
			kkk.w=t;
			ve[i].push_back(kkk);
		}
		//for(i=0;i<n;++i)
		{
			//for(j=0;j<n;++j)
				//cout<<m[i][j]<<' ';
			//cout<<endl;
		}
		ll q,k;
		cin>>q>>k;
		k--;
		dkstl(k);
		for(ll v=1;v<=q;++v)
		{
			scanf("%lld%lld",&i,&j);
			i--;j--;
			printf("%lld\n",d[i]+d[j]);
		}
	}
	return 0;
}

Compiler output:
/tmp/cclyGdz3.o: in function `dkstl(long long)':
a.cc:(.text+0x2c): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x6c): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0xb2): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x131): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x174): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x1b4): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x1dd): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x20a): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x233): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
using namespace  std;  
#define  ll long long  
static const ll INF=1e9;
static const ll MAX=1e5+7;
const    ll   len=1e5+5;
ll n;
ll m[len][len],d[len];
void dkstl(ll s)
{
	ll u,minm;
	ll flag[len];
	for(ll i=0;i<n;++i)
	{
		d[i]=INF;
		flag[i]=0;
	}
	d[s]=0;
	while(1)
	{
		minm=INF;u=-1;
		for(ll i=0;i<n;++i)
		{
			if(flag[i]==0&&d[i]<minm)
			{
				u=i;
				minm=d[i];
			}
		}
		if(u==-1)break;
		flag[u]=1;
		for(ll v=0;v<n;++v)
		{
			if(flag[v]==0&&m[u][v]!=INF)
			{
				if(d[v]>m[u][v]+d[u])
					d[v]=m[u][v]+d[u];
			}
		}
	}
	//for(ll i=0;i<n;++i)
	//	printf("%lld ",d[i]);
	//return d[z];
}
int main()
{	
	while(cin>>n)
	{
		ll i,j,t;
		for(i=0;i<n;++i)
		{
			for(j=0;j<n;++j)
				m[i][j]=INF;
		}
		for(ll u=0;u<n-1;++u)
		{
			scanf("%lld%lld",&i,&j);
			i--;j--;
			cin>>t;
			m[i][j]=t;
			m[j][i]=t;
		}
		//for(i=0;i<n;++i)
		{
			//for(j=0;j<n;++j)
				//cout<<m[i][j]<<' ';
			//cout<<endl;
		}
		ll q,k;
		cin>>q>>k;
		k--;
		dkstl(k);
		for(ll v=1;v<=q;++v)
		{
			scanf("%lld%lld",&i,&j);
			i--;j--;
			printf("%lld\n",d[i]+d[j]);
		}
	}
	return 0;
}

Compiler output:
/tmp/ccA4akB4.o: in function `dkstl(long long)':
a.cc:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0xd6): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x171): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x1f1): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x20c): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
/tmp/ccA4akB4.o: in function `main':
a.cc:(.text+0x40e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x425): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
collect2: error: ld returned 1 exit status