Language: C++

using System;
using System.Collections.Generic;
class Program{
	static List<long>[] li;
	static int[] hf;
	static int k=0;
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] h=new long[s[0]+1];
		hf=new int[s[0]+1];
		for(int i=1;i<=s[0];i++){h[i]=long.MinValue;}
		h[1]=0;
		long[][] arr=new long[s[1]][];
		for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}

		int l=0,z=0;
		bool b=true;
		while(b&&l<=s[0]){
			l++;
			b=false;
			for(int i=0;i<s[1];i++){
				if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){
					h[arr[i][1]]=h[arr[i][0]]+arr[i][2];
					b=true;
					if(l==s[0]){hf[arr[i][1]]=1;z++;}
				}
			}
		}
		if(z>0){
			li=new List<long>[s[0]+1];
			for(int i=1;i<=s[0];i++){li[i]=new List<long>();}
			for(int i=0;i<s[1];i++){li[arr[i][1]].Add(arr[i][0]);}
			fu(s[0]);
		}
		Console.WriteLine("{0}",k>0?"inf":h[s[0]].ToString());
	}
	static void fu(long n){
		k+=hf[n];
		hf[n]=2;
		for(int i=0;i<li[n].Count;i++){
			if(hf[li[n][i]]<2){fu(li[n][i]);}
		}
	}
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:4:16: error: 'List' does not name a type
    4 |         static List<long>[] li;
      |                ^~~~
a.cc:5:19: error: expected unqualified-id before '[' token
    5 |         static int[] hf;
      |                   ^
a.cc:6:20: error: ISO C++ forbids in-class initialization of non-const static member 'Program::k'
    6 |         static int k=0;
      |                    ^
a.cc:44:2: error: expected ';' after class definition
   44 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Program::Main()':
a.cc:8:21: error: structured binding declaration cannot have type 'long int'
    8 |                 long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
      |                     ^~
a.cc:8:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:8:21: error: empty structured binding declaration
a.cc:8:24: error: expected initializer before 's'
    8 |                 long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
      |                        ^
a.cc:9:21: error: structured binding declaration cannot have type 'long int'
    9 |                 long[] h=new long[s[0]+1];
      |                     ^~
a.cc:9:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:9:21: error: empty structured binding declaration
a.cc:9:24: error: expected initializer before 'h'
    9 |                 long[] h=new long[s[0]+1];
      |                        ^
a.cc:10:17: error: 'hf' was not declared in this scope
   10 |                 hf=new int[s[0]+1];
      |                 ^~
a.cc:10:28: error: 's' was not declared in this scope
   10 |                 hf=new int[s[0]+1];
      |                            ^
a.cc:11:42: error: 'h' was not declared in this scope
   11 |                 for(int i=1;i<=s[0];i++){h[i]=long.MinValue;}
      |                                          ^
a.cc:11:47: error: expected primary-expression before 'long'
   11 |                 for(int i=1;i<=s[0];i++){h[i]=long.MinValue;}
      |                                               ^~~~
a.cc:12:17: error: 'h' was not declared in this scope
   12 |                 h[1]=0;
      |                 ^
a.cc:13:21: error: structured binding declaration cannot have type 'long int'
   13 |                 long[][] arr=new long[s[1]][];
      |                     ^~
a.cc:13:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:13:21: error: empty structured binding declaration
a.cc:13:23: error: expected initializer before '[' token
   13 |                 long[][] arr=new long[s[1]][];
      |                       ^
a.cc:14:41: error: 'arr' was not declared in this scope
   14 |                 for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}
      |                                         ^~~
a.cc:14:48: error: 'Array' was not declared in this scope
   14 |                 for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}
      |                                                ^~~~~
a.cc:14:65: error: 'Console' was not declared in this scope
   14 |                 for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}
      |                                                                 ^~~~~~~
a.cc:14:92: error: expected primary-expression before 'long'
   14 |                 for(int i=0;i<s[1];i++){arr[i]=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}
      |                                                                                            ^~~~
a.cc:22:38: error: 'arr' was not declared in this scope
   22 |                                 if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){
      |                                      ^~~
a.cc:22:50: error: expected primary-expression before 'long'
   22 |                                 if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){
      |                                                  ^~~~
a.cc:22:50: error: expected ')' before 'long'
a.cc:22:35: note: to match this '('
   22 |                                 if(h[arr[i][0]]!=long.MinValue&&h[arr[i][1]]<h[arr[i][0]]+arr[i][2]){
      |                                   ^
a.cc:30:25: error: 'li' was not declared in this scope; did you mean 'l'?
   30 |                         li=new List<long>[s[0]+1];
      |                         ^~
      |                         l
a.cc:30:32: error: 'List' does not name a type
   30 |                         li=new List<long>[s[0]+1];
      |                                ^~~~
a.cc:30:37: error: expected primary-expression before 'long'
   30 |                         li=new List<long>[s[0]+1];
      |                                     ^~~~
a.cc:31:60: error: 'List' does not name a type
   31 |                         for(int i=1;i<=s[0];i++){li[i]=new List<long>();}
      |                                                            ^~~~
a.cc:31:65: error: expected primary-expression before 'long'
   31 |                         for(int i=1;i<=s[0];i++){li[i]=new List<long>();}
      |                                                                 ^~~~
a.cc:32:52: error: 'arr' was not declared in this scope
   32 |                         for(int i=0;i<s[1];i++){li[arr[i][1]].Add(arr[i][0]);}
      |                                                    ^~~
a.cc:35:17: error: 'Console' was not declared in this scope
   35 |                 Console.WriteLine("{0}",k>0?"inf":h[s[0]].ToString());
      |                 ^~~~~~~
a.cc: In static member function 'static void Program::fu(long int)':
a.cc:38:20: error: 'hf' was not declared in this scope
   38 |                 k+=hf[n];
      |                    ^~
a.cc:40:31: error: 'li' was not declared in this scope; did you mean 'i'?
   40 |                 for(int i=0;i<li[n].Count;i++){
      |                               ^~
      |                               i