Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9+7;
typedef pair<int,int> P;
signed main(){
    int N;
    cin >> N;
    vector<vector<P>>road(N);
    for(int i = 0; i < N-1; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        road[a].push_back({b,c});
        road[b].push_back({a,c});
    }
    int Q,K;
    cin >> Q >> K;
    K--;
    priority_queue<int,vector<int>,greater<int>> que;
    vector<int>cnt(N,INF);
    cnt[K] = 0;
    que.push({0,K});
    while(!que.empty()) {
        P x = que.top();
        que.pop();
        if(cnt[x.second] < x.first) {
            continue;
        }
        for(int i = 0; i < road[x.second].size(); i++) {
            if(cnt[road[x.second][i].first] > x.first+road[x.second][i].second) {
                cnt[road[x.second][i].first] =  x.first+road[x.second][i].second;
                que.push({cnt[road[x.second][i].first],road[x.second][i].first});
            }
        }
    }
    for(int i = 0; i < Q; i++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        cout << cnt[x]+cnt[y] << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:13: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::push(<brace-enclosed initializer list>)'
   23 |     que.push({0,K});
      |     ~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long int]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&' {aka 'const long long int&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long int]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&&' {aka 'long long int&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc:25:22: error: conversion from 'const __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'const long long int'} to non-scalar type 'P' {aka 'std::pair<long long int, long long int>'} requested
   25 |         P x = que.top();
      |               ~~~~~~~^~
a.cc:33:25: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::push(<brace-enclosed initializer list>)'
   33 |                 que.push({cnt[road[x.second][i].first],road[x.second][i].first});
      |                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long int]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&' {aka 'const long long int&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long int]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&&' {aka 'long long int&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~