Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long INF=1e15;
int N;
vector<int> g[size];long len[size][size];
long d[size],pre[size];
priority_queue<pair<long,int>> pq;
void dijkstra(int a){//O(E+NlogN)
	rep(i,0,N){
		d[i]=INF;
		pq.push(make_pair(-d[i],i));
	}
	d[a]=0;pq.push({0,a});
	int v;long temp;
	rep(i,0,N){
		v=pq.top().second;
		pq.pop();
		for(int u:g[v]){
			temp=d[v]+len[v][u];
			if(d[u]>temp){
				d[u]=temp;
				pre[u]=v;
				pq.push({-d[u],u});
			}
		}
	}return;
}
int main(){
	cin>>N;
	int a,b;long c;
	rep(i,0,N-1){
		cin>>a>>b>>c;a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
		len[a][b]=c;
		len[b][a]=c;
	}
	int Q,K;cin>>Q>>K;
	dijkstra(K-1);
	int x,y;
	rep(i,0,Q){
		cin>>x>>y;
		cout<<d[x-1]+d[y-1]<<endl;
	}
}

Compiler output:
a.cc:11:15: error: reference to 'size' is ambiguous
   11 | vector<int> g[size];long len[size][size];
      |               ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:11: note:                 'const int size'
    8 | const int size=1e5;
      |           ^~~~
a.cc:11:30: error: reference to 'size' is ambiguous
   11 | vector<int> g[size];long len[size][size];
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:11: note:                 'const int size'
    8 | const int size=1e5;
      |           ^~~~
a.cc:11:36: error: reference to 'size' is ambiguous
   11 | vector<int> g[size];long len[size][size];
      |                                    ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:11: note:                 'const int size'
    8 | const int size=1e5;
      |           ^~~~
a.cc:12:8: error: reference to 'size' is ambiguous
   12 | long d[size],pre[size];
      |        ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:11: note:                 'const int size'
    8 | const int size=1e5;
      |           ^~~~
a.cc:12:18: error: reference to 'size' is ambiguous
   12 | long d[size],pre[size];
      |                  ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:11: note:                 'const int size'
    8 | const int size=1e5;
      |           ^~~~
a.cc: In function 'void dijkstra(int)':
a.cc:16:17: error: 'd' was not declared in this scope
   16 |                 d[i]=INF;
      |                 ^
a.cc:19:9: error: 'd' was not declared in this scope
   19 |         d[a]=0;pq.push({0,a});
      |         ^
a.cc:24:27: error: 'g' was not declared in this scope
   24 |                 for(int u:g[v]){
      |                           ^
a.cc:25:35: error: 'len' was not declared in this scope
   25 |                         temp=d[v]+len[v][u];
      |                                   ^~~
a.cc:28:33: error: 'pre' was not declared in this scope; did you mean 'pread'?
   28 |                                 pre[u]=v;
      |                                 ^~~
      |                                 pread
a.cc:29:40: error: no matching function for call to 'std::priority_queue<std::pair<long int, int> >::push(<brace-enclosed initializer list>)'
   29 |                                 pq.push({-d[u],u});
      |                                 ~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157:
/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 = std::pair<long int, int>; _Sequence = std::vector<std::pair<long int, int>, std::allocator<std::pair<long int, int> > >; _Compare = std::less<std::pair<long int, int> >; value_type = std::pair<long int, 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<std::pair<long int, int> >::value_type&' {aka 'const std::pair<long int, 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 = std::pair<long int, int>; _Sequence = std::vector<std::pair<long int, int>, std::allocator<std::pair<long int, int> > >; _Compare = std::less<std::pair<long int, int> >; value_type = std::pair<long int, 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<std::pair<long int, int> >::value_type&&' {aka 'std::pair<long int, int>&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:39:17: error: 'g' was not declared in this scope
   39 |                 g[a].push_back(b);
      |                 ^
a.cc:41:17: error: 'len' was not declared in this scope
   41 |                 len[a][b]=c;
      |                 ^~~
a.cc:49:23: error: 'd' was not declared in this scope
   49 |                 cout<<d[x-1]+d[y-1]<<endl;
      |                       ^