Language: C++

#include<bits/stdc++.h>

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp, tmp);
	if(b & 1) tmp = mulMod(tmp, a);
	return tmp;
}

/////////////////////////////////////////////////////////

const int N = 1e5;

ll n,m,p;
ll dist[N + 5];

ll solve(){
	FOR(i,n+1) dist[i] = -INF;
	dist[1] = 0;
	FOR(j,n){
		FOR(i,m){
			if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
				dist[v[i]] = dist[u[i]] + w[i] - p;
			}
		}
	}
	ll bef = dist[n];
	FOR(i,n){
		if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
			dist[v[i]] = dist[u[i]] + w[i] - p;
		}
	}
	if(bef != dist[n]) return -1;
	return max((ll)0, dist[n]);
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> p;
	FOR(i,m) cin >> u[i] >> v[i] >> w[i];
	cout << solve() << endl;
	return 0;
}

Compiler output:
a.cc: In function 'll solve()':
a.cc:55:33: error: 'u' was not declared in this scope
   55 |                         if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
      |                                 ^
a.cc:55:55: error: 'v' was not declared in this scope
   55 |                         if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
      |                                                       ^
a.cc:55:76: error: 'w' was not declared in this scope
   55 |                         if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
      |                                                                            ^
a.cc:62:25: error: 'u' was not declared in this scope
   62 |                 if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
      |                         ^
a.cc:62:47: error: 'v' was not declared in this scope
   62 |                 if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
      |                                               ^
a.cc:62:68: error: 'w' was not declared in this scope
   62 |                 if(dist[u[i]] != -INF && dist[v[i]] < dist[u[i]] + w[i] - p){
      |                                                                    ^
a.cc: In function 'int main()':
a.cc:73:25: error: 'u' was not declared in this scope
   73 |         FOR(i,m) cin >> u[i] >> v[i] >> w[i];
      |                         ^
a.cc:73:33: error: 'v' was not declared in this scope
   73 |         FOR(i,m) cin >> u[i] >> v[i] >> w[i];
      |                                 ^
a.cc:73:41: error: 'w' was not declared in this scope
   73 |         FOR(i,m) cin >> u[i] >> v[i] >> w[i];
      |                                         ^