Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m, p;
    cin >> n >> m >> p;

    vl a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;  b[i]--;
        c[i] = p - c[i];
    }

    vl dist(n, INF);  // dist[v] : 頂点0から頂点vへの最短距離
    dist[0] = 0;
    rep(loop, n-1) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    vl negativeCycle(n);  // negativeCycle[v] : 頂点vを含む負閉路があるとき1
    rep(loop, n) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
                negativeCycle[b[i]] = 1;
            }
            if(negativeCycle[a[i]]) {
                negativeCycle[b[i]] = 1;
            }
        }
    }

    if(negativeCycle[n-1]) {
        out(-1);
    }
    else {
        out(max(0, -dist[n-1]));
    }
    
    re0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:16: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   74 |         out(max(0, -dist[n-1]));
      |             ~~~^~~~~~~~~~~~~~~
a.cc:18:24: note: in definition of macro 'out'
   18 | #define out(x) cout << x << endl
      |                        ^
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:74:16: 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'})
   74 |         out(max(0, -dist[n-1]));
      |             ~~~^~~~~~~~~~~~~~~
a.cc:18:24: note: in definition of macro 'out'
   18 | #define out(x) cout << x << 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,
                 from a.cc:4:
/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:74:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |         out(max(0, -dist[n-1]));
      |             ~~~^~~~~~~~~~~~~~~
a.cc:18:24: note: in definition of macro 'out'
   18 | #define out(x) cout << x << endl
      |                        ^