Language: C++

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

typedef struct edge{
    int from; //出発点
    int to;   //到達点
    int64_t cost; //移動コスト
}edge;

bool used[2501];
bool reachable[2501];

bool dfs(int i, int n, const vector<vector<int>> &E){
    if (reachable[i])
        return true;
    if (used[i])
        return false;
    used[i] = true;
    bool res = false;
    for (const auto &e: E[i]){
        if (i == e)
            continue;
        res |= dfs(e, n, E);
    }
    reachable[i] = res;
    return res;
}

class ECoinsRespawn {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, m, p;
    cin >> n >> m >> p;
    vector<edge> E;
    vector<vector<int>> F(n + 1);
    for (int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edge e = {a, b, -(c - p)};
        E.emplace_back(e);
        F[a].emplace_back(b);
    }

    int64_t INF = int(1e17);
    vector<int64_t> D(n + 1, INF);
    D[1] = 0;

    for (int i = 1; i <= n; i++){
        reachable[i] = false;
        used[i] = false;
    }

    reachable[n] = true;
    dfs(1, n, F);

    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++) {
            edge e = E[j];
            if (D[e.to] > D[e.from] + e.cost) {
                D[e.to] = D[e.from] + e.cost;
                if (i == n - 1 and reachable[e.to]) {         //頂点の数と同じ回数ループすると、負の閉路があるのでループをぬける
                    cout << -1 << endl;
                    return;
                }
            }
        }
    }

    cout << max(0LL, -D[n]) << endl;
}
};

int main() {
	ECoinsRespawn solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Compiler output:
a.cc: In member function 'void ECoinsRespawn::solve(std::istream&, std::ostream&)':
a.cc:79:16: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   79 |     cout << max(0LL, -D[n]) << 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:7:
/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:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   79 |     cout << max(0LL, -D[n]) << 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 /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:10:
/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:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   79 |     cout << max(0LL, -D[n]) << endl;
      |             ~~~^~~~~~~~~~~~