Language: C++

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // include pb_ds

using namespace std;
using namespace __gnu_pbds; // namespace for pb_ds

/* short forms */
#define Accelerate                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define cld(x, y) (((x) / (y)) + ((x) % (y) != 0)) //integer ceil division
#define tc(tt) \
    int tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) // testcase
#define all(cont) (cont).begin(), (cont).end()
#define sz(cont) (int)(cont).size()
#define endl '\n'
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl //print with precision
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)

/* constants */
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;

/* typedefs */
typedef pair<int,int> pii;
typedef priority_queue<int, vector<int>, greater<int> > min_heap;
typedef priority_queue<int, vector<int> > max_heap;
typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> 
    indexed_set; // integer set with indexing / pb_ds

/* main program */
vector<tuple<int,int,ll int> > edges;
vector<ll int> dis;

bool bellman_ford(int src,int n,ll int infinity) {
    dis.clear();
    dis.resize(n+1,infinity);
    dis[src] = 0;

    for(int i=1;i<n;i++) {
        for(auto e: edges) {
            int u,v;
            ll int w;
            tie(u,v,w) = e;
            dis[v] = min(dis[v],dis[u]+w);
        }
    }
    ll int x = dis[n];
    for(int i=1;i<=n;i++) {
        for(auto e: edges) {
            int u,v;
            ll int w;
            tie(u,v,w) = e;
          	if(dis[u]<inf)
            dis[v] = min(dis[v],dis[u]+w);
        }
    }
    return dis[n]<x;
    
}

/* dijkstra */
vector <vector<pair<int,ll int> > > adj;
vector <bool> vis;

void dijkstra(int src,int n,ll int infinity) {
    dis.clear();
    dis.resize(n+1,infinity);
    dis[src] = 0;
    vis.clear();
    vis.resize(n+1,0);
    priority_queue<pair<ll int,int>, vector<pair<ll int,int> >, greater<pair<ll int,int> > > q;
    q.push({0,src});
    while(!q.empty()) {
        int u = q.top().ss;
        q.pop();
        if(vis[u])continue;
        vis[u] = 1;
        for(auto v: adj[u]) {
            if(dis[v.ff]>dis[u]+v.ss) {
                dis[v.ff] = dis[u]+v.ss;
                q.push({dis[v.ff],v.ff});
            }
        }
    }
    
}


int main() {
    Accelerate;
    int n,m;
    ll int p;
    cin >>n >> m >> p;
    adj.resize(n+1);
    for(int i=1;i<=m;i++) {
        int a,b;
        ll int c;
        cin >> a >> b >> c;
        edges.pb(mt(a,b,p-c));
        adj[a].pb({b,p-c});
    }
    bool flag = bellman_ford(1,n,1e18);
    if(flag) {
        cout << -1 << endl;
        return 0;
    }    
    cout << max(0LL,dis[n]) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'bool bellman_ford(int, int, long long int)':
a.cc:65:27: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   65 |                 if(dis[u]<inf)
      |                           ^~~
      |                           ynf