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

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e18+1

using ll = long long;
const ll mod = LLONG_MAX;


struct edge{
  int from,to,cost;
};

edge es[2010];
int d[1010];//最短距離　入力を負にしてヒックリカセス
int V,E;
void shrtest_path(int s){
  rep(i,V)d[i]=INF;

  d[s]=0;
  rep(cnt,V+1){
    bool update=false;
    rep(i,E){
      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(cnt>=V){

          cout<<"inf"<<endl;
          return ;
          goto E;

        }
      }


    }
    if(!update)break;
  }
}

bool find(){
  rep(i,V)d[i]=0;
  rep(i,V){
    rep(j,E){
      edge e = es[j];
      if(d[e.to]>d[e.from]+e.cost){
        d[e.to] = d[e.from] +e.cost;

        if(i==V-1)return true;
      }
    }
  }
  return false;
}

signed main(){
  cin>>V>>E;
  rep(i,E){
    int a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    a--;b--;
    es[i].from=a;
    es[i].to=b;
    //入力　負
    es[i].cost=-c;
  }

  if(find()){
    cout<<"inf"<<endl;
  }else{
    shrtest_path(0);
    cout<<-d[V-1]<<endl;
  }
  E:
  return 0;



}


Compiler output:
a.cc: In function 'void shrtest_path(long long int)':
a.cc:35:16: error: label 'E' used but not defined
   35 |           goto E;
      |                ^
Language: C++

#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
struct P{
	ll from,to,cost;	
};
vector<P>e;
ll a[10001];
const ll inf=-999999999999999999;
bool b[1001];
signed main(){
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		e.push_back(P{a,b,c});
	}
	for(ll i=0;i<=n;i++){
		a[i]=inf;
		b[i]=false;
	}
	a[1]=0;
	ll sum=0;
	for(ll j=0;j<n;j++){
		bool up=false;
		for(ll i=0;i<m;i++){
			P t=e[i];
			if(a[t.from]!=inf&&a[t.to]<a[t.from]+t.cost){
				a[t.to]=a[t.from]+t.cost;
				up=true;
			}
		}
		if(!up) break;
	}
}
	for(ll j=0;j<n;j++){
		for(ll i=0;i<m;i++){
			P t=e[i];
			if(a[t.from]!=inf&&a[t.to]<a[t.from]+t.cost){
				a[t.to]=a[t.from]+t.cost;
				b[t.to]=true;
			}
		}
	}
	if(!b[n]){
		cout<<a[n]<<endl;
	}
	else{
		cout<<"inf"<<endl;
	}
}

Compiler output:
a.cc:38:9: error: expected unqualified-id before 'for'
   38 |         for(ll j=0;j<n;j++){
      |         ^~~
a.cc:38:20: error: 'j' does not name a type
   38 |         for(ll j=0;j<n;j++){
      |                    ^
a.cc:38:24: error: 'j' does not name a type
   38 |         for(ll j=0;j<n;j++){
      |                        ^
a.cc:47:9: error: expected unqualified-id before 'if'
   47 |         if(!b[n]){
      |         ^~
a.cc:50:9: error: expected unqualified-id before 'else'
   50 |         else{
      |         ^~~~
a.cc:53:1: error: expected declaration before '}' token
   53 | }
      | ^
Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <functional>
#define rep(i, a, b) for(int i=a;i<b;++i)
#define MOD 1000000007
#define RAND 1000
#define LLONG_MIN -9223372036854775808
using namespace std;
 
int a[100000], b[100000], n, m;
long long int c[100000];
 
long long int maxy = LLONG_MIN;
 
void g(int start, int i, long long int score)
{
	//cout << score << endl;
	if (start == n) {
		if (score > maxy)
			maxy = score;
		return;
	}
	for (int j = i; j < m; ++j)
		if (a[j] == start) {
			score += c[j];
			g(b[j], j, score);
			score = 0;
		}
}
 
int main(void)
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i] >> c[i];
	}
 
	g(1, 0, 0);
        if(maxy >= 100000000000000)
               cout<<''inf''<<endl;
        else 
	       cout << maxy << endl;
 
	//system("pause");
	return 0;
}

Compiler output:
a.cc:21:22: warning: integer constant is so large that it is unsigned
   21 | long long int maxy = LLONG_MIN;
      |                      ^~~~~~~~~
a.cc:48:22: error: empty character constant
   48 |                cout<<''inf''<<endl;
      |                      ^~~~~
a.cc:48:27: error: empty character constant
   48 |                cout<<''inf''<<endl;
      |                           ^~
a.cc: In function 'int main()':
a.cc:48:22: error: unable to find character literal operator 'operator""inf' with 'char' argument
   48 |                cout<<''inf''<<endl;
      |                      ^~~~~
Language: C++

#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define INF 1000000005
#define _INF -9000000000000000000
//#define _INF -1000000005

struct St {
	int cur;
	vector<bool> flag;
	ll cost;
	St(int _cur, vector<bool> _flag, ll _cost) {
		cur = _cur;
		flag = _flag;
		cost = _cost;
	}
};

int cost[1001][1001];
int main()
{
	int N, M;
	cin >> N >> M;

	REP(i, 0, N) REP(j, 0, N) cost[i][j] = INF;
	REP(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		cost[--a][--b] = c;
	}

	vector<bool> flag(N, false);
	St state(0, flag, 0);

	ll ans = _INF;
	queue<St> q;
	q.push(state);
	while (!q.empty()) {
		St now = q.front();
		q.pop();

		REP(i, 0, N) {
			if (cost[now.cur][i] != INF) {
				cout << now.cost << endl;
				if (now.flag[i] == true) {
					cout << "inf" << endl;
					return 0;
				}
				else if (i == N - 1) {
					ans = max(ans, now.cost + cost[now.cur][i]);
					//continue;
				}

				now.flag[now.cur] = true;
				St next(i, now.flag, now.cost + cost[now.cur][i]);
				q.push(next);
			}
		}
	}

	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

n, m = map(int, input().split())
dist = [-10**18] * n
edge = []
for i in range(m):
    a, b, c = map(int, input().split())
    edge.append((a - 1, b - 1, c))
dist[0] = 0
for i in range(n):
    for i in edge:
        a, b, c = i
        if dist[a] + c > dist[b]:
            dist[b] = dist[a] + c
            updated = True
ans = dist[n - 1]
for i in range(n):
    for i in edge:
        a, b, c = i
        if dist[a] + c > dist[b]:
            dist[b] = dist[a] + c
            updated = True
if ans == dist[n - 1]:
    print(dist[n - 1])
else:
    print("inf")


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, m = map(int, input().split())
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e18+1

using ll = long long;
const ll mod = LLONG_MAX;


struct edge{
  int from,to,cost;
};

edge es[2010];
int d[1010];//最短距離　入力を負にしてヒックリカセス
int V,E;

void shrtest_path(int s){
  rep(i,V)d[i]=INF;

  d[s]=0;
  rep(xs,100000){
    bool update=false;
    rep(i,E){
      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;
        if(e.to==V-1 && xs>V){
          cout<<"inf"<<endl;

        }
        update=true;
      }

    }
    if(!update)break;
  }
}


signed main(){
  cin>>V>>E;
  rep(i,E){
    int a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    a--;b--;
    es[i].from=a;
    es[i].to=b;
    //入力　負
    es[i].cost=-c;
  }

  if(find()){
   cout<<"inf"<<endl;
  }else{
    shrtest_path(0);
    cout<<-d[V-1]<<endl;
  }
  return 0;



}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:10: error: no matching function for call to 'find()'
   55 |   if(find()){
      |      ~~~~^~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 0 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 0 provided
In file included from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 0 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'

const ll inf = (ll)1e15;

int N, M;
int a[1005], b[1005];
ll c[1005], G[1005][1005];

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

  cin >> N >> M;
  rep(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }

  rep(i, N) rep(j, N) G[i][j] = i == j ? 0:-inf;
  rep(i, N) G[a[i]][b[i]] = c[i];

  rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);

  ll val = G[0][N - 1]
  rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);

  if (val == G[0][N - 1])
    cout << G[0][N - 1] << endl;
  else
    cout << "inf" << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:22: error: expected ',' or ';' before 'for'
    6 | #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
      |                      ^~~
a.cc:7:19: note: in expansion of macro 'REP'
    7 | #define rep(i, a) REP(i, 0, a)
      |                   ^~~
a.cc:37:3: note: in expansion of macro 'rep'
   37 |   rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);
      |   ^~~
a.cc:37:7: error: 'k' was not declared in this scope
   37 |   rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);
      |       ^
a.cc:6:45: note: in definition of macro 'REP'
    6 | #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
      |                                             ^
a.cc:37:3: note: in expansion of macro 'rep'
   37 |   rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);
      |   ^~~
a.cc:37:17: error: 'i' was not declared in this scope
   37 |   rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);
      |                 ^
a.cc:6:45: note: in definition of macro 'REP'
    6 | #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
      |                                             ^
a.cc:37:13: note: in expansion of macro 'rep'
   37 |   rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);
      |             ^~~
a.cc:37:27: error: 'j' was not declared in this scope; did you mean 'jn'?
   37 |   rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);
      |                           ^
a.cc:6:45: note: in definition of macro 'REP'
    6 | #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
      |                                             ^
a.cc:37:23: note: in expansion of macro 'rep'
   37 |   rep(k, N) rep(i, N) rep(j, N) G[i][j] = max(G[i][j], G[i][k] + G[k][j]);
      |                       ^~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

struct edge { int from, to, cost; };

int main() {
    
    int N, M;
    
    long long d[1001];
    bool done[1001];
    
    cin >> N;
    cin >> M;
    
    edge es[2000];
    
    for ( int i = 0; i < M; i++ ) {
        
        int a,b;
        long long c;
        
        cin >> a;
        cin >> b;
        cin >> c;
        
        es[i].from = a;
        es[i].to = b;
        es[i].cost = c;
        
    }
    
    for ( int i = 0; i <= N; i++ ) {
        d[i] = LLONG_MIN;
        done[i] = false;
    }
    
    d[1] = 0;
    
    for ( int i = 0; i < N; i++ ) {
        
        for ( int j = 0; j < M; j++ ) {
            edge e = es[j];
            
            if ( done[from] || e.from == 1 ) {
                
            if ( !done[e.to] ) {
                done[e.to] = true;
                d[e.to] = d[e.from] + e.cost;
                
                
            }
            else if ( d[e.to] < d[e.from] + e.cost ) {
                
                d[e.to] = d[e.from] + e.cost;
                
                
                if (  i == N-1 ) {
                    cout << "inf" << endl;
                    return 0;
                }
                
            }
            }
            
            
        }
    }
    
    cout << d[N] << endl;
    
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:23: error: 'from' was not declared in this scope; did you mean 'fromfp'?
   53 |             if ( done[from] || e.from == 1 ) {
      |                       ^~~~
      |                       fromfp
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

struct edge { int from, to, cost; };

int main() {
    
    int N, M;
    
    long long d[1001];
    bool done[1001];
    
    cin >> N;
    cin >> M;
    
    edge es[2000];
    
    for ( int i = 0; i < M; i++ ) {
        
        int a,b;
        long long c;
        
        cin >> a;
        cin >> b;
        cin >> c;
        
        es[i].from = a;
        es[i].to = b;
        es[i].cost = c;
        
    }
    
    for ( int i = 0; i <= N; i++ ) {
        d[i] = LLONG_MIN;
        done[i] = false;
    }
    
    d[1] = 0;
    
    for ( int i = 0; i < N; i++ ) {
        
        for ( int j = 0; j < M; j++ ) {
            edge e = es[j];
            
            if ( done[from] || e.forom == 1 ) {
                
            if ( !done[e.to] ) {
                done[e.to] = true;
                d[e.to] = d[e.from] + e.cost;
                
                
            }
            else if ( d[e.to] < d[e.from] + e.cost ) {
                
                d[e.to] = d[e.from] + e.cost;
                
                
                if (  i == N-1 ) {
                    cout << "inf" << endl;
                    return 0;
                }
                
            }
            }
            
            
        }
    }
    
    cout << d[N] << endl;
    
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:23: error: 'from' was not declared in this scope; did you mean 'fromfp'?
   53 |             if ( done[from] || e.forom == 1 ) {
      |                       ^~~~
      |                       fromfp
a.cc:53:34: error: 'struct edge' has no member named 'forom'; did you mean 'from'?
   53 |             if ( done[from] || e.forom == 1 ) {
      |                                  ^~~~~
      |                                  from
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
long long maxs[1010];
vector<pair<int,long long> > v[1010];

bool vis[1010],infs;

void DFS(int x,long long pnt){
	if(pnt>2000000000000)return;
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
long long maxs[1010];
vector<pair<int,long long> > v[1010];

bool vis[1010],infs;

void DFS(int x,long long pnt){
	vis[x]=true;
	for(int i=0;i<v[x].size();i++){
		int f=v[x][i].first;
		long long g=v[x][i].second;
		if(maxs[f]<pnt+g){
			
				maxs[f]=pnt+g;
				DFS(f,maxs[f]);
			
		}
	}
	vis[x]=false;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		vis[i]=false;
		maxs[i]=-2000000000000;
		v[i].clear();
	}
	for(int i=0;i<m;i++){
		int a,b;
		long long c;
		cin>>a>>b>>c;a--,b--;
		v[a].push_back(make_pair(b,c));
	}
	infs=false;
	DFS(0,0);
	if(maxs[n-1]>2000000000000)cout<<"inf"<<endl;
	else cout<<maxs[n-1]<<endl;
	getchar();
	getchar();
	return 0;
}
	vis[x]=true;
	for(int i=0;i<v[x].size();i++){
		int f=v[x][i].first;
		long long g=v[x][i].second;
		if(maxs[f]<pnt+g){
			
				maxs[f]=pnt+g;
				DFS(f,maxs[f]);
			
		}
	}
	vis[x]=false;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		vis[i]=false;
		maxs[i]=-2000000000000;
		v[i].clear();
	}
	for(int i=0;i<m;i++){
		int a,b;
		long long c;
		cin>>a>>b>>c;a--,b--;
		v[a].push_back(make_pair(b,c));
	}
	infs=false;
	DFS(0,0);
	if(maxs[n-1]>2000000000000)cout<<"inf"<<endl;
	else cout<<maxs[n-1]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void DFS(int, long long int)':
a.cc:22:30: error: a function-definition is not allowed here before '{' token
   22 | void DFS(int x,long long pnt){
      |                              ^
a.cc:36:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   36 | int main(){
      |         ^~
a.cc:36:9: note: remove parentheses to default-initialize a variable
   36 | int main(){
      |         ^~
      |         --
a.cc:36:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:36:11: error: a function-definition is not allowed here before '{' token
   36 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
long long maxs[1010];
vector<pair<int,long long> > v[1010];

bool vis[1010],infs;

void DFS(int x,long long pnt){
	if(pnt>2000000000000)return;
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
long long maxs[1010];
vector<pair<int,long long> > v[1010];

bool vis[1010],infs;

void DFS(int x,long long pnt){
	vis[x]=true;
	for(int i=0;i<v[x].size();i++){
		int f=v[x][i].first;
		long long g=v[x][i].second;
		if(maxs[f]<pnt+g){
			
				maxs[f]=pnt+g;
				DFS(f,maxs[f]);
			
		}
	}
	vis[x]=false;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		vis[i]=false;
		maxs[i]=-2000000000000;
		v[i].clear();
	}
	for(int i=0;i<m;i++){
		int a,b;
		long long c;
		cin>>a>>b>>c;a--,b--;
		v[a].push_back(make_pair(b,c));
	}
	infs=false;
	DFS(0,0);
	if(maxs[n-1]>2000000000000)cout<<"inf"<<endl;
	else cout<<maxs[n-1]<<endl;
	getchar();
	getchar();
	return 0;
}
	vis[x]=true;
	for(int i=0;i<v[x].size();i++){
		int f=v[x][i].first;
		long long g=v[x][i].second;
		if(maxs[f]<pnt+g){
			
				maxs[f]=pnt+g;
				DFS(f,maxs[f]);
			
		}
	}
	vis[x]=false;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		vis[i]=false;
		maxs[i]=-2000000000000;
		v[i].clear();
	}
	for(int i=0;i<m;i++){
		int a,b;
		long long c;
		cin>>a>>b>>c;a--,b--;
		v[a].push_back(make_pair(b,c));
	}
	infs=false;
	DFS(0,0);
	if(maxs[n-1]>2000000000000)cout<<"inf"<<endl;
	else cout<<maxs[n-1]<<endl;
	getchar();
	getchar();
	return 0;
}

Compiler output:
a.cc: In function 'void DFS(int, long long int)':
a.cc:22:30: error: a function-definition is not allowed here before '{' token
   22 | void DFS(int x,long long pnt){
      |                              ^
a.cc:36:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   36 | int main(){
      |         ^~
a.cc:36:9: note: remove parentheses to default-initialize a variable
   36 | int main(){
      |         ^~
      |         --
a.cc:36:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:36:11: error: a function-definition is not allowed here before '{' token
   36 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;
const int N_MAX = 1050;
// minus infinity
const long MINF = -int(1e9)-50;

int N,M;
long A[N_MAX][N_MAX] = {};

// i: 今居る頂点
// s: iまでのスコア・コスト
long dfs(int i, long s)
{
  if (i == N-1) return s;
  /*
  A[i]
    ;
  REP(0,j,N) {
    if (A[i])
      */
  //
  // 最高スコア
  long m = MINF;
  // どこも辿れる所がないかもしれない
  REP(0,j,N) {
    // 0 だと辿れない。探索打ち切り
    if (A[i][j] != 0) {
      int x = dfs(j, s + A[i][j]);
      // update max
      if (x > m) m = x;
    }
  }
  return m;
}

int main()
{
  cin >> N >> M;

  REP(i,0,M) {
    int a,b;
    long c;
    cin >> a >> b >> c;
    --a; --b;
    // 有向グラフ
    A[i][j] = c;
  }

  long res = dfs(0,0);
  cout << res << endl;


  return 0;
}


Compiler output:
a.cc: In function 'long int dfs(int, long int)':
a.cc:27:9: error: 'j' was not declared in this scope
   27 |   REP(0,j,N) {
      |         ^
a.cc:3:32: note: in definition of macro 'REP'
    3 | #define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
      |                                ^
a.cc:27:7: error: lvalue required as increment operand
   27 |   REP(0,j,N) {
      |       ^
a.cc:3:46: note: in definition of macro 'REP'
    3 | #define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
      |                                              ^
a.cc: In function 'int main()':
a.cc:48:10: error: 'j' was not declared in this scope
   48 |     A[i][j] = c;
      |          ^
Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <functional>
#define rep(i, a, b) for(int i=a;i<b;++i)
#define MOD 1000000007
#define RAND 1000
using namespace std;

int a[100000], b[100000], n, m;
long long int c[100000];

long long int maxy = LLONG_MIN;

void g(int start, int i, long long int score)
{
	//cout << score << endl;
	if (start == n) {
		if (score > maxy)
			maxy = score;
		return;
	}
	for (int j = i; j < m; ++j)
		if (a[j] == start) {
			score += c[j];
			g(b[j], j, score);
			score = 0;
		}
}

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

	g(1, 0, 0);

	cout << maxy << endl;

	//system("pause");
	return 0;
}

Compiler output:
a.cc:20:22: error: 'LLONG_MIN' was not declared in this scope
   20 | long long int maxy = LLONG_MIN;
      |                      ^~~~~~~~~
a.cc:12:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <functional>
  +++ |+#include <climits>
   12 | #define rep(i, a, b) for(int i=a;i<b;++i)
Language: C++

#include <iostream>
#include <vector>
using namespace std;

// 隣接リストで使う辺を表す型
struct Edge {
  long long to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(long long to, long long cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge

const long long INF = 2147483646000000;

vector<long long> dist; // 最短距離

// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(long long n, long long s) { // nは頂点数、sは開始頂点
  dist = vector<long long>(n, INF);
  dist[s] = 0; // 開始点の距離は0
  for (long long i = 0; i < n; i++) {
    for (long long v = 0; v < n; v++) {
      for (long long k = 0; k < graph[v].size(); k++) {
        Edge e = graph[v][k];
        if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (i == n - 1) return true; // n回目にも更新があるなら負の閉路が存在
          cout << e.cost << endl;
        }
      }
    }
  }
  return false;
}

int main() {
  long long n, m;
  cin >> n >> m;

  graph = AdjList(n);

  for (long long i = 0; i < m; i++) {
    long long from, to, cost;
    cin >> from >> to >> cost;
    graph[from-1].push_back(Edge(to-1, -cost));
  }

  bool tf = bellman_ford(n, 0);
  if (tf) {
    cout << "inf" << endl;
  }else{
    -dist[n-1] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:16: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator<<'
   54 |     -dist[n-1] << endl;
      |     ~~~~~~~~~~~^~~~~~~
Language: C++

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

const int N = 3010, inf = 1e17;
int n, m, a, b, c, u, v, w, flag = 0, cnt;
vector <int> top;
vector < pair <int, int> > g[N];
int was[N], dp[N];

void dfs(int v) {
    if (was[v]) return;
    was[v] = 1;
    for (auto i : g[v])
        dfs(i.first);
    top.push_back(v);
}

main() {
cin >> n >> m;
for (int i = 0; i < m; ++i) {
    cin >> a >> b >> c;
    g[b].push_back({a, c});
}
g[1].push_back({0, 0});
g[n + 1].push_back({n, 0});

for (int i = 0; i < n + 2; ++i) dfs(i);
fill(dp, dp + n + 3, -inf);
dp[0] = 0;
for (auto v : top) {
        //cerr << v << ' ';
    for (auto i : g[v]) {
        u = i.first;
        w = i.second;
        dp[v] = max(dp[v], dp[u] + w);
    }
}
for (int j = 0; j < 10500; ++j) {
    flag = 0;
    for (auto v : top) {
        for (auto i : g[v]) {
            u = i.first, w = i.second;
            if (dp[u] + w > dp[v])
                flag = 1;
            dp[v] = max(dp[v], dp[u] + w);
        }
    }
    reverse(top.begin(), top.end());
    if (flag == 0) cnt++;
    else cnt = 0
        if (cnt > 100) break;
}
if (flag) cout << "inf\n";
else cout << dp[n + 1] << '\n';
    return 0;
}


Compiler output:
a.cc:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:51:17: error: expected ';' before 'if'
   51 |     else cnt = 0
      |                 ^
      |                 ;
   52 |         if (cnt > 100) break;
      |         ~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <memory>

using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;

struct edge{ll from,to,cost;};

edge es[1001],m_es[1001];
#define MAX_V 1001
ll d[MAX_V];
ll V,E;
#define INF 1930000000000000
#define MINF -1930000000000000
void longest_path(int s){
    rep(i,V){
        d[i] = MINF;
        //d[i] = 0;
    }
    d[s] = 0;
    while(true){
        bool update = false;
        rep(i,E){
            edge e = es[i];
            cout << d[e.to] << "|" << d[e.from] + e.cost << endl;
            if(d[e.to] < d[e.from] + e.cost){//今考えている辺を経由した方が点数は高いか？
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
    }
}
//d[目的地]を出力
bool find_negative(){
    memset(d,0,sizeof(d));
    rep(i,V){
        rep(j,E){
            edge e = m_es[j];
            if(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(){
    cin >> V >> E;
    ll a,b,c;
    rep(i,E){//辺は0オリジン
        cin >> a >> b >> c;
        es[i].from = a;
        es[i].to = b;
        es[i].cost = c;
    
        m_es[i].from = a;
        m_es[i].to = b;
        m_es[i].cost = -1*c;
    }

    
    if(find_negative()==true){
        cout << "inf" << endl;
        return 0;
    }
    
    longest_path(1);
    cout << d[V] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'bool find_negative()':
a.cc:40:5: error: 'memset' was not declared in this scope
   40 |     memset(d,0,sizeof(d));
      |     ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <memory>
  +++ |+#include <cstring>
    5 |
Language: C++

#include <iostream>
#include <vector>
using namespace std;

// 隣接リストで使う辺を表す型
struct Edge {
  long long int to, cost;  // 辺の接続先頂点, 辺の重み
  Edge(long long int to, long long int cost) : to(to), cost(cost) {}  // コンストラクタ
};

typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;  // グラフの辺を格納した構造体
                // graph[v][i]は頂点vから出るi番目の辺Edge

const long long int INF = 1000000000000000000;

vector<long long int> dist; // 最短距離

// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(long long int n, long long int s) { // nは頂点数、sは開始頂点
  dist = vector<long long int>(n, INF);
  dist[s] = 0; // 開始点の距離は0
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        Edge e = graph[v][k];
        if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          if (i == n - 1) return true; // n回目にも更新があるなら負の閉路が存在
        }
      }
    }
  }
  return false;
}

int main() {
  long long int n, m;
  cin >> n >> m;

  graph = AdjList(n);
  
  for (int i = 0; i < m; i++) {
    long long int from, to, cost;
    cin >> from >> to >> cost;
    graph[from-1].push_back(Edge(to-1, -cost));
  }
  
  bellman_ford(n, 0);
  long long int ans=INF;
  
  for (int i = 1; i < n; i++) {
    if (dist[i] != INF)
    {if(ans>-dist[i])ans=-dist[i];
      //cout << "0から" << i << "へのコスト: " << -dist[i] << endl;}
  }
  cout << ""  << "" << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:2: error: expected '}' at end of input
   59 | }
      |  ^
a.cc:37:12: note: to match this '{'
   37 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;

struct edge{int from,to,cost;};

edge es[1001],m_es[1001];
#define MAX_V 1001
int d[MAX_V];
int V,E;
#define INF 1930000000
#define MINF -1930000000
void longest_path(int s){
    rep(i,V){
        d[i] = MINF;
        //d[i] = 0;
    }
    d[s] = 0;
    while(true){
        bool update = false;
        rep(i,E){
            edge e = es[i];
            if(d[e.to] < d[e.from] + e.cost){//今考えている辺を経由した方が点数は高いか？
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
    }
}
//d[目的地]を出力
bool find_negative(){
    memset(d,0,sizeof(d));
    rep(i,V){
        rep(j,E){
            edge e = m_es[j];
            if(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(){
    cin >> V >> E;
    int a,b,c;
    rep(i,E){//辺は0オリジン
        cin >> a >> b >> c;
        es[i].from = a;
        es[i].to = b;
        es[i].cost = c;
    
        m_es[i].from = a;
        m_es[i].to = b;
        m_es[i].cost = -1*c;
    }

    int score;
    
    if(find_negative()==true){
        cout << "inf" << endl;
        return 0;
    }
  
    longest_path(1);
    cout << d[V] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'bool find_negative()':
a.cc:38:5: error: 'memset' was not declared in this scope
   38 |     memset(d,0,sizeof(d));
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

using ll = long long int;

struct edge { ll from, to, cost; 
edge(ll a,ll b,ll c) : from(a) , to(b) , cost(c){

}
};

edge es[2010];

ll d[1010];
ll V, E;

ll INF = 9223372036854775807;

bool bellman_ford(int s) {
	for (int i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;

	for (int i = 0; i <= V*V; i++) {
		bool update = false;
		for (int i = 0; i < E; i++) {
			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) return false;
	}

	return true;
}

int main() {

	cin >> V >> E;

	for (ll i = 0; i < E; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		es[i] = edge(a,b,c);
	}

	if (bellman_ford(0)) {
		cout << "inf" << endl;
	}
	else {
		cout << -1LL*d[V - 1] << endl;
	}

}


Compiler output:
a.cc:17:13: error: no matching function for call to 'edge::edge()'
   17 | edge es[2010];
      |             ^
a.cc:12:1: note: candidate: 'edge::edge(ll, ll, ll)'
   12 | edge(ll a,ll b,ll c) : from(a) , to(b) , cost(c){
      | ^~~~
a.cc:12:1: note:   candidate expects 3 arguments, 0 provided
a.cc:11:8: note: candidate: 'constexpr edge::edge(const edge&)'
   11 | struct edge { ll from, to, cost;
      |        ^~~~
a.cc:11:8: note:   candidate expects 1 argument, 0 provided
a.cc:11:8: note: candidate: 'constexpr edge::edge(edge&&)'
a.cc:11:8: note:   candidate expects 1 argument, 0 provided
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    long[] d = new long[N];
    boolean flg = false;
    long ans = 0;
    ArrayList<Edge> edge = new ArrayList<Edge>();
    for(int i = 0; i < M; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      long s = (-1) * sc.nextLong();
      edge.add(new Edge(a, b, s));
    }
    // ベルマンフォード
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < edge.size(); j++) {
        Edge e = edge.get(j);
        if(d[e.to] > d[e.from] + e.score) {
          d[e.to] = d[e.from] + e.score;
          if(i == N - 1) flg = true;
        }
      }
    }
    if(flg) {
      System.out.println("inf");
    } else {
      // ベルマンフォード
      for(int i = 0; i < N; i++) {
        d[i] = (long)Math.pow(10, 15);
      }
      d[0] = 0;
      while(true) {
        boolean update = false;
        for(int i = 0; i < edge.size(); i++) {
          Edge e = edge.get(i);
          if(d[e.from] != (long)Math.pow(10, 15) && d[e.to] > d[e.from] + e.score) {
            d[e.to] = d[e.from] + e.score;
            update = true;
          }
        }
        if(!update) break;
      }
      System.out.println("inf");
    }
  }
}

Compiler output:
Main.java:11: error: cannot find symbol
    ArrayList<Edge> edge = new ArrayList<Edge>();
              ^
  symbol:   class Edge
  location: class Main
Main.java:11: error: cannot find symbol
    ArrayList<Edge> edge = new ArrayList<Edge>();
                                         ^
  symbol:   class Edge
  location: class Main
Main.java:16: error: cannot find symbol
      edge.add(new Edge(a, b, s));
                   ^
  symbol:   class Edge
  location: class Main
Main.java:21: error: cannot find symbol
        Edge e = edge.get(j);
        ^
  symbol:   class Edge
  location: class Main
Main.java:39: error: cannot find symbol
          Edge e = edge.get(i);
          ^
  symbol:   class Edge
  location: class Main
5 errors
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 2010

int n, m;

struct edge {
	int to;
	ll cost;
};

vector<edge> G[100100];

ll d[100100];
ll cnt[100100];
ll cost[1010][1010];

bool f[1010];

void check(int s, int now) {
	if (f[now])return;
	f[now] = true;

	REP(i, G[now].size()) {
		int to = G[now][i].to;
		cost[s][to] = max(cost[s][now] + G[now][i].cost, cost[s][to]);
		check(s, to);
	}
}

void solve(int now,ll cost) {
	d[now] = cost;
	REP(i, G[now].size()) {
		int to = G[now][i].to;
		ll ncost = d[now] + G[now][i].cost;
		if (d[to] < ncost)solve(to, ncost);
	}
}

int main() {
	fill(d, d + 100100, LLONG_MIN);
	cin >> n >> m;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].push_back({ b,c });
	}
	REP(i, n)REP(j, n)cost[i][j] = -1;
	REP(i, n) {
		fill(f, f + 1010, false);
		cost[i][i] = 0;
		check(i, i);
	}
	bool ok = true;
	REP(i, n) {
		FOR(j, i + 1, n) {
			if (cost[i][j] != -1 && cost[j][i] != -1) {
				if (cost[i][j] + cost[j][i] > 0)ok = false;
			}
		}
	}
	if (!ok)cout << "inf" << endl;
	else {
		solve(0, 0);
		cout << d[n - 1] << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:29: error: 'LLONG_MIN' was not declared in this scope
   79 |         fill(d, d + 100100, LLONG_MIN);
      |                             ^~~~~~~~~
a.cc:18:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include <bitset>
  +++ |+#include <climits>
   18 | #include <time.h>
Language: C++

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

typedef long long ll;

struct Edge{ //边类型定义
	ll u,v; //起点和终点
	ll l;   //边长-----------------------------******（可能是浮点型）
};
ll n,m;   //n是点数，m是边数
const ll N=1005,M=2006; //问题中给出的可能的最大点数和最大边数（无向边算两条边）-----------------*******（根据实际问题修改）
const ll MAXL = 1e15;   //边的无限长
Edge edge[M+10];  //边集
ll pre[N+10];    //从源点到该点的路径上该点的前驱(以源点为根的路径树，根结点的值为-1）
ll dist[N+10];   //从源点到该点的最短距离

//松弛操作
bool relax( Edge e ){
	if( dist[e.v] > dist[e.u]+e.l ){
		dist[e.v] = dist[e.u]+e.l;
		pre[e.v] = e.u;
		return true;  //进行更新的话返回真值
	}
	return false;
}

bool relaxX(Edge e){
	if( dist[e.v] > dist[e.u]+e.l ){
		dist[e.v] = dist[e.u]+e.l;
		pre[e.v] = e.u;
		if((e.u)==(n-1)||(e.v==(n-1))return true;  //进行更新的话返回真值
	}
	return false;
}

bool bellman(int s){
    //初始化dist[] 和 pre[]
	for(ll i=0 ; i<n ; i++){
		dist[i] = MAXL;
		pre[i] = -1;
	}
	dist[s] = 0;
	
	bool change = false;  //使用标记优化，提高效率
	for(ll i=1 ; i<n ; i++){
		change = false;
		for(ll j=0 ; j<m ; j++){
		    if( relax(edge[j]) )
              change = relax;
        }
		if( !change ) //如果对所有边进行的一次relax()操作没有更新说明已经找到了到所有点的最短路
		  break;
	}
	
    for(ll i=0 ; i<m ; i++){
		if( relaxX(edge[i]) )
			return false; //再对所有边进行一次relax()操作，如果有更新dist[]则说明存在负权回路
	}
	return true;
}

int main(){
	scanf("%lld%lld",&n,&m);
	ll a,b,c;
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld",&a,&b,&c);
		edge[i].u=a-1;
		edge[i].v=b-1;
		edge[i].l=-c;
	}
	if(bellman(0)){
		printf("%lld",-dist[n-1]);
	}else printf("inf");
	return 0;
}

Compiler output:
a.cc: In function 'bool relaxX(Edge)':
a.cc:31:46: error: expected ';' before 'return'
   31 |                 if((e.u)==(n-1)||(e.v==(n-1))return true;  //进行更新的话返回真值
      |                                              ^~~~~~
      |                                              ;
a.cc:32:9: error: expected primary-expression before '}' token
   32 |         }
      |         ^
a.cc:31:58: error: expected ')' before '}' token
   31 |                 if((e.u)==(n-1)||(e.v==(n-1))return true;  //进行更新的话返回真值
      |                   ~                                      ^
      |                                                          )
   32 |         }
      |         ~                                                 
a.cc:32:9: error: expected primary-expression before '}' token
   32 |         }
      |         ^
Language: C++

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

typedef long long ll;

struct Edge{ //边类型定义
	ll u,v; //起点和终点
	ll l;   //边长-----------------------------******（可能是浮点型）
};
ll n,m;   //n是点数，m是边数
const ll N=1005,M=2006; //问题中给出的可能的最大点数和最大边数（无向边算两条边）-----------------*******（根据实际问题修改）
const ll MAXL = 1e15;   //边的无限长
Edge edge[M+10];  //边集
ll pre[N+10];    //从源点到该点的路径上该点的前驱(以源点为根的路径树，根结点的值为-1）
ll dist[N+10];   //从源点到该点的最短距离

//松弛操作
bool relax( Edge e ){
	if( dist[e.v] > dist[e.u]+e.l ){
		dist[e.v] = dist[e.u]+e.l;
		pre[e.v] = e.u;
		return true;  //进行更新的话返回真值
	}
	return false;
}

bool relaxX(Edge e){
	if( dist[e.v] > dist[e.u]+e.l ){
		dist[e.v] = dist[e.u]+e.l;
		pre[e.v] = e.u;
		if((e.u)==(n-1)||(e.v==(n-1)return true;  //进行更新的话返回真值
	}
	return false;
}

bool bellman(int s){
    //初始化dist[] 和 pre[]
	for(ll i=0 ; i<n ; i++){
		dist[i] = MAXL;
		pre[i] = -1;
	}
	dist[s] = 0;
	
	bool change = false;  //使用标记优化，提高效率
	for(ll i=1 ; i<n ; i++){
		change = false;
		for(ll j=0 ; j<m ; j++){
		    if( relax(edge[j]) )
              change = relax;
        }
		if( !change ) //如果对所有边进行的一次relax()操作没有更新说明已经找到了到所有点的最短路
		  break;
	}
	
    for(ll i=0 ; i<m ; i++){
		if( relaxX(edge[i]) )
			return false; //再对所有边进行一次relax()操作，如果有更新dist[]则说明存在负权回路
	}
	return true;
}

int main(){
	scanf("%lld%lld",&n,&m);
	ll a,b,c;
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld",&a,&b,&c);
		edge[i].u=a-1;
		edge[i].v=b-1;
		edge[i].l=-c;
	}
	if(bellman(0)){
		printf("%lld",-dist[n-1]);
	}else printf("inf");
	return 0;
}

Compiler output:
a.cc: In function 'bool relaxX(Edge)':
a.cc:31:45: error: expected ')' before 'return'
   31 |                 if((e.u)==(n-1)||(e.v==(n-1)return true;  //进行更新的话返回真值
      |                                  ~          ^~~~~~
      |                                             )
a.cc:31:56: error: expected ')' before ';' token
   31 |                 if((e.u)==(n-1)||(e.v==(n-1)return true;  //进行更新的话返回真值
      |                   ~                                    ^
      |                                                        )
Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 10000000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
 
int n,m;
ll f[2001],t[2001],c[2001];
ll res[1001];
 
void solve(){
	for(int i=0;i<n;i++){
		res[i]=INF;
	}
	res[0]=0;
	int cnt=0;
	while(true){
		bool upd=false;
		bool upd2=false;
		for(int i=0;i<m;i++){
			if(res[f[i]]!=INF && res[f[i]]-c[i]<res[t[i]]){
				upd=true;
				res[t[i]]=res[f[i]]-c[i];
				if(t[i]==n-1)upd2=true;
			}
		}
		if(!upd)break;
		if(cnt>3*n && upd2){
			printf("inf\n");
			return;
		}
		if(cnt==4*n)break;
		cnt++;
	}
	printf("%lld\n",-res[n-1]);
}
 
int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld",&f[i],&t[i],&c[i]);
		f[i]--;
		t[i]--;
	}
	solve();
	return 0;
}

Compiler output:
a.cc:17:1: error: extended character   is not valid in an identifier
   17 |  
      | ^
a.cc:21:1: error: extended character   is not valid in an identifier
   21 |  
      | ^
a.cc:48:1: error: extended character   is not valid in an identifier
   48 |  
      | ^
a.cc:17:1: error: '\U000000a0' does not name a type
   17 |  
      | ^
a.cc:21:1: error: '\U000000a0' does not name a type
   21 |  
      | ^
a.cc:48:1: error: '\U000000a0' does not name a type
   48 |  
      | ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

using ll = long long int;

struct edge { ll from, to, cost; 
edge(ll a,ll b,ll c) : from(a) , to(b) , cost(c){

}
};

vector<edge> es[1010];

vector<ll> d;
ll V, E;

ll INF = 9223372036854775807;

// 戻り値がtrueなら負の閉路を含む
bool bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
	d = vector<ll>(n,INF);
	d[s] = 0; // 開始点の距離は0
	for (ll i = 0; i < n; i++) {
		for (ll v = 0; v < n; v++) {
			for (ll k = 0; k < es[v].size(); k++) {
				edge e = es[v][k];
				if (d[v] != INF && d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					if (i == n - 1) return true; // n回目にも更新があるなら負の閉路が存在
				}
			}
		}
	}
	return false;
}


int main() {

	cin >> V >> E;

	for (ll i = 0; i < E; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		es[a].push_back(edge(a, b, c*-1));
	}

	if (bellman_ford(V, 0)) {
		cout << "inf" << endl;
	}
	else {
		cout << -1LL*d[V - 1] << endl;
	}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:10: error: expected '}' at end of input
   59 |         }
      |          ^
a.cc:43:12: note: to match this '{'
   43 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;

struct Node {
	long long max_score;
	bool visited;
	std::vector<pair<int ,int>> connect;
};

int main()
{
	long long N, M;
	cin >> N >> M;

	std::vector<Node> nodes(N + 1);

	for (int i = 1; i <= N; i++) {
		nodes[i].max_score = LLONG_MIN;
	}

	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		nodes[a].connect.push_back(make_pair(b, c));
	}

	nodes[1].max_score = 0;

	for (int i = 1; i <= N; i++) {
		for (unsigned int j = 0; j < nodes[i].connect.size(); j++) {
			//自分自身のスコア + 移動で得るスコア
			long long score = nodes[i].max_score + nodes[i].connect[j].second;

			//すでに調査済のノードの最大スコアを更新できたらinf
			if (nodes[nodes[i].connect[j].first].max_score < score && nodes[nodes[i].connect[j].first].visited == true) {
				printf("inf\n");
				return 0;
			}

			nodes[nodes[i].connect[j].first].max_score = max(nodes[nodes[i].connect[j].first].max_score, score);
		}

		//ノードの調査済フラグを立てる
		nodes[i].visited = true;
	}

	cout << nodes[N].max_score << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:38: error: 'LLONG_MIN' was not declared in this scope
   21 |                 nodes[i].max_score = LLONG_MIN;
      |                                      ^~~~~~~~~
a.cc:5:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<algorithm>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long n,m;
bool infs;
bool vis[1010];
long long maxs[1010];
vector<long long> v[1010];
vector<long long>score[1010];
void DFS(long long key,long long pnt){
	if(vis[key]){infs=true;return;}
	maxs[key]=pnt;
	vis[key]=true;
	for(long long i=0;i<v[key].size();i++){
		long long qq=pnt+score[key][i];
		if(qq>maxs[v[key][i]]){
			DFS(v[key][i],qq);
		}
	}
	vis[key]=false;
}
long long main(){
	cin>>n>>m;
	for(long long i=0;i<m;i++){
		long long a,b;
		long long c;
		cin>>a>>b>>c;a--,b--;
		v[a].push_back(b);
		score[a].push_back(c);
	}
	infs=false;
	for(long long i=0;i<n;i++)vis[i]=false,maxs[i]=-5000000000000;
	DFS(0,0);
	if(infs)cout<<"inf"<<endl;
	else cout<<maxs[n-1]<<endl;
	return 0;
}

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

#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long

typedef pair<int,int> P;

const int INF = LLONG_MAX;
vector<int> d;
int n,m;
struct edge{int from, to, cost;};
vector<edge> es;

signed main(void){
  cin >> n >> m;

  for(int i = 0; i < m; i++){
    edge buf;
    cin >> buf.from >> buf.to >> buf.cost;
    buf.from--;
    buf.to--;
    buf.cost = -buf.cost;
    es.push_back(buf);
  }

  for(int i = 0; i < n; i++) d.push_back(INF);

  d[0] = 0;
  bool b_inf = false;
  for(int j = 0; j < n; j++){
    bool update = false;
    for(int i = 0; i < m; i++){
      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(j==n-1)b_inf=true;
    if(!update) break;
  }

  if(b_inf)cout<<"inf\r\n";
  else cout<<-d[n-1]<< "\r\n";

  return 0;
}


Compiler output:
a.cc:30:17: error: 'LLONG_MAX' was not declared in this scope
   30 | const int INF = LLONG_MAX;
      |                 ^~~~~~~~~
a.cc:25:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   24 | #include <algorithm>
  +++ |+#include <climits>
   25 | using namespace std;