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};
struck 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:42:1: error: 'struck' does not name a type; did you mean 'struct'?
   42 | struck edge{ ll to,cost;};
      | ^~~~~~
      | struct
a.cc: In function 'int main()':
a.cc:46:17: error: 'edge' was not declared in this scope
   46 |   vector<vector<edge>> e(n,vector<edge>(0));
      |                 ^~~~
a.cc:46:17: error: template argument 1 is invalid
a.cc:46:17: error: template argument 2 is invalid
a.cc:46:21: error: template argument 1 is invalid
   46 |   vector<vector<edge>> e(n,vector<edge>(0));
      |                     ^~
a.cc:46:21: error: template argument 2 is invalid
a.cc:46:39: error: template argument 2 is invalid
   46 |   vector<vector<edge>> e(n,vector<edge>(0));
      |                                       ^
a.cc:46:43: error: expression list treated as compound expression in initializer [-fpermissive]
   46 |   vector<vector<edge>> e(n,vector<edge>(0));
      |                                           ^
a.cc:52:9: error: expected ';' before 'k'
   52 |     edge k;
      |         ^~
      |         ;
a.cc:53:5: error: 'k' was not declared in this scope
   53 |     k.to=b;
      |     ^
a.cc:55:6: error: invalid types 'int[long long int]' for array subscript
   55 |     e[a].pb(k);
      |      ^
a.cc:57:6: error: invalid types 'int[long long int]' for array subscript
   57 |     e[b].pb(k);
      |      ^
a.cc:69:17: error: invalid types 'int[long long int]' for array subscript
   69 |     for(auto y:e[h]){
      |                 ^