Language: C++

#include<bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (s); i < (e); ++i)
#define per(i,s,e) for(int i = (s)-1; i >= e; --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<typename T, size_t N, typename U>
void Fill(T (&a)[N], const U&v){
    std::fill((U*)a,(U*)(a+N),v);
}

ll edge[310][310];

int n,m,l,q;

int main(){
  Fill(edge,-1);
  rep(i,0,310)edge[i][i] = 0;
  cin >> n >> m >> l;
  rep(i,0,m){
    int a, b, c; cin >> a >> b >> c;a--;b--;
    edge[a][b] = edge[b][a] = c;
  }
  

    
  rep(k,0,n){
    rep(i,0,n){
      rep(j,0,n){
	if(edge[i][k] == -1 || edge[k][j] == -1)continue;
	if(edge[i][j] == -1) edge[i][j] = edge[i][k] + edge[k][j];
	else edge[i][j] = min(edge[i][j],edge[i][k]+edge[k][j]);
      }
    }
  }
  rep(i,0,n)rep(j,0,n)if(edge[i][j]>0&&edge[i][j]<=l)edge[i][j]=1;
  
  rep(k,0,n){
    rep(i,0,n){
      rep(j,0,n){
	if(edge[i][k] == -1 || edge[k][j] == -1)continue;
	if(edge[i][j] == -1) edge[i][j] = edge[i][k] + edge[k][j];
	else edge[i][j] = min(edge[i][j],edge[i][k]+edge[k][j]);
      }
    }
  }
  
  cin >> q;      
  rep(i,0,q){
    int st, en; cin >> st >> en;st--;en--;
    cout << max(edge[st][en]-1,-1) << endl;
  }
  return 0;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:71:16: error: no matching function for call to 'max(ll, int)'
   71 |     cout << max(edge[st][en]-1,-1) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:71:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   71 |     cout << max(edge[st][en]-1,-1) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:71:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   71 |     cout << max(edge[st][en]-1,-1) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~