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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#define MAX 100000007
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  int a[M],b[M];
  ll c[M];
  ll ans=0;
  ll dp[1001];
  for(int i=0;i<M;i++){
    cin >> a[i] >> b[i] >> c[i];
    c[i]=-c[i];
    a[i]=a[i]-1;
    b[i]=b[i]-1;
  }
  for(int i=0;i<N;i++){
    dist[i]=MAX;
  }
  dist[0]=0;
  for(int loop=0;loop<N-1;loop++){
    for(int i=0;i<M;i++){
      if(a[i]==INF) continue;
      if(dist[b[i]] > dist[a[i]]+c[i]){
        dist[b[i]]=dist[a[i]]+c[i];
      }
    }
  }
  ans =dist[N-1];
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:5: error: 'dist' was not declared in this scope
   38 |     dist[i]=MAX;
      |     ^~~~
a.cc:40:3: error: 'dist' was not declared in this scope
   40 |   dist[0]=0;
      |   ^~~~
a.cc:43:16: error: 'INF' was not declared in this scope
   43 |       if(a[i]==INF) continue;
      |                ^~~
Language: C++

int main(){
printf("inf\n");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:1: error: 'printf' was not declared in this scope
    2 | printf("inf\n");
      | ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int main(){
Language: C++

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 10000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct edge{ll from, to, cost;};
struct graph{
  ll V;
  vector<ll> d;
  vector<edge> es;
  graph(ll n){
    init(n);
  }
  void init(ll n){
    V = n;
    d.resize(V);
    REP(i,V){
      d[i] = INF;
    }
  }
  void add_edge(ll from, ll to, ll cost){
    edge e;
    e.from = from, e.to = to, e.cost = cost;
    es.push_back(e);
  }
  void bellman_ford(ll s){
    REP(i,V) d[i] = INF;
    d[s] = 0;
    REP(i,V-1){
      bool update = false;
      for(auto e:es){
        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 negative_loop(ll gl){
    REP(i,V) d[i] = 0;
    REP(i,V){
      for(auto e:es){
        if(d[e.to]>d[e.from]+e.cost){
          d[e.to] = d[e.from]+e.cost;
          if(i==V-1&&e.to==gl) return true;
        }
      }
    }
    return false;
  }
};

int main(){
  ll n,m;
  cin >> n >> m;
  graph g(n);
  REP(i,m){
    ll a, b,c;
    cin >> a >> b >> c;
    g.add_edge(a-1,b-1,-c);
  }
  if(g.negative_loop()){
    cout << "inf" << endl;
  }else{
    g.bellman_ford(0);
    cout << -g.d[n-1] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:21: error: no matching function for call to 'graph::negative_loop()'
   74 |   if(g.negative_loop()){
      |      ~~~~~~~~~~~~~~~^~
a.cc:51:8: note: candidate: 'bool graph::negative_loop(ll)'
   51 |   bool negative_loop(ll gl){
      |        ^~~~~~~~~~~~~
a.cc:51:8: note:   candidate expects 1 argument, 0 provided
Language: C++

#include "stdafx.h"


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	bool check = false;
	int n, m, i, j, k;
	cin >> n >> m;
	vector<ll> score(n, -INF*INF);
	vector<vector<ll>> G(n, vector<ll>(n, -INF*INF));
	
	for (i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		cin >> G[a][b];
	}

	score[0] = 0;

	for (i = 0; i < n; i++) {
		bool update = false;
		for (j = 0; j < n; j++) {
			for (k = 0; k < n; k++) {
				if (j!=k && G[j][k] != -INF * INF && score[j] != -INF * INF && score[k] < score[j] + G[j][k]) {
					score[k] = score[j] + G[j][k];
					update = true;
				}
			}
		}
		if (!update)break;
		if (i == n - 1)check = true;
	}

	if (check)cout << "inf" << endl;
	else cout << score[n - 1] << endl;

	return 0;
}

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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <limits>

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using Weight = int64_t;

struct Edge {
	int src, dst;
	Weight weight;
};

constexpr int64_t INF = 1LL<<59;

using Edges = vector<Edge>;
using Graph = vector<Edges>;

bool shortestPath(const Graph g, int s, vector<Weight> &dist) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  bool negative_cycle = false;
  rep(k, n) rep(i, n) for(auto e: g[i]) {
    if (dist[e.dst] > dist[e.src] + e.weight) {
      dist[e.dst] = dist[e.src] + e.weight;
      if (k == n-1) {
        dist[e.dst] = -INF;
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

int main() {
	int N, M; cin >> N >> M;
	Graph G(N);
	rep(i, M) {
		Edge e; cin >> e.src >> e.dst >> e.weight;
		e.src--, e.dst--, e.weight *= -1;
		G[e.src].push_back(Edge{e.src, e.dst, e.weight});
	}
	vector<Weight> w;
	shortestPath(G, 0, w);
	if (dist[N - 1] > -INF) {
		cout << -w[N - 1] << "\n";
	} else {
		cout << "inf\n";
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:13: error: 'dist' was not declared in this scope
   50 |         if (dist[N - 1] > -INF) {
      |             ^~~~
Language: C++

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using Weight = int64_t;

struct Edge {
	int src, dst;
	Weight weight;
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

bool shortestPath(const Graph g, int s, vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF+INF); dist[s] = 0;
  prev.assign(n, -2);
  bool negative_cycle = false;
  rep(k, n) rep(i, n) for(auto e: g[i]) {
    if (dist[e.dst] > dist[e.src] + e.weight) {
      dist[e.dst] = dist[e.src] + e.weight;
      prev[e.dst] = e.src;
      if (k == n-1) {
        dist[e.dst] = std::numeric_limits<int64_t>::min();
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

int main() {
	int N, M; cin >> N >> M;
	Graph G(N);
	rep(i, M) {
		Edge e; cin >> e.src >> e.dst >> e.weight;
		e.src--, e.dst--, e.weight *= -1;
		G[e.src].push_back(Edge{e.src, e.dst, e.weight});
	}
	vector<Weight> w;
	vector<int> prev;
	if (shortestPath(G, 0, w, prev)) {
		cout << -w[N - 1] << "\n";
	} else {
		cout << "inf\n";
	}
}

Compiler output:
a.cc: In function 'bool shortestPath(Graph, int, std::vector<long int>&, std::vector<int>&)':
a.cc:23:18: error: 'INF' was not declared in this scope
   23 |   dist.assign(n, INF+INF); dist[s] = 0;
      |                  ^~~
Language: C++

#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n, m;

typedef struct edge_ {
		int from, to, cost;
		edge_(int f, int t, int c): from(f), to(t), cost(c){};
} edge;
vector<edge> vec;

ll d[1001];

bool bellmanford(){
		bool updated;
		fill(d, d+n, linf);
		d[0] = 0;
		for(int i = 0; i <= n; i++){
				updated = false;
				for(auto itr = vec.begin(); itr != vec.end(); ++itr){
						int from = (*itr).from;
						int to = (*itr).to;
						int cost = (*itr).cost;
						if(d[from] != linf && d[from] + (ll)cost < d[to]){
								if(e.to == n - 1)updated = true;
								d[to] = d[from] + (ll)cost;
						}
				}
		}
		return !updated;
}

int main(int argc, char const* argv[])
{
	cin >> n >> m;
	for(int i = 0; i < m; i++){
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			vec.pb(edge(a, b, -c));
	}
	if(bellmanford())cout << -d[n - 1] << endl;
	else cout << "inf" << endl;
	return 0;
}


Compiler output:
a.cc: In function 'bool bellmanford()':
a.cc:42:68: error: 'e' was not declared in this scope
   42 |                                                                 if(e.to == n - 1)updated = true;
      |                                                                    ^
Language: Java

import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = Long.MAX_VALUE;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n   = in.nextInt();
        int m   = in.nextInt();
        List<E> edges = new ArrayList<>();
        for(int i = 0; i < m; i++) {
            int a = in.nextInt()-1;
            int b = in.nextInt()-1;
            long c = -in.nextInt();
            E e = new E(a, b, c);
            edges.add(e);
        }

        long[] dist = new long[n];
        Arrays.fill(dist, inf);
        dist[0] = 0;
        int loopCnt = 0;
        boolean infCond = false;
        while(true) {
            if(loopCnt > 2*n) {
                infCond = true;
                break;
            }

            loopCnt++;
            boolean updated = false;
            for(E e : edges) {
                if(dist[e.from] != inf && dist[e.from] + e.w < dist[e.to]) {
                    dist[e.to] = dist[e.from] + e.w;
                    updated = true;
                }
            }

            if(!updated) break;
        }

        if(infCond) {
            print("inf");
        }else{
            print(-dist[n-1]);
        }
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
        List<E> edges = new ArrayList<>();
             ^
  symbol:   class E
  location: class Main
Main.java:15: error: cannot find symbol
            E e = new E(a, b, c);
            ^
  symbol:   class E
  location: class Main
Main.java:15: error: cannot find symbol
            E e = new E(a, b, c);
                      ^
  symbol:   class E
  location: class Main
Main.java:32: error: cannot find symbol
            for(E e : edges) {
                ^
  symbol:   class E
  location: class Main
4 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef lon glong ll;
ll MAX = 1e+15;
typedef struct{
  ll t;
  ll c;
} edge;
 
ll n,m;
vector<vector<edge>> g,subg;

ll longest_path() {
 
  vector<int> indeg(n,0);
  for(auto es : subg) {
    for(auto e : es) {
      indeg[e.t]++;
    }
  }
  
  while(1) {
    int v = -1;
	for(int i=0;i<n;i++)
      if( indeg[i] == -1 ) 
        v = i;
    
                
  }

  
}

ll solve(){
 
  // 1-Nパスに含まれる頂点からなる部分グラフ
  
  // 上記グラフがDAGか否か
  // --> DAGならば、最長路計算
  // --> else return inf
  if( is_dag() ) 
    return longest_path(); 
  else
    return MAX;
}
 
int main() {
 
  cin >> n >> m;
  g = vector<vector<edge>>(n);
  for(int i=0; i<n; i++) {
    ll a,b,c; cin >> a >> b >> c;
    a--;b--;
    g[a].push_back({b,c});
    g[b].push_back({a,c});
  }
  
  cout << (solve()==MAX ? "inf" : solve()) << endl;
  
}

Compiler output:
a.cc:3:9: error: 'lon' does not name a type; did you mean 'long'?
    3 | typedef lon glong ll;
      |         ^~~
      |         long
a.cc:4:1: error: 'll' does not name a type
    4 | ll MAX = 1e+15;
      | ^~
a.cc:6:3: error: 'll' does not name a type
    6 |   ll t;
      |   ^~
a.cc:7:3: error: 'll' does not name a type
    7 |   ll c;
      |   ^~
a.cc:10:1: error: 'll' does not name a type
   10 | ll n,m;
      | ^~
a.cc:13:1: error: 'll' does not name a type
   13 | ll longest_path() {
      | ^~
a.cc:34:1: error: 'll' does not name a type
   34 | ll solve(){
      | ^~
a.cc: In function 'int main()':
a.cc:49:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   49 |   cin >> n >> m;
      |          ^
      |          yn
a.cc:49:15: error: 'm' was not declared in this scope; did you mean 'tm'?
   49 |   cin >> n >> m;
      |               ^
      |               tm
a.cc:52:5: error: 'll' was not declared in this scope
   52 |     ll a,b,c; cin >> a >> b >> c;
      |     ^~
a.cc:52:22: error: 'a' was not declared in this scope
   52 |     ll a,b,c; cin >> a >> b >> c;
      |                      ^
a.cc:52:27: error: 'b' was not declared in this scope
   52 |     ll a,b,c; cin >> a >> b >> c;
      |                           ^
a.cc:52:32: error: 'c' was not declared in this scope
   52 |     ll a,b,c; cin >> a >> b >> c;
      |                                ^
a.cc:58:12: error: 'solve' was not declared in this scope
   58 |   cout << (solve()==MAX ? "inf" : solve()) << endl;
      |            ^~~~~
a.cc:58:21: error: 'MAX' was not declared in this scope
   58 |   cout << (solve()==MAX ? "inf" : solve()) << endl;
      |                     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef lon glong ll;

typedef struct{
  ll t;
  ll c;
} edge;

ll n,m;
vector<edge> g;

int main() {

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

Compiler output:
a.cc:3:9: error: 'lon' does not name a type; did you mean 'long'?
    3 | typedef lon glong ll;
      |         ^~~
      |         long
a.cc:6:3: error: 'll' does not name a type
    6 |   ll t;
      |   ^~
a.cc:7:3: error: 'll' does not name a type
    7 |   ll c;
      |   ^~
a.cc:10:1: error: 'll' does not name a type
   10 | ll n,m;
      | ^~
a.cc: In function 'int main()':
a.cc:15:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   15 |   cin >> n >> m;
      |          ^
      |          yn
a.cc:15:15: error: 'm' was not declared in this scope; did you mean 'tm'?
   15 |   cin >> n >> m;
      |               ^
      |               tm
a.cc:18:5: error: 'll' was not declared in this scope
   18 |     ll a,b,c; cin >> a >> b >> c;
      |     ^~
a.cc:18:22: error: 'a' was not declared in this scope
   18 |     ll a,b,c; cin >> a >> b >> c;
      |                      ^
a.cc:18:27: error: 'b' was not declared in this scope
   18 |     ll a,b,c; cin >> a >> b >> c;
      |                           ^
a.cc:18:32: error: 'c' was not declared in this scope
   18 |     ll a,b,c; cin >> a >> b >> c;
      |                                ^
Language: C++

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


#define NEG_INFTY 0x8000000000000000LL

typedef pair<ll,int> Li;

void solve(int N,int M,vi& a,vi& b,vi& c) {
    vector<vector<ii>> next(N);
    rep(i,M){
        int x=a[i],y=b[i],z=c[i];
        next[x].pb(ii(y,z));
    }
#ifdef DEBUG
    // rep(i,N){
    //     cerr << "next[" <<  i << "] -> " << next[i] << endl;
    // }
#endif
    vector<ll> dist(N, NEG_INFTY);
    vector<int> prev(N, -1);

    queue<pair<ll,ii>> q; // distance, (from, to)
    q.push( make_pair(0LL,ii(-1,0)) );
    while (!q.empty()){
        auto t = q.front(); q.pop();
#ifdef DEBUG
        cerr << ": " << t << endl;
#endif
        ll d = t.first;
        int from = t.second.first, here = t.second.second;
        if (prev[here] == -2) {
            dist[here] = d;
            prev[here] = from;
        } else {
            if (prev[here] == from && d > 0) {
                cout << "inf" <<s endl;
                return;
            }
            if (d > dist[here]) {
                dist[here] = d;
                prev[here] = from;
            } else {
                continue;
            }
        }
        for (ii nx : next[here]) {
            if (prev[nx.first] == -1
             || dist[nx.first] < d + nx.second) {
                q.push( make_pair(d + nx.second, ii(here, nx.first)) );
            }
        }
    }
#ifdef DEBUG
    cerr << dist << endl;
    cerr << prev << endl;
#endif
    cout << dist[N-1] << endl;
}

int main() {
    int N,M;cin>>N>>M;
    vi a(M),b(M),c(M);
    rep(i,M){
        cin>>a[i]>>b[i]>>c[i];
        --a[i]; --b[i];
    }
    solve(N,M,a,b,c);
    return 0;
}


Compiler output:
a.cc: In function 'void solve(int, int, vi&, vi&, vi&)':
a.cc:75:33: error: 's' was not declared in this scope
   75 |                 cout << "inf" <<s endl;
      |                                 ^
Language: C++

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


#define NEG_INFTY 0x8000000000000000LL

typedef pair<ll,int> Li;

void solve(int N,int M,vi& a,vi& b,vi& c) {
    vector<vector<ii>> next(N);
    rep(i,M){
        int x=a[i],y=b[i],z=c[i];
        next[x].pb(ii(y,z));
    }
#ifdef DEBUG
    // rep(i,N){
    //     cerr << "next[" <<  i << "] -> " << next[i] << endl;
    // }
#endif
    vector<ll> dist(N, NEG_INFTY);
    vector<int> prev(N, -1);

    queue<pair<ll,ii>> q; // distance, (from, to)
    q.push( make_pair(0LL,ii(-1,0)) );s
    while (!q.empty()){
        auto t = q.front(); q.pop();
#ifdef DEBUG
        cerr << ": " << t << endl;
#endif
        ll d = t.first;
        int from = t.second.first, here = t.second.second;
        if (prev[here] == -2) {
            dist[here] = d;
            prev[here] = from;
        } else {
            if (prev[here] == from && d > 0) {
                cout << "inf" <<s endl;
                return;
            }
            if (d > dist[here]) {
                dist[here] = d;
                prev[here] = from;
            } else {
                continue;
            }
        }
        for (ii nx : next[here]) {
            if (prev[nx.first] == -1
             || dist[nx.first] < d + nx.second) {
                q.push( make_pair(d + nx.second, ii(here, nx.first)) );
            }
        }
    }
#ifdef DEBUG
    cerr << dist << endl;
    cerr << prev << endl;
#endif
    cout << dist[N-1] << endl;
}

int main() {
    int N,M;cin>>N>>M;
    vi a(M),b(M),c(M);
    rep(i,M){
        cin>>a[i]>>b[i]>>c[i];
        --a[i]; --b[i];
    }
    solve(N,M,a,b,c);
    return 0;
}


Compiler output:
a.cc: In function 'void solve(int, int, vi&, vi&, vi&)':
a.cc:62:39: error: 's' was not declared in this scope
   62 |     q.push( make_pair(0LL,ii(-1,0)) );s
      |                                       ^
Language: C++

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

using namespace std;

using llong = long long;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<pair<int,llong>>> graph(n);
  for(int i=0;i<m;++i){
    int a,b;
    llong c;
    cin >> a >> b >> c;
    graph[a-1].emplace_back(b-1,-c);
  }

  llong INF = 100000000000000000;
  vector<llong> dist(n,INF);
  dist[0] = 0;
  for(int cnt=0;cnt<n;++cnt){
    for(int i=0;i<n;++i){
      for(const auto &p:graph[i]){
        if(dist[p.first] > dist[i] + p.second){
          dist[p.first] = dist[i] + p.second;
          if(cnt == n-1&&p.first = n-1){
            cout << "inf" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << -dist[n-1] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:24: error: lvalue required as left operand of assignment
   27 |           if(cnt == n-1&&p.first = n-1){
      |              ~~~~~~~~~~^~~~~~~~~
Language: C++

#include <iostream>

using namespace std;

int main(){
	long long a,b,c;
	cin >> V >> E;
	int i,j;
	for(i=0;i<E;i++){
		cin >> a >> b >> c ;
	}
		cout << "inf" << endl;
}



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

#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
//LLONG_MIN

int main(void){
	int N,M,x,y,z;
	vector<int> v[1010];
	vector<int> c[1010];
	scanf("%d%d",&N,&M);
	rep(i,M){
		scanf("%d%d%d",&x,&y,&z);
		v[x].push_back(y);
		c[x].push_back(z);
	}
	ll s1[1010],s2[1010],t;
	reg(i,1,N)s2[i]=-(1e14+10);
	s2[1]=0;
	reg(cnt,1,3*N+2){
		reg(i,1,N)s1[i]=s2[i];
		reg(i,1,N){
			rep(j,v[i].size()){
				if(s2[v[i][j]]<s1[i]+c[i][j])s2[v[i][j]]=s1[i]+c[i][j];
			}
		}
		if(i==N-1)t=s2[N];
	}
	if(s2[N]>t){
		printf("inf\n");
	}else{
		printf("%lld\n",s2[N]);	
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:20: error: 'i' was not declared in this scope
   42 |                 if(i==N-1)t=s2[N];
      |                    ^
Language: C++

#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

vector<pint> v[1010];
ll dist[1010];
int used[1010];
bool flag;

void bfs(){
  queue<int> q;
  q.push(0);
  dist[0]=0;
  while(q.size()){
    int x=q.front();q.pop();
    if(used[x]>=1010){
      if(x==n-1){
        flag=true;
        return;
        }
      continue;
      }
    for(auto e:v[x]){
      if(dist[e.first]>dist[x]+e.second){
        dist[e.first]=dist[x]+e.second;
        used[e.first]++;
        q.push(e.first);
        }
      }
    }
  }

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    v[a-1].push_back({b-1,-c});
    }
  rep(i,n)dist[i]=longinf;
  bfs();
  if(flag)cout<<"inf"<<endl;
  else cout<<-dist[n-1]<<endl;
  return 0;
  }

Compiler output:
a.cc: In function 'void bfs()':
a.cc:31:13: error: 'n' was not declared in this scope
   31 |       if(x==n-1){
      |             ^
Language: C++

n,m=io.read("*n","*n")
d={}
for i=1,n do
	d[i]={}
	for j=1,n do
		d[i][j]=(i==j and 0 or -1e15)
	end
end

for i=1,m do
	a,b,c=io.read("*n","*n","*n")
	d[a][b]=c
end
	
for k=1,n do
	for i=1,n do
		for j=1,n do
			d[i][j]=math.max(d[i][j],d[i][k]+d[k][j])
		end
	end
end

print(d[1][1]>0 and"inf"or d[1][n])

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,m=io.read("*n","*n")
      | ^
a.cc:3:1: error: expected unqualified-id before 'for'
    3 | for i=1,n do
      | ^~~
a.cc:5:9: error: expected unqualified-id before 'for'
    5 |         for j=1,n do
      |         ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
typedef long long ll;

using namespace std;

class Edge
{
	public:
	ll cost;
	int next;

	Edge(int n,ll c)
	{
		next=n;
		cost=c;
	}
};

vector<Edge> g[1000];
bool used[1000];
ll d[1000];
ll inf = 1e15+7;

int main()
{
	int n,m;
	bool f=false;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		ll c;
		cin>>a>>b>>c;
		a--;
		b--;
		c*=-1;
		g[a].push_back(Edge(b,c));
	}
	fill(used,used+1000,false);
	fill(d,d+1000,inf);
	d[0]=0;
	for(int i=0;i<n+10;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<g[j].size();k++)
			{
				Edge e =g[j][k];
				if(d[j]!=inf && d[e.next]>d[j]+e.cost)
				{
					d[e.next]=d[j]+e.cost;
					if(i==n+5)
					{
						f=true;
						break;
					}
				}
			}
		}
	}
	if(f){
		cout<<"inf"<<endl;
        assert(true);
    }
	else
		cout<<-1*d[n-1]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:9: error: 'assert' was not declared in this scope
   68 |         assert(true);
      |         ^~~~~~
a.cc:7:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    6 | #include <functional>
  +++ |+#include <cassert>
    7 | typedef long long ll;
Language: C++

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

const long long int INF = 1LL << 50;
const int nmax = 1001;
const int mmax = 2001;

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

edge es[2010];

int a[mmax],b[mmax];
long long int c[namx];

long long int d[nmax];
int n,m;

int main(){

    int s,t;
    long long int dd;

    cin >> n >> m;

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

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

    d[1] = 0;

    for(int loop=0; loop<n-1; loop++){
        for(int i=0; i<m; i++){
            if(d[a[i]] == INF){
                continue;
            }
            if(d[b[i]] > d[a[i]] + c[i]){
                d[b[i]] = d[a[i]] + c[i];
            }
        }
    }

    long long int ans = d[n];

    bool negative[nmax];

    for (int i = 0; i <= n; ++i) {
        negative[i] = false;
    }

    for (int loop = 0; loop < n ; loop++) {
        for (int i = 0; i < m; i++) {
            if (d[a[i]] == INF){
                continue;
            }
            if (d[b[i]] > d[a[i]] + c[i]) {
                d[b[i]] = d[a[i]] + c[i];
                negative[b[i]] = true;
            }

            if (negative[b[i]]) {
                negative[a[i]] = true;
            }
        }
    }

    if(negative[n]){
        cout << "inf" << endl;
    }
    else{
        cout << -ans << endl;
    }

    return 0;
}

Compiler output:
a.cc:16:17: error: 'namx' was not declared in this scope; did you mean 'nmax'?
   16 | long long int c[namx];
      |                 ^~~~
      |                 nmax
a.cc: In function 'int main()':
a.cc:29:32: error: 'c' was not declared in this scope
   29 |         cin >> a[i] >> b[i] >> c[i];
      |                                ^
a.cc:44:36: error: 'c' was not declared in this scope
   44 |             if(d[b[i]] > d[a[i]] + c[i]){
      |                                    ^
a.cc:63:37: error: 'c' was not declared in this scope
   63 |             if (d[b[i]] > d[a[i]] + c[i]) {
      |                                     ^
Language: C++

#include<iostream>
using namespace std;

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

int main(){

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

  const int nmax = 1000;
  const int mmax = 2000;
  int a[mmax],b[mmax];
  ll c[mmax];

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

  ll d[nmax];

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

  d[0] = 0;

  for(int loop = 0; loop < n-1; loop++){
    for(int i=0; i<m; i++){
      if(d[a[i]-1] == INF){
        continue;
      }
      if(d[b[i]-1] > d[a[i]-1] + c[i]){
        d[b[i]-1] = d[a[i]-1] + c[i];
      }
    }
  }

  ll ans = d[n-1];

  bool negative[nmax];

  for (int i = 0; i < n; ++i) {
    negative[i] = false;
  }

 for (int loop = 0; loop < n ; ++ loop) {
  for (int i = 0; i < m; ++i) {
    if (dist[a[i] - 1] == INF) continue;
    if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
      dist[b[i] - 1] = dist[a[i] - 1] + c[i];
      negative[b[i] - 1] = true;
    }

    if (negative[a[i] - 1] == true) {
      negative[b[i] - 1] = true;
    }
 }
}

if(negative[n-1]){
  cout << "inf" << endl;
}
else{
  cout << -ans << endl;
}
  return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:9: error: 'dist' was not declared in this scope
   51 |     if (dist[a[i] - 1] == INF) continue;
      |         ^~~~
a.cc:52:9: error: 'dist' was not declared in this scope
   52 |     if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
      |         ^~~~
Language: C++

#include<iostream>
using namespace std;

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

int main(){

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

  const int nmax = 1000;
  const int mmax = 2000;
  int a[mmax],b[mmax];
  ll c[mmax];

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

  ll d[nmax];

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

  d[0] = 0;

  for(int loop = 0; loop < n-1; loop++){
    for(int i=0; i<m; i++){
      if(d[a[i]-1] == INF){
        continue;
      }
      if(d[b[i]-1] > d[a[i]-1] + c[i]){
        d[b[i]-1] = d[a[i]-1] + c[i];
      }
    }
  }

  ll ans = d[n-1];

  bool negative[NMAX];

  for (int i = 0; i < N; ++i) {
    negative[i] = false;
  }

 for (int loop = 0; loop < N ; ++ loop) {
  for (int i = 0; i < M; ++i) {
    if (dist[a[i] - 1] == INF) continue;
    if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
      dist[b[i] - 1] = dist[a[i] - 1] + c[i];
      negative[b[i] - 1] = true;
    }

    if (negative[a[i] - 1] == true) {
      negative[b[i] - 1] = true;
    }
 }
}

if(negative[n-1]){
  cout << "inf" << endl;
}
else{
  cout << -ans << endl;
}
  return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:17: error: 'NMAX' was not declared in this scope
   43 |   bool negative[NMAX];
      |                 ^~~~
a.cc:45:23: error: 'N' was not declared in this scope
   45 |   for (int i = 0; i < N; ++i) {
      |                       ^
a.cc:46:5: error: 'negative' was not declared in this scope
   46 |     negative[i] = false;
      |     ^~~~~~~~
a.cc:49:28: error: 'N' was not declared in this scope
   49 |  for (int loop = 0; loop < N ; ++ loop) {
      |                            ^
a.cc:50:23: error: 'M' was not declared in this scope
   50 |   for (int i = 0; i < M; ++i) {
      |                       ^
a.cc:51:9: error: 'dist' was not declared in this scope
   51 |     if (dist[a[i] - 1] == INF) continue;
      |         ^~~~
a.cc:52:9: error: 'dist' was not declared in this scope
   52 |     if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
      |         ^~~~
a.cc:54:7: error: 'negative' was not declared in this scope
   54 |       negative[b[i] - 1] = true;
      |       ^~~~~~~~
a.cc:57:9: error: 'negative' was not declared in this scope
   57 |     if (negative[a[i] - 1] == true) {
      |         ^~~~~~~~
a.cc:63:4: error: 'negative' was not declared in this scope
   63 | if(negative[n-1]){
      |    ^~~~~~~~
Language: C++

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

#define INF 1LL << 50;

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

edge es[2010];

long long int d[1010];
long long int n,m;

bool shortest_path(long long int s){
    for(int i=0; i<=n; i++){
        d[i] = INF;
    }
    d[s] = 0;
    long long int count = 0;
    while(1){
        if(count > n){
            return true;
        }
        bool update = false;
        for(int i=0; i<m; i++){
            edge ed = es[i];
            if(d[ed.from] != INF && d[ed.to] > d[ed.from] + ed.cost){
                d[ed.to] = d[ed.from] + ed.cost;
                update = true;
            }
        }
        if(!update) break;
        count++;
    }
    return false;
}

int main(){

    long long int s,t,dd;

    cin >> n >> m;

    for(int i=0; i<m; i++){
        cin >> s >> t >> dd;
        es[i].to = t;
        es[i].from = s;
        es[i].cost = -dd;
    }

    if(shortest_path(1LL)){
        cout << "inf" << endl;
    }
    else{
        cout << -d[n] << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'bool shortest_path(long long int)':
a.cc:26:38: error: expected ')' before '[' token
   26 |             if(d[ed.from] != INF && d[ed.to] > d[ed.from] + ed.cost){
      |               ~                      ^
      |                                      )
a.cc:26:37: error: label 'd' used but not defined
   26 |             if(d[ed.from] != INF && d[ed.to] > d[ed.from] + ed.cost){
      |                                     ^
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = LONG_LONG_MAX/4;

int N, M;
int a[1010], b[1010], c[1010];
ll d[1010];
bool negative[1010];
int main() {
    cin>>N>>M;
    REP(i,0,M){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
        c[i] = -c[i];
    }
    REP(i,0,N){
        d[i] = inf;
    }
    d[0] = 0;
    REP(j,0,N-1){
        REP(i,0,M){
            if(d[a[i]]==inf) continue;
            d[b[i]] = min(d[b[i]], d[a[i]] + c[i]);
        }
    }
    REP(j,0,N-1){
        REP(i,0,M){
            if(d[a[i]]==inf) continue;
            if(d[b[i]] > d[a[i]] + c[i]){
                d[b[i]] = d[a[i]] + c[i];
                negative[b[i]]=true;
            }
            if(negative[a[i]]) negative[b[i]]=true;
        }
    }
    if(negative[N-1]) p("inf");
    else p(-d[N - 1]);
    return 0;
}

Compiler output:
a.cc:22:16: error: 'LONG_LONG_MAX' was not declared in this scope
   22 | const ll inf = LONG_LONG_MAX/4;
      |                ^~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = LLONG_MAX;
const ll MAX_E = 3000;
const ll MAX_V = 2000;

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

edge es[MAX_E];

ll d[MAX_V];
ll V, E;

bool solve(int s) {
	for (int i = 0; i < V; i++)d[i] = -INF;
	d[s] = 0;
	ll cnt = 0;
	while (true) {
		bool update = false;
		cnt++;
		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 (cnt >= V-1 && e.to == V - 1)return false;
			}
		}
		if (!update)break;
		if (cnt > V * 3 + 10) return true;

	}
	return true;
}

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

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

Compiler output:
a.cc:19:16: error: 'LLONG_MAX' was not declared in this scope
   19 | const ll INF = LLONG_MAX;
      |                ^~~~~~~~~
a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <set>
  +++ |+#include <climits>
   12 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

vector<pair<int,ll> > v[1100];
int n,m;
ll ans = -1e15;

void search(int a,ll s){
  if(a==n)
    ans = max(ans,s);

  rep(i,v[a].size()){
    search(v[a][i].first,s+v[a][i].second);
  }

}

bool infinity(int a,int c){
  if(c>n) return true;
  bool res = false;

  rep(i,v[a].size()){
    res = res||infinity(v[a][i].first,c+1);
  }

  return res;
}

int main(){
  cin>>n>>m;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    pair<int,ll> p = make_pair<int,ll>(b,c);
    v[a].push_back(p);
  }

  if(infinity(1,1))
    cout<<"inf"<<endl;

  else{
    search(1,(ll)0);
    cout<<ans<<endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:40: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   43 |     pair<int,ll> p = make_pair<int,ll>(b,c);
      |                                        ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

vector<pair<int,ll> > v[1100];
int n,m;
ll ans = -1e15;

void search(int a,ll s){
  if(a==n)
    ans = max(ans,s);

  rep(i,v[a].size()){
    search(v[a][i].first,s+v[a][i].second);
  }

}

bool infinity(int a,int c){
  if(c>n) return true;
  bool res = false;

  rep(i,v[a].size()){
    res = res||infinity(v[a][i].first,c+1);
  }

  return res;
}

int main(){
  cin>>n>>m;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    v[a].push_back(make_pair<int,ll>(b,c));
  }

  if(infinity(1,1))
    cout<<"inf"<<endl;

  else{
    search(1,(ll)0);
    cout<<ans<<endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:38: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
   43 |     v[a].push_back(make_pair<int,ll>(b,c));
      |                                      ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
struct edge{
    int v; //行き先
    ll d; //重み
};
#define inf 1e15
#define MAX_N 1000
ll dis[MAX_N];
vector<edge> G[MAX_N];

int main(){
    int N,M;
    scanf("%d %d",&N,&M);
    REP(i,M){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        G[a-1].push_back((edge){b-1,-c});
    }
    REP(i,N) dis[i] = inf;
    dis[0] = 0;
    REP(i,N-1){
        REP(u,N){
            REP(j,G[u].size()){
                ll v = G[u][j].v;
                if(dis[u] < inf && dis[v] > dis[u]+G[u][j].d){
                    dis[v] = dis[u] + G[u][j].d;
                }
            }
        }
    }//ベルマンフォード法
    bool isNcycle[N_MAX] = {};
    REP(u,N){
        if(!isNcycle){
            REP(j,G[u].size()){
                ll v = G[u][j].v;
                if(dis[u] < inf && dis[v] > dis[u]+G[u][j].d){
                    isNcycle[v] = true;
                }
            }
        }
    } //NEGATIVE CYCLEチェック
    if(isNcycle[N-1]) cout <<  "inf" << endl;
    else cout << -dis[N-1] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:19: error: 'N_MAX' was not declared in this scope; did you mean 'NL_NMAX'?
   37 |     bool isNcycle[N_MAX] = {};
      |                   ^~~~~
      |                   NL_NMAX
a.cc:39:13: error: 'isNcycle' was not declared in this scope
   39 |         if(!isNcycle){
      |             ^~~~~~~~
a.cc:48:8: error: 'isNcycle' was not declared in this scope
   48 |     if(isNcycle[N-1]) cout <<  "inf" << endl;
      |        ^~~~~~~~
Language: C++

#include <iostream>
#include <climits>
#define INF (LLONG_MAX>>2);
using namespace std;

typedef long long ll;

const int nlimit=1005;
int n, m;
int a[nlimit], b[nlimit];
ll c[nlimit];

void solve();
int main(){
  cin >> n >> m;
  ll tempc;
  for(int i=1; i<=m; i++){
    cin >> a[i] >> b[i] >> tempc;
    c[i] = -tempc;
  }

  solve();

  return 0;
}

void solve(){
  ll dist[n];
  for(int i=1; i<=n; i++) dist[i] = INF;
  dist[1] = 0;

  for(int i=1; i<=n-1; i++){
    for(int j=1; j<=m; j++){
      if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){
        dist[b[j]] = dist[a[j]] + c[j];
      }
    }
  }

  bool isNeg[n+1];
  for(int i=1; i<=n; i++) isNeg[i] = false;

  for(int i=1; i<=n; i++){
    for(int j=1; j<=m; j++){
      if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){
        isNeg[b[j]] = true;
      }

      if(isNeg[a[j]]) isNeg[b[j]] = true;
    }
  }

  cout << ((isNeg[n])? "inf": to_string(-dist[n])) << endl;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:34:33: error: expected ')' before '[' token
   34 |       if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){
      |         ~                       ^
      |                                 )
a.cc:45:33: error: expected ')' before '[' token
   45 |       if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){
      |         ~                       ^
      |                                 )
a.cc:34:29: error: label 'dist' used but not defined
   34 |       if(dist[a[j]]!=INF && dist[b[j]] > dist[a[j]] + c[j]){
      |                             ^~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,m,a,b,i,cnt=0;
	ll c,d[1234],ans;
	vector<E> g;
	E e;
	bool update,flag = true,done[1234];
	fill(d,d+1234,INFLL);
	fill(done,done+1234,false);
	cin >> n >> m;
	d[1] = 0ll;
	done[1] = true;
	for(i=0; i<m; ++i){
		cin >> a >> b >> c;
		g.push_back(E(-c,P(a,b)));
	}
	while(true){
		update = false;
		for(i=0; i<m; ++i){
			e = g[i];
			if(done[e.from] && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				done[e.to] = true;
				update = true;
			}
		}
		if(!update || cnt>n){
			break;
		}
		cnt++;
	}
	ans = -d[n];
	fill(d,d+1234,0ll);
	fill(done,done+1234,false);
	cnt = 0;
	while(true){
		update = false;
		for(i=0; i<m; ++i){
			e = g[i];
			if(d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				done[e.to] = true;
				update = true;
			}
		}
		if(!update || cnt>n){
			break;
		}
		cnt++;
	}
	if(done[n]){
		cout << "inf" << endl;
	}else{
		cout << ans << endl;
	}
	}
	return 0;
}

Compiler output:
a.cc:74:9: error: expected unqualified-id before 'return'
   74 |         return 0;
      |         ^~~~~~
a.cc:75:1: error: expected declaration before '}' token
   75 | }
      | ^
Language: C++

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


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

const long long inf = 1e18;
long long n, m; 

bool has_neg_loop(long long n, const vector<Edge> &edges) {
    bool f = false;
    vector<long long> dist(n,0);
    for (int i=0; i<n; i++) {
        for (auto e: edges) {
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i==n-1) f |= true;
            }
        }
    }
    return f;    
}

vector<long long> 
bellman_ford(vector<long long> &dist, const vector<Edge> &edges) {
    for (int i=0; i<n; i++) {
        for (auto e: edges) {
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }
    return dist;    
}

int main () {
    cin >> n >> m;
    vector<Edge> edges(m);
    for (auto &e: edges) {
        int f, t, c; cin >> f >> t >> c;
        e = {f-1, t-1, -c};
    }
    vector<long long> distance(n, inf);
    distance[0] = 0;

    distance = bellman_ford(distance, edges);
    assert(distance[n-1] != INF);
    if (has_neg_loop(n, edges)) {
        cout << "inf" << endl;
    } else {
        cout << -1*distance[n-1] << endl;
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:53:29: error: 'INF' was not declared in this scope
   53 |     assert(distance[n-1] != INF);
      |                             ^~~
a.cc:53:5: error: 'assert' was not declared in this scope
   53 |     assert(distance[n-1] != INF);
      |     ^~~~~~
a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    3 | #include <utility>
  +++ |+#include <cassert>
    4 | using namespace std;