Language: C++

#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,m,p;cin>>n>>m>>p;
    vc<tuple<int,int,int>> edge;
    vvi to(n),from(n);
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        edge.emplace_back(a-1,b-1,c-p);
        to[a-1].push_back(b-1);
        from[b-1].push_back(a-1);
    }

    int v=0;

    vi reach(n,0);
    queue<int> que;
    que.push(n-1);
    while(!que.empty()){
        int a=que.front();que.pop();
        if(reach[a]==1)continue;
        reach[a]=1;
        rep(i,from[a].size()){
            que.push(from[a][i]);
        } 
    }
    que.push(0);
    while(!que.empty()){
        int a=que.front();que.pop();
        if(reach[a]!=1)continue;
        reach[a]=2;
        v++;
        rep(i,to[a].size()){
            que.push(to[a][i]);
        } 
    }

    vl num(n,LLONG_MIN);
    num[0]=0;

    rep(i,v){
        rep(j,m){
            int a,b,c;
            tie(a,b,c)=edge[j];
            if(reach[a]*reach[b]!=4)continue;
            if(num[b]<num[a]+c){
                num[b]=num[a]+c;
                if(i==v-1){
                    cout<<-1<<"\n";
                    return 0;
                }
            }
        }
    }

    cout<<max(0,num[n-1])<<"\n";

    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:14: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   79 |     cout<<max(0,num[n-1])<<"\n";
      |           ~~~^~~~~~~~~~~~
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:79:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   79 |     cout<<max(0,num[n-1])<<"\n";
      |           ~~~^~~~~~~~~~~~
/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:79:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   79 |     cout<<max(0,num[n-1])<<"\n";
      |           ~~~^~~~~~~~~~~~