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

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 4e5 + 100;
using ll = long long;
const int M = 1e9 + 7;
vector<pair<int,int> >v1[maxn], v3[maxn], v2[maxn];
int tot = 0;
int vis[maxn];
void dij(int st,int en)
{
    static int dis[maxn];
    for(int i = 0;i <= tot; ++i) dis[i] = inf,vis[i] = 0;
    priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int>> >q;
    dis[st] = 0;
    q.push({0,st});
    while(!q.empty())
    {
        pair<int,int> tp = q.top();
        q.pop();
        vis[tp.second] = 0;
        for(auto &u:v3[tp.second])
        {
            if(dis[u.first] > dis[tp.second] + u.second)
            {
                dis[u.first] = dis[tp.second] + u.second;
                if(!vis[u.first]) 
                vis[u.first] = 1, q.push({dis[u.first],u.first});
            }
        }
    }
    int ans = dis[en];
    if(ans==inf) ans = -2;
    printf("%d\n",ans/2);
}
int main()
{
  //  freopen("1.in","r",stdin);
 //   freopen("1.out","w",stdout);
    int n, m;
  //  clock_t c1 = clock(),c2;int mx = 0;
    while (~scanf("%d%d",&n,&m))
    {
        tot = 0;
        for(int i = 1; i <= m; ++i){
            int x,y,c;
            scanf("%d %d %d",&x, &y, &c);
            v1[x].push_back({y,c});
            v2[x].push_back({c,0});
            v2[y].push_back({c,0});
        }
        tot = n;
        for(int i = 1;i <= n; ++i){
            sort(v2[i].begin(),v2[i].end());
            v2[i].erase(unique(v2[i].begin(),v2[i].end()),v2[i].end());
            for(auto &u:v2[i])
                u.second = ++tot;
        }
        for(int i = 1;i <= n; ++i){
            for(auto &u:v2[i]){
                v3[u.second].push_back({i,1});
                v3[i].push_back({u.second,1});
            }
            for(auto &u:v1[i]){
                int x = u.first,c = u.second;
                int p = lower_bound(v2[x].begin(),v2[x].end(),make_pair(c,0)) - v2[x].begin();
                p = v2[x][p].second;
                int p2 = lower_bound(v2[i].begin(),v2[i].end(),make_pair(c,0)) - v2[i].begin();
                p2 = v2[i][p2].second;
                v3[p].push_back({p2,0});
                v3[p2].push_back({p,0});
            }
        }
        dij(1,n);
        for(int i = 0;i <= tot; ++i) 
        {
            v1[i].clear();v2[i].clear();v3[i].clear();
        }
       mx = max(mx,tot);
    }
   // c2 = clock();
    //cout<<(c2-c1)/1000.0<<" "<<mx<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:8: error: 'mx' was not declared in this scope; did you mean 'm'?
   79 |        mx = max(mx,tot);
      |        ^~
      |        m
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define MAXN 500000
#define INF 0x3FFFFFFF
using namespace std;
struct edge
{
	int u,v,w;
	edge(){};
	edge(int _u,int _v,int _w):u(_u),v(_v),w(_w){};
};
struct state
{
	int u,dist;
	state(){};
	state(int _u,int _dist):u(_u),dist(_dist){};
};
bool operator < (edge a,edge b){return a.w<b.w;}
bool operator < (state a,state b){return a.dist<b.dist;}
priority_queue<state> que;
vector<edge> edges;
vector<int> G[MAXN+5];
vector<int> need;
int setfa[MAXN+5],imcnt,img[MAXN+5],dist[MAXN+5];
bool vis[MAXN+5];
void Init1()
{
	for(int i=0;i<=MAXN;i++)
		setfa[i]=i;
}
void Init(int N)
{
	if(imcnt==0)
		for(int i=0;i<=MAXN;i++)
			dist[i]=INF,G[i].clear();
	else
		for(int i=0;i<=imcnt;i++)
			dist[i]=INF,G[i].clear();
	edges.clear();
	imcnt=N;
}
inline int Findfa(int x)
{
	if(x==setfa[x])
		return x;
	return setfa[x]=Findfa(setfa[x]);
}
inline void Union(int x,int y)
{
	int fx=Findfa(x),fy=Findfa(y);
	if(fx==fy)
		return;
	setfa[fx]=fy;
}
inline void Set(int x)
{
	if(vis[x]==true)
		return;
	vis[x]=true;
	img[x]=++imcnt;
}
int Dijkstra(int ed)
{
	while(que.empty()==false)	que.pop();
	que.push(state(1,0));
	dist[1]=0;
	while(que.empty()==false)
	{
		int u=que.top().u;
		int dn=que.top().dist;
		que.pop();
		if(dist[u]!=dn)
			continue;
		if(u==ed)
			return dn;
		for(int i=0;i<(int)G[u].size();i++)
		{
			int v=G[u][i];
			if(dist[v]>dn+1)
			{
				dist[v]=dn+1;
				que.push(state(v,dist[v]));
			}
		}
	}
}
inline read()
{
	char c=0;
	int ret=0;
	while(c<'0'||c>'9')	c=getchar();
	ret=c-'0';
	while(true)
	{
		c=getchar();
		if(c<'0'||c>'9')	break;
		else				ret=10*ret+c-'0';
	}
	return ret;
}
int main()
{
	int N,M;
	Init1();
	scanf("%d %d",&N,&M);
		Init(N);
		int a,b,c;
		for(int i=1;i<=M;i++)
		{
			a=read(),b=read(),c=read();
			edges.push_back(edge(a,b,c));
			Union(a,b);
		}
		if(Findfa(1)!=Findfa(N))
		{
			printf("-1\n");
			return 0;
		}
		for(int i=0;i<=N;i++)
			setfa[i]=i;
		sort(edges.begin(),edges.end());
		for(int i=0;i<=(int)edges.size();i++)
		{
			if(i==(int)edges.size()||(i!=0&&edges[i].w!=edges[i-1].w))
			{
				for(int j=0;j<(int)need.size();j++)
				{
					Set(Findfa(need[j]));
					img[need[j]]=img[Findfa(need[j])];
					G[need[j]].push_back(img[need[j]]);
					G[img[need[j]]].push_back(need[j]);
				}
				for(int j=0;j<(int)need.size();j++)
					vis[need[j]]=false,setfa[need[j]]=need[j];
				need.clear();
			}
			if(i<(int)edges.size())
			{
				need.push_back(edges[i].u);
				need.push_back(edges[i].v);
				Union(edges[i].u,edges[i].v);
			}
		}
		int ans=Dijkstra(N);
		printf("%d\n",ans/2);
//	}
	return 0;
}

Compiler output:
a.cc:90:8: error: ISO C++ forbids declaration of 'read' with no type [-fpermissive]
   90 | inline read()
      |        ^~~~
a.cc: In function 'int Dijkstra(int)':
a.cc:89:1: warning: control reaches end of non-void function [-Wreturn-type]
   89 | }
      | ^
Language: C++

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

const int N = 1e5 + 5;
const int inf = 2e9;

int n, m;
vector<int> adj[N], col[N], imp[N];
vector<int> f[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int u, v, c; cin >> u >> v >> c;
		col[u].push_back(c), col[v].push_back(c);
		imp[u].push_back(adj[v].size()), imp[v].push_back(adj[u].size());
		adj[u].push_back(v), adj[v].push_back(u); 
	}
	
	for (int i = 1; i <= n; ++i) {
		f[i].assign(adj[i].size(), (i == 1 ? 1 : inf));
	}
	
	priority_queue<pair<int, pair<int,int> > , vector<pair<int, pair<int,int> > >, greater<pair<int, pair<int,int> > > > pq;
	for (int i = 0; i < adj[1].size(); ++i) pq.push({1, {1, i}});
	
	while (!pq.empty()) {
		auto cur = pq.top(); pq.pop();
		int u = cur.second.first, id = cur.second.second;
		if (f[u][id] != cur.first) continue;
		if (u == n) return cout << f[u][id] << '\n';
		for (int i = 0; i < adj[u].size(); ++i) {
			int nu = adj[u][i], nid = imp[u][i];
			int add = 1;
			if (col[u][id] == col[nu][nid]) add = 0;
			if (f[nu][nid] > f[u][id] + add) {
				f[nu][nid] = f[u][id] + add;
				pq.push({f[nu][nid], {nu, nid}});
			}
		} 
	} 
	cout << -1 << '\n';
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:32:53: error: cannot convert 'std::basic_ostream<char>' to 'int' in return
   32 |                 if (u == n) return cout << f[u][id] << '\n';
      |                                    ~~~~~~~~~~~~~~~~~^~~~~~~
      |                                                     |
      |                                                     std::basic_ostream<char>
Language: C++

#include <bits/stdc++.h>
#include <time.h>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <unordered_map>
using namespace std::tr1;
using namespace std;
/* cau troi cho Garena nhap de con Bach */
#define FSYNC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second

#define cur fi.fi
#define com fi.se
#define val se
#define pb push_back
#define mp make_pair
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define lb lower_bound
#define pob pop_back
#define ub upper_bound
#define ite ::iterator
#define db(x) {cout <<"#db " << x << endl;}
#define here() {cout <<"here \n";}
#define mod 1000000007
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;
const int _MOD = 998244353;
const int N = 1e5 + 2;

int fpow(int x,int y) {int res=1;while(y){if(y&1)res=res*x%MOD;x=x*x%MOD;y>>=1;}return res;}
int inverse(int x){return fpow(x,MOD-2);}
int n, m;
vii g[N];
unordered_map<ii,int> lead;
int leadcnt = 0;
int state[4*N];
queue<pair<ii,int> >q;
int ans = inf;
// cur - comp - val
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i = 0 ; i < m ; i ++){
		int u,v,c;cin >> u >> v >> c;
		g[u].pb(mp(v,c));
		g[v].pb(mp(u,c));
	}
	for(int i = 0 ; i < 4*N ; i ++) state[i] = inf;
	q.push(mp(mp(1,0),0));
	lead[ii(1,0)] = ++leadcnt;state[1] = 0;
	while(q.size()){
		int u = q.front().cur;
		int comp = q.front().com;
		int low = q.front().val;
		q.pop();
		if(low > state[lead[ii(u,comp)]]) continue;
		if(u == n){
			if(low < ans) ans = low;
			continue;
		} 
		for(ii v:g[u]){
			if(!lead[ii(v.fi,v.se)]){
				lead[ii(v.fi,v.se)] = ++leadcnt;
				state[leadcnt] = low + (v.se != comp);
				
				q.push(mp(v,low + (v.se != comp)));
			}else{
				if(low + (v.se != comp) < state[lead[v]]){
					state[lead[v]] = low + (v.se != comp);
					q.push(mp(v,low + (v.se != comp)));
				}
			}
		}
	}
	if(ans != inf) cout << ans;
	else cout << -1;
	return 0;
}


Compiler output:
a.cc:40:1: error: reference to 'unordered_map' is ambiguous
   40 | unordered_map<ii,int> lead;
      | ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/unordered_map.h:109:11: note: candidates are: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::unordered_map'
  109 |     class unordered_map
      |           ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/tr1/unordered_map:44,
                 from a.cc:3:
/usr/include/c++/14/tr1/unordered_map.h:180:11: note:                 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::tr1::unordered_map'
  180 |     class unordered_map
      |           ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:55:9: error: 'lead' was not declared in this scope; did you mean 'read'?
   55 |         lead[ii(1,0)] = ++leadcnt;state[1] = 0;
      |         ^~~~
      |         read
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <deque>
#define inf 0x3F3F3F3F
using namespace std;
struct Node
{
	int x,c;
};
deque<Node>q;
unordered_map<int,vector<int> >e[100005];
unordered_map<int,int>d[100005];
vector<int>g[100005];
int main(void)
{
	int i,x,y,c,cost,n,m,ans=inf;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d%d",&x,&y,&c);
		e[x][c].push_back(y);
		e[y][c].push_back(x);
		g[x].push_back(c);
		g[y].push_back(c);
	}
	d[0][0]=0;q.push_back((Node){1,0});
	while(!q.empty())
	{
		x=q.front().x;c=q.front().c;cost=d[x][c];q.pop_front();
		if(d[x].find(0)==d[x].end()||d[x][0]>cost)
		{
			d[x][0]=cost;q.push_front((Node){x,0});
		}
		if(c==0)
		{
			for(i=1;i<g[x].size();++i)
			{
				y=g[x][i];
				if(d[x].find(y)==d[x].end()||d[x][y]>cost+1)
				{
					d[x][y]=cost+1;q.push_back((Node){x,y});
				}
			}
			continue;
		}
		for(i=0;i<e[x][c].size;++i)
		{
			y=e[x][c][i];
			if(d[y].find(c)==d[y].end()||d[y][c]>cost)
			{
				d[y][c]=cost;q.push_front((Node){y,c});
			}
		}
	}
	unordered_map<int,int>::iterator j;
	for(j=d[n].begin();j!=d[n].end();++j)ans=min(ans,j->second);
	if(ans!=inf)printf("%d\n",ans);
	else printf("-1\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:35: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   50 |                 for(i=0;i<e[x][c].size;++i)
      |                                       ()
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <deque>
#define inf 0x3F3F3F3F
using namespace std;
struct Node
{
	int x,c;
};
deque<Node>q;
unordered_map<int,vector<int> >e[100005];
unordered_map<int,int>d[100005];
int main(void)
{
	int i,x,y,c,cost,n,m,ans=inf;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d%d",&x,&y,&c);
		e[x][c].push_back(y);
		e[y][c].push_back(x);
		g[x].push_back(c);
		g[y].push_back(c);
	}
	d[0][0]=0;q.push_back((Node){1,0});
	while(!q.empty())
	{
		x=q.front().x;c=q.front().c;cost=d[x][c];q.pop_front();
		if(d[x].find(0)==d[x].end()||d[x][0]>cost)
		{
			d[x][0]=cost;q.push_front((Node){x,0});
		}
		if(c==0)
		{
			for(i=1;i<g[x].size();++i)
			{
				y=g[x][i];
				if(d[x].find(y)==d[x].end()||d[x][y]>cost+1)
				{
					d[x][y]=cost+1;q.push_back((Node){x,y});
				}
			}
			continue;
		}
		for(i=0;i<e[x][c].size;++i)
		{
			y=e[x][c][i];
			if(d[y].find(c)==d[y].end()||d[y][c]>cost)
			{
				d[y][c]=cost;q.push_front((Node){y,c});
			}
		}
	}
	unordered_map<int,int>::iterator j;
	for(j=d[n].begin();j!=d[n].end();++j)ans=min(ans,j->second);
	if(ans!=inf)printf("%d\n",ans);
	else printf("-1\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: 'g' was not declared in this scope
   26 |                 g[x].push_back(c);
      |                 ^
a.cc:39:35: error: 'g' was not declared in this scope
   39 |                         for(i=1;i<g[x].size();++i)
      |                                   ^
a.cc:49:35: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   49 |                 for(i=0;i<e[x][c].size;++i)
      |                                       ()
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <queue>
#define inf 0x3F3F3F3F
using namespace std;
struct Node
{
	mutable int x,c,cost;
	operator int&()const{return cost;}
};
priority_queue<Node,vector<Node>,greater<Node> >q;
unordered_map<int,vector<int> >e[100005];
unordered_map<int,int>d[100005];
vector<int>g[100005];
int main(void)
{
	int i,x,y,c,cost,n,m,k,ans=inf;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d%d",&x,&y,&c);
		e[x][c].push_back(y);
		e[y][c].push_back(x);
		g[x].push_back(c);
		g[y].push_back(c);
	}
	d[0][0]=0;q.push((Node){0,0,0});
	while(!q.empty())
	{
		x=q.top().x;c=q.top().c;cost=q.top().cost;q.pop();
		if(d[x][c]!=cost)continue;
		if(d[x].find(0)==d[x].end()||d[x][0]>cost)
		{
			d[x][0]=cost;q.push((Node){x,0,cost});
		}
		if(c==0)
		{
			for(i=0;i<g[x].size();++i)
			{
				y=g[x][i];
				if(d[x].find(y)==d[x].end()||d[x][y]>cost+1)
				{
					d[x][y]=cost+1;q.push((Node){x,y,cost+1});
				}
			}
			continue;
		}
		for(i=0;i<e[x][c].size();++i)
		{
			y=e[x][c][i];
			if(d[y].find(c)==d[y].end()||d[y][c]>cost)
			{
				d[y][c]=cost;q.push((Node){y,c,cost});
			}
		}
	}
	for(i=0;i<d[n].size();++i)ans=min(ans,d[n][i].second);
	if(ans!=inf)printf("%d\n",ans);
	else printf("-1\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:55: error: request for member 'second' in 'd[n].std::unordered_map<int, int>::operator[](i)', which is of non-class type 'std::unordered_map<int, int>::mapped_type' {aka 'int'}
   61 |         for(i=0;i<d[n].size();++i)ans=min(ans,d[n][i].second);
      |                                                       ^~~~~~
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 2e6 + 5;
queue <int> que;
int n, m, dis[maxn];
vector <int> g[maxn], all[maxn];
unordered_map <int, vector <int> > g1[maxn];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i ++) {
		int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		u --; v --;
		g1[u][c].push_back(v);
		g1[v][c].push_back(u);
		all[c].push_back(u);
		all[c].push_back(v);
	}
	int cc = n;
	for (int c = 1; c <= 1000000; c ++) {
		sort(all[c].begin(), all[c].end());
		all[c].erase(unique(all[c].begin(), all[c].end()), all[c].end());
		for (int i = 0; i < (int) all[c].size(); i ++) {
			if (dis[all[c][i]] == c) continue;
			que.push(all[c][i]);
			while (!que.empty()) {
				int u = que.front(); que.pop();
				dis[u] = c;
				g[u].push_back(cc);
				g[cc].push_back(u);
				for (int i = 0; i < (int) g1[u][c].size(); i ++) {
					int v = g1[u][c][i];
					if (dis[v] != c) {
						que.push(v);
					}
				}
			}
			cc ++;
		}
	}
	memset(dis, -1, sizeof dis);
	dis[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int u = que.front();
		que.pop();
		for (int i = 0; i < (int) g[u].size(); i ++) {
			int v = g[u][i];
			if (!~dis[v]) {
				dis[v] = dis[u] + 1;
				que.push(v);
			}
		}
	}
	printf("%d\n", !~dis[n - 1] ? -1 : dis[n - 1] / 2);
	return 0;
}



Compiler output:
a.cc:14:1: error: 'unordered_map' does not name a type
   14 | unordered_map <int, vector <int> > g1[maxn];
      | ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:22:17: error: 'g1' was not declared in this scope; did you mean 'g'?
   22 |                 g1[u][c].push_back(v);
      |                 ^~
      |                 g
a.cc:39:59: error: 'g1' was not declared in this scope; did you mean 'g'?
   39 |                                 for (int i = 0; i < (int) g1[u][c].size(); i ++) {
      |                                                           ^~
      |                                                           g
Language: C++

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:1
*Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip
*Date:2018-7-14
*Algorithm:BFS Tourist's
*Stats:Unknown*/

bool debug=false;



template<typename T> struct undispose_queue{
	vector<T> v;
	int s;
	
	undispose_queue(){
		s=0;
		v.clear();
	}
	
	void push(T value){
		v.push_back(value);
	}
	void pop(){
		s++;
	}
	
	T front(){
		return v[s];
	}
	
	void clear(){
		v.clear();
		s=0;
	}
	
	bool empty(){
		return s==v.size();
	}
	
	int size(){
		return v.size()-s;
	}
	
	vector<T> getData(){
		return v;
	}
};

const int A=2e6+1;
const int B=2e5+1;
int n,m;

map<int,vector<int>> nei[B];

int col[B];

set<int> cols;
vector<int> on[A];

vector<int> nnei[A];

int dis[A];

int main(int argc,char* argv[]){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		nei[a][c].push_back(b);
		nei[b][c].push_back(a);
		on[c].push_back(a);
		on[c].push_back(b);
		cols.insert(c);
	}
	
	if(debug)cout<<"ok"<<endl;
	
	memset(col,-1,sizeof(col));
	
	int stpos=n;
	
	for(set<int>::iterator it=cols.begin();it!=cols.end();it++){
		int thscol=*it;
		if(debug)cout<<thscol<<endl;
		
		for(int i=0;i<on[thscol].size();i++){
			int thspos=on[thscol][i];
			if(col[thspos]==thscol){
				continue; //In the same block
			}
			
			undispose_queue<int> uq;
			col[thspos]=thscol;
			uq.push(thspos);
			
			while(!uq.empty()){
				
				int last=uq.front();
				uq.pop();
				
				for(int j=0;j<nei[last][thscol].size();j++){
					int nxtpos=nei[last][thscol][j];
					if(col[nxtpos]!=thscol){
						col[nxtpos]=thscol;
						uq.push(nxtpos);
					}
				}
			}
			
			vector<int> v=uq.getData();
			
			for(int j=0;j<v.size();j++){
				nnei[v[j]].push_back(stpos);
				nnei[stpos].push_back(v[j]);
				
				if(debug)cout<<"connected "<<v[j]<<" and "<<stpos<<endl;
			}
			
			stpos++;
		}
		
	}
	
	
	if(debug)cout<<"bfs"<<endl;
	
	queue<int> q;
	
	fill(dis,dis+FUCK,-2);
	dis[0]=0;
	q.push(0);
	while(!q.empty()){
		int last=q.front();
		q.pop();
		
		for(int i=0;i<nnei[last].size();i++){
			if(dis[nnei[last][i]]==-2){
				dis[nnei[last][i]]=dis[last]+1;
				q.push(nnei[last][i]);
			}
		}
	}
	
	cout<<dis[n-1]/2;
	return 0;
}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:157:22: error: 'FUCK' was not declared in this scope
  157 |         fill(dis,dis+FUCK,-2);
      |                      ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
#define mp make_pair
#define pb push_back
using namespace std;
int n, m, p[300000], q[300000], c[300000], ans[300000], nodeans[300000], expanded[300000];
vector< vector<int> > graph(300000);
map< pair<int, int>, int> m1;
vector< vector< pair<int, int> > > c_edge(1100000);
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> p[i] >> q[i] >> c[i];
		graph[p[i]].push_back(i);
		graph[q[i]].push_back(i);
		c_edge[c[i]].push_back(make_pair(p[i], q[i]));
		c_edge[c[i]].push_back(make_pair(q[i], p[i]));
		ans[i] = 1e9;
		m1[mp(p[i], c[i])] = 1e9;
		m1[mp(q[i], c[i])] = 1e9;
	}

	for (int i = 1; i <= 1e6; i++)
		sort(c_edge[i].begin(), c_edge[i].end());

	for (int i = 1; i <= n; i++)
	{
		nodeans[i] = 1e6;
		m1[mp(i, 0)] = 1e9;
	}
	
	priority_queue< pair<int, pair<int, int> > > pq;
	pq.push(mp(-1, mp(1, 0))); 
	m1[mp(1, 0)] = 1;
	while (!pq.empty())
	{
		pair<int, pair<int, int> > temp = pq.top(); pq.pop();
		int node = temp.second.first, mode = temp.second.second;
		//cout << temp.first << " " << temp.second.first << " " << temp.second.second << endl;
		if (-temp.first != m1[mp(node, mode)])
		{
			continue;
		}
		nodeans[node] = min(nodeans[node], -temp.first);
		if (node == n)
			break;
		if (mode == 0)
		{
			for (int i = 0; i < graph[node].size(); i++)
			{
				int edgenum = graph[node][i];
				if (m1[mp(node, c[edgenum])] < -temp.first)
					continue;
				int node2 = p[edgenum];
				if (node2 == node)
					node2 = q[edgenum];
				if (m1[mp(node2, c[edgenum])] > -temp.first)
				{
					m1[mp(node2, c[edgenum])] = -temp.first;
					pq.push(mp(temp.first, mp(node2, c[edgenum])));
				}
				if (m1[mp(node2, 0)] > -temp.first+1)
				{
					m1[mp(node2, 0)] = -temp.first+1;
					pq.push(mp(temp.first-1, mp(node2, 0)));
				}
			}
		}
		else
		{
			int index = lower_bound(c_edge[mode].begin(), c_edge[mode].end(), mp(node, -1)) - c_edge[mode].begin();
			while (index < c_edge[mode].size())
			{
				pair<int, int> temp2 = c_edge[mode][index++];
				if (temp2.first != node)
					break;
				if (m1[mp(temp2.second, mode)] > -temp.first)
				{
					m1[mp(temp2.second, mode)] = -temp.first;
					pq.push(mp(temp.first, mp(temp2.second, mode)));
				}
				if (m1[mp(temp2.second, 0)] > -temp.first+1)
				{
					m1[mp(temp2.second, 0)] = -temp.first + 1;
					pq.push(mp(temp.first - 1, mp(temp2.second, 0)));
				}
			}
		}
	}
	if (nodeans[n] == 1e6)
		nodeans[n] = -1;
	cout << nodeans[n] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   30 |                 sort(c_edge[i].begin(), c_edge[i].end());
      |                 ^~~~
      |                 short
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
int MOD=1000000000+7;
int INF=1e6;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n,m,visited[110000]={};
    queue<pii> v[110000];
    cin>>n>>m;
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        v[a].push({b,c});
        v[b].push({a,c});
    }
    int num=1;
    queue<int> now;
    now.push(1);
    visited[1]=1;
    while(!now.empty()){
        int t=now.size();
        rep(i,t){
            int a=now.front();
            now.pop();
            int s=v[a].size();
            rep(j,s){
                int d=v[a].front().first;
                int c=v[a].front().second.first;
                v[a].pop();
                visited[d]=1;
                now.push(d);
                queue<int> q;
                q.push(d);
                while(!q.empty()){
                    int f=q.front();
                    q.pop();
                    int h=v[f].size();                    
                    rep(ii,v[f].size()){
                        if(v[f].front().second==c){
                            if(!visited[v[f].front().first]) now.push(v[f].front().first);
                            q.push(v[f].front().first);
                            visited[v[f].front().first]=1;
                            v[f].pop();
                        }
                        else{
                            v[f].push(v[f].front());
                            v[f].pop();
                        }
                    }
                }
            }
        }
        if(visited[n]){
            cout<<num;
            return 0;
        }
        num++;
    }
    cout<<-1;
    return 0;
    
}

Compiler output:
a.cc:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:35:43: error: request for member 'first' in 'v[a].std::queue<std::pair<int, int> >::front().std::pair<int, int>::second', which is of non-class type 'int'
   35 |                 int c=v[a].front().second.first;
      |                                           ^~~~~
Language: C++

#include<bits/stdc++.h>
#define INF 0x7fffffff
#define ll long long
#define P pair<int,int>
#define MP(a,b) make_pair(a,b)
using namespace std;
P q[100005];
int n,m,dis[100005],head,tail,t,h[100005];
struct E{int v,c,next;}g[400005];
void ins(int u,int v,int c){g[++t].v=v,g[t].c=c,g[t].next=h[u],h[u]=t;}
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	memset(dis,0x3f,sizeof dis); dis[1]=0;
	n=read(),m=read();
	for(int i=1;i<=m;++i){
		int u,v,c;
		u=read(),v=read(),c=read();
		ins(u,v,c); ins(v,u,c);
	}
	q[++tail]=MP(0,1);
	while(head<=tail){
		int u=q[++head].second,lc=q[head].first;
		for(int j=h[u];j;j=g[j].next){
			int v=g[j].v,c=g[j].c,d=dis[u]+((lc==c)?0:1);
			if(d>=dis[v]) continue;
			q[++tail]=MP(c,v);
			dis[v]=d;
		}
	}
	printf("%d",dis[n]==1061109567?-1:dis[]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:47: error: expected primary-expression before ']' token
   35 |         printf("%d",dis[n]==1061109567?-1:dis[]);
      |                                               ^
Language: C++

#include<bits/stdc++.h>
#define MAXN 1000010 
#define MAXM 1000010 
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;

int read()
{
	int res=0; char ch=getchar();
	while(ch<'0' || ch>'9') ch=getchar();
	while(ch>='0' && ch<='9')
	{
		res=res*10+ch-'0'; ch=getchar();
	}
	return res;
}

struct Edge
{
	int from,to,next,com;
	Edge(){}
	Edge(int u,int v,int n,int c):from(u),to(v),next(n),com(c){}
};

struct Node
{
	int d,u;
	bool operator < (const Node &rhs) const
	{
		return d>rhs.d;
	}
};

int n,m,cnt;
Edge edges[MAXM];
int head[MAXN],tot,vis[MAXN],dis[MAXN];
vector<int> comp[MAXN],G[MAXN];

void AddEdge(int u,int v,int com)
{
	edges[tot]=Edge(u,v,head[u],com);
	head[u]=tot++;
	edges[tot]=Edge(v,u,head[v],com);
	head[v]=tot++;
}

set<int> dict;

void init()
{
	tot=0;
	for(int i=1;i<=n;++i) head[i]=-1;
}

void dijkstra(int s)
{
	for(int i=1;i<=n+cnt) dis[i]=INF,vis[i]=0;
	priority_queue<Node> q;
	dis[s]=0;
	q.push((Node){0,s});
	while(!q.empty())
	{
		Node x=q.top(); q.pop();
		int u=x.u;
		if(vis[u]) continue;
		vis[u]=1;
		int len=G[u].size();
		for(int i=0;i!=len;++i)
		{
			int v=G[u][i];
			if(dis[v]>dis[u]+1)
			{
				dis[v]=dis[u]+1;
				q.push((Node){dis[v],v});
			}
		}
	}
}

int main()
{
	n=read(),m=read();
	init();
	for(int i=0;i!=m;++i)
	{
		int u,v,com;
		u=read(),v=read(),com=read();
		AddEdge(u,v,com);
		comp[com].push_back(u);
		comp[com].push_back(v);
		dict.insert(com);
	}
	for(set<int>::iterator it=dict.begin();it!=dict.end();++it)
	{
		int com=*it;
		int len=comp[com].size();
		for(int i=0;i!=len;++i)
		{
			int u=comp[com][i];
			if(vis[u]==com) continue;
			vis[u]=com;
			queue<int> q;
			q.push(u);
			++cnt;
			while(!q.empty())
			{
				int u=q.front(); q.pop();
				for(int j=head[u];~j;j=edges[j].next)
				{
					Edge &e=edges[j];
					if(e.com!=com) continue;
					if(vis[e.to]!=com)
					{
						vis[e.to]=com; q.push(e.to);
					}
				}
				G[u].push_back(n+cnt);
				G[n+cnt].push_back(u);
			}
		}
	}
	dijkstra(1);
	int ans;
	if(dis[n]==INF) ans=-1;
	else ans=dis[n]/2;
	printf("%d\n",ans);
}

Compiler output:
a.cc: In function 'void dijkstra(int)':
a.cc:58:29: error: expected ';' before ')' token
   58 |         for(int i=1;i<=n+cnt) dis[i]=INF,vis[i]=0;
      |                             ^
      |                             ;
Language: C++

https://docs.google.com/spreadsheets/d/1NMzLiCHgiEkSukTvFjiH0vxunr4-XT1XRAihKIleq3g/htmlview?sle=true#

Compiler output:
a.cc:1:1: error: 'https' does not name a type
    1 | https://docs.google.com/spreadsheets/d/1NMzLiCHgiEkSukTvFjiH0vxunr4-XT1XRAihKIleq3g/htmlview?sle=true#
      | ^~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

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

constexpr ll INF = 1e18;

struct node {
    ll n;
    ll c;
    node (ll n, ll c) : n(n), c(c) {}
};

/*
struct route {
    node to;
    ll cost;

    route(node to, ll cost) : to(to), cost(cost) {}
};
*/

ll N, M;
                         // vectorだとかぶりが発生してダメなはず
vector<unordered_map<ll, unordered_map<ll, unordered_set<ll> > > > G;
vector<unordered_map<ll, ll> > dist;
queue<p> que;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M;

    G = vector<unordered_map<ll, unordered_map<ll, unordered_set<ll> > > >(N + 1);
    dist = vector<unordered_map<ll, ll> >(N + 1);

    for (ll i = 0; i < M; i++) {
        ll p, q, c;
        cin >> p >> q >> c;
        // move in same campanies
        G[p][c][q].insert(c);
        G[q][c][p].insert(c);

        // exit and enter
        G[p][c][p].insert(0);
        G[p][0][p].insert(c);
        G[q][c][q].insert(0);
        G[q][0][q].insert(c);

        dist[p][0] = INF;
        dist[q][0] = INF;
        dist[p][c] = INF;
        dist[q][c] = INF;
    }

    que.push(make_pair(1, 0));
    dist[1][0] = 0;
    while (!que.empty()) {
        auto token = que.front(); que.pop();
        
        for (auto Q : G[token.first][token.second]) {
            auto q = Q.first;
            for (auto c : Q.second) {
                ll newcost = dist[token.first][token.second];
                if (token.second == 0) {
                    newcost++;
                }

                if (newcost < dist[q][c]) {
                    dist[q][c] = newcost;
                    que.push(make_pair(q, c));
                }
            }
        }
    }
    
    cout << (dist[N][0] == INF ? "-1" : dist[N][0]) << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:92:32: error: operands to '?:' have different types 'const char*' and 'std::unordered_map<long long int, long long int>::mapped_type' {aka 'long long int'}
   92 |     cout << (dist[N][0] == INF ? "-1" : dist[N][0]) << endl;
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> G(N);
    map<pair<int, int>, bool> vis;
    for(int i=0; i<M; i++){
        int p, q, c;
        cin >> p >> q >> c;
        p--; q--;
        G[p].push_back(make_pair(q, c));
        G[q].push_back(make_pair(p, c));
    }
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> wsc;
    wsc.push(make_tuple(0, 0, 0));
    vector<int> d(N, 1<<30);
    while(!wsc.empty()){
        int w, s, c;
        tie(w, s, c) = wsc.top();
        wsc.pop();
        d[s] = min(d[s], w);

        for(auto sc : G[s]){
            int tt = sc.first;
            int cc = sc.second;
            if(vis[make_pair(tt, cc)]) continue;
            vis[make_pair(tt, cc)] = true;
            if(c == cc)
                wsc.push(make_tuple(w, tt, cc));
            else
                wsc.push(make_tuple(w+1, tt, cc));
        }
    }
    if(d[N-1] == 1<<30) cout << -1 << endl;
    else cout << d[N-1] << endl;
    cerr << cnt << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   43 |     cerr << cnt << endl;
      |             ^~~
      |             int
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> G(N);
    map<pair<int, int>, bool> vis;
    for(int i=0; i<M; i++){
        int p, q, c;
        cin >> p >> q >> c;
        p--; q--;
        G[p].push_back(make_pair(q, c));
        G[q].push_back(make_pair(p, c));
    }
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> wsc;
    for(auto sc : G[0])
        wsc.push(make_tuple(1, sc.first, sc.second));

    vector<int> d(N, 1<<30);
    d[0] = 0;
    while(!wsc.empty()){
        int w, s, c;
        tie(w, s, c) = wsc.top();
        wsc.pop();
        d[s] = min(d[s], w);

        for(auto sc : G[s]){
            int tt = sc.first;
            int cc = sc.second;
            if(vis[make_pair(tt, cc)]) continue;
            vis[make_tuple(tt, cc)] = true;
            if(c == cc)
                wsc.push(make_tuple(w, tt, cc));
            else
                wsc.push(make_tuple(w+1, tt, cc));
        }
    }
    if(d[N-1] == 1<<30) cout << -1 << endl;
    else cout << d[N-1] << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:16: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, bool>' and 'std::tuple<int, int>')
   37 |             vis[make_tuple(tt, cc)] = true;
      |                ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; mapped_type = bool; key_type = std::pair<int, int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'std::tuple<int, int>' to 'const std::map<std::pair<int, int>, bool>::key_type&' {aka 'const std::pair<int, int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = bool; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, bool> >; mapped_type = bool; key_type = std::pair<int, int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'std::tuple<int, int>' to 'std::map<std::pair<int, int>, bool>::key_type&&' {aka 'std::pair<int, int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;


vector<pair<int, int>> edg[100003];
set<int> used[100003];
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> que;

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int p, q, c; cin >> p >> q >> c;
		--p; --q;
		edg[p].push_back({ q, c });
		edg[q].push_back({ p, c });
    }    
          
	que.push({ 0, {0, -1} });
	while (!que.empty()) {
		int d = que.top().first; pair<int, int> pos = que.top().second;
		que.pop();
		if (pos.first == n - 1) {
			cout << d << endl;
			return 0;
        }
		int t = pos.first, c = pos.second;
      　if (used[t].count(c) == 1) continue;
		used[t].insert(c);
		if (c == -1) {
			for (int i = 0; i < (int)edg[t].size(); ++i) {
				if (used[edg[t][i].first].count(edg[t][i].second) == 1) continue;
				que.push({ d + 1, edg[t][i] });
			}
		}
		else {
			for (int i = 0; i < (int)edg[t].size(); ++i) {
				if (c != edg[t][i].second) {
					if (used[t].count(-1) == 1) continue;
					que.push({ d,{t, -1} });
				}
				else {
					if (used[edg[t][i].first].count(edg[t][i].second) == 1) continue;
					que.push({ d, edg[t][i] });
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}


Compiler output:
a.cc:39:7: error: extended character 　 is not valid in an identifier
   39 |       　if (used[t].count(c) == 1) continue;
      |       ^
a.cc: In function 'int main()':
a.cc:39:7: error: '\U00003000if' was not declared in this scope
   39 |       　if (used[t].count(c) == 1) continue;
      |       ^~~~
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
int d[N];
vector<P> g[N];
int main(){
	ll n, m;
	cin>>n>>m;
	rep(i, m){
		int u, v, c;
		cin>>u>>v>>c; u--; v--; c--;
		g[u].push_back(P(v, c));
		g[v].push_back(P(u, c));
	}
	deque<P> q;
	q.push_front(P(0, -1));
	fill(d, d+n, INF);
	d[0] = 0;
	while(!q.empty()){
		P p = q.front(); q.pop_front();
		for(auto x: g[p.fst]){
			int w = e[p.fst].count(x.snd)!=1;
			if(d[p.fst]+w<d[x.fst]){
				d[x.fst] = d[p.fst]+w;
				if(w==0) q.push_front(x);
				else q.push_back(x);
			} else if(d[p.fst]+w==d[x.fst]){
				for(auto y: g[x.fst]){
					if(y.fst==p.fst) continue;
					if(x.snd!=y.snd) continue;
					if(d[y.fst]>d[x.fst]){
						if(w==0) q.push_front(x);
						else q.push_back(x);
					}
				}
			}
		}
	}
	cout<<(d[n-1]==INF?-1:d[n-1])<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:33: error: 'e' was not declared in this scope
   59 |                         int w = e[p.fst].count(x.snd)!=1;
      |                                 ^
Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, P> PP;
priority_queue<PP, vector<PP>, greater<PP> > Q;
vector<vector<P> > G;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  G.resize(N+1);
  FOR(i,0,M) {
    int p, q, c; cin >> p >> q >> c;
    G[p].push_back(P(q, c));
    G[q].push_back(P(p, c));
  }
  int d[N+1];
  FOR(i,0,N+1) d[i] = 1e9;
  d[1] = 0;
  Q.push(PP(P(0, 1), P(0, 0)));
  while(!Q.empty()) {
    PP pp = Q.top(); Q.pop();
    int dd = pp.first.first;
    int now = pp.first.second;
    int from = pp.second.first;
    int c = pp.second.second;
    if(d[now] < dd) continue;
    if(now == N) {
      cout << dd << endl;
      return 0;
    }
    d[now] = dd;
    for(auto to : G[now]) {
      int a = to.first;
      int b = to.second;
      if(a == from) continue;
      if(c == b) {
           if(d[a] >= dd) Q.push(PP(P(dd, a), P(now, b)));
      }
      elseif(d[a] >= dd + 1) Q.push(PP(P(dd + 1, a), P(now, b)));
    }
  }
  if(d[N] == 1e9) cout << -1 << endl;
  else cout << d[N] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:7: error: 'elseif' was not declared in this scope
   59 |       elseif(d[a] >= dd + 1) Q.push(PP(P(dd + 1, a), P(now, b)));
      |       ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef pair<int,int> pii;

int n,m;
vector<pii> edge[200200];
vector<int> col[1001000];
vector<int> ned[500500];
int colour[200200],x[200200],l[200200];
int dist[500500];

int main(){
	scanf("&d &d", &n, &m);
	for (int i=1;i<=m;i++){
		int p,q,c;
		scanf("%d %d %d", &p, &q, &c);
		edge[p].pb(mp(c,q));
		edge[q].pb(mp(c,p));
		col[c].pb(q);
		col[c].pb(p);
	}
	for (int i=1;i<=n;i++){
		sort(edge[i].begin(),edge[i].end());
	}
	memset(colour,0,sizeof colour);
	memset(x,0,sizeof x);
	memset(l,0,sizeof l);
	int nw=n+1;
	for (int co=1;co<=1000000;co++){
		if (!col[co].size()) continue;
		for (int k=0;k<col[co].size();k++){
			int p=col[co][k];
			if (colour[p]==co) continue;
			colour[p]=co;
			queue<int> q;
			q.push(p);
			while (!q.empty()){
				int b=q.front();
				q.pop();
				while (l[b]<edge[b].size()){
					int c=edge[b][l[b]].f;
					if (c!=co) break;
					int pp=edge[b][l[b]].s;
					if (colour[pp]!=co){
						colour[pp]=co;
						q.push(pp);
					}
					l[b]++;
				}
				ned[b].pb(nw);
				ned[nw].pb(b);
			}
			nw++;
		}
	}
	for (int i=1;i<=nw;i++) dist[i]=-2;
	queue<int> q;
	q.push(1);
	dist[1]=0;
	while (!q.empty()){
		int b=q.front();
		q.pop();
		for (int i=0;i<ned[b].size();i++){
			int p=ned[b][i];
			if (dist[p]==-2){
				dist[p]=dist[b]+1;
				q.push(p); 
			}
		}
	} 
	printf("%d\n", &dist[n]/2);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:32: error: invalid operands of types 'int*' and 'int' to binary 'operator/'
   75 |         printf("%d\n", &dist[n]/2);
      |                        ~~~~~~~~^~
      |                        |        |
      |                        int*     int
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000
#define ulinf 10000000000000000000ull
#define MOD 1000000007
#define lson(v) ((v)<<1)
#define rson(v) (((v)<<1)^1)
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("Taken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a<b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > UMAX(T &a,T b){if(b>a) a=b;}
int n,m,cur,u[200005],v[200005],c[200005],dist[200005];
vector < pii > G[1000000];
map < int , int > mp[200005];
int main(){
	memset(dist,-1,sizeof(dist));
    scanf("%d%d",&n,&m);
	int xb,x2;	
	for(xb=0;xb<m;++xb){
		scanf("%d%d%d",u+xb,v+xb,c+xb);--c[xb];
		mp[--u[xb]][c[xb]]=mp[--v[xb]][c[xb]]=1;
	}
	#ifdef LOCAL
        TStart();
    #endif
	cur=n;
	for(x2=0;x2<n;++x2){
		map < int , int > ::iterator it;
		for(it=mp[x2].begin();it!=mp[x2].end();++it){
			it->second=cur;
			G[cur].push_back(make_pair(x2,1));
			G[x2].push_back(make_pair(cur,1));
			++cur;
		}
	}
	for(xb=0;xb<m;++xb){
		G[mp[u[xb]][c[xb]]].push_back(make_pair(mp[v[xb]][c[xb]],0));
		G[mp[v[xb]][c[xb]]].push_back(make_pair(mp[u[xb]][c[xb]],0));
	}
	deque < int > dq;
	dq.clear();
	dq.push_back(0);
	dist[0]=0;
	while(!dq.empty()){
		if(dist[n-1]>=0) break;
		int cv=dq.front();
		dq.pop_front();
		for(xb=G[cv].size()-1;xb>=0;--xb){
			pii &E=G[cv][xb];
			if(dist[E.first]==-1 || dist[cv]+E.second<dist[E.first]){
				dist[E.first]=dist[cv]+E.second;
				if(E.second) dq.push_back(E.first); else dq.push_front(E.first);
				if(E.first==n-1) break;
			}
		}
	}
	printf("%d\n",dist[n-1]>>1);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Compiler output:
a.cc:21:25: error: ISO C++ forbids declaration of 'UMIN' with no type [-fpermissive]
   21 | template < typename T > UMIN(T &a,T b){if(b<a) a=b;}
      |                         ^~~~
a.cc: In function 'int UMIN(T&, T)':
a.cc:21:52: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | template < typename T > UMIN(T &a,T b){if(b<a) a=b;}
      |                                                    ^
a.cc: At global scope:
a.cc:22:25: error: ISO C++ forbids declaration of 'UMAX' with no type [-fpermissive]
   22 | template < typename T > UMAX(T &a,T b){if(b>a) a=b;}
      |                         ^~~~
a.cc: In function 'int UMAX(T&, T)':
a.cc:22:52: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | template < typename T > UMAX(T &a,T b){if(b>a) a=b;}
      |                                                    ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>
using namespace std;
queue<pair<int,int> >q;
int n,m,nn;
vector<pair<int,int> >v[100010];
vector<int>nv[300010];
bool vis[300010];
int cur[100010];
vector<int>col[1000010];
vector<int>res;
void dfs(int x,int c)
{
	vis[x]=true;
	res.push_back(x);
	for(int i=cur[x];i<v[x].size();i++)
	{
		if(v[x][i].first!=c)break;
		cur[x]++;
		int y=v[x][i].second;
		if(vis[y])continue;
		dfs(y,c);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	nn=n;
	for(int i=1;i<=m;i++)
	{
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		v[x].push_back(make_pair(c,y));
		v[y].push_back(make_pair(c,x));
		col[c].push_back(x);
		col[c].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		sort(v[i].begin(),v[i].end());
	}
	for(int i=1;i<=1000000;i++)
	{
		if(!col[i].size())continue;
		for(int j=0;j<col[i].size();j++)
		{
			vis[col[i][j]]=false;
		} 
		for(int j=0;j<col[i].size();j++)
		{
			int x=col[i][j];
			if(vis[x])continue;
			res.clear();
			dfs(x,i);
			nn++;
			for(int k=0;k<res.size();k++)
			{
				nv[nn].push_back(res[k]);
				nv[res[k]].push_back(nn);
			}
		}
	}
	memset(vis,false,sizeof(vis));
	q.push(make_pair(1,0));
	vis[1]=true;
	while(!q.empty())
	{
		int x=q.front().first,w=q.front().second;
		q.pop();
		if(x==n)
		{
			printf("%d",w/2);
			return 0;
		}
		for(int i=0;i<nv[x].size();i++)
		{
			int y=nv[x][i];
			if(vis[y])continue;
			vis[y]=true;
			q.push(make_pair(y,w+1));
		}
	}
	printf("-1");
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:66:9: error: 'memset' was not declared in this scope
   66 |         memset(vis,false,sizeof(vis));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include<cstdio>
  +++ |+#include <cstring>
    6 | using namespace std;