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

#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

typedef struct edge {
	int a, b, cost;


};

int main() {

	int n,m,v[2501],mm=INT_MIN,p,aa,bb,costt;
	vector<edge>vv;
	cin >> n>>m>>p;

	for (int i = 0;i <= n;i++)
		v[i] = mm;
	v[1] = 0;
	for (int i = 0;i < m;i++) {
		cin >> aa >> bb >> costt;
		edge e;
		e.a = aa;
		e.b = bb;
		e.cost = costt-p;
		vv.push_back(e);
	}
	for (int i = 1;i < n;i++) {
		for (auto e : vv) {
			if (v[e.a] + e.cost > v[e.b])
				v[e.b] = v[e.a] + e.cost;
		}
	}

	int ok = 0;
	for (auto e : vv) {
		if (v[e.a] + e.cost > v[e.b])
		{
			v[e.b] = v[e.a] + e.cost;
			if (e.b == n)
			{
				ok = 1;
				break;
			}
		}
	}
	if (v[n] <= 0)
		cout << 0;
	else {
		if (ok == 1)
			cout << -1;
		else
			cout << v[n];
	}
	return 0;
}

Compiler output:
a.cc:8:1: warning: 'typedef' was ignored in this declaration
    8 | typedef struct edge {
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:16:28: error: 'INT_MIN' was not declared in this scope
   16 |         int n,m,v[2501],mm=INT_MIN,p,aa,bb,costt;
      |                            ^~~~~~~
a.cc:6:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<map>
  +++ |+#include <climits>
    6 | using namespace std;
a.cc:18:22: error: 'p' was not declared in this scope
   18 |         cin >> n>>m>>p;
      |                      ^
a.cc:24:24: error: 'aa' was not declared in this scope
   24 |                 cin >> aa >> bb >> costt;
      |                        ^~
a.cc:24:30: error: 'bb' was not declared in this scope
   24 |                 cin >> aa >> bb >> costt;
      |                              ^~
a.cc:24:36: error: 'costt' was not declared in this scope
   24 |                 cin >> aa >> bb >> costt;
      |                                    ^~~~~
Language: C++

#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

typedef struct edge {
	int a, b, cost;


};

int main() {

	int n,m,v[2501],mm=INT_MIN,p,a,b,cost;
	vector<edge>vv;
	cin >> n>>m>>p;

	for (int i = 0;i <= n;i++)
		v[i] = mm;
	v[1] = 0;
	for (int i = 0;i < m;i++) {
		cin >> a >> b >> cost;
		edge e;
		e.a = a;
		e.b = b;
		e.cost = cost-p;
		vv.push_back(e);
	}
	for (int i = 1;i < n;i++) {
		for (auto e : vv) {
			if (v[e.a] + e.cost > v[e.b])
				v[e.b] = v[e.a] + e.cost;
		}
	}

	int ok = 0;
	for (auto e : vv) {
		if (v[e.a] + e.cost > v[e.b])
		{
			v[e.b] = v[e.a] + e.cost;
			if (e.b == n)
			{
				ok = 1;
				break;
			}
		}
	}
	if (v[n] <= 0)
		cout << 0;
	else {
		if (ok == 1)
			cout << -1;
		else
			cout << v[n];
	}
	return 0;
}

Compiler output:
a.cc:8:1: warning: 'typedef' was ignored in this declaration
    8 | typedef struct edge {
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:16:28: error: 'INT_MIN' was not declared in this scope
   16 |         int n,m,v[2501],mm=INT_MIN,p,a,b,cost;
      |                            ^~~~~~~
a.cc:6:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<map>
  +++ |+#include <climits>
    6 | using namespace std;
a.cc:18:22: error: 'p' was not declared in this scope
   18 |         cin >> n>>m>>p;
      |                      ^
a.cc:24:24: error: 'a' was not declared in this scope
   24 |                 cin >> a >> b >> cost;
      |                        ^
a.cc:24:29: error: 'b' was not declared in this scope
   24 |                 cin >> a >> b >> cost;
      |                             ^
a.cc:24:34: error: 'cost' was not declared in this scope; did you mean 'const'?
   24 |                 cin >> a >> b >> cost;
      |                                  ^~~~
      |                                  const
Language: C++

#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <limits>

using namespace std;

double dist[2500+1];

int main() {
	int N, M, P;
	int a, b, c;
	vector<array<int, 3>> abc;
	array<int, 3> tmp;

	cin >> N >> M >> P;

	dist[0] = 0;

	for (int i = 1; i < 2501; i++) dist[i] = INFINITY;
	
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		tmp = { a-1, b-1, -(c-P) };
		abc.emplace_back(tmp);
	}

	for (int i = 0; i < N; i++) {
		for (auto& num : abc) {
			a = num[0];
			b = num[1];
			c = num[2];
			dist[b] = min(dist[b], dist[a] + c);
		}
	}

	double ans = dist[N - 1];

	for (int i = 0; i < N; i++) {
		for (auto& num : abc) {
			a = num[0];
			b = num[1];
			c = num[2];
			dist[b] = min(dist[b], dist[a] + c);
		}
	}

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

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:50: error: 'INFINITY' was not declared in this scope
   21 |         for (int i = 1; i < 2501; i++) dist[i] = INFINITY;
      |                                                  ^~~~~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

constexpr int N_MAX = 2500;
constexpr ll INF = 1LL<<60;

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

int n, m;
vector<ll> d(N_MAX, -1);
vector<Edge> edges;

// (n-1) 番目の頂点を含む負のサイクルがあるかどうかを返す
void bellman_ford(int start){
    d[start] = 0LL;
    bool updated = true;
    for(int i=0;i<2*n;++i) {
        updated = false;
        for(Edge e: edges){
            if(d[e.from] != -1 && (d[e.to] == -1 || d[e.from] + e.cost < d[e.to])){
                if(i > n) {
                    d[e.to] = INF;
                } else {
                    d[e.to] = d[e.from] + e.cost;
                }
                updated = true;
            }
        }
        if(!updated) return false;
    }
    return d[n-1] == INF;
}


int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b;
    ll c, p;
    cin >> n >> m >> p;
    for(int i=0;i<m;++i){
        cin >> a >> b >> c;
        --a; --b;
        edges.push_back(Edge(a, b, -(c-p)));
    }

    bool has_negative_loop = bellman_ford(0);

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


Compiler output:
a.cc: In function 'void bellman_ford(int)':
a.cc:59:29: error: return-statement with a value, in function returning 'void' [-fpermissive]
   59 |         if(!updated) return false;
      |                             ^~~~~
a.cc:61:19: error: return-statement with a value, in function returning 'void' [-fpermissive]
   61 |     return d[n-1] == INF;
a.cc: In function 'int main()':
a.cc:76:42: error: void value not ignored as it ought to be
   76 |     bool has_negative_loop = bellman_ford(0);
      |                              ~~~~~~~~~~~~^~~
Language: C++

// int N, M, A[5000], B[5000], C[5000], P;
// ll dist[2500];
// {
//   ll res;
//   wgraph<int> g;
// 
//   rd(N,M,P,(A--,B--,C)(M));
//   rep(i,M) C[i] = P - C[i];
//   g.setDirectEdge(N,M,A,B,C);
//   g.BellmanFord(0, dist, 0LL, -ll_inf);
// 
//   res = dist[N-1];
//   res = if[res==-ll_inf, -1, res>0, 0, -res];
// 
//   wt(res);
// }

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

//写経コード
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(int i= 0; i<n; i++)
#define INF (1<<29)
using namespace std;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];
//Bellman-Ford法・最大経路問題？→負の数をかけて最小経路問題
//Bellman-Ford法は負閉路検知もできる(n-1以内に収束しなければならない)
//ただしd[N]=d[2N]での判定は嘘

void dfs(int v){
    if(reachableFrom1[v]) return;
    reachableFrom1[v] = true;
    for(int u: to[v]){
        dfs(u);
    }
}

void rdfs(int v){
    if(reachableToN[v]) return;
    reachableToN[v] = true;
    for(int u: to[v]){
        rdfs(u);
    }
}

int main(){
    int n,m;
    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;//負の値に
        egdes.emplace_back(a,b,c);
        to[a].pushback(b);
        rto[b].pushback(a);
    }
    dfs(0);
    rdfs(n-1);
    rep(i,n) ok[i] = reachableFrom1[i]&reachableToN[i];
    {
        vector<int> d(n,INF);
        d[0] = 0;
        bool upd = true;
        int step = 0;
        while(upd){
            upd = false;
            rep(i,m){
                int a,b,c;
                tie(a,b,c) = edges[i];
                int newD= d[a]+c;
                if(newD < d[b]){
                    upd = true;
                    d[b] = newD;
                }
            }
        }
        int ans = -d[n-1];
        ans = max(ans,0);
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:21: error: 'p' was not declared in this scope
   35 |     cin >> n >> m >>p;
      |                     ^
a.cc:44:9: error: 'egdes' was not declared in this scope; did you mean 'edges'?
   44 |         egdes.emplace_back(a,b,c);
      |         ^~~~~
      |         edges
a.cc:45:15: error: 'class std::vector<int>' has no member named 'pushback'; did you mean 'push_back'?
   45 |         to[a].pushback(b);
      |               ^~~~~~~~
      |               push_back
a.cc:46:16: error: 'class std::vector<int>' has no member named 'pushback'; did you mean 'push_back'?
   46 |         rto[b].pushback(a);
      |                ^~~~~~~~
      |                push_back
Language: C++

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define SUM(a) accumulate(all(a),int(0))
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

struct node{
  ll v, d;
  node(ll _v, ll _d):v(_v),d(_d){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge{
  ll from, to, d;
  edge(ll _from, ll _to, ll _d):from(_from),to(_to),d(_d){}
};
class bellmanford{
public:
  ll n,m;
  vector<edge> G;
  vector<ll> dist;
  vector<ll> nega;
  vector<ll> prev;

  bellmanford(ll s, ll _n, vector<edge> &_G):n(_n),G(_G){ // s:始点
    m = G.size();
    dist.resize(n,1ll << 59);
    prev.resize(n,-1);
    dist[s] = 0;
    
    rep(i, n-1) rep(j, m){
      ll u = G[j].from, v = G[j].to, c = G[j].d;
      if(dist[v] > dist[u] + c){
	dist[v] = dist[u] + c;
	prev[v] = u;
      }
    }      
  }
  
  void negative(){ // sからtへの経路中に負閉路があればnega[t] = true
    nega.resize(n,0);
    rep(i, n) rep(j, m){
      ll u = G[j].from, v = G[j].to, c = G[j].d;
      if(dist[v] > dist[u] + c){
	dist[v] = dist[u] + c;
	nega[v] = true;
      }
      // if(nega[u]) nega[v] = true;
    }
  }
};


signed main(){
  int n, m, p; cin >> n >> m >> p;
  vector<edge> g;
  rep(i,m){
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    g.push_back(edge(a,b,-c+p));
  }
  bellmanford bf(0,n,g);
  bf.negative();
  dump(bf.nega, bf.dist);
  if(bf.nega[n-1]){
    cout << -1 << endl;
  }else{
    cout << -min(0ll,bf.dist[n-1]) << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:77:3: error: 'dump' was not declared in this scope; did you mean 'dup'?
   77 |   dump(bf.nega, bf.dist);
      |   ^~~~
      |   dup
Language: C++

#include<iostream>
#include<vector>
​
using namespace std;
​
typedef long long ll;
​
struct Edge {
	int to, cost;
	Edge(int a, int b) {
		to = a, cost = b;
	}
};
​
vector<vector<Edge>> E;
int N, M, P;
ll d[2500];
ll INF = -1145141919810893;
​
int main() {
	cin >> N >> M >> P;
	E.resize(N);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		c -= P;
		E[a].push_back(Edge(b, c));
	}
	​
		for (int i = 0; i < N; i++) {
			//d[i] = INF;
		}
	d[0] = 0;
	for (int i = 0; i < N; i++) {//頂点のループ
		for (int j = 0; j < N; j++) {
			//if (d[j] == INF)continue;
			for (int k = 0; k < E[j].size(); k++) {
				int from = j, to = E[j][k].to, cost = E[j][k].cost;
				if (d[from] + cost > d[to]) {
					d[to] = d[from] + cost;
					​
					if (i == N - 1 && to == N - 1) {
						cout << -1 << endl;
						return 0;
					}
					​
				}
			}
		}
	}
	if (d[N - 1] < 0)cout << 0 << endl;
	else cout << d[N - 1] << endl;
	return 0;
}

Compiler output:
a.cc:3:1: error: '\U0000200b' does not name a type
    3 | ​
      |  
a.cc:5:1: error: '\U0000200b' does not name a type
    5 | ​
      |  
a.cc:7:1: error: '\U0000200b' does not name a type
    7 | ​
      |  
a.cc:14:1: error: '\U0000200b' does not name a type
   14 | ​
      |  
a.cc:17:1: error: 'll' does not name a type
   17 | ll d[2500];
      | ^~
a.cc:18:1: error: 'll' does not name a type
   18 | ll INF = -1145141919810893;
      | ^~
a.cc:19:1: error: '\U0000200b' does not name a type
   19 | ​
      |
Language: C++

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;
const ll INF = 1LL << 60;

ll bellman_ford(vector<vector<P>> &edge, int s) {
    int V = edge.size();
    vector <ll> dist(V, INF);
    dist[s] = 0;
    for (int i = 1; i < V; i++) {
        for (int from = 0; from < V; from++) {
            if (dist[from] == INF) continue;
            for (P e : edge[from]) {
                int to = e.first;
                dist[to] = min(dist[to], dist[from] + e.second);
            }
        }
    }

    for (int i = 1; i < 3 * V; i++) {
        for (int from = 0; from < V; from++) {
            if (dist[from] == INF) continue;
            for (P e : edge[from]) {
                int to = e.first;
                if (to = V - 1 && dist[to] > dist[from] + e.second) return -1;
                dist[to] = min(dist[to], dist[from] + e.second);
            }
        }
    }

    return max(0LL, -tmp);
}


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

    int n, m, p;
    cin >> n >> m >> p;

    vector <vector<P>> edge(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c = -c + p;
        edge[a].push_back({b, c});
    }

    cout << bellman_ford(edge, 0) << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'll bellman_ford(std::vector<std::vector<std::pair<int, int> > >&, int)':
a.cc:46:22: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   46 |     return max(0LL, -tmp);
      |                      ^~~
      |                      tm
Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second     
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define mp make_pair
#define int long long
#define double float
using namespace std;
template <typename T>
void watch(vector<T> v)
{
    for(int i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    cout<<"Look above\n";
    cout<<"\n";
}
const int INF = 1e15;
const int MAX = 1e5+3;
bool comp(pair<int, int> p1, pair<int, int> p2)
{
    if(p1.f > p2.f)
        return true;

    if(p1.f < p2.f)
        return false;

    if(p1.s > p2.s)
        return false;

    return true;
}
int32_t main()
{
    fio
    int n, m, p;
    cin>>n>>m>>p;
    vector<pair<int, pair<int, int> > > edge;
    vector<int> d(n+3, INF);
    for(int i=0;i<m;i++)
    {
        int u, v, w;
        cin>>u>>v>>w;
        edge.pb({-w+p, {u, v}});
    }
    d[1] = 0;
    for(int i=0;i<2*n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(d[u] < INF){
                int u = edge[j].s.f, v = edge[j].s.s, w = edge[j].f;
                if(d[v] > d[u] + w){
                    if(i < n)
                        d[v] = max(-INF, min(INF, d[u] + w));
                    else
                        d[v] = -INF;
                }
            }
        }
    }
    
    if(d[n] == -INF)
        cout<<-1;
    else
    {
        int ans = max(0LL, -d[n]);
        cout<<ans;
    }

}



Compiler output:
a.cc: In function 'int32_t main()':
a.cc:51:18: error: 'u' was not declared in this scope
   51 |             if(d[u] < INF){
      |                  ^
a.cc:52:21: error: redeclaration of 'long long int u'
   52 |                 int u = edge[j].s.f, v = edge[j].s.s, w = edge[j].f;
      |                     ^
a.cc:51:18: note: '<typeprefixerror>u' previously declared here
   51 |             if(d[u] < INF){
      |                  ^
Language: C++

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

const int INF = 1001001001;

vector<int> to[2505]; //辺があるか判定
vector<int> revto[2505];	//Nにたどり着けるか判定
bool reachableFrom1[2505]; //1から到達できるか判定
bool reachableToN[2505];	//Nまで到達できるか判定
bool ok[2505];

void dfs(int v){
	if (reachableFrom1[v]) return;
	reachableFrom1 = true; //到達出来たらtrue
	for (int u : to[v]) {
		dfs(u);
	}
}
//0から出発できる頂点を判定

void rdfs(int v){
	if (reachableToN[v]) return;
	reachableToN = true;
	for (int u : revto[v]) {
		rdfs(u);
	}
}
//Nに到達できる頂点を判定

int main(){
	int n, m, p;
	cin >> n >> m >> p;
	vector<tuple<int, int, int>> edges;	//3つの値をまとめる
	repp(i, 0, m){
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b; //1-indexなので0始まりにする
		c -= p;	//各辺costからp引いておく
		c = -c;	//符号を逆転
		edges.emplace_back(a, b, c); //push_back的な
		to[a].push_back(b);
		revto[b].push_back(a);
	}
	dfs(0); //0からdfs
	rdfs(n-1); //Nからrdfs
	repp(i, 0, n) ok[i] = reachableFrom1[i]&reachableToN[i]
	//okがtrueになっている頂点だけ考慮する

	{ //bellman ford
		vector<int> d(n, INF);
		d[0] = 0;
		bool update = true; //更新されたか
		int step = 0;
		while(update) { //更新が行われたら更新し続ける
			update = false; 
			repp(i, 0, m) {
				int a, b, c;
				tie(a, b, c) = edges[i];
				if (!ok[a]) continue;
				if (!ok[b]) continue; //okじゃない頂点は除く
				int newD = d[a] + c;
				if (newD < d[b]) {
					update = true; //更新が行われたらtrueにする
					d[b] = newD; //updateする
				}
			}
			step++;
			if (step > n) { //最大N回目まではstep数がカウントされる.超えたら負閉路なのでアウト
				puts("-1");
				return 0;
			}
		}
		int ans = -d[n-1]; //無事通り抜けたら、符号を反転
		ans = max(0, ans); //マイナスの場合もあるのでmax通しておく
		cout << ans << endl;
	}
	return 0;	
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:16:24: error: incompatible types in assignment of 'bool' to 'bool [2505]'
   16 |         reachableFrom1 = true; //到達出来たらtrue
      |         ~~~~~~~~~~~~~~~^~~~~~
a.cc: In function 'void rdfs(int)':
a.cc:25:22: error: incompatible types in assignment of 'bool' to 'bool [2505]'
   25 |         reachableToN = true;
      |         ~~~~~~~~~~~~~^~~~~~
a.cc: In function 'int main()':
a.cc:48:64: error: expected ';' before '{' token
   48 |         repp(i, 0, n) ok[i] = reachableFrom1[i]&reachableToN[i]
      |                                                                ^
      |                                                                ;
......
   51 |         { //bellman ford
      |         ~
Language: C++

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

const int INF = 1001001001;

vector<int> to[2505]; //辺があるか判定
vector<int> revto[2505];	//Nにたどり着けるか判定
bool reachableFrom1[2505]; //1から到達できるか判定
bool reachableToN[2505];	//Nまで到達できるか判定
bool ok[2505];

void dfs(int v){
	if (reachableFrom1[v]) return;
	reachableFrom1 = true; //到達出来たらtrue
	for (int u : to[v]) {
		dfs(u);
	}
}
//0から出発できる頂点を判定

void rdfs(int v){
	if (reachableToN[v]) return;
	reachableToN = true;
	for (int u : revto[v]) {
		rdfs(u);
	}
}
//Nに到達できる頂点を判定

int main(){
	int n, m, p;
	cin >> n >> m >> p;
	vector<tuple<int, int, int>> edges;	//3つの値をまとめる
	repp(i, 0, m){
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b; //1-indexなので0始まりにする
		c -= p;	//各辺costからp引いておく
		c = -c;	//符号を逆転
		edges.emplace_back(a, b, c); //push_back的な
		to[a].push_back(b);
		revto[b].push_back(a);
	}
	dfs(0); //0からdfs
	rdfs(n-1); //Nからrdfs
	repp(i, 0, n) ok[i] = reachableFrom1[i]&reachableToN[i]
	//okがtrueになっている頂点だけ考慮する

	{ //bellman ford
		vector<int> d(n, INF);
		d[0] = 0;
		bool update = true; //更新されたか
		int step = 0;
		while(update) { //更新が行われたら更新し続ける
			update = false; 
			repp(i, 0, m) {
				int a, b, c;
				tie(a, b, c) = edges[i];
				if (!ok[a]) continue;
				if (!ok[b]) continue; //okじゃない頂点は除く
				int newD = d[a] + c;
				if (newD < d[b]) {
					update = true; //更新が行われたらtrueにする
					d[b] = newD; //updateする
				}
			}
			step++;
			if (step > n) { //最大N回目まではstep数がカウントされる.超えたら負閉路なのでアウト
				puts("-1");
				return 0;
			}
		}
		int ans = -d[n-1]; //無事通り抜けたら、符号を反転
		ans = max(0, ans); //マイナスの場合もあるのでmax通しておく
		cout << ans << endl;
	}
	return 0;	
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:16:24: error: incompatible types in assignment of 'bool' to 'bool [2505]'
   16 |         reachableFrom1 = true; //到達出来たらtrue
      |         ~~~~~~~~~~~~~~~^~~~~~
a.cc: In function 'void rdfs(int)':
a.cc:25:22: error: incompatible types in assignment of 'bool' to 'bool [2505]'
   25 |         reachableToN = true;
      |         ~~~~~~~~~~~~~^~~~~~
a.cc: In function 'int main()':
a.cc:48:64: error: expected ';' before '{' token
   48 |         repp(i, 0, n) ok[i] = reachableFrom1[i]&reachableToN[i]
      |                                                                ^
      |                                                                ;
......
   51 |         { //bellman ford
      |         ~
Language: C++

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

const int INF = 1001001001;

vector<int> to[2505]; //辺があるか判定
vector<int> revto[2505];	//Nにたどり着けるか判定
bool reachableFrom1[2505]; //1から到達できるか判定
bool reachableToN[2505];	//Nまで到達できるか判定
bool ok[2505];

void dfs(int v){
	if (reachableFrom1[v]) return;
	reachableFrom1 = true; //到達出来たらtrue
	for (int u : to[v]) {
		dfs(u);
	}
}
//0から出発できる頂点を判定

void rdfs(int v){
	if (reachableToN[v]) return;
	reachableToN = true;
	for (int u : revto[v]) {
		rdfs(u);
	}
}
//Nに到達できる頂点を判定

int main(){
	int n, m, p;
	cin >> n >> m >> p;
	vector<tuple<int, int, int>> edges;	//3つの値をまとめる
	repp(i, 0, m){
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b; //1-indexなので0始まりにする
		c -= p;	//各辺costからp引いておく
		c = -c;	//符号を逆転
		edges.emplace_back(a, b, c); //push_back的な
		to[a].push_back(b);
		revto[b].push_back(a);
	}
	dfs(0); //0からdfs
	rdfs(n-1); //Nからrdfs
	repp(i, 0, n) ok[i] = reachableFrom1[i]&reachableToN[i]
	//okがtrueになっている頂点だけ考慮する

	{ //bellman ford
		vector<int> d(n, INF);
		d[0] = 0;
		bool update = true; //更新されたか
		int step = 0;
		while(update) { //更新が行われたら更新し続ける
			update = false; 
			repp(i, 0, m) {
				int a, b, c;
				tie(a, b, c) = edges[i];
				if (!ok[a]) continue;
				if (!ok[b]) continue; //okじゃない頂点は除く
				int newD = d[a] + c;
				if (newD < d[b]) {
					update = true; //更新が行われたらtrueにする
					d[b] = newD; //updateする
				}
			}
			step++;
			if (step > n) { //最大N回目まではstep数がカウントされる.超えたら負閉路なのでアウト
				puts("-1");
				return 0;
			}
		}
		int ans = -d[n-1]; //無事通り抜けたら、符号を反転
		ans = max(0, ans); //マイナスの場合もあるのでmax通しておく
		cout << ans << endl;
	}
	return 0;	
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:16:24: error: incompatible types in assignment of 'bool' to 'bool [2505]'
   16 |         reachableFrom1 = true; //到達出来たらtrue
      |         ~~~~~~~~~~~~~~~^~~~~~
a.cc: In function 'void rdfs(int)':
a.cc:25:22: error: incompatible types in assignment of 'bool' to 'bool [2505]'
   25 |         reachableToN = true;
      |         ~~~~~~~~~~~~~^~~~~~
a.cc: In function 'int main()':
a.cc:48:64: error: expected ';' before '{' token
   48 |         repp(i, 0, n) ok[i] = reachableFrom1[i]&reachableToN[i]
      |                                                                ^
      |                                                                ;
......
   51 |         { //bellman ford
      |         ~
Language: C++

//@HelloElwin-20190817
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
int n, m, p, ghd, hd[3000];
long long d[3000];
bool inQ[3000];
int cnt[3000];
bool bk[3000];
bool vi[3000];

struct Edge {
	int u, v, w, nxt;
}g[5005];

void AddEdge (int a, int b, int c) {
	g[ghd] = (Edge){a, b, c};
	g[ghd].nxt = hd[a];
	hd[a] = ghd++;
}

bool Spfa () {
	queue<int> Q; d[1] = 0;
	Q.push(1); inQ[1] = true;
	while (!Q.empty()) {
		int u = Q.front();
		inQ[u] = false; Q.pop();
		for (int i = hd[u]; ~i; i = g[i].nxt) {
			int v = g[i].v, w = g[i].w;
			if (d[u] + w > d[v] && bk[v]) {
				d[v] = d[u] + w;
				if (inQ[v]) continue;
				++cnt[v]; 
				if (cnt[n] > n) return true;
				inQ[v] = true;
				Q.push(v);

			}
		}
	}
	return 0;
}

bool Dfs (int u) {
	vi[u] = true;
	if (v == n) return true;
	for (int i = hd[u]; ~i; i = g[i].nxt) {
		int v = g[i].v;
		if (vi[v]) continue;
		if (v == n) return true;
		if (Dfs(v)) return true;
	}
	return false;
}

int main() {
	
	memset(hd, -1, sizeof(hd));
	scanf("%d %d %d", &n, &m, &p);
	for (int i = 0; i <= n; i++) d[i] = -2e10;
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		AddEdge(a, b, c - p);
	}

	bk[n] = true;
	for (int i = 1; i < n; i++) {
		memset(vi, 0, sizeof(vi));
		bk[i] = Dfs(i);
	}

	if (Spfa()) {
		printf("-1\n");
		return 0;
	}

	printf("%lld\n", max(0ll, d[n]));

	return 0;
}


Compiler output:
a.cc: In function 'bool Dfs(int)':
a.cc:49:13: error: 'v' was not declared in this scope
   49 |         if (v == n) return true;
      |             ^
Language: C++

// //@HelloElwin-20190817
// #include <algorithm>
// #include <iostream>
// #include <cstring>
// #include <cstdio>
// #include <queue>
// using namespace std;
// int n, m, p, ghd, hd[3000];
// long long d[3000];
// bool inQ[3000];
// int cnt[3000];
// bool bk[3000];
// bool vi[3000];

// struct Edge {
// 	int u, v, w, nxt;
// }g[5005];

// void AddEdge (int a, int b, int c) {
// 	g[ghd] = (Edge){a, b, c};
// 	g[ghd].nxt = hd[a];
// 	hd[a] = ghd++;
// }

// bool Spfa () {
// 	queue<int> Q; d[1] = 0;
// 	Q.push(1); inQ[1] = true;
// 	while (!Q.empty()) {
// 		int u = Q.front();
// 		inQ[u] = false; Q.pop();
// 		for (int i = hd[u]; ~i; i = g[i].nxt) {
// 			int v = g[i].v, w = g[i].w;
// 			if (d[u] + (long long)w > d[v]) {
// 				d[v] = d[u] + (long long)w;
// 				if (inQ[v]) continue;
// 				if (++cnt[v] > n && bk[v]) return true;
// 				if (  cnt[v] > n &&!bk[v]) g[i].w = -1000000000; 
// 				inQ[v] = true;
// 				Q.push(v);

// 			}
// 		}
// 	}
// 	return 0;
// }



// int main() {
	
// 	memset(hd, -1, sizeof(hd));
// 	scanf("%d %d %d", &n, &m, &p);
// 	for (int i = 0; i <= n; i++) d[i] = -20000000000;
// 	for (int i = 0; i < m; i++) {
// 		int a, b, c;
// 		scanf("%d %d %d", &a, &b, &c);
// 		AddEdge(a, b, c - p);
// 	}

// 	bk[n] = true;
// 	GoGoGo(1);
// 	for (int i = 1; i <= n; ++i)
// 	{
// 		printf("%d ", bk[i]);
// 	}
// 	cerr<<endl;

// 	if (Spfa()) {
// 		printf("-1\n");
// 		return 0;
// 	}

// 	printf("%lld\n", max(0ll, d[n]));

// 	return 0;
// }
//@HelloElwin-20190817
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
int n, m, p, ghd, hd[3000];
long long d[3000];
bool inQ[3000];
int cnt[3000];
bool bk[3000];
bool vi[3000];

struct Edge {
	int u, v, w, nxt;
}g[5005];

void AddEdge (int a, int b, int c) {
	g[ghd] = (Edge){a, b, c};
	g[ghd].nxt = hd[a];
	hd[a] = ghd++;
}

bool Spfa () {
	queue<int> Q; d[1] = 0;
	Q.push(1); inQ[1] = true;
	while (!Q.empty()) {
		int u = Q.front();
		inQ[u] = false; Q.pop();
		for (int i = hd[u]; ~i; i = g[i].nxt) {
			int v = g[i].v, w = g[i].w;
			if (d[u] + w > d[v] && bk[v]) {
				d[v] = d[u] + w;
				if (inQ[v]) continue;
				++cnt[v]; 
				if (cnt[n] > n) return true;
				inQ[v] = true;
				Q.push(v);

			}
		}
	}
	return 0;
}

void Go (int u) {
	vi[u] = true;
	for (int i = hd[u]; ~i; i = g[i].nxt) {
		int v = g[i].v;
		if (!vi[u]) Go(v);
		if (bk[v]) bk[u] = true;
	}
	return bk[u];
}

int main() {
	
	memset(hd, -1, sizeof(hd));
	scanf("%d %d %d", &n, &m, &p);
	for (int i = 0; i <= n; i++) d[i] = -2e10;
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		AddEdge(a, b, c - p);
	}

	bk[n] = true;
	Go(1);
	memset(vi, 0, sizeof(vi));
	Go(1);

	if (Spfa()) {
		printf("-1\n");
		return 0;
	}

	printf("%lld\n", max(0ll, d[n]));

	return 0;
}


Compiler output:
a.cc: In function 'void Go(int)':
a.cc:130:20: error: return-statement with a value, in function returning 'void' [-fpermissive]
  130 |         return bk[u];
      |                ~~~~^
Language: C++

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

#define INF 100000000000000

int main() {
    int N, M, P;
    cin >> N >> M >> P;
    vector<int>A(M);
    vector<int>B(M);
    vector<int>C(M);
    for (int i = 0; i < M; ++i) {
      cin >> A[i] >> B[i] >> C[i];
    }
    for (int i = 0; i < M; ++i) {
        C[i] = P - C[i]; // コスト
    }
    
    vector<ll>dist(N+1, 0);
    dist[1] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            if(dist[A[j]] != INF && dist[B[j]] > dist[A[j]] + C[j]){
                dist[B[j]] = dist[A[j]] + C[j];
            }
        }
    }
    int temp = dist[N];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            if(dist[A[j]] != INF && dist[B[j]] > dist[A[j]] + C[j]){
                dist[B[j]] = dist[A[j]] + C[j];
            }
        }
    }
    if(dist[N] != temp) {
        cout << -1;
        return 0;
    }
    
    vector<ll>dist(N+1, INF); // i-indexed
    dist[1] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            if(dist[A[j]] != INF && dist[B[j]] > dist[A[j]] + C[j]){
                dist[B[j]] = dist[A[j]] + C[j];
            }
        }
    }
    dist[N] *= -1;
    if(dist[N] < 0) dist[N] = 0;
    cout << dist[N];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:15: error: redeclaration of 'std::vector<long long int> dist'
   42 |     vector<ll>dist(N+1, INF); // i-indexed
      |               ^~~~
a.cc:20:15: note: 'std::vector<long long int> dist' previously declared here
   20 |     vector<ll>dist(N+1, 0);
      |               ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ' ' << n << endl;

inline bool ChangeMin(int&a, int b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

void CheckReachableNode(const vector<unordered_set<int>>&movable_list
			, int pos
			, bitset<2500>&nodes){
  
  if(nodes[pos] == 1){
    return;
  } else {
    nodes[pos] = 1;
    for(auto&&node:movable_list[pos]){
      CheckReachableNode(movable_list, node, nodes);
    }
  }
}

int main(){
  int v, e, p;
  cin >> v >> e >> p;

  vector<tuple<int, int, int>> edges;
  vector<unordered_set<int>> in_list(e);
  vector<unordered_set<int>> out_list(e);
  bitset<10000> reachable_from_start = 0;
  bitset<10000> reachable_in_goal = 0;

  for(int i = 0; i < e; ++i){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edges.emplace_back(a,b,-(c-p));
    out_list[a].insert(b);
    in_list[b].insert(a);
  }


  CheckReachableNode(out_list, 0, reachable_from_start);
  CheckReachableNode(in_list, v - 1, reachable_in_goal);

  bitset<10000>on_path;
  for(int i = 0; i < 10000; ++i){
    on_path[i] = reachable_from_start[i] & reachable_in_goal[i];
  }

  vector<int> costs(v, 1e+9);
  int loop_count = 0;
  bool loop_fin = false;

  costs[0] = 0;

  while(!loop_fin){
    loop_fin = true;
    for(auto&&edge:edges){
      int a, b, c;
      tie(a,b,c) = edge;
      if(out_list[a].count(b) != 0  &&  on_path[a] & on_path[b]){
	if(ChangeMin(costs[b], costs[a] + c)){
	  loop_fin = false;
	}
      }
    }
    if(loop_count++ > v) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << max(-costs[v - 1], 0) << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:35: error: invalid initialization of reference of type 'std::bitset<2500>&' from expression of type 'std::bitset<10000>'
   50 |   CheckReachableNode(out_list, 0, reachable_from_start);
      |                                   ^~~~~~~~~~~~~~~~~~~~
a.cc:17:40: note: in passing argument 3 of 'void CheckReachableNode(const std::vector<std::unordered_set<int> >&, int, std::bitset<2500>&)'
   17 |                         , bitset<2500>&nodes){
      |                           ~~~~~~~~~~~~~^~~~~
a.cc:51:38: error: invalid initialization of reference of type 'std::bitset<2500>&' from expression of type 'std::bitset<10000>'
   51 |   CheckReachableNode(in_list, v - 1, reachable_in_goal);
      |                                      ^~~~~~~~~~~~~~~~~
a.cc:17:40: note: in passing argument 3 of 'void CheckReachableNode(const std::vector<std::unordered_set<int> >&, int, std::bitset<2500>&)'
   17 |                         , bitset<2500>&nodes){
      |                           ~~~~~~~~~~~~~^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

void dfs(int x, vector<vector<int>> &da, vector<bool> &ju) {
	int y = da[x].size();
	for (int i = 0;i < y;i++) {
		if (!ju[da[x][i]]) {
			ju[da[x][i]] = true;
			dfs(da[x][i], da, ju);
		}
	}
	return;
}

int main() {
	int n, m, p;
	cin >> n >> m >> p;
	vector<vector<int>> da1(n), da2(n);
	vector<tuple<int, int, int>> da(m);
	vector<bool> ju1(n, false), ju2(n, false);
	ju1[0] = true;
	ju2[n - 1] = true;
	for (int i = 0;i < m;i++) {
		int a, b, c;
		cin >> a >> b >> c;
		da1[a - 1].push_back(b - 1);
		da2[b - 1].push_back(a - 1);
		da[i] = make_tuple(a-1, b-1, p-c);
	}
	dfs(0, da1, ju1);
	dfs(n - 1, da2, ju2);
	vector<tuple<int, int, int>>daa(0);
	for (int i = 0;i < m;i++){
		if (ju2[get<1>(da[i])] && ju1[get<0>(da[i])] && ju2[get<0>(da[i])] && ju1[get<1>(da[i])]) {
			daa.push_back(da[i]);
		}
	}
	m = daa.size();
	vector<int> st(n, INT_MAX);
	st[0] = 0;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) {
			if (st[get<0>(daa[j])] != INT_MAX) {
				st[get<1>(daa[j])] = min(st[get<1>(daa[j])], st[get<0>(daa[j])] + get<2>(daa[j]));
			}
		}
	}
	bool ju = true;
	for (int i = 0;i < m;i++) {
		if (st[get<0>(daa[i])] != INT_MAX) {
			if (st[get<1>(daa[i])] > st[get<0>(daa[i])] + get<2>(daa[i])) {
				ju = false;
				break;
			 }
		}
	}
	if (ju) {
		cout << max(-st[n-1],0);
	}
	else {
		cout << -1;
	}
	cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:27: error: 'INT_MAX' was not declared in this scope
   43 |         vector<int> st(n, INT_MAX);
      |                           ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | #include <tuple>
Language: C++

#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const ll infll = (1ll<<60);
const int mod = 1000000007;
using namespace std;

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

vector<edge> graph;

vector<int> checkgraph[3000];
bool besucht[3000];

void checkdfs( int punkt ){
	if( besucht[punkt] ) return;
	besucht[punkt] = true;
	for( auto nextp : checkgraph[punkt] ){
		checkdfs( nextp );
	}
}

int main(){
	int n, m; ll p; cin >> n >> m >> p;
	const int s = 0, g = n-1;
	for( int i = 0; i < m; ++i ){
		int a, b, c; cin >> a >> b >> c;
		--a; --b;
		graph.push_back( (edge){a, b, -(c-p)} );
		checkgraph[a].push_back(b);
	}
	checkdfs(0); 
	vector<ll> d(n);
	fill_n( d.begin(), n, infll );
	// スタート地点を 0 にしておく
	d[s] = 0;
	int k = n-1;
	while( k-- ){
		for( auto e : graph ){
			if( !besucht[e.from] ) continue;
			d[e.to] = min(d[e.to], d[e.from]+e.cost);
		}
	}
	bool negativ[n];
	fill_n( negativ, n, false );
	for( auto e : graph ){
		if( !besucht[e.from] ) continue;
		if( d[e.to] > d[e.from]+e.cost ){
			d[e.to] = d[e.from]+e.cost;
			negativ[e.to] = true;
		}
	}
	k = n;
	while( k-- ){
		if( negativ[e.from] ) negativ[e.to] = true;
	}
	if( negativ[g] ) cout << -1 << endl;
	else cout << max(0ll, -d[g]) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:29: error: 'e' was not declared in this scope
   59 |                 if( negativ[e.from] ) negativ[e.to] = true;
      |                             ^
Language: C++

#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
const ll infll = (1ll<<60);
const int mod = 1000000007;
using namespace std;

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

vector<edge> graph;

vector<int> checkgraph[3000];
bool besucht[3000];

void checkdfs( int punkt ){
	if( besucht[punkt] ) return;
	besucht[punkt] = true;
	for( auto nextp : checkgraph[punkt] ){
		checkdfs( nextp );
	}
}

int main(){
	int n, m; ll p; cin >> n >> m >> p;
	const int s = 0, g = n-1;
	for( int i = 0; i < m; ++i ){
		int a, b, c; cin >> a >> b >> c;
		--a; --b;
		graph.push_back( (edge){a, b, -(c-p)} );
		checkgraph[a].push_back(b);
	}
	checkdfs(0); 
	vector<ll> d(n);
	fill_n( d.begin(), n, infll );
	// スタート地点を 0 にしておく
	d[s] = 0;
	int k = n-1;
	while( k-- ){
		for( auto e : graph ){
			if( !besucht[e.from] ) continue;
			d[e.to] = min(d[e.to], d[e.from]+e.cost);
		}
	}
	bool negativ[n];
	fill_n( negativ, n, false );
	for( auto e : graph ){
		if( !besucht[e.from] ) continue;
		if( d[e.to] > d[e.from]+e.cost ){
			d[e.to] = d[e.from]+e.cost;
			negativ[e.to] = true;
	}
	k = n;
	while( k-- ){
		if( negativ[e.from] ) negativ[e.to] = true;
	}
	if( negativ[g] ) cout << -1 << endl;
	else cout << max(0ll, -d[g]) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:27:11: note: to match this '{'
   27 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<math.h>
using namespace std;

#define FOR(i,a) for(int i=0;i<a;i++)
#define int long long int
signed main(){
	int n,m,p;
	cin>>n>>m>>p;
	int score=0;
	int path[5000][3];
	FOR(i,m){
		FOR(j,3){cin>>path[i][j];}
	}
	int cost[2500];
	FOR(i,n){cost[i]=-1612695271;}
	cost[0]=0;
	int newcount =0;
	bool update=true;
	int old[2500];
	int reach[2500];
	FOR(i,2500){reach[i]=0;}
	reach[n-1]=1;
	FOR(i,m){
		if(reach[path[i][1]-1]==1){reach[path[i][0]-1]=1;}
	}
	while(update==true){
		update=false;
		if(newcount==m){FOR(i,2500){old[i]=cost[i];}}
		if(newcount>m){
			FOR(i,2500){
				if(reach[i]==1 and old[i]!=cost[i]){
					cout<<-1<<endl;return 0;
				}
			}
		}
		FOR(i,m){
			if(cost[path[i][0]-1]!=-1612695271 and cost[path[i][1]-1]<cost[path[i][0]-1]+path[i][2]-p){
				update=true;
				cost[path[i][1]-1]=cost[path[i][0]-1]+path[i][2]-p;
			}
		}
		if(newcount>m){break;}
		newcount++;
	}
	cout<<max(cost[n-1],0)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:18: error: no matching function for call to 'max(long long int&, int)'
   46 |         cout<<max(cost[n-1],0)<<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:46:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |         cout<<max(cost[n-1],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
Language: C++

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int  N,M;
    long long Q, inf = 1e17;
    cin >> N >> M >> Q;
    vector<long long> cost(N,inf),rev(N,1);
    vector<long long> A(M),B(M),C(M);
    for(int i = 0; i < M; ++i){
        cin >> A[i] >> B[i] >> C[i];
        A[i]--,B[i]--;
    }
    cost[0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < M; ++j){
            chmin(cost[B[j]],cost[A[j]] + Q - C[j]);  
        }
    }
    auto tmp = cost;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < M; ++j){
            chmin(tmp[B[j]],tmp[A[j]] + Q - C[j]);  
        }
    }
    rev[N-1] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < M; ++j){
            chmin(rev[A[j]],rev[B[j]]);  
        }
    }
    
    for(int i = 0; i < N; ++i){
        if(tmp[i]<cost[i] && !rev[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(0LL,-cost[N-1]) << endl;


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: 'chmin' was not declared in this scope
   18 |             chmin(cost[B[j]],cost[A[j]] + Q - C[j]);
      |             ^~~~~
a.cc:24:13: error: 'chmin' was not declared in this scope
   24 |             chmin(tmp[B[j]],tmp[A[j]] + Q - C[j]);
      |             ^~~~~
a.cc:30:13: error: 'chmin' was not declared in this scope
   30 |             chmin(rev[A[j]],rev[B[j]]);
      |             ^~~~~
Language: C++

#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

signed main() {
  int n,m,p;cin>>n>>m>>p;
  pair<pair<int,int>,int> g[5100];int d[2600];
  rep(i,m){
    cin>>g[i].first.first>>g[i].first.second>>g[i].second;
    g[i].second -= p;g[i].second *= -1;
  }
  rep(i,2600)d[i] = INF;
  d[1] = 0;
  int dd;
  while(true){
    bool updated = false;
    rep(j,m){
      pair<int,int> e = g[j].first;int cost = g[j].second;
      if(d[e.first] != INF && d[e.second] > d[e.first]+cost){
        d[e.second] = d[e.first]+cost;
        updated = true;
      }
    }
    if(i < n-1){
      dd = d[n];
    }
    if(!updated)break;
  }
  if(dd == d[n])cout << max((ll)0,d[n]*-1) << endl;
  else cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:8: error: 'i' was not declared in this scope
   30 |     if(i < n-1){
      |        ^
Language: C++

#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

signed main() {
  int n,m,p;cin>>n>>m>>p;
  pair<pair<int,int>,int> g[5100];int d[2600];
  rep(i,m){
    cin>>g[i].first.first>>g[i].first.second>>g[i].second;
    g[i].second -= p;g[i].second *= -1;
  }
  rep(i,2600)d[i] = INF;
  d[1] = 0;
  int dd;
  rep(i,n){
    if(i == n-1){
      break;
    }else{
      dd = d[n]*(-1);
    }
    bool updated = false;
    rep(j,m){
      pair<int,int> e = g[j].first;int cost = g[j].second;
      if(d[e.first] != INF && d[e.second] > d[e.first]+cost){
        d[e.second] = d[e.first]+cost;
        updated = true;
      }
    }
    if(!updated)break;
  }
  if(dd == d[n]*-1)cout << max(0,d[n]*-1) << endl;
  else cout << -1 << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:37:31: error: no matching function for call to 'max(int, long long int)'
   37 |   if(dd == d[n]*-1)cout << max(0,d[n]*-1) << 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:37:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   37 |   if(dd == d[n]*-1)cout << max(0,d[n]*-1) << 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:37:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |   if(dd == d[n]*-1)cout << max(0,d[n]*-1) << endl;
      |                            ~~~^~~~~~~~~~~