Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
 
struct Z2 {
	public int x, y;
	public Z2(int x, int y){
		this.x = x; this.y = y;
	}
}
struct Z3 {
	public int x, y, z;
	public Z3(int x, int y, int z){
		this.x = x; this.y = y; this.z = z;
	}
}
 
public class A {
	
	int MAX_N = 100008;
	int N,M;
	List<Z2>[] edges;
    
	
	public A(){
		edges = new List<Z2>[MAX_N];
		for(int i=0;i<MAX_N;i++) edges[i] = new List<Z2>();
	}
	
	string[] Rs(){
		return Console.ReadLine().Split(' ');
	}
	public void run(){
		string[] str = Rs();
		N = int.Parse(str[0]); M = int.Parse(str[1]);
		for(int i=0;i<M;i++){
			int[] inp = Rs().Select( x => int.Parse(x)-1 ).ToArray();
			edges[ inp[0] ].Add( new Z2(inp[1],inp[2]) );
			edges[ inp[1] ].Add( new Z2(inp[0],inp[2]) );
        }
        edges[N-1].Add(new Z2(N-1,-1));
		
        Dictionary<Z2, int> dis = new Dictionary<Z2,int>();
        LinkedList<Z3> que = new LinkedList<Z3>();
		
		que.AddLast(new Z3(0, -1, 0) ); 
		dis.Add(new Z2(0,-1), 0);
		
        
        Z2 end = new Z2(N-1,-1);
        
        
		while(que.Count != 0){
			Z3 n = que.First(); que.RemoveFirst();
            Z2 n2 = new Z2(n.x, n.y);
			if(dis.ContainsKey(end)){ 
				Console.WriteLine(dis[end]-1);
				return;
			}
            if(dis[n2] < n.z) continue;
            foreach(Z2 e in edges[n.x]){
                Z3 e3 = new Z3(e.x, e.y, dis[n2]);
                if(e.y == n.y){
                    if(!dis.ContainsKey(e)){
                        dis.Add(e, dis[n2]);
                        que.AddFirst(e3);
                    } else if(dis[n2] < dis[e]){
                        dis[e] = dis[n2];
                        que.AddLast(e3);
                    }
                } else {
                    e3.z += 1;
                    if(!dis.ContainsKey(e)){
                        dis.Add(e, e3.z);
                        que.AddLast(e3);
                    } else if(dis[n2]+1 < dis[e]){
                        dis[e] = e3.z;
                        que.AddLast(e3);
                    }
                }
            }
		} 
		Console.WriteLine("-1");
	}
}
 
public class Program {
	static void Main(string[] args){
		A a = new A();
		a.run();
	}
}

Compiler output:
a.cc:4:1: error: extended character   is not valid in an identifier
    4 |  
      | ^
a.cc:17:1: error: extended character   is not valid in an identifier
   17 |  
      | ^
a.cc:86:1: error: extended character   is not valid in an identifier
   86 |  
      | ^
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:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:1: error: '\U000000a0' does not name a type
    4 |  
      | ^
a.cc:12:15: error: expected ':' before 'int'
   12 |         public int x, y, z;
      |               ^~~~
      |               :
a.cc:13:15: error: expected ':' before 'Z3'
   13 |         public Z3(int x, int y, int z){
      |               ^~~
      |               :
a.cc: In constructor 'Z3::Z3(int, int, int)':
a.cc:14:22: error: request for member 'x' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?)
   14 |                 this.x = x; this.y = y; this.z = z;
      |                      ^
a.cc:14:34: error: request for member 'y' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?)
   14 |                 this.x = x; this.y = y; this.z = z;
      |                                  ^
a.cc:14:46: error: request for member 'z' in '(Z3*)this', which is of pointer type 'Z3*' (maybe you meant to use '->' ?)
   14 |                 this.x = x; this.y = y; this.z = z;
      |                                              ^
a.cc: At global scope:
a.cc:18:1: error: expected initializer before 'public'
   18 | public class A {
      | ^~~~~~
a.cc:86:1: error: '\U000000a0' does not name a type
   86 |  
      | ^