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

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    MODint依存
*/
template <typename T>
struct Comb{
    vector<T> fac, fin;

    Comb(int sz) : fac(sz + 1), fin(sz + 1){
        fac[0] = fin[sz] = T(1);
        for(int i = 1; i <= sz; i++){
            fac[i] = fac[i - 1] * T(i);
        }
        fin[sz] /= fac[sz];
        for(int i = sz - 1; i >= 0; i--){
            fin[i] = fin[i + 1] * T(i + 1);
        }
    }

    /* 階乗 */
    inline T fact(int k) const { return fac[k]; }

    inline T finv(int k) const { return fin[k]; }

    /* 順列 */
    T P(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k];
    }

    /* 組み合わせ */
    T C(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k] * fin[k];
    }

    /* 重複組み合わせ */
    T H(int n, int k) const {
        if(n < 0 || k < 0) return T(0);
        return k == 0 ? T(1) : C(n + k - 1, k);
    }

    /* ベル数 */
    T B(int n, int k) const {
        if(n == 0) return T(1);
        k = min(k, n);
        vector<T> dp(k + 1);
        dp[0] = T(1);
        for(int i = 1; i <= k; i++){
            if(i & 1) dp[i] = dp[i - 1] - fin[i];
            else dp[i] = dp[i - 1] + fin[i];
        }
        T res(0);
        for(int i = 1; i <= k; i++){
            /* MODint依存 */
            res += T(i).pow(n) * fin[i] * dp[k - i];
        }
        return res;
    }

    /* スターリング数 */
    T S(int n, int k) const {
        T res(0);
        for(int i = 1; i <= k; i++){
            /* MODint依存 */
            T t = C(k, i) * T(i).pow(n);
            if((k - i) & 1) res -= t;
            else res += t;
        }
        return res * fin[k];
    }
};

/*
    P(5, 3)の場合 : 
    0 + 0 + 5 = 0 + 1 + 4 = 0 + 2 + 3 = 1 + 1 + 3 = 1 + 2 + 2
    よって、P(5, 3) = 5
*/
template <typename T>
struct Partition{
    vector<vector<T>> dp;

    Partition(int sz) : dp(sz + 1, vector<T>(sz + 1)){
        dp[0][0] = T(1);
        for(int i = 0; i <= sz; i++){
            for(int j = 1; j <= sz; j++){
                if(i - j >= 0) dp[i][j] = dp[i][j - 1] + dp[i - j][j];
                else dp[i][j] = dp[i][j - 1];
            }
        }   
    }

    /* 分割数 */
    T P(int n, int k){
        if(n < 0 || k < 0) return T(0);
        return dp[n][k];
    }
};

signed main(){
    int n;
    cin >> n;
    int a;
    int cnt[n + 1];
    REP(i,n + 1){
        cin >> a;
        cnt[a]++;
    }
    Comb<Mint<>> C(1000);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:118:10: error: 'Mint' was not declared in this scope; did you mean 'uint'?
  118 |     Comb<Mint<>> C(1000);
      |          ^~~~
      |          uint
a.cc:118:14: error: template argument 1 is invalid
  118 |     Comb<Mint<>> C(1000);
      |              ^
a.cc:118:15: error: expected unqualified-id before '>' token
  118 |     Comb<Mint<>> C(1000);
      |               ^~
Language: C++

//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;
ll n, m;
vector<vector<ll>> g(1001, vector<ll>());
map<pair<ll, ll>, ll> m1;
vector<ll> vec(1001, 0);

ll ans = -INF;

ll ret(ll a, ll s,vector<ll> svec, ll k) {
	k++;
	if (k > 1000) return 0;
	if (svec[a]==1) {
		if (vec[a] < s) {
			cout << "inf" << endl;
			exit(0);
		}
		else {
			return 0;
		}
	}
	svec[a] = 1;
	vec[a] = s;
	for (auto b : g[a]) {
		if (b == n) {
			ans = max(ans, s + m1[{a, b}]);

		}
		ret(b, s+ m1[{a, b}],svec);
	}
}


int main() {
	cin >> n >> m;
	rep(i, m) {
		ll a, b, c; cin >> a >> b >> c;
		g[a].emplace_back(b);
		m1[{a, b}] = c;
	}
	vector<ll> svec(n+1, 0);
	ret(1, 0, svec,0);
	cout << ans << endl;
	
}

Compiler output:
a.cc: In function 'll ret(ll, ll, std::vector<long long int>, ll)':
a.cc:37:20: error: too few arguments to function 'll ret(ll, ll, std::vector<long long int>, ll)'
   37 |                 ret(b, s+ m1[{a, b}],svec);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:18:4: note: declared here
   18 | ll ret(ll a, ll s,vector<ll> svec, ll k) {
      |    ^~~
a.cc:39:1: warning: control reaches end of non-void function [-Wreturn-type]
   39 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int n, m;
long long res[50000];
long long a[50000], b[50000], c[50000];
vector<int> g[50000], vg[50000];
int t[50000], f[50000];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) {cin >> a[i] >> b[i] >> c[i]; g[a[i]].push_back(b[i]); vg[b[i]].push_back(a[i]);}
    vector<int> v(1); t[1] = 1;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < g[v[i]].size(); j++)
        {
            if (t[g[v[i]][j]] == 0) {t[g[v[i]][j]] = 1; v.push_back(g[v[i]][j]);}
        }
    }
    v = {n}; f[n] = 1;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < vg[v[i]].size(); j++)
        {
            if (f[vg[v[i]][j]] == 0) {f[vg[v[i]][j]] = 1; v.push_back(vg[v[i]][j]);}
        }
    }
    fill(res, res + n + 1, -1000000000000000000);
    res[1] = 0;
    for (int i = 0; i < n - 1; i++)
        for (int j = 0; j < m; j++)
            if (res[b[j]] < res[a[j]] + c[j]) res[b[j]] = res[a[j]] + c[j];
    for (int j = 0; j < m; j++)
        if (t[a[j]] && res[b[j]] < res[a[j]] + c[j] && f[b[j]]) {cout << "inf"; return 0;}
    cout << res[n];
}


Compiler output:
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<int> g[50000], vg[50000];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:16:63: error: 'g' was not declared in this scope
   16 |     for (int i = 0; i < m; i++) {cin >> a[i] >> b[i] >> c[i]; g[a[i]].push_back(b[i]); vg[b[i]].push_back(a[i]);}
      |                                                               ^
a.cc:16:88: error: 'vg' was not declared in this scope
   16 |     for (int i = 0; i < m; i++) {cin >> a[i] >> b[i] >> c[i]; g[a[i]].push_back(b[i]); vg[b[i]].push_back(a[i]);}
      |                                                                                        ^~
a.cc:17:5: error: 'vector' was not declared in this scope
   17 |     vector<int> v(1); t[1] = 1;
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <set>
  +++ |+#include <vector>
    4 | 
a.cc:17:12: error: expected primary-expression before 'int'
   17 |     vector<int> v(1); t[1] = 1;
      |            ^~~
a.cc:18:25: error: 'v' was not declared in this scope
   18 |     for (int i = 0; i < v.size(); i++)
      |                         ^
a.cc:20:29: error: 'g' was not declared in this scope
   20 |         for (int j = 0; j < g[v[i]].size(); j++)
      |                             ^
a.cc:25:5: error: 'v' was not declared in this scope
   25 |     v = {n}; f[n] = 1;
      |     ^
a.cc:28:29: error: 'vg' was not declared in this scope
   28 |         for (int j = 0; j < vg[v[i]].size(); j++)
      |                             ^~
Language: C++

#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int n, m;
long long res[50000];
long long a[50000], b[50000], c[50000];
vector<int> g[50000], vg[50000];
int t[50000], f[50000];

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) {cin >> a[i] >> b[i] >> c[i]; g[a[i]].push_back(b[i]); vg[b[i]].push_back(a[i]);}
    vector<int> v(1); t[1] = 1;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < g[v[i]].size(); j++)
        {
            if (t[g[v[i]][j]] == 0) {t[g[v[i]][j]] = 1; v.push_back(g[v[i]][j]);}
        }
    }
    v = {n}; f[n] = 1;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < vg[v[i]].size(); j++)
        {
            if (f[vg[v[i]][j]] == 0) {f[vg[v[i]][j]] = 1; v.push_back(vg[v[i]][j]);}
        }
    }
    fill(res, res + n + 1, -1000000000000000000);
    res[1] = 0;
    for (int i = 0; i < n - 1; i++)
        for (int j = 0; j < m; j++)
            if (t[a[j]] && res[b[j]] < res[a[j]] + c[j] && f[b[j]]) res[b[j]] = res[a[j]] + c[j];
    for (int j = 0; j < m; j++)
        if (res[b[j]] < res[a[j]] + c[j]) {cout << "inf"; return 0;}
    cout << res[n];
}


Compiler output:
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<int> g[50000], vg[50000];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:16:63: error: 'g' was not declared in this scope
   16 |     for (int i = 0; i < m; i++) {cin >> a[i] >> b[i] >> c[i]; g[a[i]].push_back(b[i]); vg[b[i]].push_back(a[i]);}
      |                                                               ^
a.cc:16:88: error: 'vg' was not declared in this scope
   16 |     for (int i = 0; i < m; i++) {cin >> a[i] >> b[i] >> c[i]; g[a[i]].push_back(b[i]); vg[b[i]].push_back(a[i]);}
      |                                                                                        ^~
a.cc:17:5: error: 'vector' was not declared in this scope
   17 |     vector<int> v(1); t[1] = 1;
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <set>
  +++ |+#include <vector>
    4 | 
a.cc:17:12: error: expected primary-expression before 'int'
   17 |     vector<int> v(1); t[1] = 1;
      |            ^~~
a.cc:18:25: error: 'v' was not declared in this scope
   18 |     for (int i = 0; i < v.size(); i++)
      |                         ^
a.cc:20:29: error: 'g' was not declared in this scope
   20 |         for (int j = 0; j < g[v[i]].size(); j++)
      |                             ^
a.cc:25:5: error: 'v' was not declared in this scope
   25 |     v = {n}; f[n] = 1;
      |     ^
a.cc:28:29: error: 'vg' was not declared in this scope
   28 |         for (int j = 0; j < vg[v[i]].size(); j++)
      |                             ^~
Language: C

#include<iostream>
#include<vector>
using namespace std;
struct edge{long from,to,cost;};
long bellman_ford(int start){
    long n,m,a;
    cin>>n>>m;
    edge es[m];
    for(int i=0;i<m;i++){
        cin>>es[i].from>>es[i].to>>es[i].cost;
        es[i].from--;es[i].to--;es[i].cost*=-1;
    }
    vector<long>dist(n,0x7fffffffffffff);
    dist[start]=0L;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dist[es[j].to]>dist[es[j].from]+es[j].cost){
                dist[es[j].to]=dist[es[j].from]+es[j].cost;
            }
        }
    }
    
    bool f[n]={};
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dist[es[j].from]==0x7fffffffffffff)continue;
            if(dist[es[j].to]>dist[es[j].from]+es[j].cost){
                dist[es[j].to]=dist[es[j].from]+es[j].cost;
                f[es[j].to]=true;
            }
            if(f[es[j].from]==true)f[es[j].to]=true;
        }
    }
    return f[n-1]?0x7fffffffffffff:dist[n-1];
}

int main(){
    long a=bellman_ford(0)*-1;
    if(a==0x7fffffffffffff*-1)cout<<"inf"<<endl;
    else cout<<a<<endl;
    return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1000000000000 ;
const ll mod=1000003 ;

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

edge es[200020];

ll d[200020];
int V,E;

void shortest_path(int s){
  for(int i=0;i<V;i++)d[i]=longinf;
  d[s]=0;
  while(true){
    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)break;
  }
}

bool find_negative_loop(){
  memset(d,0,sizeof(d));
  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;
}

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    es[i]={x,y,-z};
  }
  V=n;
  E=m;
  if(find_negative_loop()){
    cout << "inf" << endl;
    return 0;
  }
  shortest_path(0);
  if(ng){
    cout << "inf" << endl;
    return 0;
  }
  cout << -d[n-1] << endl;
return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:6: error: 'ng' was not declared in this scope; did you mean 'n'?
   78 |   if(ng){
      |      ^~
      |      n
Language: C++

#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<62 ;
const ll mod=1000003 ;

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

edge es[200020];

ll d[200020];
int V,E;

void shortest_path(int s){
  for(int i=0;i<V;i++)d[i]=longinf;
  d[s]=0;
  while(true){
    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;
        cnt++;
      }
    }
    if(!update)break;
  }
}

bool find_negative_loop(){
  memset(d,0,sizeof(d));
  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;
}

int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    es[i]={x,y,-z};
  }
  V=n;
  E=m;
  if(find_negative_loop()){
    cout << "inf" << endl;
    return 0;
  }
  shortest_path(0);
  if(ng){
    cout << "inf" << endl;
    return 0;
  }
  cout << -d[n-1] << endl;
return 0;}

Compiler output:
a.cc: In function 'void shortest_path(int)':
a.cc:42:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   42 |         cnt++;
      |         ^~~
      |         int
a.cc: In function 'int main()':
a.cc:79:6: error: 'ng' was not declared in this scope; did you mean 'n'?
   79 |   if(ng){
      |      ^~
      |      n
Language: C++

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

using namespace std;

const long long int INF=1e14;
vector<pair<pair<int, long long int>, int> > E;

int main() {
    int N, M;
    cin >> N >> M;
    E.resize(M);
    
    for(int m=0; m<M; m++) {
        int a, b;
        long long int c;
        cin >> a >> b >> c;
        
        E[m]=make_pair(make_pair(a-1, b-1), -c);
    }

    vector<long long int> score(N, INF);
    score[0]=0;

    for(int n=0; n<N; n++) {
        for(int m=0; m<M; m++) {
            int from = E[m].first.first;
            int target = E[m].first.second;
            long long int cost = E[m].second;
            if(score[from]!=INF && score[target]>score[from]+cost) {
                if(n==N-1 && score[target]!=INF) {
                    cout << "inf" << endl;
                    return 0;
                }
                score[target] = score[from]+cost;
                // if(n==N-1) {
                //     cout << "inf" << endl;
                //     return 0;
                }
            }
        }
    }

    cout << -score[N-1] << endl;
    
    return 0;
    
}

Compiler output:
a.cc:46:5: error: 'cout' does not name a type
   46 |     cout << -score[N-1] << endl;
      |     ^~~~
a.cc:48:5: error: expected unqualified-id before 'return'
   48 |     return 0;
      |     ^~~~~~
a.cc:50:1: error: expected declaration before '}' token
   50 | }
      | ^
Language: C++

#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<int, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int M;
	cin >> N >> M;

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

	for (int i = 0; i < N;++i) {
		cost[i] = INF;
	}
	cost[0] = 0;
	
	bool isInf = false;
	for (int i = 0; i < N;++i) {
		for (int j = 0; j < N;++j) {
			for (P e : connect[j]) {
				if (cost[j] != INF && cost[j] + e.second < cost[e.first]) cost[e.first] = cost[j] + e.second;
				if (i == N - 1 && j == N - 1)isInf = true;
			}
		}
	}

	if (isInf)cout << "inf" << endl;
	else cout << -cost[N - 1] << endl;
}


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

from collections import deque


N,M = map(int,input().split())

dic = {}

for i in range(M):

    a,b,c = map(int,input().split())

    a -= 1
    b -= 1

    if a not in dic:
        dic[a] = []

    dic[a].append([b,c])

lis = [[0] * N for j in range(N)]
lis[0][0] = 1
lmax = [0] * N
lmax[0] = 1

mcost = [-1 * float("inf")] * N
mcost[0] = 0

q = deque([])
q.append(0)
cnt = 0

while len(q) > 0:

    now = q.pop()

    if now not in dic or lmax[now] > N:
        continue

    for npath in dic[now]:

        b = npath[0]
        c = npath[1]

        if mcost[now] + c > mcost[b]:
            mcost[b] = mcost[now] + c
            lis[b] = lis[now].copy()
            lmax[b] = lmax[now]
            lis[b][b] += 1
            lmax[b] = max(lmax[b],lis[b][b])

            if lmax[b] >= 2:
                mcost[b] = float("inf")
            q.append(b)

    if lis[N-1][N-1] != -1 * float("inf") and lmax[N-1] >= 2:
        mcost[N-1] = float("inf")
        break

    elif mcost[N-1] == float("inf"):
        break

print (mcost[N-1])


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
a.cc:8:1: error: expected unqualified-id before 'for'
    8 | for i in range(M):
      | ^~~
Language: C++

#include<cstdio>

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

int n, m;
long d[1000];
bool jf[1000], jb[1000];
edge e[2000];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        e[i].from = a - 1;
        e[i].to = b - 1;
        e[i].cost = c;
    }
    
    jf[0] = true;
    for (int i = 0; i < v; i++) {
        for (int j = 0; j < m; j++) {
            if (jf[e[j].from]) jf[e[j].to] = true;
        }
    }
    jb[n - 1] = true;
    for (int i = 0; i < v; i++) {
        for (int j = 0; j < m; j++) {
            if (jb[e[j].to]) jb[e[j].from] = true;
        }
    }
    
    for (int i = 1; i < n; i++) d[i] = -1e18;
    bool update = true;
    int cnt = 0;
    while (update) {
        if (++cnt == n + 1) {
            printf("inf\n");
            return 0;
        }
        update = false;
        for (int i = 0; i < m; i++) {
            if (jf[e[i].from] && jb[e[i].to] && d[e[i].from] + e[i].cost > d[e[i].to]) {
                d[e[i].to] = d[e[i].from] + e[i].cost;
                update = true;
            }
        }
    }

    printf("%ld\n", d[n - 1]);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:25: error: 'v' was not declared in this scope
   24 |     for (int i = 0; i < v; i++) {
      |                         ^
a.cc:30:25: error: 'v' was not declared in this scope
   30 |     for (int i = 0; i < v; i++) {
      |                         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    vector<vector<P>> graph(N);
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a].push_back({b, -c});
    }

    vector<ll> cost(N, INF);
    bool updated = false;
    cost[0] = 0;
    rep(k, N) {
        for (int i = 0; i < N; ++i) {
            for (P &p : graph[i]) {
                if (cost[p.first] > cost[i] + p.second) {
                    cost[p.first] = cost[i] + p.second;
                    if (k == N - 1 && p.first == N -1) updated = true;
                }
            }
        }
    }
    print(cost);
    if (updated) {
        cout << "inf" << '\n';
    } else {
        cout << -cost[N - 1] << '\n';
    }
}

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


Compiler output:
a.cc: In function 'void Main()':
a.cc:48:5: error: 'print' was not declared in this scope; did you mean 'rint'?
   48 |     print(cost);
      |     ^~~~~
      |     rint
Language: C++


#include <bits/stdc++.h>
#define For(i,n) for(long long i=0; i<n; i++)
using namespace std;

long long dp[2020];
bool visited[2020];
bool inff = false;

struct line{
  long long a;
  long long b;
  long long c;
};

bool cmp(const line a, const line b){
  return a.a<b.a;
}


void move(long long i, line* tes, long long M, long long N){
  if(inff) return;
  if(visited[tes[i].b && dp[tes[i].b]<dp[tes[i].a]+tes[i].c) inff=true;
  else visited[tes[i].b] = true;
  dp[tes[i].b] = max(dp[tes[i].b], dp[tes[i].a]+tes[i].c);
  for(long long j=0; j<M; j++) if(tes[j].a==tes[i].b) move(j,tes,M,N);
  visited[tes[i].b] = false;
}

int main(){

  long long N,M;
  long long inf=-1e12+10;
  cin >> N >> M;
  struct line tes[M];
  For(i,M) cin >> tes[i].a >> tes[i].b >> tes[i].c;

  For(i,2020) dp[i] = inf;
  dp[1] = 0;
  For(i,2020) visited[i] = false;
  visited[1]=true;
  sort(tes,tes+M,cmp);
  for(long long i=0; i<M; i++) if(tes[i].a==1) move(i,tes,M,N);

  if(inff) cout << "inf" << endl;
  else cout << dp[N] << endl;

  return 0;
}


Compiler output:
a.cc: In function 'void move(long long int, line*, long long int, long long int)':
a.cc:23:60: error: expected ']' before ')' token
   23 |   if(visited[tes[i].b && dp[tes[i].b]<dp[tes[i].a]+tes[i].c) inff=true;
      |                                                            ^
      |                                                            ]
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using ll = long long;
using Graph = vector<vector<int>>;

vector<bool> seen, finished;
int pos;  // vertex in cycle
stack<int> hist;
vector<ll> score;
vector<vector<ll>> value;
const ll INFTY = 1000000000001;

void loop(stack<int> st) {  // score increase in cycle
  vector<int> cycle;
  while (!st.empty()) {  // restore cycle
    int t = st.top();
    cycle.push_back(t);
    st.pop();
    if (t == pos) break;
  }
  int s = cycle.size();
  cycle.push_back(cycle.at(0));
  ll sum = 0;
  rep(i,s) sum += value[cycle.at(i+1)][cycle.at(i)];
  if (sum > 0) rep(i,s) score[cycle.at(i)] = INFTY;
  return;
}

void dfs(const Graph &G, int v) {
  seen[v] = true;
  hist.push(v);
  for (auto nv : G[v]) {
    if (score[nv] == INFTY) {  // entered cycle
      continue;
    }
    if (seen[nv] && !finished[nv]) {  //detected cycle
      pos = nv;
      loop(hist);
      continue;
    }
    if (score[v] == INFTY && score[nv] =! INFTY) {
      score[nv] = INFTY;
      dfs(G, nv);
      continue;
    }
    if (score[nv] < score[v]+value[v][nv]) {
      score[nv] = score[v]+value[v][nv];
      dfs(G, nv);
    }
  }
  hist.pop();
  finished[v] = true;
}

int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  value.assign(N, vector<ll>(N));
  rep(i,M) {
    int a, b; ll c;
    cin >> a >> b >> c;
    --a, --b;  // 0-indexed
    G[a].push_back(b);
    value[a][b] = c;
  }

  seen.assign(N, false), finished.assign(N, false);
  score.assign(N, -INFTY);
  score[0] = 0;

  dfs(G,0);

  if (score[N-1] == INFTY) cout << "inf" << endl;
  else cout << score[N-1] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void dfs(const Graph&, int)':
a.cc:42:27: error: lvalue required as left operand of assignment
   42 |     if (score[v] == INFTY && score[nv] =! INFTY) {
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

vector<int> G[1'005];
vector<int> revG[1'005];
bool reachableFrom1[1'005];
bool reachableToN[1'005];

void dfs1(int v){
  if(reachableFrom1[v]){
    return;
  }
  reachableFrom1[v] = true;
  for(int next_:G[v]){
    dfs1(next_);
  }
  return;
}

void dfsN(int v){
  if(reachableToN[v]){
    return;
  }
  reachableToN[v] = true;
  for(int next_:revG[v]){
    dfsN(next_);
  }
  return;
}

int main(){
  
  int n,m;
  cin>>n>>m;
  int a[m],b[m],c[m];
  REP(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    revG[b[i]].push_back(a[i]);
  }
  
  bool usable[n]={};
  dfs1(0);
  dfsN(n-1);
  REP(i,n){
    usable[i] = reachableFrom1[i] && reachableToN[i];
  }
  
  vector<long long> dist(n,-INF);
  dist[0] = 0;
  REP(_,m){
    REP(i,m){
      if(usable[a[i]] && usable[b[i]]){
        dist[b[i]] = max(dist[b[i]], dist[a[i]] + c[i]);
      }
    }
  }
  bool cycle_ = false;
  REP(i,m){
    if(usable[a[i]] && usable[b[i]]){
      if(dist[b[i]]<dist[a[i]] + c[i]){
        cycle = true;
        break;
      }
    }
  }
  
  if(cycle_){
    cout<<"inf"<<endl;
  }else{
    cout<<dist[n-1]<<endl;
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:104:9: error: 'cycle' was not declared in this scope; did you mean 'cycle_'?
  104 |         cycle = true;
      |         ^~~~~
      |         cycle_
Language: C++

#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100009;
int n,m,tim,str[N],en[N];
vector< vector< pair<int,int> > >v(N);
ll mem[N];
bool iscy=0;
ll solve(int no)
{
    if(no==n)
        return 0;
    ll &ret=mem[no];
    if(ret!=-1)
        return ret;
    ll ret=-1e14;
    for(int i=0;i<sz(v[no]);i++)
    {
        int nw=v[no][i].first;
        int co=v[no][i].second;

        ret=max(ret,co+solve(nw));
    }
    return ret;
}
void dfs(int no)
{
    str[no]=tim++;
    for(int i=0;i<sz(v[no]);i++)
    {
        int nw=v[no][i].first;
        if(str[nw]==-1)
        {
            dfs(nw);
        }
        else
        {
            if(en[nw]==-1)
            {
                iscy=1;
            }
            else
            {
                ;
            }
        }
    }
    en[no]=tim++;
}
int main()
{
    cin>>n>>m;

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

        v[a].pb(mp(b,c));
    }
    clr(str,-1);
    clr(en,-1);
    tim=1;
    dfs(1);
    if(iscy)
    {
        cout<<"inf"<<endl;
        return 0;
    }
    clr(mem,-1);
    cout<<solve(1)<<endl;
}










Compiler output:
a.cc: In function 'll solve(int)':
a.cc:49:8: error: conflicting declaration 'll ret'
   49 |     ll ret=-1e14;
      |        ^~~
a.cc:46:9: note: previous declaration as 'll& ret'
   46 |     ll &ret=mem[no];
      |         ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long
struct edge{int a,b,c;};
main(){
  int n,m,r;
  cin>>n>>m;
  vector<edge> e(m);
  vector<int> d(n,-1e18),nc(n,0);
  for(int i=0;i<m;++i){
    cin>>e[i].a>>e[i].b>>e[i].c;
    --e[i].a;--e[i].b;
  }
  dist[0]=0;
  for(int i=0;i<2*n-1;++i)for(int j=0;j<m;++j){
    if(d[e[j].a]+e[j].c>d[e[j].b]){
      if(i>n-2)nc[e[j].b]=1;
      d[e[j].b]=d[e[j].a]+e[j].c;
    }
    nc[e[j].b]|=nc[e[j].a];
  }
  if(nc[n-1])cout<<"inf";
  else cout<<r;
}

Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:14:3: error: 'dist' was not declared in this scope
   14 |   dist[0]=0;
      |   ^~~~
Language: C++

void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
using namespace std;

int N, M,;
class edge {
public:
	int a, b, c;
};
vector<edge> Edges;
vector<int> dp;

void solve() {
	cin >> N >> M;
	Edges.resize(M);
	for (int m = 0; m < M; m++) {
		cin >> Edges[m].a >> Edges[m].b >> Edges[m].c;
		Edges[m].a--; Edges[m].b--;
		Edges[m].c =  - Edges[m].c;
	}
	dp.resize(N, INT_MAX);
	dp[0] = 0;
	for (int time = 0;time < N; time++) {
		for (auto itr = Edges.begin(); itr != Edges.end(); itr++) {
			if (dp[itr->a] == INT_MAX)continue;
			if (dp[itr->b] > dp[itr->a] + itr->c) {
				dp[itr->b] = dp[itr->a] + itr->c;
			}
		}
	}
	vector<bool> negcheck;
	negcheck.resize(N,false);
	for (int time = 0; time < N; time++) {
		for (auto itr = Edges.begin(); itr != Edges.end(); itr++) {
			if (dp[itr->a] == INT_MAX)continue;
			if (dp[itr->b] > dp[itr->a] + itr->c) {
				dp[itr->b] = dp[itr->a] + itr->c;
				negcheck[itr->a] = true;
			}
		}
	}
	if (negcheck[N - 1])cout << "inf" << endl;
	else cout << -dp[N - 1] << endl;
	return;
}

Compiler output:
a.cc:22:10: error: expected unqualified-id before ';' token
   22 | int N, M,;
      |          ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

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

edge es[2020];
int d[1010];
bool dd[1010];
int N, M;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> M;
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        a --; b --;
        es[i] = edge{a, b, c};
    }

    rep(i, N) d[i] = INF;
    rep(i, N) dd[i] = false;
    d[0] = 0; int cnt = 0;
    while(true) {
        bool update = true;
        cnt ++;
        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(cnt >= N) {
            rep(i, M) {
                edge e = es[i];
                if(d[e.from] != INF && d[e.to] = d[e.from] + e.cost) {
                    dd[e.to] = true;
                }
                if(dd[e.from]) {
                    dd[e.to] = true;
                }
            }
        }
        if(!update) break;
        if(cnt >= 2 * N) break;
    }
    if(dd[N - 1]) {
        cout << "inf" << endl;
    } else {
        cout << d[N - 1] << endl;
    }
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:33: error: lvalue required as left operand of assignment
   80 |             if(d[e.from] != INF && d[e.to] = d[e.from] + e.cost) {
      |                ~~~~~~~~~~~~~~~~~^~~~~~~~~~
a.cc:88:37: error: lvalue required as left operand of assignment
   88 |                 if(d[e.from] != INF && d[e.to] = d[e.from] + e.cost) {
      |                    ~~~~~~~~~~~~~~~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = -1e17;

int n, m;

bool loop = false;

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

edge es[2001];
ll d[1001];

void serch(int s){
    int cnt = 0;
    rep(i, n) d[i] = INF;
    d[s] = 0;
    while(true){
        int update = -1;
        int flag = 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 = e.to;
            }
            if(update == n-1) flag = true;
        }
        if(update == -1) break;
        v++;
        cnt += flag;
        if(cnt > m+1) {
            loop = true;
            break;
        }
    }
}

int main(){
    cin >> n >> m;
    rep(i, m){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--; es[i].to--;
    }
    serch(0);
    if(loop) cout << "inf" << endl;
    else cout << d[n-1] << endl;
}

Compiler output:
a.cc: In function 'void serch(int)':
a.cc:39:9: error: 'v' was not declared in this scope
   39 |         v++;
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const int MAXN = 2000;
const ll _MAX_ = 1e17;

int N, M;
struct Edge {
    int u, v;
    ll c;
};

vector<Edge> edges;
ll dist[MAXN];

int main() {
    FAST_IO();
    cin >> N >> M;
    rep(i, M) {
        Edge e; cin >> e.u >> e.v >> e.c;
        e.u--; e.v--;
        e.c = -e.c;
        edges.push_back(e);
    }
    // Bellman-Ford
    rep(i, N) dist[i] = _MAX_;
    dist[0] = 0;
    rep(i, N) {
        for(auto &e : edges) {
            ll tmp = dist[V-1];
            if(dist[e.u] != _MAX_ && dist[e.v] > dist[e.u] + e.c) {
                dist[e.v] = dist[e.u] + e.c;
                if(i == N - 1 && dist[V - 1] < tmp) {
                    cout << "inf\n";
                    return 0;
                }
            }   
        }
    }   
    cout << -dist[N-1] << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:27: error: 'V' was not declared in this scope
   42 |             ll tmp = dist[V-1];
      |                           ^
Language: C++

#include <bits/stdc++.h>
int main(){
  cout<<"inf"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    3 |   cout<<"inf"<<endl;
      |   ^~~~
      |   std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:3:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    3 |   cout<<"inf"<<endl;
      |                ^~~~
      |                std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
int main(){
  cout<<"inf"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    3 |   cout<<"inf"<<endl;
      |   ^~~~
      |   std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:3:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    3 |   cout<<"inf"<<endl;
      |                ^~~~
      |                std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

vector <pair <int, long long> > edges[1000];
long long max_d[1000];
int main(){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a;
    int b;
    long long c;
    cin >> a >> b >> c;
    edges[a - 1].push_back(make_pair(b - 1, c));
  }

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



  bool updated_N = false;
  int update_num = 0;
  for(int k = 0; k < 2; k++){
    update_num = 0;
    while(true){
      for(int i = 0; i < N; i++){
        for(int j = 0; j < edges[i].size(); j++){
          if(max_d[dst] == LLONG_MIN){
            continue;
          }
          int dst = edges[i][j].first;
          long long cost = edges[i][j].second;
          if(max_d[dst] < max_d[i] + cost){
            max_d[dst] = max_d[i] + cost;
            if(dst == N - 1 && k == 1){
              updated_N = true;
            }
          }
        }
      }
      update_num ++;
      if(update_num > N){
        break;
      }
    }
  }

  if(!updated_N){
    cout << max_d[N - 1] << endl;
  } else {
    cout << "inf" << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:20: error: 'dst' was not declared in this scope
   40 |           if(max_d[dst] == LLONG_MIN){
      |                    ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 20000000000099;

vector<ll> BF(ll s,vector<vector<ll>>& v ,ll V){//Vは頂点の数
  vector<ll> d(V,INF);
  d[s]=0;
  int cnt=0;
  bool update=false;

  while(1){
    update=false;
    for(int i=0;i < (ll)v.size();i++)
    {
      for(int j=0;j < (ll)v.size();j++)
      {

        if(v[i][j]<INF && d[i] < INF/*更新済みか */ && d[j]> d[i]+v[i][j]){
          update=true;
          d[j]=d[i]+v[i][j];
        }
      }
    }
    if(!update)break;
    cnt++;
    //cout<<cnt<<endl;
    if(100V+1<=cnt){
      d=vector<ll>(V,INF);
      break;
    }
  }

  return d;
}


signed main(){
  ll n,m;cin>>n>>m;
  vector<vector<ll>> G(n,vector<ll>(n,INF));

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

  vector<ll> ans=BF(0,G,n);

  if(ans[n-1]==INF)cout<<"inf"<<endl;
  else cout<<-ans[n-1]<<endl;
}

Compiler output:
a.cc: In function 'std::vector<long long int> BF(ll, std::vector<std::vector<long long int> >&, ll)':
a.cc:39:8: error: unable to find numeric literal operator 'operator""V'
   39 |     if(100V+1<=cnt){
      |        ^~~~
Language: C++

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

const long long MOD = 1000000007LL;
const long long INF = 1e18;

long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

long long best[1003], c[2003];
int a[2003], b[2003];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m; cin >> n >> m;

    for(int i = 1; i <= n; ++i)
        best[i] = -INF;
    for(int i = 0; i < m; ++i)
        cin >> a[i] >> b[i] >> c[i];

    best[1] = 0;

    for(int i = 1; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(best[a[j]] == -INF) continue;
            best[b[j]] = max(best[b[j]], best[a[j]] + c[j]);
        }
    }

    for(int j = 0; j < m; ++j){
        if(best[a[j]] == -INF) continue;
        if(best[a[j]] + c[j] > best[b[j]]){
            if(i == n - 1 && b[j] == n){
                cout << "inf";
                return 0;
            }
        }
    }

    cout << best[n];

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:16: error: 'i' was not declared in this scope
   51 |             if(i == n - 1 && b[j] == n){
      |                ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;

ll N,M;  vector<vector<pair<ll,ll>>> to ;

vector<ll> dist;

int main(){
cin >> N >> M; 
  dist = vector<ll> (N,INF);
  
  to.resize( N + 10);
  
  for(ll i = 0; i < M; i++){
    ll a,b,c; cin >> a >> b >> c; a--; b--; c *= -1;
    to[a].push_back(make_pair(b,c));}
  
  bool closed = false;
  
  dist[0] = 0;
  
  for(ll i = 1; i <=  2 * N - 2; i++){
    for(ll v = 0; v < N; v++){
      if( dist[v] == INF){ continue;}//
      else{
        if( to[v].empty()){ continue;}
        for( ll k = 0; k < to[v].size(); k++){
          ll p =  to[v][k].first; //vから繋がる先
          ll q =  to[v][k].second; // v- p間のコスト
          if( dist[p] > dist[v] + q){
            dist[p] = dist[v] + q;
            if( i >= N && p == N - 1){ closed = true;}}
        }}
    }}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:7: error: expected '}' at end of input
   39 |     }}
      |       ^
a.cc:13:11: note: to match this '{'
   13 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<vector>

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;

int main(){
  ll N,M; cin >> N >> M;
  vector<pair<ll,ll>> to[1001]
  for(ll i = 0; i < M; i++){
    ll a,b,w; cin >> a >> b >> w; a--; b--; w *= - 1;
    to[a] = make_pair(b,w);}
  
  vector<ll> dist(N,INF);
  dist[0] = 0;
  bool closed = false;
  for(ll i = 0; i < 2*N; i++){
    for(ll v = 0; v < N; v++){
      if(dist[v] = INF){ continue;}
      else{
        //to[v]に格納されている辺に着目する　辺が主語
          ll b = to[v].first;
          if(dist[b] > dist[v] + to[v].second){
            dist[b] = dist[v] + to[v].second;
          if(b == N - 1 && i >= N){//N回目以降にノードN-1が更新されていないかを確認
            closed = true;}
          }}}}
  
  if(closed){ cout << "inf" << endl;}
  else{
    cout << -dist[N-1] << endl; } return 0;}
            
    


Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: expected initializer before 'for'
   13 |   for(ll i = 0; i < M; i++){
      |   ^~~
a.cc:13:17: error: 'i' was not declared in this scope
   13 |   for(ll i = 0; i < M; i++){
      |                 ^
a.cc:25:18: error: 'to' was not declared in this scope; did you mean 'tm'?
   25 |           ll b = to[v].first;
      |                  ^~
      |                  tm