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: wrong number of template arguments (1, should be 2)
    4 | #define int long long int;
      |                       ^~~
a.cc:7:14: note: in expansion of macro 'int'
    7 | typedef pair<int,int> P;
      |              ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/vector:62,
                 from a.cc:2:
/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:7:1: warning: 'typedef' was ignored in this declaration
    7 | typedef pair<int,int> P;
      | ^~~~~~~
a.cc:7:17: error: expected unqualified-id before ',' token
    7 | typedef pair<int,int> P;
      |                 ^
a.cc:4:13: error: expected unqualified-id before 'long'
    4 | #define int long long int;
      |             ^~~~
a.cc:7:18: note: in expansion of macro 'int'
    7 | typedef pair<int,int> P;
      |                  ^~~
a.cc:7:21: error: expected unqualified-id before '>' token
    7 | typedef pair<int,int> P;
      |                     ^
a.cc:8:8: error: 'P' was not declared in this scope
    8 | vector<P> G[200000];
      |        ^
a.cc:8:9: error: template argument 1 is invalid
    8 | vector<P> G[200000];
      |         ^
a.cc:8:9: error: template argument 2 is invalid
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long int;
      |                       ^~~
a.cc:9:1: note: in expansion of macro 'int'
    9 | int d[200000];
      | ^~~
a.cc:9:5: error: 'd' does not name a type
    9 | int d[200000];
      |     ^
a.cc:4:26: error: expected ')' before ';' token
    4 | #define int long long int;
      |                          ^
a.cc:11:10: note: in expansion of macro 'int'
   11 | void dfs(int prev, int now, int cost) {
      |          ^~~
a.cc:11:9: note: to match this '('
   11 | void dfs(int prev, int now, int cost) {
      |         ^
a.cc:11:14: error: 'prev' does not name a type
   11 | void dfs(int prev, int now, int cost) {
      |              ^~~~
a.cc:11:24: error: 'now' does not name a type
   11 | void dfs(int prev, int now, int cost) {
      |                        ^~~
a.cc:11:33: error: 'cost' does not name a type; did you mean 'const'?
   11 | void dfs(int prev, int now, int cost) {
      |                                 ^~~~
      |                                 const
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long int;
      |                       ^~~
a.cc:21:1: note: in expansion of macro 'int'
   21 | int main(void) {
      | ^~~
a.cc:21:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | int main(void) {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long int;
      |                       ^~~
a.cc:22:5: note: in expansion of macro 'int'
   22 |     int n;
      |     ^~~
a.cc:22:9: error: 'n' was not declared in this scope
   22 |     int n;
      |         ^
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long int;
      |                       ^~~
a.cc:25:9: note: in expansion of macro 'int'
   25 |     for(int i=0; i<n-1; i++) {
      |         ^~~
a.cc:25:13: error: 'i' was not declared in this scope
   25 |     for(int i=0; i<n-1; i++) {
      |             ^
a.cc:25:23: error: expected ')' before ';' token
   25 |     for(int i=0; i<n-1; i++) {
      |        ~              ^
      |                       )
a.cc:25:25: error: 'i' was not declared in this scope
   25 |     for(int i=0; i<n-1; i++) {
      |                         ^
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long int;
      |                       ^~~
a.cc:33:5: note: in expansion of macro 'int'
   33 |     int q,k;
      |     ^~~
a.cc:33:9: error: 'q' was not declared in this scope
   33 |     int q,k;
      |         ^
a.cc:33:11: error: 'k' was not declared in this scope
   33 |     int q,k;
      |           ^
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long int;
      |                       ^~~
a.cc:38:9: note: in expansion of macro 'int'
   38 |     for(int i=0; i<q; i++) {
      |         ^~~
a.cc:38:21: error: expected ')' before ';' token
   38 |     for(int i=0; i<q; i++) {
      |        ~            ^
      |                     )