Language: C++

#include <bits/stdc++.h>

// #include <iostream>
// #include <fstream>
// #include <string>
// #include <map>
// #include <vector>
// #include <algorithm>
// #include <regex>
// #include <chrono>
// #include <sstream>
// #include <iomanip>
// #include <queue>
// #include <stack>
// #include <set>
// #include <unordered_map>
// #include <unordered_set>


using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}

int n, m, p;
int a[5050], b[5050], c[5050];


signed main() {

	cin >> n >> m >> p;

	for(int i = 0; i < m; i++) {
		
		cin >> a[i] >> b[i] >> c[i];
		c[i] = p - c[i];
	}
	
	vector<int> dist(n+1, INF);
	dist[1] = 0;
	
	for(int l = 0; l < n-1; l++) {
		for(int i = 0; i < m; i++) {
			
			if(dist[a[i]] == INF) continue;
			chmin(dist[b[i]], dist[a[i]] + c[i]);
		}
	}

	vector<bool> neg(n+1, false);
	ll ans = dist[n];

	for(int l = 0; l < n; l++) {
		for(int i = 0; i < m; i++) {

			if(dist[a[i]] == INF) continue;

			if(chmin(dist[b[i]], dist[a[i]] + c[i]) || neg[a[i]]) 
				neg[b[i]] = true;
		}
	}

	if(neg[n]) cout << -1 << endl;
	else cout << max(0,-ans) << endl;
			
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:87:25: error: no matching function for call to 'max(int, ll)'
   87 |         else cout << max(0,-ans) << 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:87:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   87 |         else cout << max(0,-ans) << 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:87:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   87 |         else cout << max(0,-ans) << endl;
      |                      ~~~^~~~~~~~