Language: C++

#include <bits/stdc++.h>
#define M 1000000007
#define U 998244353
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define N 2505
#define U 998244353
#define bs binary_search
#define endl '\n'
#define FILEIO     freopen("input.txt","r",stdin); freopen("output.txt","w", stdout);
#define PI 3.1415926535
#define INF (int)1e15
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int po(int n, int exp){
    int prod=1;
    rep(i,0,exp)
        prod*=n;
    return prod;
}
int n,m,p;
vector<int> g[N];
vector<pair<pair<int,int>,int>> edge;
vector<int> vis(N,0);
int dfs(int i, int d)
{
    if(i==d) return 1;
    if(vis[i]) return 0;
    // if(d==n) cout<<i<<" ";
    vis[i] = 1;
    int ans = 0;
    rep(j,0,sz(g[i]))
        ans = ans|dfs(g[i][j], d);
    return ans;
}
map<pair<int,int>,int> mp;
signed main()
{
    ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        cin>>n>>m>>p;
        int tm = m;
        while(tm--){
            int a,b,w;
            cin>>a>>b>>w;
            edge.pb({{a,b},p-w)});
            g[a].pb(b);
        }
        vector<int> d(N,INF);
        d[1] = 0;
        rep(i,0,n-1){
            rep(j,0,m){
                if(d[edge[j].fr.fr]<INF)
                    d[edge[j].fr.sc] = min(d[edge[j].fr.sc], d[edge[j].fr.fr]+edge[j].sc);
            }
        }
        vector<int> change;
        rep(j,0,m){
            if(d[edge[j].fr.fr]<INF){
                // trace(edge[j].fr.fr, edge[j].fr.sc, d[edge[j].fr.fr], d[edge[j].fr.sc]);
                if(d[edge[j].fr.sc]>d[edge[j].fr.fr]+edge[j].sc) change.pb(edge[j].fr.sc);
            }
        }
        for(auto j:change){
            // cout<<j;
            vis.assign(N,0);
            if(dfs(1,j)){
                vis.assign(N,0);
                if(dfs(j,n)){
                    cout<<-1;
                    r0;
                }
            }
        }
      if(d[n]>0){
        cout<<0;
        r0;
      }
        cout<<-d[n];
    }   
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:68:31: error: expected '}' before ')' token
   68 |             edge.pb({{a,b},p-w)});
      |                     ~         ^
a.cc:68:32: error: expected ';' before '}' token
   68 |             edge.pb({{a,b},p-w)});
      |                                ^
      |                                ;
a.cc:68:33: error: expected primary-expression before ')' token
   68 |             edge.pb({{a,b},p-w)});
      |                                 ^
a.cc:69:15: error: 'a' was not declared in this scope
   69 |             g[a].pb(b);
      |               ^
a.cc:69:21: error: 'b' was not declared in this scope
   69 |             g[a].pb(b);
      |                     ^
a.cc: At global scope:
a.cc:103:1: error: expected declaration before '}' token
  103 | }
      | ^