Language: C++

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random#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);
            }
        }
    }

    ll tmp = dist[V - 1];
    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);
        }
    }

    if (dist[V - 1] == tmp) {
        return max(0LL, -tmp);
    } else {
        return -1;
    }
}


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;
}
#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 int INF = 1 << 30;

int bellman_ford(vector<vector<P>> &edge, int s) {
    int V = edge.size();
    vector <int> 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);
            }
        }
    }

    int tmp = dist[V - 1];
    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);
        }
    }

    if (dist[V - 1] == tmp) {
        return max(0, -tmp);
    } else {
        return -1;
    }
}


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:8:10: fatal error: random#include <functional: No such file or directory
    8 | #include <random#include <functional>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.