Language: C++

#include <bits/stdc++.h>
using namespace std;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(){
  int N;cin>>N;
  graph g(N);
  vector<int>A(N-1);
  vector<int>B(N-1);
  vector<int>C(N-1);
  for(int i=0;i<N-1;i++){
    cin>>A[i]>>B[i]>>C[i];
    g.add_edge(A[i]-1,B[i]-1,C[i]);
  }
  int Q,K;cin>>Q>>K;
  g.dijkstra(K);
  vector<int>x(Q);
  vector<int>y(Q);
  long long ans=0;
  for(int i=0;i<Q;i++){
    cin>>x[i]>>y[i];
    ans+=g.d[x[i]-1]+g.d[y[i]-1];
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc:2:33: error: 'll' does not name a type
    2 | using namespace std;struct edge{ll to, cost;};
      |                                 ^~
a.cc:3:14: error: 'll' was not declared in this scope
    3 | typedef pair<ll,ll> P;
      |              ^~
a.cc:3:17: error: 'll' was not declared in this scope
    3 | typedef pair<ll,ll> P;
      |                 ^~
a.cc:3:19: error: template argument 1 is invalid
    3 | typedef pair<ll,ll> P;
      |                   ^
a.cc:3:19: error: template argument 2 is invalid
a.cc:5:3: error: 'll' does not name a type
    5 |   ll V;
      |   ^~
a.cc:7:10: error: 'll' was not declared in this scope
    7 |   vector<ll> d;
      |          ^~
a.cc:7:12: error: template argument 1 is invalid
    7 |   vector<ll> d;
      |            ^
a.cc:7:12: error: template argument 2 is invalid
a.cc:8:11: error: expected ')' before 'n'
    8 |   graph(ll n){
      |        ~  ^~
      |           )
a.cc:11:13: error: 'll' has not been declared
   11 |   void init(ll n){
      |             ^~
a.cc:19:17: error: 'll' has not been declared
   19 |   void add_edge(ll s, ll t, ll cost){
      |                 ^~
a.cc:19:23: error: 'll' has not been declared
   19 |   void add_edge(ll s, ll t, ll cost){
      |                       ^~
a.cc:19:29: error: 'll' has not been declared
   19 |   void add_edge(ll s, ll t, ll cost){
      |                             ^~
a.cc:24:17: error: 'll' has not been declared
   24 |   void dijkstra(ll s){
      |                 ^~
a.cc: In member function 'void graph::init(int)':
a.cc:12:5: error: 'V' was not declared in this scope
   12 |     V = n;
      |     ^
a.cc:14:7: error: request for member 'resize' in '((graph*)this)->graph::d', which is of non-class type 'int'
   14 |     d.resize(V);
      |       ^~~~~~
a.cc:15:9: error: 'i' was not declared in this scope
   15 |     REP(i,V){
      |         ^
a.cc:15:5: error: 'REP' was not declared in this scope
   15 |     REP(i,V){
      |     ^~~
a.cc: In member function 'void graph::add_edge(int, int, int)':
a.cc:21:7: error: 'struct edge' has no member named 'to'
   21 |     e.to = t, e.cost = cost;
      |       ^~
a.cc:21:17: error: 'struct edge' has no member named 'cost'
   21 |     e.to = t, e.cost = cost;
      |                 ^~~~
a.cc: In member function 'void graph::dijkstra(int)':
a.cc:25:9: error: 'i' was not declared in this scope
   25 |     REP(i,V){
      |         ^
a.cc:25:11: error: 'V' was not declared in this scope
   25 |     REP(i,V){
      |           ^
a.cc:25:5: error: 'REP' was not declared in this scope
   25 |     REP(i,V){
      |     ^~~
a.cc:28:6: error: invalid types 'int[int]' for array subscript
   28 |     d[s] = 0;
      |      ^
a.cc:30:19: error: expression list treated as compound expression in functional cast [-fpermissive]
   30 |     que.push(P(0,s));
      |                   ^
a.cc:33:7: error: 'll' was not declared in this scope
   33 |       ll v = p.second;
      |       ^~
a.cc:34:12: error: 'v' was not declared in this scope
   34 |       if(d[v]<p.first) continue;
      |            ^
a.cc:34:17: error: request for member 'first' in 'p', which is of non-class type 'P' {aka 'int'}
   34 |       if(d[v]<p.first) continue;
      |                 ^~~~~
a.cc:35:22: error: 'v' was not declared in this scope
   35 |       for(auto e : G[v]){
      |                      ^
a.cc:38:34: error: expression list treated as compound expression in functional cast [-fpermissive]
   38 |           que.push(P(d[e.to],e.to));
      |                                  ^
a.cc: In function 'int main()':
a.cc:46:12: error: no matching function for call to 'graph::graph(int&)'
   46 |   graph g(N);
      |            ^
a.cc:4:8: note: candidate: 'graph::graph()'
    4 | struct graph{
      |        ^~~~~
a.cc:4:8: note:   candidate expects 0 arguments, 1 provided
a.cc:4:8: note: candidate: 'graph::graph(const graph&)'
a.cc:4:8: note:   no known conversion for argument 1 from 'int' to 'const graph&'
a.cc:4:8: note: candidate: 'graph::graph(graph&&)'
a.cc:4:8: note:   no known conversion for argument 1 from 'int' to 'graph&&'
a.cc:61:13: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   61 |     ans+=g.d[x[i]-1]+g.d[y[i]-1];
      |             ^
a.cc:61:25: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   61 |     ans+=g.d[x[i]-1]+g.d[y[i]-1];
      |                         ^