Language: C++

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

vector<int> cost;
vector<pair<int,int>> edge;
vector<int> node;

bool bellman_ford(int n,int s) {
	node = vector<int>(node.size(),INF);
	node[s] = 0;
	REP (i,n) {
		REP (j,edge.size()) {
			int from = edge[j],to = edge[j];
			if (node[from] != INF && node[to] > node[from] + cost[j]) {
				node[to] = node[from] + cost[j];
				if (i == n - 1) return true;
			}
		}
	}
	return false;
}

signed main() {
	int n,m;
	cin >> n >> m;
	node = vector<int>(n);
	cost = vector<int>(m);
	edge = vector<pair<int,int>>(m);
	REP (i,m) {
		cin >> edge[i].F >> edge[i].S >> cost[i];
		edge[i].F--;edge[i].S--;
		edge[i].F *= (-1);edge[i].S *= (-1);
	}
	if (bellman_ford(0,n)) {
		cout << "inf" << endl;
	} else {
		cout << -cost[n-1] << endl;
	}
}

Compiler output:
a.cc:110:23: error: 'std::vector<std::pair<long long int, long long int> > edge' redeclared as different kind of entity
  110 | vector<pair<int,int>> edge;
      |                       ^~~~
a.cc:32:35: note: previous declaration 'typedef struct std::pair<long long int, std::pair<long long int, long long int> > edge'
   32 | typedef pair<int, pair<int, int>> edge;
      |                                   ^~~~
a.cc: In function 'bool bellman_ford(long long int, long long int)':
a.cc:117:28: error: expected primary-expression before '.' token
  117 |                 REP (j,edge.size()) {
      |                            ^
a.cc:9:41: note: in definition of macro 'FOR'
    9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                                         ^
a.cc:117:17: note: in expansion of macro 'REP'
  117 |                 REP (j,edge.size()) {
      |                 ^~~
a.cc:118:40: error: expected primary-expression before '[' token
  118 |                         int from = edge[j],to = edge[j];
      |                                        ^
a.cc:119:55: error: 'to' was not declared in this scope; did you mean 'tm'?
  119 |                         if (node[from] != INF && node[to] > node[from] + cost[j]) {
      |                                                       ^~
      |                                                       tm
a.cc: In function 'int main()':
a.cc:133:14: error: expected unqualified-id before '=' token
  133 |         edge = vector<pair<int,int>>(m);
      |              ^
a.cc:135:28: error: expected primary-expression before '[' token
  135 |                 cin >> edge[i].F >> edge[i].S >> cost[i];
      |                            ^
a.cc:135:41: error: expected primary-expression before '[' token
  135 |                 cin >> edge[i].F >> edge[i].S >> cost[i];
      |                                         ^
a.cc:136:21: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'}
  136 |                 edge[i].F--;edge[i].S--;
      |                     ^~~
a.cc:136:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:136:22: error: redeclaration of 'auto i'
  136 |                 edge[i].F--;edge[i].S--;
      |                      ^
a.cc:134:14: note: 'long long int i' previously declared here
  134 |         REP (i,m) {
      |              ^
a.cc:9:29: note: in definition of macro 'FOR'
    9 | #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                             ^
a.cc:134:9: note: in expansion of macro 'REP'
  134 |         REP (i,m) {
      |         ^~~
a.cc:136:24: error: expected initializer before '.' token
  136 |                 edge[i].F--;edge[i].S--;
      |                        ^
a.cc:136:24: error: expected ';' before '.' token
a.cc:136:33: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'}
  136 |                 edge[i].F--;edge[i].S--;
      |                                 ^~~
a.cc:136:33: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:136:36: error: expected initializer before '.' token
  136 |                 edge[i].F--;edge[i].S--;
      |                                    ^
a.cc:137:21: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'}
  137 |                 edge[i].F *= (-1);edge[i].S *= (-1);
      |                     ^~~
a.cc:137:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:137:24: error: expected initializer before '.' token
  137 |                 edge[i].F *= (-1);edge[i].S *= (-1);
      |                        ^
a.cc:137:39: error: structured binding declaration cannot have type 'edge' {aka 'std::pair<long long int, std::pair<long long int, long long int> >'}
  137 |                 edge[i].F *= (-1);edge[i].S *= (-1);
      |                                       ^~~
a.cc:137:39: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:137:42: error: expected initializer before '.' token
  137 |                 edge[i].F *= (-1);edge[i].S *= (-1);
      |                                          ^