Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

const int max_v = 100010;
const ll infinite = 1000'0000'0000'0000;

ll cost[max_v][max_v]; // e=(u,v) cost, if not exists, INF
ll d[max_v]; // distance
bool used[max_v]; // flag
int V; // vertex count

void dijkstra(int s) {
    fill(d, d + V, infinite);
    fill(used, used + V, false);

    d[s] = 0;
    while(true) {
        int v = -1;
        // find minimum distance not used vertex
        for(int u = 0; u < V; u++) {
            if(!used[u] && (v == -1 || d[u] < d[v])) {
                v = u;
            }
        }

        if(v == -1) {
            break;
        }

        used[v] = true;
        for(int u = 0; u < V; u++) {
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }
}


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

    int n;
    cin >> n;

    for(int i = 0; i <= n; i++) {
        fill(cost[i], cost[i] + max_v, infinite);
    }

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

    int q, k;
    cin >> q >> k;
    V = n + 1;
    dijkstra(k);

    int x, y;
    for(int i = 0; i < q; i++) {
        cin >> x >> y;
#if DEBUG
        cout << "** RESULT **" << endl; // debug
        _DDEBUG(x, y);
        _DDEBUG(d[x], d[y]);
#endif
        cout << d[x] + d[y] << endl;
   }	
	return 0;
}



Compiler output:
/tmp/ccUWg2PW.o: in function `dijkstra(int)':
a.cc:(.text+0xd): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0x32): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0x44): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0x62): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0xdf): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccUWg2PW.o
a.cc:(.text+0xf8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status