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

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
struct edge{int from,to,cost;};


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n,m;
  cin>>n>>m;
  vector<edge>edges(m);
  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    edges[i]={a,b,c};
  }
  bool update=0;
  vector<ll>dist(n+1,LLONG_MIN);
  dist[1]=0;
  rep(i,n)
  {
    update=0;
    rep(j,m)
    {
      update|=chmax(dist[edges[j].to],dist[edges[j].from]+edges[j].cost);
    }
  }
  if(update==1)cout<<"inf"<<endl;
  else cout<<dist[n]<<endl;

  return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:22: error: 'LLONG_MIN' was not declared in this scope
   42 |   vector<ll>dist(n+1,LLONG_MIN);
      |                      ^~~~~~~~~
a.cc:13:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <iomanip>
  +++ |+#include <climits>
   13 |
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

//ベルマンフォード法
//https://abc061.contest.atcoder.jp/submissions/4484303

struct edge {ll to, cost;};
vector<vector<edge>> g;
const ll INF = 1e18;
const int MAX_N = 1e5;

ll dist[MAX_N];
ll n,m;

/*
bool bellman_ford(ll s){
  REP(i,n) dist[i] = INF;
  dist[s] = 0;

  bool negative_cycle = false;

  REP(i, n){
    REP(v, n){
      for(edge e: g[v]){
	if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
	  dist[e.to] = dist[v] + e.cost;
	  //n回目に n-1 に更新がある -> 負のサイクル
	  if(i == n-1 && e.to == n-1){
	    dist[e.to] = -INF;
	    negative_cycle = true;
	  }
	}
      }
    }
  }
  return negative_cycle;
}
*/

bool bellman_ford(ll s){
  memset(dist, 0, sizeof(dist));
  bool negative_cycle = false;
  REP(v, n){
    for(edge e: g[v]){
      if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
	dist[e.to] = dist[v] + e.cost;
	//n回目に n-1 に更新がある -> 負のサイクル
	if(i == n-1 && e.to == n-1){
	  dist[e.to] = -INF;
	  negative_cycle = true;
	}
      }      
    }
  }
  return negative_cycle;
}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;  
  g.assign(n, vector<edge>());  
  REP(i, m){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--; c*=-1;
    g[a].push_back(edge{b, c});
  }
  
  bool negative_cycle = bellman_ford(0);

  cout << (!negative_cycle ? to_string(-dist[n-1]) : "inf" ) << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'bool bellman_ford(ll)':
a.cc:89:12: error: 'i' was not declared in this scope
   89 |         if(i == n-1 && e.to == n-1){
      |            ^
Language: C++

/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

const ll MAX_V = 1e3;
const ll MAX_E = 2*1e3;

// 頂点fromから頂点toへのコストcostの辺
struct edge {ll from, to, cost;};

edge es[MAX_V]; // 辺 EdgeS [V][3]

ll d[MAX_E]; // 最短距離
ll V, E; // Vは頂点数, Eは辺数

// s番目の頂点から各頂点への最短距離を求める
void shortest_path(ll s){
	REP(i,V) d[i] = INF; // infで初期化
	d[s] = 0; // 始点sから始点sまでの距離
	while (true){
		bool update = false; // 1ループ中で一度でも最短経路の更新があったか
		REP(i,E){ // 全ての辺について
			edge e = es[i]; // 解析する辺を指定
			// sからe.fromまでの最短距離が探索済み かつ
			// 現在記録されているsからe.fromまでの最短距離 
			// > sからe.fromまでの最短距離 + この辺のコスト
			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; // 更新がなくなったら終了
	}
}

// trueなら負の経路が存在する
bool find_negative_loop(){
	REP(i,V) d[i] = INF; // infで初期化
	d[s] = 0; // 始点sから始点sまでの距離

	REP(i,V){
		REP(j,E){
			edge e = es[j];
			if (d[e.from]!=INF && 
			    d[e.to]>d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				
				// n回目にも更新があるなら負の閉路が存在する
				if (i==V-1) return true;
			}
		}
	}
	return false;
}


int main() {
	// 入力
	cin>>V>>E;
	REP(i,E){
		ll a,b,c;cin>>a>>b>>c;a--;b--;
		es[i].from = a;
		es[i].to   = b;
		es[i].cost = -c; // コストをマイナスにして再消費用経路の問題に治す
	}
	// REP(i,E) printf("%lld %lld %lld\n", es[i].from, es[i].to, es[i].cost);
	
	// 解法
	ll judge = find_negative_loop(); // 負の閉路が存在するか
	if (judge) cout << "inf" << endl;
	else{
		shortest_path(0);
		ll ans = d[V-1];
		// REP(i,E) printf("d[%lld] = %lld\n", i, d[i]);
		
		//出力
		cout << -ans << endl;
	}
}


Compiler output:
a.cc: In function 'bool find_negative_loop()':
a.cc:111:11: error: 's' was not declared in this scope; did you mean 'es'?
  111 |         d[s] = 0; // 始点sから始点sまでの距離
      |           ^
      |           es
Language: C++

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

int main(){
	int N,M;
	cin>>N>>M;
	
	//距離をInfで初期化
	long long dis[N][N];
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j)dis[i][j]=0;
			else dis[i][j]=Inf;
		}
	}
	
	//辺の情報を受け取る(有向辺を想定)
	for(int i=0;i<M;i++){
		int a,b,d;
		cin>>a>>b>>d;
		a--;b--;
		dis[a][b]=min(dis[a][b],(long long)-d);
	}
	bool flag = true;
	//最短距離を求める
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(dis[i][j]>dis[i][k]+dis[k][j]){
					dis[i][j]=min(Inf,dis[i][k]+dis[k][j]);
				}
				if(i==j&&dis[i][j]<0){
					flag=false;
				}
			}
		}
	}
	if(flag)cout<<-dis[0][N-1]<<endl;
	else cout<<"inf"<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:54: error: no matching function for call to 'min(long int, long long int)'
   31 |                                         dis[i][j]=min(Inf,dis[i][k]+dis[k][j]);
      |                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:31:54: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   31 |                                         dis[i][j]=min(Inf,dis[i][k]+dis[k][j]);
      |                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:31:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   31 |                                         dis[i][j]=min(Inf,dis[i][k]+dis[k][j]);
      |                                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int, int> p;
vector<ll> x(1010);

void x_init(){
  x[0] = 0;
  for (int i = 1; i < 1010; i++) {
    x[i] = -LLONG_MAX;
  }
}

set<int> use;
ll n, m;
vector<int> A;
vector<int> B;
vector<int> C;

void dfs(int from, set<int> tmp){
  // print(tmp);
  // cout << from << endl;
  if(from == n-1){
    use.insert(tmp.begin(), tmp.end());
    return;
  }

  for (int i = 0; i < m; i++) {
    if(A[i] == from) {
      if(tmp.count(B[i]) == 1) return;
      tmp.insert(A[i]);
      tmp.insert(B[i]);
      dfs(B[i], tmp);
      tmp.erase(A[i]);
      tmp.erase(B[i]);
    }
  }
  return;
}




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

  A = a;
  B = b;
  C = c;

  x_init();

  set<int> tmp;
  dfs(0, tmp);

  print(use);


  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if(use.count(b[j]) == 1)
        x[b[j]] = max(x[b[j]], x[a[j]] + c[j]);
    }
  }


  // for (int i = 0; i < n; i++) {
  for (int j = 0; j < m; j++) {
    if(use.count(b[j]) == 1){
      if(x[b[j]] != max(x[b[j]], x[a[j]] + c[j])){
        // cout << x[b[j]] << endl;
        // cout << x[a[j]] + c[j] << endl;
        // print(x);
        cout << "inf" << endl;
        return 0;
      }
    }
  }
  // }

  cout << x[n-1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:3: error: 'print' was not declared in this scope; did you mean 'rint'?
   72 |   print(use);
      |   ^~~~~
      |   rint
Language: C++

#include <iostream>
using namespace std;


struct edge{ int from, to, cost; };
const int MAX_E = 1e3;
const int MAX_V = 1e6;
edge e[MAX_E];
long long d[MAX_V];
int V, E;

int main(){

    cin >> V >> E;
    for (int i = 0; i < E; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        e[i] = edge{a,b,c};
    }

    for (int i = 1; i <= V; ++i) d[i] = LLONG_MIN;
    d[1] = 0;
    bool update;

    for (int i = 0; i <= V; ++i){
        update = false;
        for (int j = 0; j < E; j++){
            edge _e = e[j];
            if (d[_e.to] < d[_e.from] + _e.cost){
                d[_e.to] = d[_e.from] + _e.cost;
                update = true;
            } 
        }
        if (!update) {
            break;
        }
    }

    if (!update){
        cout << d[V] << endl;
    }else{
        cout << "inf" << endl;
    }
}

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

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

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

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

    vector<int> dist(N, -1e18);
    dist[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (dist[a[j]] == -inf) continue;
            if (dist[a[j]] + c[j] <= dist[b[j]]) continue;
            dist[b[j]] = dist[a[j]] + c[j];
            if (i == N - 1 && b[j] == N - 1) return cout << "inf" << endl, 0;
        }
    }
    cout << dist[N - 1] << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:32: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   19 |             if (dist[a[j]] == -inf) continue;
      |                                ^~~
      |                                ynf
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
typedef long long ll;
#define MAX_V 10000
const ll INF = 1LL << 50;
using namespace std;

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

edge es[MAX_V];

ll d[MAX_V];
bool neg[MAX_V];
int V,E;

void Bellman_Ford(int s){
  for(int i=0;i<=V;i++)d[i]=INF;
  d[s]=0;
  ll cnt = 0;
  while(true){
    cnt++;
    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;
    if(cnt==V)return;
  }
}

bool find_negative_loop(){
  memset(neg,0,sizeof(neg));
  for(int i=0;i<V;i++){
    for(int j = 0; j < E;j++){
      edge e = es[j];
      if(d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        neg[e.to]=true;
        if(i==V-1)return true;
      }
      if(neg[e.from])neg[e.to] = true;
    }
  }
  return false;
}

int main(){
  cin >> V >> E;
  ll a,b,c;
  for(int i=0;i<E;i++){
    cin >> a >> b >> c;
    es[i].from = a-1;
    es[i].to = b-1;
    es[i].cost = -1*c;
  }
  bool ch;
  Bellman_Ford(0);
  ll ret = -neg[V-1]
  ch=find_negative_loop();
  if(neg[V-1])cout << "inf" << endl;
  else cout << ret << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:68:3: error: expected ',' or ';' before 'ch'
   68 |   ch=find_negative_loop();
      |   ^~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
typedef long long ll;
#define MAX_V 10000
const ll INF = 1LL << 50;
using namespace std;

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

edge es[MAX_V];

ll d[MAX_V];
bool neg[MAX_V];
int V,E;

void Bellman_Ford(int s){
  for(int i=0;i<=V;i++)d[i]=INF;
  d[s]=0;
  ll cnt = 0;
  while(true){
    cnt++;
    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;
    if(cnt==V)return;
  }
}

void find_negative_loop(){
  memset(neg,0,sizeof(neg));
  for(int i=0;i<V;i++){
    for(int j = 0; j < E;j++){
      edge e = es[j];
      if(d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        neg[e.to]=true;
        if(i==V-1)return true;
      }
      if(neg[e.from])neg[e.to] = true;
    }
  }
  return false;
}

int main(){
  cin >> V >> E;
  ll a,b,c;
  for(int i=0;i<E;i++){
    cin >> a >> b >> c;
    es[i].from = a-1;
    es[i].to = b-1;
    es[i].cost = -1*c;
  }
  bool ch;
  Bellman_Ford(0);
  ll ret = -neg[V-1]
  ch=find_negative_loop();
  if(neg[V-1])cout << "inf" << endl;
  else cout << ret << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void find_negative_loop()':
a.cc:48:26: error: return-statement with a value, in function returning 'void' [-fpermissive]
   48 |         if(i==V-1)return true;
      |                          ^~~~
a.cc:53:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   53 |   return false;
      |          ^~~~~
a.cc: In function 'int main()':
a.cc:68:3: error: expected ',' or ';' before 'ch'
   68 |   ch=find_negative_loop();
      |   ^~
Language: C++

def bellman_ford(N, M, edge):
    d = [10 ** 100] * N
    d[0] = 0
    infFlag = False
    for count in range(N + 1):
        for i in range(M):
            if d[edge[i][0]] + edge[i][2] < d[edge[i][1]]:
                d[edge[i][1]] = d[edge[i][0]] + edge[i][2]
                if count == N and edge[i][1] == N - 1:
                    infFlag = True
    return infFlag, -d[N - 1]


def main():
    N, M = map(int, input().split())
    edge = []
    for i in range(M):
        a, b, c = map(int, input().split())
        edge.append([a - 1, b - 1, -c])
    infFlag, ans = bellman_ford(N, M, edge)
    if infFlag:
        print('inf')
    else:
        print(ans)


if __name__ == '__main__':
    main()


Compiler output:
a.cc:22:15: warning: multi-character character constant [-Wmultichar]
   22 |         print('inf')
      |               ^~~~~
a.cc:27:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   27 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def bellman_ford(N, M, edge):
      | ^~~
Language: C++

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

struct edge{long to,cost;};
typedef pair<long,long> P;
vector<edge> g[1010];
long d[1010];
bool mugen = false;
long n,m,kekka = -1000000000000000;
int cou[1010];
long inf = 1000000000000000;

void dfs(long s,long p){
  //cout << s << " " << p << " " << p-d[s] << endl;
  if(s == 1){
    cou++;
  }
  if(d[s] != inf){
    if(p - d[s] > 0 && s != 1){
      mugen = true;
      return;
    }
    if(s == 1 && cou > 1 && p - d[1] > 0){
      mugen = true;
      return;
    }
  }
  d[s] = p;
  if(s == n){
    kekka = max(kekka,p);
    return;
  }
  for(int i = 0;i < g[s].size();i++){
    dfs(g[s][i].to,p + g[s][i].cost);
  }
}

int main(){
  cin >> n >> m;
  for(int i = 0;i <= n;i++){
    d[i] = inf;
  }
  d[1] = 0;
  for(int i = 1;i <= m;i++){
    edge k;
    long a;
    cin >> a >> k.to >> k.cost;
    g[a].push_back(k);
  }
  dfs(1,0);
  if(mugen == true){
    cout << "inf" << endl;
  }
  else{
    cout << kekka << endl;
  }
}

Compiler output:
a.cc: In function 'void dfs(long int, long int)':
a.cc:16:5: error: lvalue required as increment operand
   16 |     cou++;
      |     ^~~
a.cc:23:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   23 |     if(s == 1 && cou > 1 && p - d[1] > 0){
      |                  ~~~~^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_E 2010
#define MAX_V 1010

struct edge {
	ll from, to, cost;
};
ll d[MAX_V];
int V, E;

edge es[MAX_E];

void shortest_path(int s) {
	rep(i, 0, V) d[i] = INF;
	d[s] = 0;
	while(true) {
		bool update = false;
		rep(i, 0, 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(!update) break;
	}
}

bool find_negative_loop(int s) {
	//memset(d, 0, sizeof(d));
	fill(d, d + V, INF);
	d[s] = 0;
	rep(i, 0, V) {
		rep(j, 0, E) {
			edge e = es[j];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if(i == V - 1 and e.to = V - 1) return true;
			}
		}
	}
	return false;
}

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

	cin >> V >> E;
	rep(i, 0, E) {
		int s, t, d;
		cin >> s >> t >> d;
		es[i].from = --s;
		es[i].to = --t;
		es[i].cost = -d;
	}

	if(find_negative_loop(0)) {
		cout << "inf" << endl;
		return 0;
	}

	if(d[V - 1] != INF) cout << -d[V - 1] << endl;
	else cout << "inf" << endl;
}


Compiler output:
a.cc: In function 'bool find_negative_loop(int)':
a.cc:66:47: error: lvalue required as left operand of assignment
   66 |                                 if(i == V - 1 and e.to = V - 1) return true;
      |                                    ~~~~~~~~~~~^~~~~~~~
Language: C++

// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1LL << 50


long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

struct edge{int from,to;
            long long cost;};
std::vector<edge> edges;
long long d[1000];


int main(){
    int N,M; cin >> N >> M;
    REP(i, M){
        int a,b; cin >> a >> b;
        long long c; cin >> c;
        edge e = {a-1,b-1,-1LL*c};
        edges.push_back(e);
    }

    for(int i=0; i<1000; i++){
        dist[i] = INF;
    }
    d[0] = 0LL;

    bool terminate = true;

    REP(i, N){
        REP(j, edges.size()){
            edge e = edges[j];
            if(d[e.to] > d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                if(i == N-1){
                    terminate = false;
                }
            }
        }
    }

    if(terminate) cout << -1*d[N-1] << endl;
    else cout << "inf" << endl;


    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:9: error: 'dist' was not declared in this scope
   53 |         dist[i] = INF;
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
struct edge{int from,to,cost;};
int n,m,a,b,c,d[1010];
vector<edge> vec;
void bf(int s){
	for(int i=1;i<=n;i++)d[i]=INF;
	d[s]=0;
	while(true){
		bool update=false;
		for(edge e:vec){
			if(d[e.from]==INF)continue;
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(!update)break;
	}
}
bool check(){
	memset(d,0,sizeof(d));
	int cnt=0;
	while(true){
		for(edge e:vec){
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				if(i>=n-1)return true;
			}
		}
		cnt++;
	}
	return false;
}
signed main(){
	cin>>n>>m;
	rep(i,m){
		cin>>a>>b>>c;
		vec.push_back({a,b,-c});
	}
	if(check())cout<<"inf"<<endl;
	else{
		bf(1);
		cout<<-d[n]<<endl;
	}
    return 0;
}

Compiler output:
a.cc: In function 'bool check()':
a.cc:36:36: error: 'i' was not declared in this scope
   36 |                                 if(i>=n-1)return true;
      |                                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;cin>>n>>m;
  ll in=-10000000000;
  ll a[m],b[m],c[m];
  vector<pair<ll,ll>>list[n+1];
  for(ll i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
    list[a[i]].push_back(make_pair(b[i],c[i]));
    
  }
  ll score[n+1];
  //cout<<list[1][1].first<<list[1][1].second<<endl;return 0;
  for(ll i=0;i<=n;i++)score[i]=in;
  score[1]=0;
  ll ans;
  for(ll i=0;i<3*n;i++){
    bool update=false;
    for(ll j=0;j<m;j++){
      if(score[a[j]]!=in){
          if(score[b[j]]<score[a[j]]+c[j]){
            score[b[j]]=score[a[j]]+c[j];
            
          }
        }
      }
    }
    if(i==n-2)ans=score[n];
      if(i>=n-1&&score[n]>ans){
        cout<<"inf"<<endl;
        return 0;
      }
    
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:8: error: 'i' was not declared in this scope
   30 |     if(i==n-2)ans=score[n];
      |        ^
a.cc:31:10: error: 'i' was not declared in this scope
   31 |       if(i>=n-1&&score[n]>ans){
      |          ^
a.cc: At global scope:
a.cc:37:3: error: 'cout' does not name a type
   37 |   cout<<ans<<endl;
      |   ^~~~
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;cin>>n>>m;
  ll in=-10000000000;
  ll a[m],b[m],c[m];
  vector<pair<ll,ll>>list[n+1];
  for(ll i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
    list[a[i]].push_back(make_pair(b[i],c[i]));
    
  }
  ll score[n+1];
  //cout<<list[1][1].first<<list[1][1].second<<endl;return 0;
  for(ll i=0;i<=n;i++)score[i]=in;
  score[1]=0;
  for(ll i=0;i<n-1;i++){
    for(ll j=1;j<=n;j++){
      if(score[j]!=in){
        for(ll k=0;k<list[j].size();k++){
          ll f=list[j][k].first;
          ll s=list[j][k].second;
          if(score[f]<score[j]+s){
            score[f]=score[j]+s;
           
          }
        }
      }
    }
  }
  bool update[n+1];
  for(ll i=0;i<=n;i++)update[i]=false;
  for(ll i=0;i<n;i++){
    for(ll j=1;j<=n;j++){
      if(score[j]!=in){
        for(ll k=0;k<list[j].size();k++){
          ll f=list[j][k].first;
          ll s=list[j][k].second;
          if(score[f]<score[j]+s){
            score[f]=score[j]+s;
            update[f]=true;
          }
          if(update[j]){
            for(ll p=0;p<list[j].size();p++){
              update[list[j][p]]=true;
            }
          }
        }
      }
    }
  }
      if(update[n]){
        cout<<"inf"<<endl;
        return 0;
      }
  cout<<score[n]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:21: error: no match for 'operator[]' (operand types are 'bool [(n + 1)]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
   46 |               update[list[j][p]]=true;
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;cin>>n>>m;
  ll in=-10000000000;
  ll a[m],b[m],c[m];
  vector<pair<ll,ll>>list[n+1];
  for(ll i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
    list[a[i]].push_back(make_pair(b[i],c[i]));
    
  }
  ll score[n+1];
  //cout<<list[1][1].first<<list[1][1].second<<endl;return 0;
  for(ll i=0;i<=n;i++)score[i]=in;
  score[1]=0;
  for(ll i=0;i<n-1;i++){
    for(ll j=1;j<=n;j++){
      if(score[j]!=in){
        for(ll k=0;k<list[j].size();k++){
          ll f=list[j][k].first;
          ll s=list[j][k].second;
          if(score[f]<score[j]+s){
            score[f]=score[j]+s;
           
          }
        }
      }
    }
  }
  bool update[n+1];
  for(ll i=0;i<=n;i++)update[i]=false;
  for(ll i=0;i<n;i++){
    for(ll j=1;j<=n;j++){
      if(score[j]!=in){
        for(ll k=0;k<list[j].size();k++){
          ll f=list[j][k].first;
          ll s=list[j][k].second;
          if(score[f]<score[j]+s){
            score[f]=score[j]+s;
            update[f]=true;
          }
        }
      }
    }
  }
      if(update[n]){
        cout<<"inf"<<endl;
        return 0;
      }
    }
  }
  cout<<score[n]<<endl;
}


Compiler output:
a.cc:53:3: error: expected declaration before '}' token
   53 |   }
      |   ^
a.cc:54:3: error: 'cout' does not name a type
   54 |   cout<<score[n]<<endl;
      |   ^~~~
a.cc:55:1: error: expected declaration before '}' token
   55 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MIN -100000000000000000
#define INF 100000000000000000
ll n,m;
bool ab;
vector<ll> d;
vector<ll> b;
vector<vector<ll>> a,c;
void daiku(ll i){
  b[i]++;
  for(ll j:a[i]){
    if(c[i][j]+d[i]>d[j]){
      if(b[j]<1){
        d[j]=c[i][j]+d[i];
        daiku(j);
      }else{
        ab=true;
      }
    }
  }
  b[i]=0;
}
int main(){
  cin>>n>>m;
  n++;
  a.resize(n);
  b.resize(n);
  d.resize(n);
  c.resize(n);
  for(int i=0;i<n;i++){
    b[i]=0;
    c[i].resize(n);
    d[i]=MIN;
  }
  for(int i=0;i<m;i++){
    ll aa,bb,cc;
    cin>>aa>>bb>>cc;
    a[aa].push_back(bb);
    c[aa][bb]=cc;
  }
  d[1]=0;
  ab=false;
  daiku(1);
  if(ab)
    cout<<"inf";
  else
    cout<<ma;
}
    


Compiler output:
a.cc: In function 'int main()':
a.cc:49:11: error: 'ma' was not declared in this scope; did you mean 'm'?
   49 |     cout<<ma;
      |           ^~
      |           m
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MIN -100000000000000000
#define INF 100000000000000000
ll n,m,;
vector<ll> d;
vector<ll> b;
vector<vector<ll>> a,c;
void daiku(ll i){
  b[i]++;
  for(ll j:a[i]){
    if(c[i][j]+d[i]>d[j]){
      if(b[j]<1){
        d[j]=c[i][j]+d[i];
        daiku(j);
      }
    }
  }
  b[i]=0;
}
void ddaiku(ll i){
  b[i]++;
  for(ll j:a[i]){
    if(c[i][j]+d[i]>d[j]){
      if(b[j]<10){
        d[j]=c[i][j]+d[i];
        ddaiku(j);
      }
    }
  }
  b[i]=0;
}
int main(){
  cin>>n>>m;
  n++;
  a.resize(n);
  b.resize(n);
  d.resize(n);
  c.resize(n);
  for(int i=0;i<n;i++){
    b[i]=0;
    c[i].resize(n);
    d[i]=MIN;
  }
  for(int i=0;i<m;i++){
    ll aa,bb,cc;
    cin>>aa>>bb>>cc;
    a[aa].push_back(bb);
    c[aa][bb]=cc;
  }
  d[1]=0;
  daiku(1);
  ll ma=d[n-1];
  for(int i=0;i<n;i++){
    d[i]=MIN;
  }
  d[1]=0;
  ddaiku(1);
  if(ma<d[n-1])
    cout<<"inf";
  else
    cout<<ma;
}
    


Compiler output:
a.cc:6:8: error: expected unqualified-id before ';' token
    6 | ll n,m,;
      |        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MIN -100000000000000000
#define INF 100000000000000000
ll n,m;
vector<ll> d,dd;
vector<ll> b;
vector<vector<ll>> a,c;
void daiku(ll i){
  b[i]++;
  for(ll j:a[i]){
    if(c[i][j]+d[i]>d[j]){
      if(b[i]<1){
        d[j]=c[i][j]+d[i];
        daiku(j);
      }
    }
  }
  b[i]=0;
}
void ddaiku(ll i){
  b[i]++;
  for(ll j:a[i]){
    if(c[i][j]+dd[i]>dd[j]){
      if(b[i]<2){
        dd[j]=c[i][j]+dd[i];
        daiku(j);
      }
    }
  }
  b[i]=0;
}
int main(){
  cin>>n>>m;
  n++;
  a.resize(n);
  b.resize(n);
  d.resize(n);
  dd.resize(n);
  c.resize(n);
  for(int i=0;i<n;i++){
    b[i]=0;
    c[i].resize(n);
    d[i]=MIN;
    dd[i]=MIN;
  }
  for(int i=0;i<m;i++){
    ll aa,bb,cc;
    cin>>aa>>bb>>cc;
    a[aa].push_back(bb);
    c[aa][bb]=cc;
  }
  cnt=0;
  d[1]=0;
  daiku(1);
  dd[1]=0;
  ddaiku(1);
  if(d[n-1]<dd[n-1])
    cout<<"inf";
  else
    cout<<d[n-1];
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:54:3: error: 'cnt' was not declared in this scope; did you mean 'int'?
   54 |   cnt=0;
      |   ^~~
      |   int
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int INF = 1e9;

int n, m;
vector<map<int,ll>> mp(1001);
bool used[1001] = {};
bool if_inf = false;
ll ans = -1e18;

void dfs(int k, ll dd) {
  if (used[k]) {
    if_inf = true;
    return;
  }
  if (k == n) {
    ans = max(ans, dd);
  }
  used[k] = true;
  for (auto p& : mp[k]) {
    if (used[p.first]) {
      if_inf = true;
      break;
    }
    dfs(p.first, dd + p.second);
  }
  if (if_inf) return;
  used[k] = false;
}

int main(){
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    mp[a][b] = c;
  }
  dfs(1, 0);
  if (if_inf) cout << "inf" << endl;
  else cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, ll)':
a.cc:22:14: error: expected ';' before '&' token
   22 |   for (auto p& : mp[k]) {
      |              ^
      |              ;
a.cc:22:16: error: expected primary-expression before ':' token
   22 |   for (auto p& : mp[k]) {
      |                ^
a.cc:22:15: error: expected ';' before ':' token
   22 |   for (auto p& : mp[k]) {
      |               ^~
      |               ;
a.cc:22:16: error: expected primary-expression before ':' token
   22 |   for (auto p& : mp[k]) {
      |                ^
a.cc:22:15: error: expected ')' before ':' token
   22 |   for (auto p& : mp[k]) {
      |       ~       ^~
      |               )
a.cc:22:16: error: expected primary-expression before ':' token
   22 |   for (auto p& : mp[k]) {
      |                ^
Language: C++

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

const int MAX_E = 2001;
const int MAX_V = 1001;

//Ｏ(|V||E|)
//単一始点最短経路（負の経路があってもよい）

//頂点fromから頂点toへのコストcostの辺
struct edge {
  int from, to, cost;
};

edge es[MAX_E]; //辺
int d[MAX_V];   //最短距離
int V, E;       // Vは頂点数、Eは辺数
bool check[MAX_V];

// s番目の頂点から各頂点への最短距離を求める。
void shortest_path(int s) {
  for (int i = 0; i < V; i++)
    d[i] = INF;
  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;
  }
}

// trueなら負の経路が存在する
bool find_negative_loop() {
  memset(d, 0, sizeof(d));
  memset(check, 0, sizeof(check));

  for (int i = 0; i <= V + 10; i++) {
    for (int j = 0; j < E; j++) {
      edge e = es[j];
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if (i == V) {
          check[e.to] = true;
          check[e.from] = true;
        }
        if (i == V + 5) {
          return true;
        }
      }
    }
  }
  return false;
}

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

  if (find_negative_loop()) {
    if (check[V - 1]) {
      cout << "inf" << end5l;
      return 0;
    }
  }

  shortest_path(0);

  cout << -d[V - 1] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:110:24: error: 'end5l' was not declared in this scope
  110 |       cout << "inf" << end5l;
      |                        ^~~~~
Language: Java

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main{


	static int[][] map ;
	static long INF =Long.MAX_VALUE/2;
	static int n,m ;
static	long[] dis;

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		n = sc.nextInt();
		m = sc.nextInt();
	Edge[] v = new Edge[m];

		for(int i = 0;i < m;i++){
			v[i]=new Edge();
			v[i].from=sc.nextInt();
			v[i].to=sc.nextInt();
			v[i].cost=-sc.nextInt();		//ベルマンフォードを使うためにわざとマイナスにしている
		}

		dis = new long[n+1];
		Arrays.fill(dis, INF);
		
		boolean flag = false;
		long ans = 0;
		int count = 0;
		while(flag){
			flag = false;
			for(int i = 0;i < m;i++){
				if(dis[v[i].from] + v[i].cost < dis[v[i].to]){
					dis[v[i].to]=dis[v[i].from]+v[i].cost;
					flag= true;
				}
			}
			
			if(count == n){
				ans = dis[n];
			}
			
			if(count == 2*n){						//閉路に入った時
				if(ans > dis[n]){					//閉路がプラスループ
					System.out.println("inf");
					return;
				}else{								//閉路がマイナスループ
					System.out.println(-dis[n]);
					return;
				}
			}
			
			count++;
			if(!flag){					//更新なしだったらループ出る
				break;
			}
			System.out.println(-dis[n]);
			
			
		}
		for(int i  = 1;i <= n;i++){
			if(	map[n][i] > 0){						//道があったら
				if(map[i][n] > 0){

					System.out.println("inf");
					System.exit(0);

				}else if(map[i][n] < 0){
						if(map[n][i] + map[i][n] > 0){

							System.out.println("inf");
							System.exit(0);

						}
					
				}
			}else if(map[n][i] < 0){
				if(map[i][n] > 0 && map[i][n] + map[n][i] > 0){
					System.out.println("inf");
					System.exit(0);

				}
				
				
			}
		}
		
		dfs(1,0);
		System.out.println(ans);


	}


	static void dfs(int p,long score){
		if(p == n){


			ans = Math.max(ans,score);
		}


		for(int i  = 1;i <= n;i++){
			if(	map[p][i] != 0){						//道があったら
				dfs(i, score+ map[p][i]);
			}
		}

		return;


	}

}

class Edge{
	int to;
	int from;
	int cost;
}

class MyComparator implements Comparator {

	public int compare(Object obj1, Object obj2) {

		int num1 = (int)obj1;
		int num2 = (int)obj2;

		if(num1 < num2) {
			return 1;
		} else if(num1 > num2) {
			return -1;
		} else{
			return 0;
		}
	}
}




Compiler output:
Main.java:103: error: cannot find symbol
			ans = Math.max(ans,score);
			^
  symbol:   variable ans
  location: class Main
Main.java:103: error: cannot find symbol
			ans = Math.max(ans,score);
			               ^
  symbol:   variable ans
  location: class Main
2 errors
Language: C++

inf = int(1e20)
node,edge = map(int,input().split())
ed = []
for e in range(edge):
    ed.append(e[0]-1,e[1]-1,-e[2])
start = 0
goal = node-1



d = [inf for i in range(node)]
pre = [inf for i in range(node)]
d[start] = 0

for i in range(node):
    update = False
    for e in ed:
        if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
            d[e[1]] = d[e[0]]+e[2]
            update = True
            pre[e[1]] = e[0]
    if update==False:
        print(-d[goal])
        break
else:
    nowcos = d[goal]
    for i in range(node):
        for e in ed:
            if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
                d[e[1]] = d[e[0]]+e[2]
                pre[e[1]] = e[0]
    if nowcos != d[goal]:
        print('inf')
    else:
        print(-d[goal])

Compiler output:
a.cc:33:15: warning: multi-character character constant [-Wmultichar]
   33 |         print('inf')
      |               ^~~~~
a.cc:1:1: error: 'inf' does not name a type; did you mean 'int'?
    1 | inf = int(1e20)
      | ^~~
      | int
Language: C++

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, m;
  ccin >> n >> m;

  vector<Edge> edges;
  rep(i, m) {
    ll a, b, c;
    ccin >> a >> b >> c;
    --a;
    --b;
    edges.emplace_back(a, b, -c);
  }
  ccout << "inf" << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Compiler output:
a.cc:1:6: error: variable or field 'solve' declared void
    1 | void solve(istream &ccin = cin, ostream &ccout = cout) {
      |      ^~~~~
a.cc:1:12: error: 'istream' was not declared in this scope
    1 | void solve(istream &ccin = cin, ostream &ccout = cout) {
      |            ^~~~~~~
a.cc:1:21: error: 'ccin' was not declared in this scope
    1 | void solve(istream &ccin = cin, ostream &ccout = cout) {
      |                     ^~~~
a.cc:1:28: error: 'cin' was not declared in this scope
    1 | void solve(istream &ccin = cin, ostream &ccout = cout) {
      |                            ^~~
a.cc:1:33: error: 'ostream' was not declared in this scope
    1 | void solve(istream &ccin = cin, ostream &ccout = cout) {
      |                                 ^~~~~~~
a.cc:1:42: error: 'ccout' was not declared in this scope
    1 | void solve(istream &ccin = cin, ostream &ccout = cout) {
      |                                          ^~~~~
a.cc:1:50: error: 'cout' was not declared in this scope
    1 | void solve(istream &ccin = cin, ostream &ccout = cout) {
      |                                                  ^~~~
a.cc: In function 'int main()':
a.cc:18:3: error: 'ios' has not been declared
   18 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:19:3: error: 'solve' was not declared in this scope
   19 |   solve();
      |   ^~~~~
Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }


struct Edge {
  int to;
  ll w;
};

int V,E;


template<typename T>
bool visit(const T& G,int v,vector<int>& order,vector<int>& color){
  color[v] = 1;
  for(__typeof((G[v]).begin()) e = G[v].begin();e != G[v].end();e++){
      if(color[e->to] == 2)continue;
      if(color[e->to] == 1)return false;
      if(!visit(G,e->to,order,color))return false;
    }
  order.push_back(v);
  color[v] = 2;
  return true;
}

template<typename T>
bool topologicalSort(const T& G,vector<int>& order){
  int SizeG = G.size();
  vector<int> color(SizeG); 
  for(int u=0;u<SizeG;u++) if(!color[u] && !visit(G,u,order,color)) return false;
  reverse(order.begin(),order.end());
  return true;
}

vector<vector<Edge> > G;

void init(int V) {
  G.resize(V,vector<Edge>());
}


void add_edge(int s,int t,int c){
  G[s].push_back((Edge){t,c});
}


void compute() {

}

ll dp[1010];

int main() {
  cin >> V >> E;
  init(V);
  rep(i,E) {
    int a,b,c;
    cin >> a >> b >> c;
    --a, --b;
    add_edge(a,b,c);
  }

  rep(i,V) dp[i] = -LLONG_MAX;
  dp[0] = 0;
  vector<int> order;
  if( !topologicalSort(G,order) ) { puts("inf"); return 0; }
  rep(i,(int)order.size()) {
    int j = order[i];
    rep(k,(int)G[j].size()) {
      int nex = G[j][k].to;
      ll cost = G[j][k].w;
      if( dp[j] == -LLONG_MAX ) continue;
      dp[nex] = max(dp[nex],dp[j]+cost);
    }
  }

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

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

typedef long long ll;
const ll INF = 1LL << 50;

int n, m;
int a[2000], b[2000];
ll c[2000]
ll dist[2000];

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

    for (int i = 0; i < n; i++){
        dist[i] = INF;
    }
    dist[0] = 0;

    for (int i = 0; i <= n; i++){
        for (int j = 0; j < m; j++){
            if (dist[b[j]] > dist[a[j]] + c[j]){
                dist[b[j]] = dist[a[j]] + c[j];
                if (i == n){
                    cout << "inf" << endl;
                    return 0;
                }
            }
        }
    }


    cout << -dist[n-1] << endl;

}


Compiler output:
a.cc:10:1: error: expected initializer before 'll'
   10 | ll dist[2000];
      | ^~
a.cc: In function 'int main()':
a.cc:15:32: error: 'c' was not declared in this scope
   15 |         cin >> a[i] >> b[i] >> c[i];
      |                                ^
a.cc:21:9: error: 'dist' was not declared in this scope
   21 |         dist[i] = INF;
      |         ^~~~
a.cc:23:5: error: 'dist' was not declared in this scope
   23 |     dist[0] = 0;
      |     ^~~~
a.cc:27:43: error: 'c' was not declared in this scope
   27 |             if (dist[b[j]] > dist[a[j]] + c[j]){
      |                                           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const ll INF=1e18;
const int MAX_E=2525;
const int MAX_V=1252;

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

// 辺
edge es[MAX_E];

// 最短距離
ll d[MAX_V];
int V, E;

void shortest_path(int s){
	fill(d, d+V, INF);
	d[s]=0;
	while(true){
		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(!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(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, a, b
	ll c;
	cin>>n>>m;
	V=n;
	E=m;
	REP(i, m){
		edge e;
		cin>>a>>b>>c;
		e.from=a-1;
		e.to=b-1;
		e.cost=-c;
		es[i]=e;
	}
	if(find_negative_loop()){
		cout<<"inf"<<'\n';
	}
	else{
		shortest_path(0);
		cout<<-d[n-1]<<'\n';
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:9: error: expected initializer before 'll'
   87 |         ll c;
      |         ^~
a.cc:93:25: error: 'b' was not declared in this scope
   93 |                 cin>>a>>b>>c;
      |                         ^
a.cc:93:28: error: 'c' was not declared in this scope
   93 |                 cin>>a>>b>>c;
      |                            ^