criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#include<map>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
const int maxn = 5e3 + 5;
using namespace std;
ll m,n;
ll dis[maxn];
bool inQ[maxn];
int cnt[maxn];
vector<pii> E[maxn];
int SPFA() {
	rep(i, 1, n)dis[i] = 1e18, inQ[i] = 0,cnt[i]=0;
	queue<int> Q;
	Q.push({ 1 });
	dis[1] = 0;
	cnt[1]++;
	while (!Q.empty()) {
		auto now = Q.front();
		Q.pop();
		if (cnt[now] >= 3 * n + 1)dis[now] = -1e9;
		inQ[now] = 0;
		for (auto v : E[now]) {
			if (dis[v.first] > dis[now] + v.second) {
				dis[v.first] = dis[now] + v.second);
				if (!inQ[v.first] && cnt[v.first] <= 3 * n + 1)Q.push(v.first), inQ[v.first] = 1, cnt[v.first]++;
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int p;
	cin >> n >> m >> p;

	rep(i, 1, m) {
		int x, y, z;
		cin >> x >> y >> z;
		E[x].push_back({y,  p - z });
	}
	SPFA();
	
	if (-dis[n]>=1e9)cout << -1<<endl;
	 else cout << max(0ll,-dis[n]) << endl;
		cin >> m;
}

/*
2 2 10
1 2 100
2 2 100
*/

Compiler output:
a.cc: In function 'int SPFA()':
a.cc:35:67: error: expected ';' before ')' token
   35 |                                 dis[v.first] = dis[now] + v.second);
      |                                                                   ^
      |                                                                   ;
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
struct edge { int to, from, cost; };
int INF = 1000000000000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, p;
  cin >> n >> m >> p;

  int a[m], b[m], c[m];
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }

  edge es[m];
  for(int i = 0; i < m; i++) {
    es[i] = (edge) { b[i], a[i], p - c[i]};
  }
  int d[n];
  for(int i = 0; i < n; i++) d[i] = INF;
  d[0] = 0;

  bool neg_loop = false;
  for(int i = 0; i < 2 * n; i++) {
    for(int j = 0; j < m; j++) {
      edge e = es[j];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if(i >= n - 1 && e.to == n - 1) {
          neg_loop = true;
          break;
        }
      }

    }
  }

  if(neg_loop) {
    cout << -1 << "\n";
    return 0;
  }


  cout << max(0LL, -d[n - 1]) << "\n";
  return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
struct edge { int to, from, cost; };
int INF = 1000000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, p;
  cin >> n >> m >> p;

  int a[m], b[m], c[m];
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }

  edge es[m];
  for(int i = 0; i < m; i++) {
    es[i] = (edge) { b[i], a[i], p - c[i]};
  }
  long d[n];
  for(int i = 0; i < n; i++) d[i] = INF;
  d[0] = 0;

  bool neg_loop = false;
  for(int i = 0; i < 2 * n; i++) {
    for(int j = 0; j < m; j++) {
      edge e = es[j];
      if(d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if(i >= n && e.to == n - 1) {
          neg_loop = true;
          break;
        }
      }

    }
  }

  if(neg_loop) {
    cout << -1 << "\n";
    return 0;
  }


  cout << max(0, -d[n - 1]) << "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:14: error: no matching function for call to 'max(int, long int)'
   48 |   cout << max(0, -d[n - 1]) << "\n";
      |           ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:48:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   48 |   cout << max(0, -d[n - 1]) << "\n";
      |           ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:48:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   48 |   cout << max(0, -d[n - 1]) << "\n";
      |           ~~~^~~~~~~~~~~~~~
Language: C++

signed main() {
    cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:5: error: 'cout' was not declared in this scope
    2 |     cout << -1 << endl;
      |     ^~~~
a.cc:2:19: error: 'endl' was not declared in this scope
    2 |     cout << -1 << endl;
      |                   ^~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
long long int a[5003], b[5003], c[5003];
int asc(const void* x, const void* y)
{
	if (a[*(long long int*)x] > a[*(long long int*)y])return 1;
	if (a[*(long long int*)x] < a[*(long long int*)y])return -1;
	return 0;
}
int main()
{
	long long int n, m, p;
	scanf("%lld %lld %lld", &n, &m, &p);
	long long int i;
	for (i = 0; i < m; i++)
	{
		scanf("%lld %lld %lld", &a[i], &b[i], &c[i]);
		a[i]--;
		b[i]--;
	}
	long long int d[5003];
	for (i = 0; i < m; i++)
		d[i] = i;
	qsort(d, n, sizeof(long long int), asc);
	long long int ans = 0;
	long long int t;
	int min, max, mid;
	long long int res[2][2503];
	for (i = 0; i < n; i++)
		res[0][i] = 0;
	for (t = 0; t < 2 * m t++)
	{
		for (i = 0; i < n; i++)
			res[1][i] = 0;
		for (i = 0; i < n; i++)
		{
			min = 0;
			max = m - 1;
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (a[d[mid]] >= i)
					max = mid;
				else
					min = mid;
			}
			if (a[d[min]] != i)
				min++;
			if (min < n)
			{
				while (a[d[min]] == i)
				{
					if (res[1][b[d[min]]] < res[0][a[d[min]]] + c[d[min]])
						res[1][b[d[min]]] = res[0][a[d[min]]] + c[d[min]];
					min++;
					if (min == n)
						break;
				}
			}
		}
		for (i = 0; i < n; i++)
			res[0][i] = res[1][i];
		if (ans < res[0][n - 1] - (p * (t + 1)))
			ans = res[0][n - 1] - (p * (t + 1));
	}
	for (; t < 3 * m; t++)
	{
		for (i = 0; i < n; i++)
			res[1][i] = 0;
		for (i = 0; i < n; i++)
		{
			min = 0;
			max = m - 1;
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (a[d[mid]] >= i)
					max = mid;
				else
					min = mid;
			}
			if (a[d[min]] != i)
				min++;
			if (min < n)
			{
				while (a[d[min]] == i)
				{
					if (res[1][b[d[min]]] < res[0][a[d[min]]] + c[d[min]])
						res[1][b[d[min]]] = res[0][a[d[min]]] + c[d[min]];
					min++;
					if (min == n)
						break;
				}
			}
		}
		for (i = 0; i < n; i++)
			res[0][i] = res[1][i];
		if (ans < res[0][n - 1] - (p * (t + 1)))
		{
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:31:30: error: expected ';' before 't'
   31 |         for (t = 0; t < 2 * m t++)
      |                              ^~
      |                              ;
Language: C++

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

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'a'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int n, m, p;

int head[250000 + 5];
struct Edge {
	int u, v, c, next;
}edge[500000 + 5];

int cnt = 0;

void add(int u, int v, int c)
{
	edge[cnt].u = u;
	edge[cnt].v = v;
	edge[cnt].c = -(c - p);
	edge[cnt].next = head[u];
	head[u] = cnt++;
}

void init()
{
	cnt = 0;
	memset(head, -1, sizeof head);
}

long long dist[250000 + 5];

bool vis[250000 + 5];
bool vis2[250000 + 5];
bool dfs(int u, int fa)
{
	vis2[u] = 1;
	if (u == n)
		vis[u] = 1;
	if (vis[u] == 1)return;
	for (int i = head[u]; i != -1; i = edge[i].next)
	{
		int v = edge[i].v;
		if (v == fa||vis2[v])continue;
		dfs(v, u);
		if (vis[v])
			vis[u] = 1;
	}
	return vis[u];
}

bool bellman(int n)
{
	for (int i = 1; i <= n; i++)dist[i] = 0x3f3f3f3f3f3f3f3f;
	dist[1] = 0;
	for (int i = 1; i < n; i++)
	{
		bool flag = 0;
		for (int j = 0; j < cnt; j++)
		{
			int u = edge[j].u;
			int v = edge[j].v;
			int c = edge[j].c;
			if (dist[v] > dist[u] + c)
			{
				dist[v] = dist[u] + c;
				flag = 1;
			}
		}
		if (!flag)
			return 1;
	}
	for (int j = 0; j < cnt; j++)
	{
		int u = edge[j].u;
		int v = edge[j].v;
		int c = edge[j].c;
		if (vis[u] && vis[v] && dist[v] > dist[u] + c)
			return 0;
	}
	return 1;
}

int main()
{
	file(1);
	init();
	scanf("%d%d%d", &n, &m, &p);
	for (int i = 1; i <= m; i++)
	{
		int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		add(u, v, c);
	}
	dfs(1, -1);
	if (bellman(n))
	{
		dist[n] *= -1;
		printf("%lld\n", max(0ll, dist[n]));
	}
	else
		printf("-1\n");
	return 0;
}


Compiler output:
a.cc: In function 'bool dfs(int, int)':
a.cc:66:25: error: return-statement with no value, in function returning 'bool' [-fpermissive]
   66 |         if (vis[u] == 1)return;
      |                         ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

LL N, M, P;
LL d[2504], D[2504], chk2[2504], can[2504];
vector < pair < LL, LL > > way[2504], way2[2504];
void dfs2(int x){
    chk2[x] = 1;
    can[x] = 1;
    for(auto&i:way2[x]){
        if(!chk2[i]){
            dfs2(i);
        }
    }
}
int main(){
    scanf("%lld %lld %lld", &N, &M, &P);
    for(LL i = 1; i <= M; ++i){
        LL a, b, c; scanf("%lld %lld %lld", &a, &b, &c);
        way[a].push_back(make_pair(b, c));
    }
    memset(d, -1, sizeof(d));
    memset(D, -1, sizeof(D));
    d[1] = 0;
    dfs2(N);
    LL ans = 0, ans2 = -(LL)1e18, when;
    for(LL i = 1; i <= M * 16; ++i){
        for(LL j = 1; j <= N; ++j){
            if(d[j] == -1) continue;
            for(auto&x:way[j]){
                D[x.first] = max(d[j] + x.second, D[x.first]);
            }
        }
        memset(D, -1, sizeof(D));
        if(i > M * 6){
            if(d[N] - P * i > ans2){
                puts("-1"); return 0;
            }
            for(int j = 1; j <= N; ++j){
                if(D[j] > d[j] && can[j]){
                puts("-1"); return 0;
                }
            }
        }
        for(LL j = 1; j <= N; ++j) d[j] = D[j];
        if(i <= M * 6){
            ans = max(ans, d[N] - P * i);
            ans2 = max(ans2, d[N] - P * i);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Compiler output:
a.cc: In function 'void dfs2(int)':
a.cc:14:17: error: no match for 'operator[]' (operand types are 'LL [2504]' {aka 'long long int [2504]'} and 'std::pair<long long int, long long int>')
   14 |         if(!chk2[i]){
      |                 ^
a.cc:15:18: error: cannot convert 'std::pair<long long int, long long int>' to 'int'
   15 |             dfs2(i);
      |                  ^
      |                  |
      |                  std::pair<long long int, long long int>
a.cc:10:15: note:   initializing argument 1 of 'void dfs2(int)'
   10 | void dfs2(int x){
      |           ~~~~^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

LL N, M, P;
LL d[2504], D[2504], chk2[2504], can[2504];
vector < pair < LL, LL > > way[2504];
void dfs2(int x){
    chk2[x] = 1;
    can[x] = 1;
    for(auto&i:way2[x]){
        if(!chk2[i]){
            dfs2(i);
        }
    }
}
int main(){
    scanf("%lld %lld %lld", &N, &M, &P);
    for(LL i = 1; i <= M; ++i){
        LL a, b, c; scanf("%lld %lld %lld", &a, &b, &c);
        way[a].push_back(make_pair(b, c));
    }
    memset(d, -1, sizeof(d));
    memset(D, -1, sizeof(D));
    d[1] = 0;
    dfs2(N);
    LL ans = 0, ans2 = -(LL)1e18, when;
    for(LL i = 1; i <= M * 16; ++i){
        for(LL j = 1; j <= N; ++j){
            if(d[j] == -1) continue;
            for(auto&x:way[j]){
                D[x.first] = max(d[j] + x.second, D[x.first]);
            }
        }
        memset(D, -1, sizeof(D));
        if(i > M * 6){
            if(d[N] - P * i > ans2){
                puts("-1"); return 0;
            }
            for(int j = 1; j <= N; ++j){
                if(D[j] > d[j] && can[j]){
                puts("-1"); return 0;
                }
            }
        }
        for(LL j = 1; j <= N; ++j) d[j] = D[j];
        if(i <= M * 6){
            ans = max(ans, d[N] - P * i);
            ans2 = max(ans2, d[N] - P * i);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Compiler output:
a.cc: In function 'void dfs2(int)':
a.cc:13:16: error: 'way2' was not declared in this scope; did you mean 'way'?
   13 |     for(auto&i:way2[x]){
      |                ^~~~
      |                way
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int from,to;
  ll cost;
}edge;
const int V_MAX = 2510,E_MAX = 5010;
int V,E;
ll P;
vector<edge>es(E_MAX);
vector<vector<int> >G(V_MAX);
vector<vector<int> >G2(V_MAX);
vector<bool> canmove(V_MAX,false);
vector<ll> d(V_MAX,MAX_I);

//ゴールまで行ける場所
int dfs(int g){
  if(canmove[g]) return 0;
  canmove[g] = true;
  for(const int & e : G[g]){
    dfs(e);
  }
  return 0;
}
int dfs(int g){
  if(canmove[g]) return 0;
  canmove[g] = true;
  for(const int & e : G2[g]){
    dfs(e);
  }
  return 0;
}

int bellmanford(int s){
  rep(i,V)d[i] = MAX_I;
  d[s] = 0;
  if(!canmove[s]) return 0;
  while(true){
    bool update = false;
    for(const edge &e : es){
      if(!canmove[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        update = true;
      }
    }
    if(!update)break;
  }
  return 1;
}

bool find_negative_loop(){
  rep(i,V)d[i] = 0;
  rep(i,V){
    for(const edge &e : es){
      if(!canmove[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        if(i==V-1)return true;
      }
    }
  }
  return false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E >> P;
  rep(i,E){
    int A,B;
    ll C;cin >> A >> B >> C;
    --A;--B;
    es.push_back({A,B,P-C});
    G[B].push_back(A);
    G2[A].push_back(B);
  }
  dfs(V-1);
  dfs(0);
  if(find_negative_loop()){
    cout << -1 << endl;
    return 0;
  }
  bellmanford(0);
  cout << max(0ll,-d[V-1]) << endl;
  return 0;
}


Compiler output:
a.cc:54:5: error: redefinition of 'int dfs(int)'
   54 | int dfs(int g){
      |     ^~~
a.cc:46:5: note: 'int dfs(int)' previously defined here
   46 | int dfs(int g){
      |     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int INF=0x3F3F3F3F;
int n,m,g[100010][100010],s,t,ans,hh;
int main(){
    memset(g,INF,sizeof(g));
    cin>>n>>m>>hh;
    for(int i=0;i<m;i++){
   // 	cout<<i<<" ";
        int a,b,c;
        cin>>a>>b>>c;
       // cout<<i<<endl;
        g[a][b]=0-c+hh;
     //   cout<<i<<endl;
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if (g[i][k]<INF&&g[k][j]<INF){
                    g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
                }
			}
		}
	}
    cin>>s>>t;
    ans=0-g[s][t];
    if (ans==INF){
		ans=-1;
	}
	if(ans<0){
		ans=0;
	}
    for(int i=1;i<=n;i++){
        if (g[i][i]<0&&g[s][i]<INF&&g[i][t]<INF){
            ans=-1;
		}
	}
    cout<<ans<<endl;
    return 0;
}

Compiler output:
/tmp/ccD4d4Kg.o: in function `main':
a.cc:(.text+0x5d): relocation truncated to fit: R_X86_64_PC32 against symbol `hh' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `hh' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x268): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x284): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x295): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x29b): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x2c4): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x2ca): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x2d7): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x2e1): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccD4d4Kg.o
a.cc:(.text+0x2eb): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int from,to;
  ll cost;
}edge;
const int V_MAX = 2510,E_MAX = 5010;
int V,E;
ll P;
vector<edge>es(E_MAX);
vector<vector<int> >G(V_MAX);
vector<vector<int> >G2(V_MAX);
vector<bool> canmove(V_MAX,false);
vector<ll> d(V_MAX,MAX_I);

//ゴールまで行ける場所
int dfs(int g){
  if(canmove[g]) return 0;
  canmove[g] = true;
  for(const int & e : G[g]){
    dfs(e);
  }
  return 0;
}
int dfs(int g){
  if(canmove[g]) return 0;
  canmove[g] = true;
  for(const int & e : G21[g]){
    dfs(e);
  }
  return 0;
}

int bellmanford(int s){
  rep(i,V)d[i] = MAX_I;
  d[s] = 0;
  if(!canmove[s]) return 0;
  while(true){
    bool update = false;
    for(const edge &e : es){
      if(!canmove[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        update = true;
      }
    }
    if(!update)break;
  }
  return 1;
}

bool find_negative_loop(){
  rep(i,V)d[i] = 0;
  rep(i,V){
    for(const edge &e : es){
      if(!canmove[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        if(i==V-1)return true;
      }
    }
  }
  return false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E >> P;
  rep(i,E){
    int A,B;
    ll C;cin >> A >> B >> C;
    --A;--B;
    es.push_back({A,B,P-C});
    G[B].push_back(A);
    G2[A].push_back(B);
  }
  dfs(V-1);
  dfs(0);
  if(find_negative_loop()){
    cout << -1 << endl;
    return 0;
  }
  bellmanford(0);
  cout << max(0ll,-d[V-1]) << endl;
  return 0;
}


Compiler output:
a.cc:54:5: error: redefinition of 'int dfs(int)'
   54 | int dfs(int g){
      |     ^~~
a.cc:46:5: note: 'int dfs(int)' previously defined here
   46 | int dfs(int g){
      |     ^~~
a.cc: In function 'int dfs(int)':
a.cc:57:23: error: 'G21' was not declared in this scope; did you mean 'G2'?
   57 |   for(const int & e : G21[g]){
      |                       ^~~
      |                       G2
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<vector<int> > map;
typedef vector<vector<P> > score_map;

int n,m,pp;

void calc(vector<ll> &scr_arr, score_map &mp) {
	for(int loop = 0; loop < n; loop++) {
		for(int now = 0; now < n; now++) {
			for(int i = 0; i < mp[now].size(); i++) {
				P p = mp[now][i];
				int next = p.first;
				ll score = p.second;
				scr_arr[next] = max(scr_arr[next],scr_arr[now]+score);
			}
		}
	}
}

int main() {
	cin>>n>>m>>pp;
	score_map mp(n);
	for(int i = 0; i < n; i++) {
		int a,b,c;
		cin>>a>>b>>c;
		a--;
		b--;
		P p(b,c-pp);
		mp[a].push_back(p);
	}
	vector<ll> scr_arr(n,-(1<<30));
	scr_arr[0] = 0;
	calc(scr_arr,mp);
	int ans = scr_arr[n-1];
	calc(scr_arr,mp);
	calc(scr_arr,mp);
	int tmp = scr_arr[n-1];
	if(ans>=0) {
		if(ans!=tmp) {
			cout << "-1" << endl;
		}else {
			cout << ans << endl;
		}
		return;
	}
	cout << 0 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   52 |                 return;
      |                 ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

vector<pair<Int, Int>> G[3000];

Int n, m, p;
Int a[5001], b[5001], c[5001];
Int d[3000];
Int dd[3000];

int main() {
    cin >> n >> m >> p;
    for (Int i = 1; i <= m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        G[a[i]].emplace_back(b[i], c[i]);
    }
    for (Int i = 1; i <= n; i++) d[i] = -INF;
    for (Int i = 1; i <= n; i++) dd[i] = INF;
    dd[1] = 0;
    queue<Int> q;
    q.push(1);
    while (!q.empty()) {
        Int p = q.front();
        q.pop();
        for (Int i = 0; i < (Int)G[p].size(); i++) {
            pair<Int, Int> to = G[p][i];
            if (dd[p] + 1 < dd[to.fi]) {
                dd[to.fi] = dd[p] + 1;
                q.push(to.fi);
            }
        }
    }
    d[1] = 0;
    //for (Int i = 1; i <= n; i++) cout << dd[i] << " "; cout << endl;
    for (Int i = 1; i <= m; i++) {
        if (dd[a[i]] == INF) continue;
        d[b[i]] = max(d[b[i]], d[a[i]] + c[i] - p * dd[b[i]]);
    }
    Int f = d[n];
    for (Int i = 1; i <= m * n; i++) {
        if (dd[a[i]] == INF) continue;
        d[b[i]] = max(d[b[i]], d[a[i]] + c[i] - (p * dd[b[i]]);
    }
    Int s = d[n];
    //cout << f << " " << s << endl;
    dump(f < s ? -1 : max((Int)0, f));
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:63: error: expected ')' before ';' token
   50 |         d[b[i]] = max(d[b[i]], d[a[i]] + c[i] - (p * dd[b[i]]);
      |                      ~                                        ^
      |                                                               )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll INF = 1e10;

int V, E;
struct egde{int from, to; ll cost;};
egde es[5001]; ll d[5001];

void longest_path(int s){
  rep(i, V+1) d[i] = -INF;
  d[s] = 0;
  int j = 0;
  while(true){
    bool update = false;
    bool g = false;
    rep(i,E){
      egde e = es[i];
      if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update = true;
        if(e.to == V) g = true;
      }
    }
    if(!update) break;
    if(j == 5*V)){
        if(g) d[V] = INF;
        break;
    }
    j++;
  }
}

int main(){
    ll p;
    cin >> V >> E >> p;
    rep(i,E){
        int a, b; ll c;
        cin >> a >> b >> c;
        es[i] = {a, b, c-p};
    }
    longest_path(1);
    ll x = 0;
    if(d[V] == INF) cout << "-1" <<  endl;
    else cout << max(x,d[V]) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void longest_path(int)':
a.cc:27:17: error: expected primary-expression before ')' token
   27 |     if(j == 5*V)){
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll INF = 1e10;

int V, E;
struct egde{int from, to; ll cost;};
egde es[5001]; ll d[5001];

void longest_path(int s){
  rep(i, V+1) d[i] = -INF;
  d[s] = 0;
  int j = 0;
  while(true){
    bool update = false;
    bool g = false;
    rep(i,E){
      egde e = es[i];
      if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update = true;
        if(e.to == V) g = true;
      }
    }
    if(!update) break;
    if(j == 5*V)){
        if(g) d[V] = INF;
        break;
    }
    j++;
  }
}

int main(){
    ll p;
    cin >> V >> E >> p;
    rep(i,E){
        int a, b; ll c;
        cin >> a >> b >> c;
        es[i] = {a, b, c-p};
    }
    longest_path(1);
    if(d[V] == INF) cout << "-1" <<  endl;
    ll x = 0;
    else cout << max(x,d[V]) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void longest_path(int)':
a.cc:27:17: error: expected primary-expression before ')' token
   27 |     if(j == 5*V)){
      |                 ^
a.cc: In function 'int main()':
a.cc:46:5: error: 'else' without a previous 'if'
   46 |     else cout << max(x,d[V]) << endl;
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const ll INF=1e18;


struct edge{int from, to; ll cost;};
int N,M,P;
vector<edge> es;
ll d[MAX];
 
void add_edge(int u, int v, ll cost){
	edge e = {u, v, cost};
	es.push_back(e);
}

//負閉路のないケース
void BF(int s){
	rep(i,N)d[i]=INF;//1-indexedならrep1に変更;
	d[s]=0;
	while(true){
		bool update=false;
		rep(i,M){
			edge e=es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update=true;
			}
		}
	if(!update) break;
	}
}

//負閉路もある場合
//始点s, 終点tの場合の最小、無限に小さくなるならtrue
bool BF_nloop(int s, int t){
	rep(i,N)d[i]=INF;//1-indexedならrep1に変更;
	d[s]=0;
	rep(i,N){
		rep(j,M){
			edge e=es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i == 2*N && e.to == t) return true;
			}
		}
	}
	return false;
}

void input(){
    cin>>N>>M>>P;
    rep(i,M){
        int A, B;
        ll C;
        cin>>A>>B>>C;
        A--;B--;
        add_edge(A, B, P-C);
    }
}


void solve(){
    bool ng=BF_nloop(0,N-1);
    if(ng)cout<<-1<<endl;
    else cout<<max((ll)0, -d[N-1])<<endl;
}

void output(){

}

int main(){
  input();
  solve();
  output();
}

Compiler output:
a.cc:24:9: error: 'int P' redeclared as different kind of entity
   24 | int N,M,P;
      |         ^
a.cc:17:24: note: previous declaration 'typedef struct std::pair<int, int> P'
   17 | typedef pair<int, int> P;
      |                        ^
a.cc: In function 'void input()':
a.cc:68:17: error: expected primary-expression before ';' token
   68 |     cin>>N>>M>>P;
      |                 ^
a.cc:74:25: error: expected primary-expression before '-' token
   74 |         add_edge(A, B, P-C);
      |                         ^
Language: C++

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

typedef long long ll;

const ll INF=1e12;
ll dp[1005][1005];


int main()
{
    int n,m;
    cin>>n>>m>>p;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++){
            if(i==j)continue;
            dp[i][j]=INF;
        }

    for(int i=0;i<m;i++){
       int a,b,cost;
       cin>>a>>b>>cost;
       dp[a-1][b-1]=-cost+p;

    }
    for(int k=0;k<n;k++)
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    if(dp[0][0]==0)cout<<-dp[0][n-1];
    else cout<<"-1";

}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: 'p' was not declared in this scope
   13 |     cin>>n>>m>>p;
      |                ^
Language: C++

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int nmax=5e3+3;
int usu[nmax],viz[nmax],da[nmax],n,p,m,a,b,cost;
vector <int> v[nmax],c[nmax];
void dfs(int nod,int ant)
{
    if(usu[nod]==n) da[nod]=1;
    for(int i=0;i<v[nod].size();++i)
    {
        int urm=v[nod][i];
        da[urm]=max(da[urm],da[nod]);
        if(viz[urm]==n) continue;
        if(usu[urm]<usu[nod]+c[nod][i]-p)
        {
            viz[urm]++;
            if(viz[urm]==n) da[urm]=1;
            usu[urm]=usu[nod]+c[nod][i]-p;
            dfs(urm,nod);
        }
    }
}
main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>p;
    for(int i=1;i<=m;++i)
    {
        cin>>a>>b>>cost;
        v[a].push_back(b);
        c[a].push_back(cost);
    }
    dfs(1,0);
    if(da[n])
    {
        cout<<-1;
        exit(0);
    }
    cout<<max(0,usu[n]);
}


Compiler output:
a.cc:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   24 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:40:14: error: no matching function for call to 'max(int, long long int&)'
   40 |     cout<<max(0,usu[n]);
      |           ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:40:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   40 |     cout<<max(0,usu[n]);
      |           ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:40:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |     cout<<max(0,usu[n]);
      |           ~~~^~~~~~~~~~
Language: C++

#include <cstdio>
#include <iostream>

using namespace std;

typedef long long int64;

int n, m, p, now;
int64 ans;
int64 f[5555], t[5555], v[5555], d[2][5555];

void go() {
  auto &d_now = d[now % 2];
  auto &d_next = d[(now + 1) % 2];
  int64 tmp = d_now[n] - p * now;
  if (tmp > ans) {
    ans = tmp;
  }
  for (int i = 0; i <= n; i++) d_next[i] = -1E18;
  for (int i = 0; i < m; i++) {
    int64 ff = f[i], tt = t[i], vv = v[i];
    if (d_now[ff] + vv > d_next[tt]) {
      d_next[tt] = d_now[ff] + vv;
    }
  }
}

int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 0; i < m; i++) {
    int ff, tt, vv;
    scanf("%d%d%d", &ff, &tt, &vv);
    f[i] = ff;
    t[i] = tt;
    v[i] = vv;
  }
  for (int i = 0; i <= n; i++) {
    d[0][i] = d[1][i] = -1E18;
  }
  d[0][1] = 0;
  for (int i = 0; i < n * 5 + 10; i++) {
    go();
    now += 1;1
  }

  int64 maybe_ans = ans;
  if (maybe_ans <= 0) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < n * 5 + 10; i++) {
    go();
    now += 1;
  }

  if (ans > maybe_ans) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:15: error: expected ';' before '}' token
   43 |     now += 1;1
      |               ^
      |               ;
   44 |   }
      |   ~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

int n,m;
int p;
vector<pair<int,ll>> nei[2505];

bool instack[2505];
ll dis[2505];

void spfa(int a){
    instack[a]=true;//节点入栈
    for(pii to:nei[a]){
    	if(dis[a]+to.second<dis[to.first]){
    		dis[to.first]=dis[a]+to.second;
    		if(!instack[to.first]){
    			spfa(to.first);
			}else{
				cout<<-1;
				exit(0);
			}
		}
	}
        
    instack[a]=false;//将当前结点退栈
}

int main(int argc,char* argv[]){
	qi;
	cin>>n>>m>>p;
	for(int i=0;i<n;i++){
		int a,b;
		ll c;
		cin>>a>>b>>c;
		c-=p;
		a--;b--;
		nei[a].push_back(make_pair(b,-c));
//		nei[b].push_back(make_pair(a,-c));
	}
	
	fill(dis,dis+n,-inf);
	dis[0]=0;
	
	spfa(0);
	cout<<max(-dis[n-1],0ll);
	return 0;
}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:76:25: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   76 |         fill(dis,dis+n,-inf);
      |                         ^~~
      |                         ynf
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
ll n,m,p;
ll f[2600];
vector<int> v[2600],v2[2600];int o;
bool ok[2600][2600];bool bo=0;
int st(int cr,ll sum)
{
    if(f[cr]>=sum)
    {
        return;
    }
    f[cr]=sum;

    if(cr==o&&sum>=1&&ok[cr][n]&&ok[1][cr])
    {
        bo=1;
        return 0;
    }
    if(cr==o&&!ok[1][cr]||!ok[cr][n])
        return;
    if(!ok[cr][o])
        return;
    if(!ok[cr][n])
        return;
    for(int i=0;i<v[cr].size();i++)
    {
        st(v[cr][i],sum+v2[cr][i]-p);
    }
    return 0;
}
int go(int cr,int rot)
{
    if(ok[rot][cr]==1)
        return 0;
    ok[rot][cr]=1;
    for(int i=0;i<v[cr].size();i++)
    {
        go(v[cr][i],rot);
    }
    return 0;
}
int gop(int cr,ll sum)
{
    if(!ok[cr][n])
        return 0;
    if(f[cr]>=sum)
        return 0;
    f[cr]=sum;
    for(int i=0;i<v[cr].size();i++){
        gop(v[cr][i],sum+v2[cr][i]-p);
    }
    return 0;

}
int main() {
    cin>>n>>m>>p;
    for(int i=0;i<m;i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        v[a].pb(b);
        v2[a].pb(c);
    }
    for(int i=1;i<=n;i++)
    {
        go(i,i);
    }
    for(int i=1;i<=n;i++)
    {   for(int j=1;j<=n;j++)
            f[i]=-1e15;
            o=i;
        st(i,0);
        if(bo)
        {
            cout<<-1;
            return 0;
        }
    }
    for(int i=1;i<=n;i++)
        f[i]=-1e15;
    gop(1,0);
    cout<<max(f[n],0LL);
    return 0;
    }


Compiler output:
a.cc: In function 'int st(int, ll)':
a.cc:16:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   16 |         return;
      |         ^~~~~~
a.cc:26:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   26 |         return;
      |         ^~~~~~
a.cc:28:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   28 |         return;
      |         ^~~~~~
a.cc:30:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   30 |         return;
      |         ^~~~~~
Language: C++

#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
#include<boost/scope_exit.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

typedef std::vector<std::map<index_t, std::int64_t>> edge_t;

template<class Value, class Compare>auto bellman_ford(std::vector<std::map<index_t, Value>>const& edge, Compare compare)
->boost::optional<std::vector<boost::optional<Value>>>
{
	auto N = edge.size();
	std::vector<boost::optional<Value>> result(N);
	result[0] = 0;
	for (auto c : boost::irange<index_t>(1, N))
	{
		for (auto i : boost::irange<index_t>(0, N))
		{
			for (auto&& e : edge[i])
			{
				auto j = e.first;
				auto v = e.second;
				if (!result[j] || compare(*result[i] + v, *result[j]))
				{
					result[j] = *result[i] + v;
				}
			}
		}
	}
	lib::print::debug(result);
	for (auto i : boost::irange<index_t>(0, N))
	{
		for (auto&& e : edge[i])
		{
			auto j = e.first;
			auto v = e.second;
			if (result[i] && result[j] && compare(*result[i] + v, *result[j]))
			{
				return boost::none;
			}
		}
	}
	return result;
}

bool edge_cut(index_t i, index_t goal, edge_t const& edge,edge_t& target, boost::dynamic_bitset<>& flag)
{
	if (flag[i])
	{
		return false;
	}
	if (i == goal)
	{
		return true;
	}
	flag[i] = true;
	std::vector<index_t> inserter;
	for (auto&& e : edge[i])
	{
		if (edge_cut(e.first, goal, edge,target, flag))
		{
			inserter.emplace_back(e.first);
		}
	}
	for (auto&& j : inserter)
	{
		target[i][j] = edge.at(i).at(j);
	}
	flag[i] = false;
	return edge[i].size();
}

void Main()
{
	int N, M;
	std::int64_t P;
	std::cin >> N >> M >> P;
	edge_t edge(N);
	edge_t target(N);
	for (auto i : boost::irange(0, M))
	{
		int A, B;
		std::int64_t C;
		std::cin >> A >> B >> C;
		--A;
		--B;
		if (edge[A].count(B))
		{
			edge[A][B] = std::max(edge[A][B], C - P);
		}
		else
		{
			edge[A].emplace(B, C - P);
		}
	}
	boost::dynamic_bitset<> flag(N);
	edge_cut(0, N - 1, edge, target, flag);
	auto result = bellman_ford(target, std::greater<>());
	if (result)
	{
		std::cout << std::max(std::int64_t(), *(result->at(N - 1))) << std::endl;
	}
	else
	{
		std::cout << -1 << std::endl;
	}
	for (auto i : boost::irange(0, N))
	{
		for (auto&& e : edge[i])
		{
			lib::print::debug(i + 1, e.first + 1, e.second);
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Compiler output:
a.cc:2:9: fatal error: boost/multi_array.hpp: No such file or directory
    2 | #include<boost/multi_array.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++


#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
//#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;



template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  bool b[110000]={};
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
      b[e.to]|=b[e.src];
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]){
      b[e.to]=true;
      continue;
    }
  }
  if(b[V-1]) return vi();
  return dist;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,m,p;
  cin>>n>>m>>p;
  b=vector<bool>(n,false);

  WG<int> es(n);
  Edges<int> et;

  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--,c-=p;
    es[a].PB(edge<int>(b,-c));
    et.PB(edge<int>(a,b,-c));
  }


  vi ans=bellman_ford(et,n,0);

  if(ans.empty()){
    cout<<-1<<endl;
  }else{
    cout<<max(0LL,-ans[n-1])<<endl;
  }




}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:3: error: 'b' was not declared in this scope
   87 |   b=vector<bool>(n,false);
      |   ^
Language: C++

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2500;

int N, M, P;
vector<pii> adj[MAXN+10];
ll dist[MAXN+10], ans;

int main()
{
    int i, j;

    scanf("%d%d%d", &N, &M, &P);
    for(i=1; i<=M; i++)
    {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c); c-=P;
        adj[a].push_back({b, c});
    }

    for(i=1; i<=N; i++) dist[i]=-987654321;
    dist[1]=0;
    for(i=1; i<=N; i++)
    {
        for(int now=1; now<=N; now++)
        {
            for(pii nxt : adj[now])
            {
                if(dist[now]+nxt.second>dist[nxt.first])
                {
                    dist[nxt.first]=dist[now]+nxt.second;
                }
            }
        }
        if(i==N-1) ans=dist[N];
    }
    if(ans!=dist[N]) printf("-1");
    else printf("%lld", max(0, dist[N]));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:28: error: no matching function for call to 'max(int, ll&)'
   43 |     else printf("%lld", max(0, dist[N]));
      |                         ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:43:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   43 |     else printf("%lld", max(0, dist[N]));
      |                         ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:43:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   43 |     else printf("%lld", max(0, dist[N]));
      |                         ~~~^~~~~~~~~~~~