Language: C++

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

ll INF = (1LL << 60);

template <typename A>
string to_string(A x[], signed n) {
    string result = "{";
    for (signed i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    ll N, M, P;
    cin >> N >> M >> P;

    vector<tuple<int, int, int>> edges (M);
    
    for (int i = 0; i < M; ++i) {
        ll A, B, C;
        cin >> A >> B >> C;
        edges[i] = (A-1, B-1, P - C);
    }

    ll dist[N];
    for (int i = 0; i < N; ++i) dist[i] = INF;

    dist[0] = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (auto edge : edges) {
            ll s, e, c;
            tie(s, e, c) = edge;
            if (dist[s] != INF && dist[s] + c < dist[e]) {
                dist[e] = dist[s] + c;
            }
        }
    }

    // Do one more time
    ll score = dist[N-1];
    
    for (auto edge : edges) {
        ll s, e, c;
        tie(s, e, c) = edge;
        if (dist[s] != INF && dist[s] + c < dist[e] && e == N - 1) {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << max(0LL, -score) << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:36: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'std::tuple<int, int, int>'} and 'll' {aka 'long long int'})
   28 |         edges[i] = (A-1, B-1, P - C);
      |                                    ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/tuple:1930:9: note: candidate: 'template<class ... _UElements> std::__enable_if_t<((bool)__assignable<const _UElements& ...>()), std::tuple< <template-parameter-1-1> >&> std::tuple< <template-parameter-1-1> >::operator=(const std::tuple<_Args1 ...>&) [with _UElements = {_UElements ...}; _Elements = {int, int, int}]'
 1930 |         operator=(const tuple<_UElements...>& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:1930:9: note:   template argument deduction/substitution failed:
a.cc:28:36: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'll' {aka 'long long int'}
   28 |         edges[i] = (A-1, B-1, P - C);
      |                                    ^
/usr/include/c++/14/tuple:1940:9: note: candidate: 'template<class ... _UElements> std::__enable_if_t<((bool)__assignable<_UElements ...>()), std::tuple< <template-parameter-1-1> >&> std::tuple< <template-parameter-1-1> >::operator=(std::tuple<_Args1 ...>&&) [with _UElements = {_UElements ...}; _Elements = {int, int, int}]'
 1940 |         operator=(tuple<_UElements...>&& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:1940:9: note:   template argument deduction/substitution failed:
a.cc:28:36: note:   mismatched types 'std::tuple<_UTypes ...>' and 'll' {aka 'long long int'}
   28 |         edges[i] = (A-1, B-1, P - C);
      |                                    ^
/usr/include/c++/14/tuple:1907:7: note: candidate: 'std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(std::__conditional_t<((bool)__assignable<const _Elements& ...>()), const std::tuple< <template-parameter-1-1> >&, const std::__nonesuch&>) [with _Elements = {int, int, int}; std::__conditional_t<((bool)__assignable<const _Elements& ...>()), const std::tuple< <template-parameter-1-1> >&, const std::__nonesuch&> = const std::tuple<int, int, int>&]'
 1907 |       operator=(__conditional_t<__assignable<const _Elements&...>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:1909:52: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::__conditional_t<true, const std::tuple<int, int, int>&, const std::__nonesuch&>' {aka 'const std::tuple<int, int, int>&'}
 1907 |       operator=(__conditional_t<__assignable<const _Elements&...>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1908 |                                 const tuple&,
      |                                 ~~~~~~~~~~~~~       
 1909 |                                 const __nonesuch&> __in)
      |                                 ~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/tuple:1918:7: note: candidate: 'std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(std::__conditional_t<((bool)__assignable<_Elements ...>()), std::tuple< <template-parameter-1-1> >&&, std::__nonesuch&&>) [with _Elements = {int, int, int}; std::__conditional_t<((bool)__assignable<_Elements ...>()), std::tuple< <template-parameter-1-1> >&&, std::__nonesuch&&> = std::tuple<int, int, int>&&]'
 1918 |       operator=(__conditional_t<__assignable<_Elements...>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:1920:47: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::__conditional_t<true, std::tuple<int, int, int>&&, std::__nonesuch&&>' {aka 'std::tuple<int, int, int>&&'}
 1918 |       operator=(__conditional_t<__assignable<_Elements...>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1919 |                                 tuple&&,
      |                                 ~~~~~~~~       
 1920 |                                 __nonesuch&&> __in)
      |                                 ~~~~~~~~~~~~~~^~~~