Language: C++

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE

constexpr int INF = 2500 * 1e5;

pair<ll, bool> SPFA(int N, int M, const vector<vector<pair<int, ll>>>& E) {
    vector<ll> d(N, INF), inq(N), vis(N);
    d[0] = 0;
    queue<int> q;
    q.push(0); inq[0] = 1;
    ll k = 0;
    while (!q.empty() && k < (N + 5) * (M + 5)) {

        int u = q.front(); q.pop(); inq[u] = 0; ++vis[u];
        ++k;
        //debug(u, inq, vis, d);
        if (u == N-1 && vis[u] > N) return {-1, false};
        for (auto e : E[u]) {
            int v = e.first;
            ll w = e.second;
            //debug(e, d[u], d[v]);
            if (d[u] + w < d[v]) {
                d[v] = d[u] + w;
                if (!inq[v]) {
                    q.push(v); inq[v] = 1;
                }
            }
        }
    }
    return {d[N-1], true};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M, P; cin >> N >> M >> P;
    vector<vector<pair<int, ll>>> E(N);
    REP(i, N) {
        int u, v, C; cin >> u >> v >> C; --u, --v;
        E[u].push_back({v, -C + P});
    }

    auto ans = SPFA(N, M, E);
    cout << (ans.second ? max(-ans.first, 0LL) : -1) << '\n';

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:122:30: error: no matching function for call to 'max(long int, long long int)'
  122 |     cout << (ans.second ? max(-ans.first, 0LL) : -1) << '\n';
      |                           ~~~^~~~~~~~~~~~~~~~~
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:122:30: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
  122 |     cout << (ans.second ? max(-ans.first, 0LL) : -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,
                 from a.cc:7:
/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:122:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
  122 |     cout << (ans.second ? max(-ans.first, 0LL) : -1) << '\n';
      |                           ~~~^~~~~~~~~~~~~~~~~