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

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<pair<ll,ll>,ll>> z(m);
    for (int i = 0; i < m; i++) {
        cin >> z[i].first.first >> z[i].first.second >> z[i].second;
        z[i].first.first--;
        z[i].first.second--;
    }
    vector<ll> point(n, -100000000000000000);
    point[0] = 0;
    for (int iii = 0; iii < n; iii++) {
        for (int i = 0; i < m; i++) {
            point[z[i].first.second] = max(point[z[i].first.second], point[z[i].first.first] + z[i].second);
        }
    }
    for (int iii = 0; iii < n+5; iii++) {
        for (int i = 0; i < m; i++) {
            if (point[z[i].first.second] < point[z[i].first.first] + z[i].second && z[i].first.second == n - 1)point[n - 1] = -1000000000000000000;
            point[z[i].first.second] = max(point[z[i].first.second], point[z[i].first.first] + z[i].second);
        }
    }
    if (point[n - 1] == -1000000000000000000)cout << "inf" << endl;
    else cout << point[n - 1] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:115:39: error: expected '}' at end of input
  115 |     else cout << point[n - 1] << endl;
      |                                       ^
a.cc:92:12: note: to match this '{'
   92 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<pair<ll,ll>,ll>> z(m);
    for (int i = 0; i < m; i++) {
        cin >> z[i].first.first >> z[i].first.second >> z[i].second;
        z[i].first.first--;
        z[i].first.second--;
    }
    vector<ll> point(n, -100000000000000000);
    point[0] = 0;
    for (int iii = 0; iii < n; iii++) {
        for (int i = 0; i < m; i++) {
            point[z[i].first.second] = max(point[z[i].first.second], point[z[i].first.first] + z[i].second);
        }
    }
        for (int i = 0; i < m; i++) {
            if (point[z[i].first.second] < point[z[i].first.first] + z[i].second && point[z[i].first.first] + z[i].second > -10000000000000000)point[n - 1] = -1000000000000000000;
        }
    if (point[n - 1] == -1000000000000000000)cout << "inf" << endl;
    else cout << point[n - 1] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:112:39: error: expected '}' at end of input
  112 |     else cout << point[n - 1] << endl;
      |                                       ^
a.cc:92:12: note: to match this '{'
   92 | int main() {
      |            ^
Language: C++

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

template<typename T> struct WG{
  using P = tuple<int, int, T>;
  int n; T inf = 2000000000000000000;
  vector<bool> negative_loop(n, false);
  vector<P> edges;
  vector<T> ans;
  WG(int n_){
    n = n_;
    ans.resize(n, inf);
  }
  void add_edge(int from, int to, T cost){
    P edge = make_tuple(from, to, cost);
    edges.push_back(edge);
  }
  void bellmanford(int start){
    ans[start] = 0;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < edges.size()*2; ++j){
        int from = get<0>(edges[j]);
        int to = get<1>(edges[j]);
        T cost = get<2>(edges[j]);
        if(ans[from] < inf && ans[to] > ans[from] + cost){
          ans[to] = ans[from] + cost;
          if(i > n-2) negative_loop[to] = true;
        }
      }
    }
  }
};

int main(){
  int n, m; cin >> n >> m;
  WG<long> g(n);
  rep(i, m){
    int a, b; long c; cin >> a >> b >> c; --a; --b;
    g.add_edge(a, b, -1*c);
  }
  g.bellmanford(0);
  if(g.negative_loop[n-1]) cout << "inf\n";
  else cout << g.ans[n-1] * -1<< "\n";
  return 0;
}

Compiler output:
a.cc:8:30: error: 'n' is not a type
    8 |   vector<bool> negative_loop(n, false);
      |                              ^
a.cc:8:33: error: expected identifier before 'false'
    8 |   vector<bool> negative_loop(n, false);
      |                                 ^~~~~
a.cc:8:33: error: expected ',' or '...' before 'false'
a.cc: In function 'int main()':
a.cc:43:21: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   43 |   if(g.negative_loop[n-1]) cout << "inf\n";
      |                     ^
a.cc: In instantiation of 'void WG<T>::bellmanford(int) [with T = long int]':
a.cc:42:16:   required from here
   42 |   g.bellmanford(0);
      |   ~~~~~~~~~~~~~^~~
a.cc:28:23: error: invalid use of member function 'std::vector<bool> WG<T>::negative_loop(int, int) [with T = long int]' (did you forget the '()' ?)
   28 |           if(i > n-2) negative_loop[to] = true;
      |                       ^~~~~~~~~~~~~
Language: C++

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// =================グラフテンプレート==================

// costの部分の型は指定できます
template <typename T>
struct edge {
  int from, to;
  T cost;

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

  // 行き先を代入できる
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  // intにキャスト(?)するとかなんとか
  operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;

template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
using Matrix = vector<vector<T>>;

using UnWeightedGraph = vector<vector<int>>;

// =============ベルマン・フォード法=============
// 負の閉路を検出できます(空のvectorを返します)
// bellman<距離の型>(重み付き辺の集合,頂点数,始点)

template <typename T>
vector<T> bellman_ford(Edges<T> &edges, int V, int s) {
  const auto INF = numeric_limits<T>::max();
  vector<T> dist(V, INF);

  dist[s] = 0;
  for (int i = 0; i < V - 1; i++) {
    for (auto &e : edges) {
      if (dist[e.from] != INF)  // 遷移できるなら
        dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
    }
  }
  for (auto &e : edges) {  // 離島、負の閉路について
    if (dist[e.from] == INF) continue;
    if (dist[e.from] + e.cost < dist[e.to]) return vector<T>();
  }
  return dist;
}

// ====================================================================

int main() {
  int n, m;
  cin >> n >> m;
  
  Edges<ll> edges;
  for (int i = 0; i < m; i++) {
    int s, t;
    ll c;
    cin >> s >> t >> c;
    s--;t--;
    edges.push_back(edge<ll>{s, t, -c});
  }

  vector<ll> ans = bellman_ford(edges, n, 0);

  if (ans.size())
    cout<<-ans[N-1]<<endl;
  else
    cout << "inf" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:82:16: error: 'N' was not declared in this scope
   82 |     cout<<-ans[N-1]<<endl;
      |                ^
Language: C++

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const ll INF = -1e10+7;

struct edge{
    int from;
    int to;
    int c;
};

bool bellman_ford(const ll &s,const ll &V,const ll &E,const vector<edge> &ed, vector<ll> &d){

    // s=スタート, Vが頂点数，Eが辺の数, ed=どのようなパスを持つか, 
    //d=答えを保持するvector．今は１つの経路が欲しいので参照して書き換えているが全ての経路について必要になった場合にはdをreturnするように改造する

    // 初期化
    for(ll i = 0; i < V+1; i++){
        d[i] = INF;
    }

    d[s] = 0;
    while(true){
        //updateが更新されなくなるまでこの操作を繰り返す
        bool update = false;
        for(ll i = 0; i < E; i ++){
            edge e = ed[i];
            if(d[e.from]!=INF && d[e.to]<d[e.from]+ e.c){  // 更新条件を変更
                if(d[e.to]!=INF){ // loopの検出
                    return true;
                }
                d[e.to] = d[e.from]+ e.c;
                update = true;
            }
        }
        if(!update){
            break;
        }
    }
    return false;
}


int main(){

    ll V,E; cin >> V >> E;
    vector<edge> ed(E);
    rep(i,E){
        cin >> ed[i].from >> ed[i].to >> ed[i].c;
    }
    vector<ll> d(V+5); // スタートの頂点番号を0ではなく１としたいので余分に作ってd[0]は使わない
    bool loop = bellman_ford(1, V, E, ed, d);

    if(loop){
        cout << "inf" << endl;
    }else{
        cout << d[V] << endl;
    }
_
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:1: error: '_' was not declared in this scope
   65 | _
      | ^
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll INF = (ll)pow(10, 16);

int main(){
  ll N, M;
  cin >> N >> M;
  vvl abc(M, vl(3));
  rep(i, M){
    cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    abc[i][2] = -abc[i][2];
  }

  vl dist(N + 1, INF);
  dist[0] = dist[1] = 0;
  bool neg(N + 1, false);

  rep(i, N - 1){
    rep(j, M){
      if(dist[abc[j][0]] == INF) continue;
      
      if(dist[abc[j][1]] > dist[abc[j][0]] + abc[j][2]){
		dist[abc[j][1]] = dist[abc[j][0]] + abc[j][2];
      }
    }
  }

  ll ans = -dist[N];

  vector<bool> neg(N + 1, false);

  rep(i, N){
    rep(j, M){
      if(dist[abc[j][0]] == INF) continue;

      if(dist[abc[j][1]] > dist[abc[j][0]] + abc[j][2]){
        dist[abc[j][1]] = dist[abc[j][0]] + abc[j][2];
        neg[abc[j][1]] = true;
      }

      if(neg[abc[j][0]] == true){
		neg[abc[j][1]] = true;
      }
    }
  }

  if(neg[N])
    cout << "inf" << endl;
  else
    cout << ans << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:24: error: expression list treated as compound expression in initializer [-fpermissive]
   27 |   bool neg(N + 1, false);
      |                        ^
a.cc:41:16: error: conflicting declaration 'std::vector<bool> neg'
   41 |   vector<bool> neg(N + 1, false);
      |                ^~~
a.cc:27:8: note: previous declaration as 'bool neg'
   27 |   bool neg(N + 1, false);
      |        ^~~
a.cc:49:12: error: invalid types 'bool[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   49 |         neg[abc[j][1]] = true;
      |            ^
a.cc:52:13: error: invalid types 'bool[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   52 |       if(neg[abc[j][0]] == true){
      |             ^
a.cc:53:20: error: invalid types 'bool[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   53 |                 neg[abc[j][1]] = true;
      |                    ^
a.cc:58:9: error: invalid types 'bool[ll {aka long long int}]' for array subscript
   58 |   if(neg[N])
      |         ^
Language: C++

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

struct edge {
    int from;
    int to;
    long long cost;
};
long long INF = 1e12;

vector<long long> bellman_ford(vector<edge> es, int start_point, int vertex_num) {
    vector<long long> shortest_path(vertex_num, INF);
    shortest_path[start_point] = 0;
    for (int i = 0; i < vertex_num-1; i++) {
        for (int j = 0; j < es.size(); j++) {
            shortest_path[es[j].to] = min(shortest_path[es[j].to], shortest_path[es[j].from]+es[j].cost);
        }
    }
    return shortest_path;
}

bool find_negative_loop(vector<edge> es, int start_point, int vertex_num) {
    vector<long long> shortest_path(vertex_num, INF);
    shortest_path[start_point] = 0;
    for (int i = 0; i < vertex_num; i++) {
        for (int j = 0; j < es.size(); j++) {
            if (shortest_path[es[j].to] > shortest_path[es[j].from]+es[j].cost) {
                shortest_path[es[j].to] = shortest_path[es[j].from]+es[j].cost;
                if (i == vertex_num-1 && es[j].to == vertex_num-1)
                    return true;
            }
        }
    }
    return false;
}

int main(void){
    int N, M;
    cin >> N >> M;
    vector<edge> es(M);
    for (int i = 0; i < M; i++) {
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--;
        es[i].to--;
        es[i].cost = -es[i].cost;
    }
    if (find_negative_loop(es, 0, N))
        cout << "inf";
    else {
        vector<long long> shortest_path = bellman_ford(es, 0, N);
        cout << -shortest_path[N-1]
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:36: error: expected ';' before '}' token
   51 |         cout << -shortest_path[N-1]
      |                                    ^
      |                                    ;
   52 |     }
      |     ~
Language: C++

//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge {
    ll from;
    ll to;
    ll cost;
};

ll V, E, d[1010];
edge es[2010];


bool find_negative_loop() {
    memset(d,0,sizeof(d));
    for (ll i = 0; i < V; i++) {
        for (ll j = 0; j < E; j++) {
            edge e = es[j];
            if (d[e.from]!=INF&&d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (e.to== V - 1) {
                    return true;
                }
            }
        }
    }
    return false;
}
void shortest_path(ll s){
  rep(i,V)d[i]=INF;
  d[s]=0;
  rep(j,V){
    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;
    return;
  }
}
int main(){
  cin>>V>>E;
  rep(i,E){
    ll f,t,c;
    cin>>f>>t>>c;
    es[i].from=f-1;
    es[i].to=t-1;
    es[i].cost=-c;
  }
  shortest_path();
  if(find_negative_loop()){
    cout<<"inf"<<endl;
    return 0;
  }
  rep(j,V){
        rep(i,E){
            edge e=es[i];
            if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                if(e.to==V-1){
                    cout<<"inf"<<endl;
                    return 0;
                }
            }
        }
    }
  //shortest_path(0);
  cout<<-d[V-1]<<endl;
  
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:66:16: error: too few arguments to function 'void shortest_path(ll)'
   66 |   shortest_path();
      |   ~~~~~~~~~~~~~^~
a.cc:41:6: note: declared here
   41 | void shortest_path(ll s){
      |      ^~~~~~~~~~~~~
Language: C++

//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge {
    ll from;
    ll to;
    ll cost;
};

ll V, E, d[1010];
edge es[2010];


bool find_negative_loop() {
    memset(d,0,sizeof(d));
    for (ll i = 0; i < V; i++) {
        for (ll j = 0; j < E; j++) {
            edge e = es[j];
            if (d[e.from]!=INF&&d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (e.to== V - 1) {
                    return true;
                }
            }
        }
    }
    return false;
}
void shortest_path(ll s){
  rep(i,V)d[i]=INF;
  d[s]=0;
  rep(j,V){
    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;
    return;
  }
}
int main(){
  cin>>V>>E;
  rep(i,E){
    ll f,t,c;
    cin>>f>>t>>c;
    es[i].from=f-1;
    es[i].to=t-1;
    es[i].cost=-c;
  }
  //if(find_negative_loop()){
    //cout<<"inf"<<endl;
    //return 0;
  //}
  rep(j,V){
        rep(i,E){
            edge e=es[i];
            if(d[e.from]!=inf&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                if(e.to==V-1){
                    cout<<"inf"<<endl;
                    return;
                }
            }
        }
    }
  shortest_path(0);
  cout<<-d[V-1]<<endl;
  
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:73:27: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   73 |             if(d[e.from]!=inf&&d[e.to]>d[e.from]+e.cost){
      |                           ^~~
      |                           ynf
a.cc:77:21: error: return-statement with no value, in function returning 'int' [-fpermissive]
   77 |                     return;
      |                     ^~~~~~
Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const ll inf=1ll<<60;
typedef int ll;

int main(){
  int n,m; cin >> n >> m;
  vector<tiii> edges;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    edges.emplace_back(a,b,-c);
  }
  vector<ll> dist(n,inf);
  dist[0]=0;
  bool update=true;
  int step=0;
  while(update){
    update=false;
    rep(i,m){
      int a,b; ll c;
      tie(a,b,c)=edges[i];
      if(dist[a]+c<dist[b]){
        update=true;
        dist[b]=dist[a]+c;
      }
    }
    step++;
    if(step>n){
      cout << "inf" << endl;
      return 0;
    }
  }
  cout << -dist[n-1] << endl;
}

Compiler output:
a.cc:15:13: error: conflicting declaration 'typedef int ll'
   15 | typedef int ll;
      |             ^~
a.cc:8:19: note: previous declaration as 'typedef long long int ll'
    8 | typedef long long ll;
      |                   ^~
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 100100100100100

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

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

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


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

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

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

  graph = AdjList(n);

  for (int i = 0; i < m; i++) {
    int from, to;
    ll cost;
    cin >> from >> to >> cost;
    --from; --to;
    cost*=-1;
    graph[from].push_back(Edge(to, cost));
  }
  bellman_ford(n, 0);
  if(d[n-1]=-INF){
    cout << "inf" << endl;
  } else {
    cout << -dist[n-1] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'void bellman_ford(int, int)':
a.cc:39:22: error: expected ';' before '}' token
   39 |             loop=true
      |                      ^
      |                      ;
   40 |           } // n回目にも更新があるなら負の閉路が存在
      |           ~           
a.cc:58:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   58 | int main() {
      |         ^~
a.cc:58:9: note: remove parentheses to default-initialize a variable
   58 | int main() {
      |         ^~
      |         --
a.cc:58:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:58:12: error: a function-definition is not allowed here before '{' token
   58 | int main() {
      |            ^
a.cc:79:2: error: expected '}' at end of input
   79 | }
      |  ^
a.cc:27:33: note: to match this '{'
   27 | void bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
      |                                 ^
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	

	int n,m;

	scanf("%d %d",&n,&m);
	std::vector<tuple<int,int,int>> edges(m);
	for(int i=0,a,b,c;i<m;i++)scanf("%d %d %d",&a,&b,&c),edges[i]={a,b,c};

	std::vector<ll> dist(n+1,-1e18);
	
	dist[1]=0;
	for(int i=1;i<n;i++){
		for(auto e : edges){
			int a,b,c;
			tie(a,b,c) = e;
			if(dist[b]<dist[a]+c){
				dist[b]=dist[a]+c;
			}
		}

	}

	for(auto e : edges){
		int a,b,c;
		tie(a,b,c) = e;

		if(b==n && dist[n]<dist[a]+c){
			return !printf("inf\n");
		}	
	}

	printf("%lld\n",dist[n] );
}		


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::tuple<int, int, int>]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	

	int n,m;

	scanf("%d %d",&n,&m);
	std::vector<tuple<ll,ll,ll>> edges(m);
	for(int i=0,a,b,c;i<m;i++)scanf("%lld %lld %lld",&a,&b,&c),edges[i]={a,b,c};

	std::vector<ll> dist(n+1,-1e18);
	
	dist[1]=0;
	for(int i=1;i<n;i++){
		for(auto e : edges){
			ll a,b,c;
			tie(a,b,c) = e;
			if(dist[b]<dist[a]+c){
				dist[b]=dist[a]+c;
			}
		}

	}

	for(auto e : edges){
		int a,b,c;
		tie(a,b,c) = e;

		if(b==n && dist[n]<dist[a]+c){
			return !printf("inf\n");
		}	
	}

	printf("%lld\n",dist[n] );
}		


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::tuple<long long int, long long int, long long int>]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAX_V 1000
#define MAX_E 2000
#define INF 1e9
struct edge {
  int from, to, cost;
};
int V, E, d[MAX_V];
edge es[MAX_E];
bool find_negative_loop(int s)
{
    int cnt = 0;
    for (int i = 0; i < V; i++) {
	d[i] = INF;
    }
    d[s] = 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;
		if (cnt == V) {
                    return true;
                }
		update = true;
	    }
	}
	if (!update) {
            break;
        }
    }
    return false;
}

int main()
{
    int r=0;
    cin >> V >> E;
    for (int i = 0; i < E; i++) {
	cin >> es[i].from >> es[i].to >> es[i].cost;
      es[i].from--; es[i].to--;
      es[i].cost=-es[i].cost;
    }
    if (find_negative_loop(r)) {
	cout << "inf" << endl;
    } else {
      cout << d[V-1] << endl;
	}
    }
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2000 + 5;
const ll oo = 0x3f3f3f3f3f3f3f3f;
int N, M;
ll d1, d2;
int main(){
	while (cin >> N >> M){
		vector<int>a(M);
		vector<int>b(M);
		vector<ll>c(M);
		for (int i = 0; i < M; i++){
			cin >> a[i] >> b[i] >> c[i];
			a[i]--,	b[i]--;
		}
		vector<ll>d(N, -oo);
		d[0] = 0LL;
		for (int i = 0; i < 2 * N; i++){
			for (int j = 0; j < M; j++){
				d[b[j]] = max(d[b[j]], d[a[j]] + c[j]);
			}
			if (i == N - 1)d1 = d[N - 1];
			if (i == 2 * N - 1)d2 = d[N - 1];
		}
		if (d1 == d2)cout << d1 << endl;
		else cout << "inf" << endl;
	}


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

#include "pch.h"
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {

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

	vector<ll> d(n, BIG_NUM);
	d[0] = 0;
	bool isInf = false;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n;j++) {
			for (pii e : g[j]) {
				if (d[e.first] > d[j] + e.second) {
					d[e.first] = d[j] + e.second;
					if (i == n - 1) {
						isInf = true;
					}

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





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

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll max_E=100000;
const ll max_V=100000;
ll INF=9000000000000000000;

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

edge es[max_E];
ll dist[max_V];
ll N,M;
bool negative[max_V];

void shortest_path(ll s){
    fill(negative,negative+N,0);
    for(int i=0;i<N;i++) dist[i]=INF;//INFを作る
    dist[s]=0;
    for(int loop=0;loop<N-1;loop++){
        for(int i=0;i<M;i++){
            edge e=es[i];
            if(dist[e.from]==INF) continue;
            if(dist[e.from]!=INF&&dist[e.to]>dist[e.from]+e.cost){
                dist[e.to]=dist[e.from]+e.cost;
            }
        }
    }
}

void find_negative_loop(){
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(dist[e.from]==INF) continue;
            edge e=es[j];
            if(dist[e.to]>dist[e.from]+e.cost){
                dist[e.to]=dist[e.from]+e.cost;
                negative[e.to]=1;
            }
            if(negative[e.from]) negative[e.to]=1;
        }
    }
}

int main(){
    cin>>N>>M;
    for(ll i=0;i<M;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        es[i].from=a;
        es[i].to=b;
        es[i].cost=-c;
    }
    shortest_path(0);
    find_negative_loop();
    if(negative[N-1]) cout<<"inf"<<endl;
    else{
        cout<<-dist[N-1]<<endl;
    }
}

Compiler output:
a.cc: In function 'void find_negative_loop()':
a.cc:53:21: error: 'e' was not declared in this scope
   53 |             if(dist[e.from]==INF) continue;
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct BellmanFord {
private:
    struct Edge { int from, to, cost; };
    vector<Edge> edges;
    int n;
    
public:
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<bool> negative;
    
    BellmanFord() {}
    BellmanFord(int _n) {
        n = _n;
        dist.resize(n);
        negative.resize(n);
    }
    
    void add_edge(int from, int to, int cost) {
        edges.push_back((Edge){from, to, cost});
    }
    
    void get_distance(int from) {
        for (int i = 0; i < n; i++) {
            dist[i] = inf;
            negative[i] = false;
        }
        dist[from] = 0;
        for (int i = 0; i < (n - 1); 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;
                    update = true;
                }
            }
        }
        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;
                    negative[e.from] = negative[e.to] = true;
                }
            }
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    BellmanFord<ll> bf(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bf.add_edge(a, b, -c);
    }
    bf.get_distance(0);
    if (bf.negative[n - 1]) {
        cout << "inf" << endl;
    }
    else {
        cout << (-bf.dist[n - 1]) << endl;
    }
    return 0;
}


Compiler output:
a.cc: In member function 'void BellmanFord<T>::get_distance(int)':
a.cc:45:21: error: 'update' was not declared in this scope
   45 |                     update = true;
      |                     ^~~~~~
Language: C++


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

typedef long long ll;
//Number unexplored line, INF = infinity
const ll INF = 1LL << 50;

int main(void){
    
    //문제에서 주어진 노드와 간선의 최대수
    const int NMAX = 1005;
    const int MMAX = 2005;
    
    //Number of Node, N and Roads, M
    int N, M;
    cin >> N >> M;
    
    //각각의 노드 사이의 비중과 경로 dist
    vector< pair<int, int> > Node[MMAX];
    ll dist[NMAX]; fill_n(dist, sizeof(dist), INF);
    
    //노드와 노드사이를 연결하는 입력이 주어진다
    for(int i = 0; i < M; i++){
        int node1, node2, weight; 
        cin >> node1 >> node2 >> weight;
        Node[node1].emplace_back(node2, weight);
    }
    
    //최단경로는 순환을 포함해서는 안되므로
    //최단경로의 최대 길이는 N-1
    //즉, N 이상이 된다면 음수사이클이 생기므로 멈춰야함
    //간선의 최대수는 M^2까지 생기므로 시간복잡도는 N^3
    
    int Start_Point = 1;
    int End_Point = N-1;
    
    //자기자신까지의 최단경로는 0
    dist[Start_Point] = 0;
    bool Cycle = 0;
    
    //N-1번 루프. N번째는 사이클 확인
    for(int i = 1; i <= N; i++){
        //N-1번 루프에 걸쳐서 각 노드가 i개의 정점을 거쳐오는 최단경로 갱신
        for(int j = 1; j <= N; j++){
            for(auto &fd : Node[j]){
                //아직 
                if(dist[j] == INF) continue;
                if(dist[j] + fd.second < dist[fd.first]){
                    dist[fd.first] = fd.second + dist[j];
                    if (i == N) Cycle = TRUE;
                }
            }
        }
        
    }
    
    if(Cycle == TRUE) cout << "inf" << endl;
    else cout << dist[End_Point];
    
}



Compiler output:
a.cc: In function 'int main()':
a.cc:51:41: error: 'TRUE' was not declared in this scope
   51 |                     if (i == N) Cycle = TRUE;
      |                                         ^~~~
a.cc:58:17: error: 'TRUE' was not declared in this scope
   58 |     if(Cycle == TRUE) cout << "inf" << endl;
      |                 ^~~~
Language: C++

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

typedef long long ll;
//Number unexplored line, INF = infinity
const ll INF = 1LL << 50;

int main(void){
    
    //문제에서 주어진 노드와 간선의 최대수
    const int NMAX = 1005;
    const int MMAX = 2005;
    
    //Number of Node, N and Roads, M
    int N, M;
    cin >> N >> M;
    
    //각각의 노드 사이의 비중과 경로 dist
    vector< pair<int, int> > Node[MMAX];
    ll dist[NMAX]; fill_n(dist, sizeof(dist), INF);
    
    //노드와 노드사이를 연결하는 입력이 주어진다
    for(int i = 0; i < M; i++){
        int node1, node2, weight; 
        cin >> node1 >> node2 >> weight;
        Node[node1].emplace_back(node2, weight);
    }
    
    //최단경로는 순환을 포함해서는 안되므로
    //최단경로의 최대 길이는 N-1
    //즉, N 이상이 된다면 음수사이클이 생기므로 멈춰야함
    //간선의 최대수는 M^2까지 생기므로 시간복잡도는 N^3
    
    int Start_Point = 1;
    int End_Point = N-1;
    
    //자기자신까지의 최단경로는 0
    dist[Start_Point] = 0;
    bool Cycle = 0;
    
    //N-1번 루프. N번째는 사이클 확인
    for(int i = 1; i <= N; i++){
        //N-1번 루프에 걸쳐서 각 노드가 i개의 정점을 거쳐오는 최단경로 갱신
        for(int j = 1; j <= N; j++){
            for(auto &fd : Node[j]){
                //아직 
                if(dist[j] == INF) continue;
                if(dist[j] + fd.second < dist[fd.first]){
                    dist[fd.first] = fd.second + dist[j];
                    if (i == N) Cycle = True;
                }
            }
        }
        
    }
    
    if(Cycle == True) cout << "Cycle" << endl;
    else cout << dist[End_Point];
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:41: error: 'True' was not declared in this scope
   50 |                     if (i == N) Cycle = True;
      |                                         ^~~~
a.cc:57:17: error: 'True' was not declared in this scope
   57 |     if(Cycle == True) cout << "Cycle" << endl;
      |                 ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;//ベルマンとかはllにしよ
//ここ十分にしないとだめ
#define INF 1000000000000

struct Edge{
  ll to_Node;
  ll cost;
  Edge(ll t,ll c){to_Node=t;cost=c;}
};

//関係ないループを外す
bool bellmanford(vector< vector<Edge> >& Edges,vector<ll>& mincost,ll n){
  //(l1-1)(普通のbellman)+1(検出)
  for(ll i=0;i<n;i++){
    f=false;
    for(ll j=0;j<n;j++){
      if(mincost[j]!=INF){
        ll e=Edges[j].size();
        for(ll k=0;k<e;k++){
          ll new_mincost=mincost[j]+Edges[j][k].cost;
          if(mincost[Edges[j][k].to_Node]>new_mincost){
            mincost[Edges[j][k].to_Node]=new_mincost;
            if(i==n-1 and Edges[j][k].to_Node==n-1)return true;
          }
        }
      }
    }
  }
  return false;//負の閉路があればtrue
}

int main(){
  ll n,m;cin >> n >> m;
  vector<ll> mincost(n,INF);
  vector< vector<Edge> > Edges(n);
  //mincost0の更新だけしっかりやる
  mincost[0]=0;

  for(ll i=0;i<m;i++){
    ll a,b,c;cin >> a >> b >> c;
    Edges[a-1].push_back(Edge(b-1,-c));
  }
  //Nodesを更新
  if(bellmanford(Edges,mincost,n)){
    cout << "inf" << endl;
  }else{
    cout << -mincost[n-1] << endl;
  }

}


Compiler output:
a.cc: In function 'bool bellmanford(std::vector<std::vector<Edge> >&, std::vector<long long int>&, ll)':
a.cc:20:5: error: 'f' was not declared in this scope
   20 |     f=false;
      |     ^
Language: C++

#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;//ベルマンとかはllにしよ
//ここ十分にしないとだめ
#define INF 1000000000000

struct Node{
  //ノードの情報
  vector<pair<ll,ll>> edge;//各エッジの接続先のノード番号とコスト
  //ベルマンフォード法用のデータ
  ll mincost=INF;//そのノードへの最小コスト
};

//関係ないループを外す
bool bellmanford(vector<Node>& nodes,ll l1){
  //(l1-1)(普通のbellman)+1(検出)
  for(ll i=0;i<l1;i++){
    for(ll j=0;j<l1;j++){
      Node x=nodes[j];
      if(x.mincost!=INF){
        ll l2=x.edge.size();
        for(ll k=0;k<l2;k++){
          ll a=x.mincost+x.edge[k].second;
          if(nodes[x.edge[k].first].mincost>a){
            nodes[x.edge[k].first].mincost=a;
            if(i==l-1 and x.edge[k].first==l-1) return true;
          }
        }
      }
    }
  }
  return false;//負の閉路があればtrue
}

int main(){
  ll n,m;cin >> n >> m;
  vector<Node> Nodes(n);
  //mincost0の更新だけしっかりやる
  Nodes[0].mincost=0;

  for(ll i=0;i<m;i++){
    ll a,b,c;cin >> a >> b >> c;
    Nodes[a-1].edge.push_back(make_pair(b-1,-c));
  }
  //Nodesを更新
  if(bellmanford(Nodes,n)){
    cout << "inf" << endl;
  }else{
    cout << -Nodes[n-1].mincost << endl;
  }

}


Compiler output:
a.cc: In function 'bool bellmanford(std::vector<Node>&, ll)':
a.cc:29:19: error: 'l' was not declared in this scope
   29 |             if(i==l-1 and x.edge[k].first==l-1) return true;
      |                   ^
Language: C++

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

template <typename T>
struct edge{
    int from, to;
    T cost;
    edge(int from, int to, T cost = 1) : from(from), to(to), cost(cost){}
    bool operator < (const edge & e) const{
        return cost < e.cost;
    }
};

/*
    sからたどりつける負の閉路を検出したとき、空の vector を返す
    頂点数 V, 始点 s, 辺の集合 es, INF として LINF を使うとき : 
    vector<ll> dist = BellmanFord(V, s, es, LINF);
*/
template <typename T>
vector<T> BellmanFord(int V, int s, vector<edge<T>> & es, const T INF = 1e9){
    int E = es.size();
    vector<T> dist(V, INF);
    dist[s] = 0;
    for(int i = 0; i < V - 1; i++){
        for(edge<T> & e : es){
            if(dist[e.from] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
        }
    }
    for(edge<T> & e : es){
        if(dist[e.from] == INF) continue;
        if(dist[e.from] + e.cost < dist[e.to] && e.to == n - 1) return vector<T>();
    }
    return dist;
}

//グラフ全体をみて、負の閉路が存在するとき true を返す
template <typename T>
bool FindNegativeLoop(int V, vector<edge<T>> & es){
    vector<T> dist(V, 0);
    for(int i = 0; i < V; i++){
        for(edge<T> & e : es){
            if(dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                if(i == V - 1) return true;
            }
        }
    }
    return false;
}

signed main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    ll c;
    vector<edge<ll>> es;
    REP(i,m){
        cin >> a >> b >> c;
        a--;
        b--;
        es.emplace_back(a, b, -c);
    }
    vector<ll> dist = BellmanFord(n, 0, es, LINF);
    if(dist.size() > 0) cout << -dist[n - 1] << endl;
    else cout << "inf" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'std::vector<_Tp> BellmanFord(int, int, std::vector<edge<T> >&, T)':
a.cc:39:58: error: 'n' was not declared in this scope
   39 |         if(dist[e.from] + e.cost < dist[e.to] && e.to == n - 1) return vector<T>();
      |                                                          ^
Language: C++

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

template <typename T>
struct edge{
    int from, to;
    T cost;
    edge(int from, int to, T cost = 1) : from(from), to(to), cost(cost){}
    bool operator < (const edge & e) const{
        return cost < e.cost;
    }
};

/*
    sからたどりつける負の閉路を検出したとき、空の vector を返す
    頂点数 V, 始点 s, 辺の集合 es, INF として LINF を使うとき : 
    vector<ll> dist = BellmanFord(V, s, es, LINF);
*/
template <typename T>
vector<T> BellmanFord(int V, int s, vector<edge<T>> & es, const T INF = 1e9){
    int E = es.size();
    vector<T> dist(V, INF);
    dist[s] = 0;
    for(int i = 0; i < V - 1; i++){
        for(edge<T> & e : es){
            if(dist[e.from] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
        }
    }
    for(edge<T> & e : es){
        if(dist[e.from] == INF) continue;
        if(dist[e.from] + e.cost < dist[e.to]) return vector<T>();
    }
    return dist;
}

//グラフ全体をみて、負の閉路が存在するとき true を返す
template <typename T>
bool FindNegativeLoop(int V, vector<edge<T>> & es){
    vector<T> dist(V, 0);
    for(int i = 0; i < V; i++){
        for(edge<T> & e : es){
            if(dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                if(i == V - 1) return true;
            }
        }
    }
    return false;
}

signed main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    ll c;
    vector<edge<ll>> es;
    REP(i,m){
        cin >> a >> b >> c;
        a--;
        b--;
        es.emplace_back(a, b, -c);
    }
    vector<ll> dist = BellmanFord(n, 0, es, 1e15);
    if(dist.size()) cout << -dist[n - 1] << endl;
    else cout << "inf" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:34: error: no matching function for call to 'BellmanFord(int&, int, std::vector<edge<long long int> >&, double)'
   71 |     vector<ll> dist = BellmanFord(n, 0, es, 1e15);
      |                       ~~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:27:11: note: candidate: 'template<class T> std::vector<_Tp> BellmanFord(int, int, std::vector<edge<T> >&, T)'
   27 | vector<T> BellmanFord(int V, int s, vector<edge<T>> & es, const T INF = 1e9){
      |           ^~~~~~~~~~~
a.cc:27:11: note:   template argument deduction/substitution failed:
a.cc:71:34: note:   deduced conflicting types for parameter 'T' ('long long int' and 'double')
   71 |     vector<ll> dist = BellmanFord(n, 0, es, 1e15);
      |                       ~~~~~~~~~~~^~~~~~~~~~~~~~~~