criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s,int x) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost =< dist[e.to] and e.to==x) return vector< T >();
  }
  return dist;
}

bool solve(){
  ll n,m,p;cin>>n>>m>>p;
  Edges<ll>e;
  rep(i,m){
    ll a,b,c;cin>>a>>b>>c;
    e.emplace_back(--a,--b,-(c-p));
  }
  ll ans=0;
  auto v=bellman_ford(e,n,0,n-1);
  if(v.size()==0){
    cout<<-1<<endl;
    return false;
  }else cout<<max<ll>(-v[n-1],0)<<endl;
  return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Compiler output:
a.cc: In function 'std::vector<_Tp> bellman_ford(Edges<T>&, int, int, int)':
a.cc:64:30: error: expected primary-expression before '<' token
   64 |     if(dist[e.src] + e.cost =< dist[e.to] and e.to==x) return vector< T >();
      |                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

struct edge{
    lli to;
    lli cost;
};

lli ava[3000];
lli ava2[3000];

vector<edge> G[3000];
vector<edge> G2[3000];
lli d[3000];
lli out[3000];

void dfs(lli now){
    ava[now]=1;
    for(auto e:G[now]){
        if(ava[e.to]==1)continue;
        dfs(e.to);
    }
}

void dfs2(lli now){
    ava2[now]=1;
    for(auto e:G2[now]){
        if(ava2[e.to]==1)continue;
        dfs(e.to);
    }
}

void func(long long N, long long M, long long P, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){

    lli cnt=0;

    REP(i,0,N)d[i]=INF;
    d[0]=0;

    dfs(0);
    dfs2(N-1);

    while(1){

        bool update=false;
        REP(i,0,N){
            if(ava[i]!-1 || ava2[i]!=-1)continue;
            REP(j,0,G[i].size()){
                LOG3(cnt,i,j);
                edge &e = G[i][j];
                if(ava[e.to] != 1 || ava2[e.to]!=1)continue;
                if(d[e.to]>d[i]+e.cost){
                    d[e.to] = d[i]+e.cost;
                    LOG3(d[e.to],i,e.to);
                    update=true;
                }
            }
        }

        if(cnt>2*N){
            cout<<-1<<endl;
            return;
        }
        cnt++;
    }

    cout<<max(0LL,-d[N-1])<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long P;
    scanf("%lld",&P);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
        A[i]--,B[i]--;
        G[A[i]].push_back({B[i],-(C[i]-P)});
        G2[B[i]].push_back({A[i],-(C[i]-P)});
    }
    func(N, M, P, std::move(A), std::move(B), std::move(C));
    return 0;
}


Compiler output:
a.cc: In function 'void func(long long int, long long int, long long int, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
a.cc:64:22: error: expected ')' before '!' token
   64 |             if(ava[i]!-1 || ava2[i]!=-1)continue;
      |               ~      ^
      |                      )
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

struct edge {
	int from, to, cost;
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m, p;
	cin >> n >> m >> p;
	vector<edge> graph;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph.pb({ a,b,p - c });
	}
	vector<int> dis(n, inf);
	dis[0] = 0;
	set<int> st;
	rep(cnt, n) {
		rep(i, m) {
			edge e = graph[i];
			if (dis[e.from] != inf && dis[e.to] > dis[e.from] + e.cost) {
				dis[e.to] = dis[e.from] + e.cost;
				update = true;
				if (cnt >= n - 1) st.insert(e.to);
			}
        }
	}
	queue<int> que;
	vector<bool> ok(n);
	que.push(0); ok[0] = true;
	while (!que.empty()) {
		int q = que.front(); que.pop();
		for (edge i : graph) {
			if (i.from == q) {
				if (!ok[i.to]) {
					ok[i.to] = true;
					que.push(i.to);
				}
			}
		}
	}
	queue<int> que2;
	vector<bool> ok2(n);
	que2.push(n - 1); ok2[n - 1] = true;
	while (!que2.empty()) {
		int q = que2.front(); que2.pop();
		for (edge i : graph) {
			if (i.to == q) {
				if (!ok2[i.from]) {
					ok2[i.from] = true;
					que2.push(i.from);
				}
			}
		}
	}
	rep(i, n) {
		if (ok[i] && ok2[i] && st.count(i)) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << max(-dis[n - 1], 0) << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:33: error: 'update' was not declared in this scope
   65 |                                 update = true;
      |                                 ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int n;

struct Edge{
	int from, to, cost;
	Edge(int from, int to, int cost) : from(from), to(to), cost(cost){}
};

vector<vector<int>> to;
vector<vector<int>> rev_to;
vector<bool> reach1; 
vector<bool> reach2; 

void dfs(int v){
	if(reach1[v])return;
	reach1[v] = true;
	for(auto nv : to[v])dfs(nv);
}

void dfs2(int v){
	if(reach2[v])return;
	reach2[v] = true;
	for(auto nv : rev_to[v])dfs2(nv);
}


int ng = 0;

vector<Edge> es;
vector<int> dist;
void bellman_ford(int s){	
	dist.assign(n, INF);
	dist[s] = 0;
	for(int i = 0; i < n; ++i){	
		update = false;
		for(auto e : es){
			if(e.from == INF)continue;
			if(!reach1[e.from] || !reach2[e.from])continue;
			if(!reach1[e.to] || !reach2[e.to])continue;
			if(dist[e.from] + e.cost < dist[e.to]){
				dist[e.to] = dist[e.from] + e.cost;
				if(i == n - 1)ng = 1;
			}
		}
	}
}

int main(){
  int m, p;
  cin >> n >> m >> p;
  to.resize(n);
  rev_to.resize(n);
  for(int i = 0; i < m; ++i){
  	int a, b, c;
  	cin >> a >> b >> c;
  	--a;
  	--b;
  	c -= p;
  	c *= -1;
  	es.push_back(Edge(a, b, c));
  	to[a].push_back(b);
  	rev_to[b].push_back(a);
  }

  reach1.assign(n, false);
  reach2.assign(n, false);
  dfs(0);
  dfs2(n - 1);
  bellman_ford(0);
  if(ng)cout << -1 << endl;
  else cout << max(0, -dist[n - 1]) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void bellman_ford(int)':
a.cc:51:17: error: 'update' was not declared in this scope
   51 |                 update = false;
      |                 ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e3 + 4;
ll dist[T];
bool vis[T];
vii g[T];
int n,m;
ll p;

void bellman() {
    for(int i = 0; i < n; i++)
        for(int u = 1; u <= n ; u++)
            for(ii v : g[u]) {
                if(!vis[v.fi]) dist[v.fi] = dist[u]+v.se;
                vis[v.fi] = 1;
                dist[v.fi] = max(dist[v.fi],dist[u]+v.se);
            }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> p;
    for(int i = 2; i <= n; i++) dist[i] = -1e18;

    for(int i = 0; i < m; i++) {
        int a,b,c; cin >> a >> b >> c;
        g[a].eb(b,c-p);
    }

    bellman();
    ll ans = dist[n];
    bellman();

    if(ans == dist[n]) cout << max(0,ans) << endl;
    else cout << -1 << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:48:35: error: no matching function for call to 'max(int, ll&)'
   48 |     if(ans == dist[n]) 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:48:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   48 |     if(ans == dist[n]) 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:48:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   48 |     if(ans == dist[n]) cout << max(0,ans) << endl;
      |                                ~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


const ll maxn=2505;
vector<vll> G(maxn);
bool visited[maxn];
void dfs(ll v){
  if(visited[v]) return;
  visited[v]=true;
  for(auto nv: G[v]){
    dfs(nv);
  }
}

vector<vll> rG(maxn);
bool rvisited[maxn];
void rdfs(ll v){
  if(rvisited[v]) return;
  rvisited[v]=true;
  for(auto nv: rG[v]){
    rdfs(nv);
  }
}

ll n,m;
vector<tuple<ll,ll,ll>> es;
ll dist[maxn];
bool ok[maxn];

bool bellmanford(ll s){
  fill(dist,dist+n,INF);
  dist[0]=0;
  bool update=true;
  ll cnt=0;
  while(update){
    update=false;
    for(auto e: es){
      ll a,b,c;
      tie(a,b,c)=e;
      if(!ok[a]||!ok[b]) continue;
      if(chmin(dist[b],dist[a]+c)) update=true;
    }
    if(cnt>=n){
      return true; // has negative loop
    }
    cnt++;
  }
  return false;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll p;
  cin>>n>>m>>p;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--; c=-(c-p);
    es.push_back({a,b,c});
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=visited[i]&&rvisited[i];
  
  if(!bellmanford(0)){
    if(dist<0) cout<<-dist[n-1]<<endl;
    else cout<<0<<endl;
  }else{
    puts("-1");
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:105:12: error: ordered comparison of pointer with integer zero ('ll*' {aka 'long long int*'} and 'int')
  105 |     if(dist<0) cout<<-dist[n-1]<<endl;
      |        ~~~~^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


ll N, M;  // 頂点, 辺
const ll MAXN = 2505;

vll G[MAXN];
bool from1[MAXN];
void dfs(ll v){
  if(from1[v]) return;
  from1[v]=true;
  
  for(auto nv: G[v]){
    dfs(nv);
  }
  return;
}


vvll rG(N);
bool toN[MAXN];
void rdfs(ll v){
  if(toN[v]) return;
  toN[v]=true;
  
  for(auto nv: G[v]){
    dfs(nv);
  }
}

vector<tuple<ll,ll,ll>> es;
ll dist[MAXN];

void bellmanford(ll s){
  fill(dist,dist+N,INF);
  dist[0]=0;
  
  bool update=true;
  ll cnt=0;
  while(update){
    update=false;
    rep(i,m){
      ll a,b,c;
      tie(a,b,c)=es[i];
      
      if(!from1[a] || !toN[a]) continue;
      if(!from1[b] || !toN[b]) continue;
      
      if(dist[b]>dist[a]+c){
        update=true;
        dist[b]=dist[a]+c;
      }
    }
    cnt++;
    if(cnt>N){
      cout<<-1<<endl;
      exit(0);
    }
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll p; cin>>N>>M>>p;
  
  rep(i,M){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--;
    c=(c-p)*-1;
    es.emplace_back(a,b,c);
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  
  dfs(0);
  dfs(N-1);
  
  bellmanford(0);
  
  cout<<max(-dist[N-1],0LL)<<endl;
}

Compiler output:
a.cc: In function 'void bellmanford(ll)':
a.cc:78:11: error: 'm' was not declared in this scope
   78 |     rep(i,m){
      |           ^
a.cc:5:52: note: in definition of macro 'rep'
    5 | #define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
      |                                                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define int int64_t

signed main() {
  const int inf = 1e18;
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int, int, int>> to;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    c -= p;
    to.emplace_back(a, b, c);
  }
  vector<int> coins(n, -inf);
  coins.at(0) = 0;
  for (int i = 0; i < n; i++) {
    for (auto x : to) {
      int a = get<0>(x), b = get<1>(x), c = get<2>(x);
      coins.at(b) = max(coins.at(b), coins.at(a) + c);
    }
  }
  int ans = coins.at(n - 1);
  for (int i = 0; i < n; i++) {
    for (auto x : to) {
      int a = get<0>(x), b = get<1>(x), c = get<2>(x);
      coins.at(b) = max(coins.at(b), coins.at(a) + c);
    }
  }
  if (ans != coins.at(n - 1)) {
    cout << -1 << endl;
  } else {
    cout << max(0, ans) << endl;
  }
}


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

#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
const int MAX_E = 5100;
const int MAX_V = 2600;
struct edge { int from, to, cost; };

edge es[MAX_E];

int d[MAX_V];   // 最短距離
int V, E;

// s番目の頂点から各頂点への最短距離を求める
void shortest_path(int s) {
    rep(loop, M-1) {
        bool update = false;
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if (!update) break;
    }
}
int P;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> V >> E >> P;
    rep(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es[i] = {a, b, -c + P};
    }
    for (int i = 0; i < V; i++) d[i] = INF;
    d[0] = 0;
    shortest_path(0);
    int ans = d[V - 1];
    shortest_path(0);
    shortest_path(0);
    if (d[V - 1] >= ans) {
        cout << max(0LL, -ans) << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'void shortest_path(long long int)':
a.cc:24:15: error: 'M' was not declared in this scope
   24 |     rep(loop, M-1) {
      |               ^
a.cc:4:38: note: in definition of macro 'rep'
    4 | #define rep(i,n) for( int i = 0; i < n; i++ )
      |                                      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct edge {
    int from, to;
    ll cost;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    ll p;
    cin >> n >> m >> p;
    vector<edge> g(m);
    for(int i = 0; i < m; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        g[i] = edge{a - 1, b - 1, -(c - p)};
    }
    vector<ll> d(n, LLINF);

    auto bellmanFord = [&](int start) {
        d[start] = 0;
        for(int i = 0; i < n; i++) {
            for(auto e : g) {
                if(d[e.from] != LLINF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                }
            }
        }
    };

    vector<bool> neg(n, false);

    auto findNegativeLoop = [&]() {
        for(int i = 0; i < n; i++) {
            for(auto e : g) {
                if(d[e.from] != LLINF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    neg[e.to] = true;
                }
                if(neg[e.from]) {
                    neg[e.to] = true;
                }
            }
        }
    };

    bellmanFord(0, n - 1);
    findNegativeLoop();

    cout << (neg[n - 1] ? -1 : max(0LL, -d[n - 1])) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:16: error: no match for call to '(main()::<lambda(int)>) (int, int)'
   79 |     bellmanFord(0, n - 1);
      |     ~~~~~~~~~~~^~~~~~~~~~
a.cc:52:24: note: candidate: 'main()::<lambda(int)>'
   52 |     auto bellmanFord = [&](int start) {
      |                        ^
a.cc:52:24: note:   candidate expects 1 argument, 2 provided
Language: C++

#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

struct edge {
	int from;
	int to;
	ll cost;
};

//有向グラフ、負の閉路がある場合の最短経路算出
struct BellmanFord {
	static const ll INF = 1e15;
	static const ll INVALID = 1e16;
	std::vector<edge> edges_;
	int vertexCount_;
	std::vector<ll> cost;

	BellmanFord(int vertexCount, std::vector<edge>&& edges) : edges_(std::move(edges)), vertexCount_(vertexCount) {
	}

	ll solve(int start, int goal, const std::vector<bool>& visit, const std::vector<bool>& visit2)
	{
		cost.resize(vertexCount_, INF);
		cost[start] = 0; //始点を0にする

		for (int i = 0; i < cost.size(); i++) {
			for (int j = 0; j < (int)edges_.size(); j++) {
				const auto& e = edges_[j];
				if (!visit[e.to] || !visit2[e.to]) continue;
				if (cost[e.to] > cost[e.from] + e.cost) {  //移動した後のコストが小さいと、頂点のコストを更新
					cost[e.to] = cost[e.from] + e.cost;
					if (i == cost.size() - 1) {         //頂点の数と同じ回数ループすると、負の閉路があるのでループをぬける
						return INVALID;
					}
				}
			}
		}
		return cost[goal];
	}
};

std::vector<bool> bfs(std::vector<std::vector<int>> g, int v, int start) {
	std::vector<bool> vs(v,false);
	queue<int> q;
	q.push(start);
	while (!q.empty()) {
		auto f = q.front(); q.pop();
		if (vs[f]) continue;
		vs[f] = true;
		for (auto e : g[f]) {
			if (vs[e]) continue;
			q.push(e);
		}
	}
	return vs;
}

int main(void)
{
	ll n, m, p;
	cin >> n >> m >> p;
	vector<edge> vs(m);
	vector<vector<int>> g(n);
	vector<vector<int>> rev_g(n);
	rep(i, m) { cin >> vs[i].from >> vs[i].to >> vs[i].cost; 
		vs[i].from--;
		vs[i].to--;
		vs[i].cost = p - vs[i].cost;
		rev_g[vs[i].to].push_back(vs[i].from);
		g[vs[i].from].push_back(vs[i].to);
	}
	auto v1 = bfs(rev_g, n, n-1);
	auto v2 = bfs(g, n, 0);
	BellmanFord bf(n, std::move(vs));
	auto cost = bf.solve(0, n - 1, v1, v2);
	if (cost == BellmanFord::INVALID) {
		cout << -1 << endl;
		return 0;
	}
	cout << max(0LL, -cost) << endl;
	return 0;
}


Compiler output:
a.cc:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
/usr/bin/ld: /tmp/ccygpnMl.o: warning: relocation against `_ZN11BellmanFord3INFE' in read-only section `.text._ZN11BellmanFord5solveEiiRKSt6vectorIbSaIbEES4_[_ZN11BellmanFord5solveEiiRKSt6vectorIbSaIbEES4_]'
/usr/bin/ld: /tmp/ccygpnMl.o: in function `BellmanFord::solve(int, int, std::vector<bool, std::allocator<bool> > const&, std::vector<bool, std::allocator<bool> > const&)':
a.cc:(.text._ZN11BellmanFord5solveEiiRKSt6vectorIbSaIbEES4_[_ZN11BellmanFord5solveEiiRKSt6vectorIbSaIbEES4_]+0x2f): undefined reference to `BellmanFord::INF'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
Language: C++

main(){printf("-1\n");}

Compiler output:
a.cc:1:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    1 | main(){printf("-1\n");}
      | ^~~~
a.cc: In function 'int main()':
a.cc:1:8: error: 'printf' was not declared in this scope
    1 | main(){printf("-1\n");}
      |        ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | main(){printf("-1\n");}
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

void dfs(int v, vvi &G, vector<bool> &seen){
  if(seen[v]) return;
  seen[v] = true;
  for(auto nv : G[v]) {
    dfs(nv, G, seen);
  }
}

int main(){
  int n,m,p; cin >> n >> m >> p;
  vvi G(n),rG(n);
  vector<tuple<int, int, int>> edges;
  rep(i,m) {
    int a,b,c; cin >> a >> b >> c;
    a--; b--;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    G[a].pb(b);
    rG[b].pb(a);
  }

  vector<bool> seen1(n,false);
  vector<bool> seen2(n,false);

  dfs(0, G, seen1);
  dfs(n-1, rG, seen2);

  vector<bool> ok(n);
  rep(i,n) ok[i] = seen1[i]&seen2[i];

  vi d(n,1e9);
  d[0] = 0;
  int step = 0;
  bool upd = true;
  while(upd){
    upd = false;
    rep(i,m) {
      int a,b,c;
      tie(a,b,c) = edges[i];
      if(!ok[a] || !ok[b]) continue;
      upd = chmin(d[b] = d[a] + c);
    }
    step++;
    if(step > n){
      cout << -1 << endl;
      return 0;
    }
  }
    
  int ans = -d[n-1];
  ans = max(ans,0);
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:90:18: error: no matching function for call to 'chmin(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   90 |       upd = chmin(d[b] = d[a] + c);
      |             ~~~~~^~~~~~~~~~~~~~~~~
a.cc:23:31: note: candidate: 'template<class T> bool chmin(T&, T)'
   23 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
      |                               ^~~~~
a.cc:23:31: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

vector<int> to[2505];
vector<int> ot[2505];
bool reach[2505];
bool reach1[2505];
bool ok[2505];

void dfs(int i){
  if(reach[i]) return;
  reach[i] = true;
  for(int j : to[i]){
    dfs(j);
  }
}

void dfs1(int i){
  if(reach1[i]) return;
  reach1[i] = true;
  for(int j : ot[i]){
    dfs(j);
  }
}

int main(){
  int n,m,p;
  cin >> n >> m >> p;
  vector<tuple<int,int,int>> edges;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    ot[b].push_back(a);
  }
  dfs(0);
  dfs1(n-1);
  rep(i,n){
    ok[i] = reach[i] & reach1[i];
  }
  int step = 0;
  bool flg = true;
  vector<int> d(n,INF);
  d[0] = 0;
  while(true){
    flg = false;
    rep(i,m){
      tie(a,b,c) = edges[i];
      int newD = d[a] + c;
      if(newD<d[b]){
        d[b] = newD;
        flg = true;
      }
    }
    step++;
    if(step>n){
      puts("-1");
      return 0;
    }
  }
  int ans = -d[n-1];
  ans = max(0,ans);
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:11: error: 'a' was not declared in this scope
   56 |       tie(a,b,c) = edges[i];
      |           ^
a.cc:56:13: error: 'b' was not declared in this scope
   56 |       tie(a,b,c) = edges[i];
      |             ^
a.cc:56:15: error: 'c' was not declared in this scope
   56 |       tie(a,b,c) = edges[i];
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> v1;
typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;
ll n,m,p;
v1 a,b,c;
graph g;
graph rg;
graph cost;
v1 dist;
bool is_update;
v1 vis;
v1 mem;

void rdfs(ll x){
    vis[x] = 1;
    ll siz = rg[x].size();
    for(ll y : rg[x]){
        if(vis[y] == 0) rdfs(y);
    }
}

void dfs(ll x){
    // if(vis[x]) return;
    vis[x] = 1;
    ll siz = g[x].size();
    for(ll i = 0;i < siz;i++){
        if(mem[g[x][i]]){
            if(vis[g[x][i] == 0) dfs(g[x][i]);
            a.push_back(x);
            b.push_back(g[x][i]);
            c.push_back(cost[x][i]);
        }
    }
}

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> p;
    dist = v1(n+1, -INF);
    // a=b=c=v1(m);
    g = graph(n+1);
    rg = graph(n+1);
    cost = graph(n+1);
    for(ll i = 0;i < m;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        rg[b].push_back(a);
        g[a].push_back(b);
        cost[a].push_back(c-p);
    }
    vis = v1(n+1,0ll);
    rdfs(n);
    mem = vis;
    vis = v1(n+1,0ll);
    dfs(1);
    // for(ll i = 0;i < a.size();i++){
    //     cerr << a[i] << " " << b[i] << " " << c[i] << endl;
    // }
    dist[1] = 0;
    ll siz = a.size();
    for(ll i = 0;i < n+1;i++){
        is_update = false;
        for(ll j = 0;j < siz;j++){
            if(dist[b[j]] < dist[a[j]]+c[j]){
                dist[b[j]] = dist[a[j]]+c[j];
                is_update = true;
            }
        }
        if(is_update == false) break;
    }
    if(is_update) cout << -1 << endl;
    else cout << max(dist[n],0ll) << endl;
    // if(bellman_ford()){
    //     cout << max(dist[n],0ll) << endl;
    // }else{
    //
    // }
    // bellman_ford();
    // ll tmp = dist[n];
    // bellman_ford();
    // if(tmp == dist[n]) cout << max(dist[n],0ll) << endl;
    // else cout << -1 << endl;
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(ll)':
a.cc:33:32: error: expected ']' before ')' token
   33 |             if(vis[g[x][i] == 0) dfs(g[x][i]);
      |                                ^
      |                                ]
a.cc: At global scope:
a.cc:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main(){
      | ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,M;ll off; cin >> N >> M >> off;
	using P = pair<int,ll>;
	VV<P> G(N);
	rep(i,M){
		int x,y;ll c;
		cin >> x >> y >> c;
		x--,y--,c-=off;
		G[x].pb(P(y,-c));
	}
	const int T = N*6 + 10
	ll inf = 1e18;
	V<ll> d(N,inf); d[0] = 0;
	ll d_mid = 0;
	rep(t,T){
		rep(v,N) if(d[v] != inf){
			for(auto e: G[v]){
				int u = e.fs; ll c = e.sc;
				chmin(d[u],d[v]+c);
			}
		}
		if(t == T/2) d_mid = d[N-1];
	}
	show(d);
	if(d_mid > d[N-1]){
		cout << -1 << endl;
		return 0;
	}
	cout << max(-d[N-1],0LL) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:9: error: expected ',' or ';' before 'll'
   49 |         ll inf = 1e18;
      |         ^~
a.cc:50:19: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   50 |         V<ll> d(N,inf); d[0] = 0;
      |                   ^~~
      |                   ynf
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll inf = LLONG_MAX;
ll minf = -inf;

int main(){
    int N, M, P;
    cin >> N >> M >> P;
    vector<vector<int>> edge(M, vector<int>(3));
    for (int i = 0; i < M; i++) {
        cin >> edge[i][0] >> edge[i][1] >> edge[i][2];
        edge[i][2] -= P;
    }
    
    vector<ll> score(N+1, minf);
    score[1] = 0;
    for (int i = 0; i < N; i++) {
        for (auto e : edge) {
            if (score[e[0]] == minf) continue;
            score[e[1]] = max(score[e[1]], score[e[0]] + e[2]);
        }
    }
    
    ll ans = score[N];
    
    for (int i = 0; i < N; i++) {
        for (auto e : edge) {
            if (score[e[0]] == minf) continue;
            score[e[1]] = max(score[e[1]], score[e[0]] + e[2]);
        }
    }
    
    if (ans != score[N]) {
        cout << -1 << endl;
    } else {
        cout << max(ans, 0) << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:20: error: no matching function for call to 'max(long long int&, int)'
   38 |         cout << max(ans, 0) << 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:38:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   38 |         cout << max(ans, 0) << 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:38:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   38 |         cout << max(ans, 0) << endl;
      |                 ~~~^~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

struct bellman_fold{//1-origin
	vector<ll> min_dst;
	vector<vector<ll>> edge;
	bellman_fold(ll n){
		min_dst.resize(n);
	}

	void append(ll u, ll v, ll cost){edge.push_back({u-1, v-1, cost});}
	
	void run(ll s){
		fill(min_dst.begin(), min_dst.end(), 1e18);
		min_dst[s-1] = 0;
		
		for(ll ite = 1; ite < min_dst.size(); ite++){
			for(ll j = 0; j < edge.size(); j++){
				if(min_dst[edge[j][0]] != 1e18 && min_dst[edge[j][0]]+edge[j][2] < min_dst[edge[j][1]]){
					min_dst[edge[j][1]] = min_dst[edge[j][0]] + edge[j][2];
				}
			}
		}
	}
	
	ll get(ll at){return min_dst[at-1];}
	
	bool loop(){
		for(ll ite = 1; ite <= min_dst.size(); ite++){
			for(ll j = 0; j < edge.size(); j++){
				if(min_dst[edge[j][0]] != 1e18 && min_dst[edge[j][0]]+edge[j][2] < min_dst[edge[j][1]]){
					min_dst[edge[j][1]] = -1e18
				}
			}
		}
		if(min_dst[min_dst.size()-1] <= -1e18){
			return true;
		}
		else{
			return false;
		}
	}
};

ll n, m, p, a, b, c;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m >> p;
	bellman_fold bf(n);
	rep(i, 1, n){
		cin >> a >> b >> c;
		bf.append(a, b, -c+p);
	}
	bf.run(1);
	
	if(bf.loop()){
		print(-1)
	}
	else{
		print(max(-bf.get(n), 0LL))
	}
	return 0;
}

Compiler output:
a.cc: In member function 'bool bellman_fold::loop()':
a.cc:41:33: error: expected ';' before '}' token
   41 |                                 }
      |                                 ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs)        \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

struct edge {
    long to;
    long cost;
};

const int MAX_V = 100005;
vector<edge> G[MAX_V];
vector<edge> Ginv[MAX_V];
long d[MAX_V];
long n;
bool use1[MAX_V];
bool usen[MAX_V];

bool bellmanFord(long s) {
  fill(d, d+n, INF*INF);
  d[s] = 0;
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      if (!use1[v] || !useN[v]) continue;
      for (int k = 0; k < G[v].size(); k++) {
        edge e = G[v][k];
        if (d[v] != INF*INF && d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          if (i == n-1) {
            return true;
          } 
        }
      }
    }
  }
  return false;
}

void dfs(long s) {
  if(use1[s]) return;
  use1[s] = true;
  for(auto v: G[s]) {
    dfs(v.to);
  }
  return;
}

void dfsn(long s) {
  if(usen[s]) return;
  usen[s] = true;
  for(auto v: Ginv[s]) {
    dfs(v.to);
  }
  return;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  long m, p;
  cin >> n >> m >> p;

  rep(i, m) {
    long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back({b, p-c});
    Ginv[b].push_back({a, p-c});
  }

  dfs(0);
  dfsn(n-1);
  bool res = bellmanFord(0);

  cout << (res?-1:max(0L, -d[n-1])) << endl;
}


Compiler output:
a.cc: In function 'bool bellmanFord(long int)':
a.cc:72:24: error: 'useN' was not declared in this scope; did you mean 'usen'?
   72 |       if (!use1[v] || !useN[v]) continue;
      |                        ^~~~
      |                        usen
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs)        \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

struct edge {
    long to;
    long cost;
};

const int MAX_V = 100005;
vector<edge> G[MAX_V];
long d[MAX_V];
long n;
bool use[MAX_V];
bool skip[MAX_V];

bool bellmanFord(long s) {
  fill(d, d+n, INF*INF);
  d[s] = 0;
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      if (!use[v]) continue;
      for (int k = 0; k < G[v].size(); k++) {
        edge e = G[v][k];
        if (d[v] != INF*INF && d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          if (i == n-1) {
            return true;
          } 
        }
      }
    }
  }
  return false;
}

bool dfs(long s) {
  if(skip[s]) return;
  skip[s] = true;
  if (s == n-1) {
    use[s] = true;
    return true;
  }
  bool u = false;
  for(auto i : G[s]) {
    u = u | dfs(i.to);
  }
  use[s] = true; 
  return u;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  long m, p;
  cin >> n >> m >> p;

  rep(i, m) {
    long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back({b, p-c});
  }

  dfs(0);
  bool res = bellmanFord(0);

  cout << (res?-1:max(0L, -d[n-1])) << endl;
}


Compiler output:
a.cc: In function 'bool dfs(long int)':
a.cc:87:15: error: return-statement with no value, in function returning 'bool' [-fpermissive]
   87 |   if(skip[s]) return;
      |               ^~~~~~