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

#include<bits/stdc++.h>
#define N 500005
#define M 500005
using namespace std;
inline int read(){
    int ans=0;
    char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
    return ans;
}
int n,m,first[N],cnt=0,d[N];
bool vis[N];
struct edge{int v,next,c;}e[M<<1];
inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;}
struct heap{int u,v;};
inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;}
priority_queue<heap>q;
set<int>col[N];
inline void dijkstra(){
    for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false;
    d[1]=0;
    q.push((heap){1,d[1]});
    while(!q.empty()){
        heap x=q.top();
        q.pop();
        if(vis[x.u])continue;
        vis[x.u]=1;
        for(int i=first[x.u];i;i=e[i].next){
            int v=e[i].v,w=col[x.u].count(e[i].c)?0:1;
            if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c);
            else if(d[v]==d[x.u]+w)col[v].insert(e[i].c);
        }
    }
}
signed main(){
    n=read();m=read();
    for(int i=1;i<=m;i++){
        int x=read();int y=read();int z=read();
        addedge(x,y,z);addedge(y,x,z);
    }
    memset(dis,0x3f,sizeof(dis));
    dijkstra();
    if(d[n]==0x3f3f3f3f)cout<<-1<<endl;
    else cout<<d[n]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: 'addedge' was not declared in this scope; did you mean 'edge'?
   40 |         addedge(x,y,z);addedge(y,x,z);
      |         ^~~~~~~
      |         edge
a.cc:42:12: error: 'dis' was not declared in this scope; did you mean 'vis'?
   42 |     memset(dis,0x3f,sizeof(dis));
      |            ^~~
      |            vis
Language: C++

#include<bits/stdc++.h>
#define N 500005
#define M 500005
using namespace std;
inline int read(){
    int ans=0;
    char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
    return ans;
}
int n,m,first[N],cnt=0,d[N];
bool vis[N];
struct edge{int v,next,c;}e[M<<1];
inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;}
struct heap{int u,v;};
inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;}
priority_queue<heap>q;
set<int>col[N];
inline void dijkstra(){
    for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false;
    q.push((heap){1,d[1]});
    while(!q.empty()){
        heap x=q.top();
        q.pop();
        if(vis[x.u])continue;
        vis[x.u]=1;
        for(int i=first[x.u];i;i=e[i].next){
            int v=e[i].v,w=col[x.u].count(e[i].c)?0:1;
            if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c);
            else if(d[v]==d[x.u]+w)col[v].insert(e[i].c);
        }
    }
}
signed main(){
    n=read();m=read();
    for(int i=1;i<=m;i++){
        int x=read();int y=read();int z=read();
        addedge(x,y,z);addedge(y,x,z);
    }
    memset(dis,0x3f,sizeof(dis));
    dijkstra();
    if(d[n]==0x3f3f3f3f)cout<<-1<<endl;
    else cout<<d[n]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'addedge' was not declared in this scope; did you mean 'edge'?
   39 |         addedge(x,y,z);addedge(y,x,z);
      |         ^~~~~~~
      |         edge
a.cc:41:12: error: 'dis' was not declared in this scope; did you mean 'vis'?
   41 |     memset(dis,0x3f,sizeof(dis));
      |            ^~~
      |            vis
Language: C++

#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct edge {ll to, company;};

int main(){
    ll N, M; cin >> N >> M;
    vector<edge> ed[N];
    REP(i, M){
        ll p, q, c; cin >> p >> q >> c; p--; q--;
        ed[p].pb({q, c});
        ed[q].pb({p, c});
    }
    
    vl dist(N, LINF); dist[0] = 1;
    priority_queue<pair<ll, PL>> pq;
    for(auto e : ed[0]){
        pq.push({-1, {0, e.company}}); // -cost, current_vertex, company
    }
    
    while(!pq.empty()){
        auto tmp = pq.top(); pq.pop();
        ll cur_cost = -tmp.ff; ll cur_ver = tmp.ss.ff; ll cur_company = tmp.ss.ss;
        if(dist[cur_ver] =< cur_cost) continue;
        
        for(auto& e : ed[cur_ver]){
            if(e.company == cur_company){
                if(dist[e.to] >= dist[cur_ver]){
                    dist[e.to] = cur_cost;
                    pq.push({-dist[e.to], {e.to, e.company}});
                }
            }
            else{
                if(dist[e.to] >= cur_cost + 1){
                    dist[e.to] = cur_cost+1;
                    pq.push({-dist[e.to], {e.to, e.company}});
                }
            }
        }
    }
    cout << (dist[N-1] == LINF ? -1 : dist[N-1]) << endl;
    
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:84:27: error: expected primary-expression before '<' token
   84 |         if(dist[cur_ver] =< cur_cost) continue;
      |                           ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
const int inf = 1e+7;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
typedef long long int;

void Yes() {
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

struct edge {int to, company;};
int N, M;
vector<edge> G[100100];

int d[100100];

int zero_one_bfs() {
	deque<P> deq;
	rep(i, N) d[i] = inf;
	d[0] = 0;
    deq.push_back(P(0, 0));
	while(deq.size()) {
		P p = deq.front(); deq.pop_front();
		if(p.fr == N - 1) break;
		rep(i, G[p.fr].size()) {
			edge eg = G[p.fr][i];
			if(p.sc == eg.company ) {
				if(d[eg.to] != inf) continue;
				deq.push_front(P(eg.to, eg.company));
				d[eg.to] = d[p.fr];
			} else {
				if(d[eg.to] != inf) continue;
				deq.push_back(P(eg.to, eg.company));
				d[eg.to] = d[p.fr] + 1;
			}
		}
	}
	if(d[N - 1] == inf) {
		return -1;
	}
	return d[N - 1];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
		int p, q, c; cin >> p >> q >> c; p --; q --;
		G[p].push_back(edge{q, c});
		G[q].push_back(edge{p, c});
  }
  int res = zero_one_bfs();
  cout << res << "\n";
  return 0;
}

Compiler output:
a.cc:42:19: error: declaration does not declare anything [-fpermissive]
   42 | typedef long long int;
      |                   ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

    int N, M; cin>>N>>M;
    struct Line {
        int t,c,i;
    };
    vector<Line> graph[N];
    for (int i = 0; i < M; i++) {
        int p,q,c; cin>>p>>q>>c;
        p--,q--;
        graph[p].push_back({q,c,i});
        graph[q].push_back({p,c,i});
    }


    vector<bool> used(M, false);
    int ans = numeric_limits<int>::max();
    function<void(int,int,int)> dfs = [&](int s, int c, int v) {
        if (q.s == N-1) {
            ans = min(ans, q.v);
            return;
        }
        for (auto& line : graph[q.s]) {
            if (used[line.i])
                continue;
            used[line.i] = true;
            dfs(line.t, line.c, q.v+(q.c != line.c ? 1 : 0));
        }
    };
    dfs(0,0,0);
    if (ans == numeric_limits<int>::max())
        ans = -1;
    cout << ans << endl;

    return 0;
}



Compiler output:
a.cc: In lambda function:
a.cc:24:13: error: 'q' was not declared in this scope
   24 |         if (q.s == N-1) {
      |             ^
a.cc:28:33: error: 'q' was not declared in this scope
   28 |         for (auto& line : graph[q.s]) {
      |                                 ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define mem(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

const int mn = 5e5 + 5;
const int mod = 1e9 + 7;

struct edge {
    int to, dist;
};

template<>
struct hash<pii> {
    size_t operator()(const pii &s) const {
        size_t out = 14695981039346656037ULL;
        static const size_t mul = 1099511628211ULL;
        out = (out ^ s.first) * mul;
        out = (out ^ s.second) * mul;
        return out;
    }
};

int n, m;
unordered_map<pii, int> h;
int cnt;
vector<edge> g[mn];
int ans;

inline void add_edge(int u, int v, int w) {
    int u1, v1;
    pii p{u, w};
    if (!h.count(p)) {
        h[p] = ++cnt;
        g[cnt].pb({u, 1});
        g[u].pb({cnt, 1});
    }
    u1 = h[p];
    p = make_pair(v, w);
    if (!h.count(p)) {
        h[p] = ++cnt;
        g[cnt].pb({v, 1});
        g[v].pb({cnt, 1});
    }
    v1 = h[p];
    g[u1].pb({v1, 0});
    g[v1].pb({u1, 0});
}

struct node {
    int id, dist;

    bool operator<(const node &p) const {
        return dist > p.dist;
    }
};

int dist[mn];
priority_queue<node> q;

void dijk(int s, int t) {
    memset(dist, 1, sizeof dist);
    q.push({s, dist[s] = 0});
    while (!q.empty()) {
        node u = q.top();
        q.pop();
        if (dist[u.id] < u.dist) continue;
        for (auto &i:g[u.id]) {
            int nxtdist = i.dist + u.dist;
            if (dist[i.to] > nxtdist) {
                dist[i.to] = nxtdist;
                q.push({i.to, nxtdist});
            }
        }
    }
}

int main() {
#ifdef LOCAL
    freopen("../1.txt", "r", stdin);
    freopen("../2.txt", "w", stdout);
#endif

    scanf("%d%d", &n, &m);
    cnt = n;
    for (int i = 1; i <= m; i++) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        add_edge(u, v, w);
    }
    dijk(1, n);
    ans = dist[n];
    if (ans > 1e7) {
        ans = -2;
    }
    printf("%d\n", ans/2);
}



Compiler output:
a.cc:22:8: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
   22 | struct hash<pii> {
      |        ^~~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
struct Edge {
    int to,next,val;
    Edge(){}
    Edge(int to,int next,int val):to(to),next(next),val(val){}
    bool operator < (const Edge& rhs)const{
        return val>rhs.val;
    }
}edge[N*2];
int tot,head[N];
void addEdge(int from,int to,int val) {
    edge[tot].next=head[from];
    edge[tot].to=to;
    edge[tot].val=val;
    head[from]=tot++;
}
bool vis[N];
int dis[N];
int SPFA(int s,int e) {
    memset(vis,false,sizeof(vis));
    memset(dis,INF,sizeof(dis));
    dis[s]=0;

    queue<Edge> Q;
    Q.push(Edge(s,0,0));
    while (!Q.empty()) {
        Edge temp=Q.top();
        Q.pop();
        if(vis[temp.to])
            continue;
        vis[temp.to]=true;

        for(int i=head[temp.to]; i!=-1; i=edge[i].next) {
            if(dis[edge[i].to]>dis[temp.to]+edge[i].val) {
                dis[edge[i].to]=dis[temp.to]+edge[i].val;
                Q.push(Edge(edge[i].to,0,dis[edge[i].to]));
            }
        }
    }
    if(dis[e]!=INF)
        return dis[e]/2;
    return -1;
}
map<int,int> mp[N];
int allPoint;
int getPoint(int x,int y) {
    if (!mp[x][y])
        mp[x][y]=++allPoint;
    return mp[x][y];
}
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    allPoint=n;
    for (int i=1; i<=m; i++) {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);

        int newX=getPoint(x,w);
        int newY=getPoint(y,w);

        addEdge(x,newX,1);
        addEdge(newX,x,1);
        addEdge(newX,newY,0);
        addEdge(newY,newX,0);
        addEdge(y,newY,1);
        addEdge(newY,y,1);
    }
    int res=SPFA(1,n);
    printf("%d\n",res);
    return 0;
}

Compiler output:
a.cc: In function 'int SPFA(int, int)':
a.cc:49:21: error: 'class std::queue<Edge>' has no member named 'top'; did you mean 'pop'?
   49 |         Edge temp=Q.top();
      |                     ^~~
      |                     pop
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
struct Edge {
    int to,next,val;
    Edge(){}
    Edge(int to,int next,int val):to(to),next(next),val(val){}
    bool operator < (const Edge& rhs)const{
        return val>rhs.val;
    }
}edge[N*2];
int tot,head[N];
void addEdge(int from,int to,int val) {
    edge[tot].next=head[from];
    edge[tot].to=to;
    edge[tot].val=val;
    head[from]=tot++;
}
bool vis[N];
int dis[N];
void SPFA(int s,int e) {
    memset(vis,false,sizeof(vis));
    memset(dis,INF,sizeof(dis));
    dis[s]=0;

    priority_queue<Edge> Q;
    Q.push(Edge(s,0,0));
    while (!Q.empty()) {
        Edge temp=Q.top();
        Q.pop();
        if(vis[temp.to])
            continue;
        vis[temp.to]=true;

        for(int i=head[temp.to]; i!=-1; i=edge[i].next) {
            if(dis[edge[i].to]>dis[temp.to]+edge[i].val) {
                dis[edge[i].to]=dis[temp.to]+edge[i].val;
                Q.push(Edge(edge[i].to,0,dis[edge[i].to]));
            }
        }
    }
    if(dis[e]!=INF)
        return dis[e]/2;
    return -1;
}
map<int,int> mp[N];
int allPoint;
int getPoint(int x,int y) {
    if (!mp[x][y])
        mp[x][y]=++allPoint;
    return mp[x][y];
}
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    allPoint=n;
    for (int i=1; i<=m; i++) {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);

        int newX=getPoint(x,w);
        int newY=getPoint(y,w);

        addEdge(x,newX,1);
        addEdge(newX,x,1);
        addEdge(newX,newY,0);
        addEdge(newY,newX,0);
        addEdge(y,newY,1);
        addEdge(newY,y,1);
    }
    SPFA(1,n);

    return 0;
}


Compiler output:
a.cc: In function 'void SPFA(int, int)':
a.cc:63:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
   63 |         return dis[e]/2;
      |                ~~~~~~^~
a.cc:64:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   64 |     return -1;
      |            ^~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 2000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
struct Edge{
    int to,next;
    int val;
    Edge(){}
    Edge(int to,int next,int val):to(to),next(next),val(val){}
    bool operator < (const Edge &rhs)const{
        val>rhs.val;
    }
}edge[N*2];
int head[N*2],tot;
bool vis[N*2];
int dis[N];
void addEdge(int from,int to,int val){
    edge[tot].next=head[from];
    edge[tot].to=to;
    edge[tot].val=val;
    head[from]=tot++;
}
int SPFA(int s,int e){
    memset(vis,false,sizeof(vis));
    memset(dis,INF,sizeof(dis));
    dis[s]=0;
    priority_queue<Edge> Q;
    Q.push(Edge(s,0,0));

    while(!Q.empty()){
        Edge temp=Q.front();
        Q.pop();

        if(!vis[temp.to]){
            vis[temp.to]=true;
            for(int i=head[temp.to];i!=-1;i=edge[i].next){
                if(dis[edge[i].to]>dis[temp.to]+edge[i].val){
                    dis[edge[i].to]=dis[temp.to]+edge[i].val;
                    Q.push(Edge(edge[i].to,0,dis[edge[i].to]));
                }
            }
        }
    }
    if(dis[e]==INF)
        return -1;
    return dis[e]/2;
}
map<int,int> mp[N];
int allPoint;
int getPoint(int x,int y){
    if(!mp[x][y]){
        allPoint++;
        mp[x][y]=allPoint;
    }
    return mp[x][y];
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);

    allPoint=n;
    memset(head,-1,sizeof(head));
    for(int i=1;i<=m;i++){
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);

        int newX=getPoint(x,w);
        int newY=getPoint(y,w);

        addEdge(x,newX,1);
        addEdge(newX,x,1);
        addEdge(newX,newY,0);
        addEdge(newY,newX,0);
        addEdge(newY,y,1);
        addEdge(y,newY,1);
    }
    int res=SPFA(1,n);
    printf("%d\n",res);
    return 0;
}


Compiler output:
a.cc: In member function 'bool Edge::operator<(const Edge&) const':
a.cc:31:5: warning: no return statement in function returning non-void [-Wreturn-type]
   31 |     }
      |     ^
a.cc: In function 'int SPFA(int, int)':
a.cc:50:21: error: 'class std::priority_queue<Edge>' has no member named 'front'
   50 |         Edge temp=Q.front();
      |                     ^~~~~
Language: C++

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

main(){
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> edge[100000];
	rep(i, m){
		int A, B, C;
		cin >> A >> B >> C;
		edge[A-1].pb(mp(B-1, C));
		edge[B-1].pb(mp(A-1, C));
	}
	map<int, int> cost[100000];
	priority_queue<pair<int,pair<int,int>>> que;
	for(int i=0; i<edge[0].size(); i++){
		cost[0][edge[0][i].second] = 0;
		que.push({ 0,{0,edge[0][i].second} });
	}
	while(!que.empty()){
		int c = -que.top().first;
		int v = que.top().second.first;
		int t = que.top().second.second;
		que.pop();
		for(int i=0; i<edge[v].size(); i++){
			if(cost[edge[v][i].first].count(edge[v][i].second) == 0 || cost[edge[v][i].first][edge[v][i].second] > c+(edge[v][i].second==t ? 0 : 1)){
				cost[edge[v][i].first][edge[v][i].second] = c+(edge[v][i].second==t ? 0 : 1);
				que.push({ -cost[edge[v][i].first][edge[v][i].second],{edge[v][i].first,edge[v][i].second} });
			}
		}
	}
	int ans = INT_MAX;
	for(auto itr=cost[N-1].begin(); itr!=cost[N-1].end(); itr++) ans = min(ans, itr->second);
	if(ans == INT_MAX) cout << -1 << endl;
	else cout << ans + 1 << endl;
}


Compiler output:
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:12:16: error: 'm' was not declared in this scope
   12 |         rep(i, m){
      |                ^
a.cc:4:39: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
      |                                       ^
Language: C++

8 11
1 3 1
1 4 2
2 3 1
2 5 1
3 4 3
3 6 3
3 7 3
4 8 4
5 6 1
6 7 5
7 8 5

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 8 11
      | ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

/**
 * Created by darshan on 3/28/19.
 */
public class C061 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        st = new StringTokenizer(br.readLine());
        int numStations = Integer.parseInt(st.nextToken());
        int numLines = Integer.parseInt(st.nextToken());

        List<List<Edge>> edges = new ArrayList<>(numStations);
        List<Set<Integer>> visitedFrom = new ArrayList<>();
        for (int i = 0; i < numStations; i++) {
            edges.add(new ArrayList<>());
            visitedFrom.add(new HashSet<>());
        }
        int[] minCost = new int[numStations];
        Arrays.fill(minCost, Integer.MAX_VALUE);
        minCost[0] = 0;

        for (int i = 0; i < numLines; i++) {
            st = new StringTokenizer(br.readLine());
            int stationP = Integer.parseInt(st.nextToken()) - 1;
            int stationQ = Integer.parseInt(st.nextToken()) - 1;
            int company = Integer.parseInt(st.nextToken());
            edges.get(stationP).add(new Edge(stationQ, company));
            edges.get(stationQ).add(new Edge(stationP, company));
        }

        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(0);
        while (!queue.isEmpty()) {
            int station = queue.poll();
            if (station == numStations - 1) {
                System.out.println(minCost[station]);
                return;
            }

            for (Edge edge : edges.get(station)) {
                int cost = minCost[station];
                if (!visitedFrom.get(station).contains(edge.company)) {
                    cost += 1;
                }
                if (minCost[edge.station] > cost) {
                    queue.add(edge.station);
                }
                if (minCost[edge.station] >= cost) {
                    minCost[edge.station] = cost;
                    visitedFrom.get(edge.station).add(edge.company);
                }
            }
        }

        System.out.println(-1);
    }

    private static class Edge {
        private int station;
        private int company;

        private Edge(int station, int company) {
            this.station = station;
            this.company = company;
        }
    }
}


Compiler output:
Main.java:16: error: class C061 is public, should be declared in a file named C061.java
public class C061 {
       ^
1 error
Language: C++

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<pair<int,int>>> e(n);
  int p,q,c;
  for(int i=0;i<m;i++){
    cin >> p >> q >> c;
    p--,q--;
    e[p].push_back({q,c});
    e[q].push_back({p,c});
  }
  deque<pair<int,pair<int,int>>> bfs;
  set<pair<int,int>> st;
  pair<int,pair<int,int>> now;a
  bfs.push_back({0,{-1,0}});
  int ans=IINF;
  while(!bfs.empty()){
    now=bfs.front();
    bfs.pop_front();
    if(now.first==n-1){
      cout << now.second.second << endl;
      return 0;
    }
    for(auto &pa:e[now.first]){
      if(st.find(pa)==st.end()){
        st.insert(pa);
        if(pa.second==now.second.first){
          bfs.push_front({pa.first,{pa.second,now.second.second}});
        }else{
          bfs.push_back({pa.first,{pa.second,now.second.second+1}});
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:31: error: 'a' was not declared in this scope
   30 |   pair<int,pair<int,int>> now;a
      |                               ^
a.cc:31:27: error: expected primary-expression before ')' token
   31 |   bfs.push_back({0,{-1,0}});
      |                           ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 100005



typedef struct edge{
    pair<int,int> to;//今いる位置、会社
    int cost;//移動にかかるコスト
}EDGE;

int n,m;
map<P,vector<EDGE> > G;
set<P> used;

int bfs(){

    deque<EDGE> deq;
    deq.push_back(EDGE{P(0,-1),0});
    int ans = -1;

    while(!deq.empty()){
        EDGE es = deq.front();
        deq.pop_front();
        if(used.find(es.to) != used.end()){
            //もう使ったので調べない
            continue;
        }
        used.insert(es.to);
        if(es.to == P(n-1,-1)){
            //目的地に着いた
            //つまり、駅nの改札を出たところなら
            ans = es.cost;
            break;
        }
        for(auto itr:G[es.to]){
            //次の駅の候補を調べる
            if(used.find(itr.to) != used.end()){
                //次の駅がすでに調べられているなら調べない
                continue;
            }
            if(itr.cost == 0){
                deq.push_front({itr.to,es.cost});
            }else{
                deq.push_back({itr.to,es.cost+1});
            }
        }       
    }
    return ans;
}



int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> n >> m;
    REP(i,m){
        int p,q,c;
        cin >> p >> q >> c;
        p--;
        q--;
        //同じ会社の間にコスト0の辺を張る
        G[P(p,c)].push_back((EDGE){P(q,c),0});
        G[P(q,c)].push_back((EDGE){P(p,c),0});


        //駅番号-1は駅から改札を出ることを表す,コスト0の辺を張る
        G[P(p,c)].push_back((EDGE){P(p,-1),0});
        G[P(q,c)].push_back((EDGE){P(q,-1),0});

        
        //改札を出て別の会社の駅に入る時にコスト1かかるとする,コスト1の辺を張る
        //途中で別の会社を使って再びもとの会社を使う時にもコストはかかる
        G[P(p,-1)].push_back((EDGE){P(q,c),1});
        G[P(q,-1)].push_back((EDGE){P(p,c),1});
    }

    int ans = bfs();
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:22: error: 'setprecision' was not declared in this scope
   84 |     cout << fixed << setprecision(10);
      |                      ^~~~~~~~~~~~
a.cc:13:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
   12 | #include<set>
  +++ |+#include <iomanip>
   13 |
Language: C++

#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
const int Maxn = 1e5;
const int INF = 0x3f3f3f3f;
struct Edge {
    int to,cost;
    Edge(int a,int b){to=a,cost=b;}
};
vector<Edge> G[8*Maxn+5];
void AddEdge(int u,int v,int w) {
    G[u].push_back(Edge(v,w));
    G[v].push_back(Edge(u,w));
}

int dist[8*Maxn+5];
bool vis[8*Maxn+5];
void SPFA(int s) {
    memset(dist,0x3f,sizeof dist);
    memset(vis,false,sizeof vis);
    queue<int> q;

    q.push(s);
    vis[s]=true,dist[s]=0;

    while(!q.empty()) {
        int u=q.front();
        q.pop();vis[u]=false;

        for(int i=0;i<G[u].size();i++) {
            int v=G[u][i].to,w=G[u][i].cost;
            if(dist[v]>dist[u]+w) {
                dist[v]=dist[u]+w;
                if(!vis[v]) {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}

map<pair<int,int>,int> P;
int cnt;
int Getid(int u,int c) {
    if(P.find(make_pair(u,c))!=P.end())
        return P[make_pair(u,c)];
    return P[make_pair(u,c)]=++cnt;
}

int N,M;
int main() 
{
    scanf("%d %d",&N,&M);
    cnt=N;
    for(int i=1;i<=M;i++) {
        int u,v,c;
        scanf("%d %d %d",&u,&v,&c);
        int t1=Getid(u,c);
        int t2=Getid(v,c);
        AddEdge(t1,t2,0);
        AddEdge(u,t1,1);
        AddEdge(v,t2,1);
    }
    SPFA(1);
    if(dist[N]==INF)puts("-1");
    else printf("%d\n",dist[N]/2);
    return 0;
}

Compiler output:
a.cc:11:1: error: 'vector' does not name a type
   11 | vector<Edge> G[8*Maxn+5];
      | ^~~~~~
a.cc: In function 'void AddEdge(int, int, int)':
a.cc:13:5: error: 'G' was not declared in this scope
   13 |     G[u].push_back(Edge(v,w));
      |     ^
a.cc: In function 'void SPFA(int)':
a.cc:22:5: error: 'queue' was not declared in this scope
   22 |     queue<int> q;
      |     ^~~~~
a.cc:4:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    3 | #include <cstring>
  +++ |+#include <queue>
    4 | using namespace std;
a.cc:22:11: error: expected primary-expression before 'int'
   22 |     queue<int> q;
      |           ^~~
a.cc:24:5: error: 'q' was not declared in this scope
   24 |     q.push(s);
      |     ^
a.cc:31:23: error: 'G' was not declared in this scope
   31 |         for(int i=0;i<G[u].size();i++) {
      |                       ^
a.cc:33:32: error: 'w' was not declared in this scope
   33 |             if(dist[v]>dist[u]+w) {
      |                                ^
a.cc: At global scope:
a.cc:44:1: error: 'map' does not name a type
   44 | map<pair<int,int>,int> P;
      | ^~~
a.cc: In function 'int Getid(int, int)':
a.cc:47:8: error: 'P' was not declared in this scope
   47 |     if(P.find(make_pair(u,c))!=P.end())
      |        ^
a.cc:49:12: error: 'P' was not declared in this scope
   49 |     return P[make_pair(u,c)]=++cnt;
      |            ^
Language: C++

#include<bits/stdc++.h>
#define MX 1000005
#define INF 1000000005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 vector<int> sad[12312313]
struct UF
{
	int par[MX],rank[MX];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	void rem(int i)
	{
		par[i]=i;
		rank[i]=0;
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF uf;
vector <int> vec[MX];
vector <P> query[MX];
int id[MX];
bool use[MX];
int dp[MX];
 
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int p,q,c;
		scanf("%d %d %d",&p,&q,&c);p--,q--,c--;
		query[c].push_back(P(p,q));
	}
	int sz=n;
	for(int i=0;i<MX;i++)
	{
		if(query[i].empty()) continue;
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.rem(p.first);
			uf.rem(p.second);
			id[p.first]=id[p.second]=-1;
			use[p.first]=use[p.second]=false;
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.unite(p.first,p.second);
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
				use[p.first]=true;
				int r=uf.find(p.first);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.first);
				vec[p.first].push_back(id[r]);
				vec[id[r]].push_back(p.first);
				use[p.second]=true;
				r=uf.find(p.second);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.second);
				vec[p.second].push_back(id[r]);
				vec[id[r]].push_back(p.second);
		}
	}
	queue <int> que;
	que.push(0);
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	while(!que.empty())
	{
		int v=que.front();que.pop();
		for(int i=0;i<vec[v].size();i++)
		{
			int to=vec[v][i];
			if(dp[to]==-1)
			{
				dp[to]=dp[v]+1;
				que.push(to);
			}
		}
	}
	if(dp[n-1]==-1) puts("-1");
	else printf("%d\n",dp[n-1]/2);
	return 0;
}

Compiler output:
a.cc:8:1: error: expected initializer before 'struct'
    8 | struct UF
      | ^~~~~~
a.cc:50:1: error: 'UF' does not name a type
   50 | UF uf;
      | ^~
a.cc: In function 'int main()':
a.cc:74:25: error: 'uf' was not declared in this scope
   74 |                         uf.rem(p.first);
      |                         ^~
a.cc:82:25: error: 'uf' was not declared in this scope
   82 |                         uf.unite(p.first,p.second);
      |                         ^~
a.cc:88:39: error: 'uf' was not declared in this scope
   88 |                                 int r=uf.find(p.first);
      |                                       ^~
Language: C++

#include<bits/stdc++.h>
#define MX 1000005
#define INF 1000000005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
struct UF
{
	int par[MX],rank[MX];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	void rem(int i)
	{
		par[i]=i;
		rank[i]=0;
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF uf;
vector <int> vec[MX];
vector <P> query[MX];
int id[MX];
bool use[MX];
int dp[MX];
 
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int p,q,c;
		scanf("%d %d %d",&p,&q,&c);p--,q--,c--;
		query[c].push_back(P(p,q));
	}
	int sz=n;
	for(int i=0;i<MX;i++)
	{
		if(query[i].empty()) continue;
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.rem(p.first);
			uf.rem(p.second);
			id[p.first]=id[p.second]=-1;
			use[p.first]=use[p.second]=false;
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.unite(p.first,p.second);
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
				use[p.first]=true;
				int r=uf.find(p.first);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.first);
				vec[p.first].push_back(id[r]);
				vec[id[r]].push_back(p.first);
				use[p.second]=true;
				int r=uf.find(p.second);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.second);
				vec[p.second].push_back(id[r]);
				vec[id[r]].push_back(p.second);
		}
	}
	queue <int> que;
	que.push(0);
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	while(!que.empty())
	{
		int v=que.front();que.pop();
		for(int i=0;i<vec[v].size();i++)
		{
			int to=vec[v][i];
			if(dp[to]==-1)
			{
				dp[to]=dp[v]+1;
				que.push(to);
			}
		}
	}
	if(dp[n-1]==-1) puts("-1");
	else printf("%d\n",dp[n-1]/2);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:94:37: error: redeclaration of 'int r'
   94 |                                 int r=uf.find(p.second);
      |                                     ^
a.cc:88:37: note: 'int r' previously declared here
   88 |                                 int r=uf.find(p.first);
      |                                     ^
Language: C++

#include<bits/stdc++.h>
#define MX 1000005
#define INF 1000000005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
struct UF
{
	int par[MX],rank[MX];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=0;
		}
	}
	void rem(int i)
	{
		par[i]=i;
		rank[i]=0;
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		cout<<sum(par,par+10,0);
		return find(x)==find(y);
	}
};
UF uf;
vector <int> vec[MX];
vector <P> query[MX];
int id[MX];
bool use[MX];
int dp[MX];
 
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int p,q,c;
		scanf("%d %d %d",&p,&q,&c);p--,q--,c--;
		query[c].push_back(P(p,q));
	}
	int sz=n;
	for(int i=0;i<MX;i++)
	{
		if(query[i].empty()) continue;
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.rem(p.first);
			uf.rem(p.second);
			id[p.first]=id[p.second]=-1;
			use[p.first]=use[p.second]=false;
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			uf.unite(p.first,p.second);
		}
		for(int j=0;j<query[i].size();j++)
		{
			P p=query[i][j];
			if(!use[p.first])
			{
				use[p.first]=true;
				int r=uf.find(p.first);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.first);
				vec[p.first].push_back(id[r]);
				vec[id[r]].push_back(p.first);
			}
			if(!use[p.second])
			{
				use[p.second]=true;
				int r=uf.find(p.second);
				if(id[r]==-1) id[r]=sz++;
				//printf("%d %d: %d\n",r,id[r],p.second);
				vec[p.second].push_back(id[r]);
				vec[id[r]].push_back(p.second);
			}
		}
	}
	queue <int> que;
	que.push(0);
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	while(!que.empty())
	{
		int v=que.front();que.pop();
		for(int i=0;i<vec[v].size();i++)
		{
			int to=vec[v][i];
			if(dp[to]==-1)
			{
				dp[to]=dp[v]+1;
				que.push(to);
			}
		}
	}
	if(dp[n-1]==-1) puts("-1");
	else printf("%d\n",dp[n-1]/2);
	return 0;
}


Compiler output:
a.cc: In member function 'bool UF::same(int, int)':
a.cc:47:23: error: 'sum' was not declared in this scope
   47 |                 cout<<sum(par,par+10,0);
      |                       ^~~
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 tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 600010
#define MAX_V 900010
using namespace std;
//ダイクストラ法、負の閉路ダメ
struct edge{int to,cost;};
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
void dijkstra(int s){
    priority_queue<pii> que;
    fill(d,d+MAX_V,INF);
    d[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first)continue;
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push({d[e.to],e.to});
            }
        }
    }
}
main(){
    int mm;cin>>V>>mm;
    V++;
    map<pii,int> m;
    int temp=3;
    m[{1,0}]=1;m[{V-1,0}]=2;
    rep(i,mm){
        int p,q,c;cin>>p>>q>>c;
        int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}];
        if(a==0){
            a=m[{p,c}]=temp;
            temp++;
        }
        if(b==0){
            b=m[{q,c}]=temp;temp++;
        }
        G[a].pb({b,0});G[b].pb({a,0});
        if(aa==0){
            aa=m[{p,0}]=temp;temp++;
        }
        if(bb==0){
            bb=m[{q,0}]=temp;temp++;
        }
        G[aa].pb({a,1});G[a].pb({aa,1});
        G[bb].pb({b,1});G[b].pb({bb,1});
    }
    dijkstra(1);
    cout<<(d[2]==INF?-1:d[2]/2);
}


Compiler output:
a.cc:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   39 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:47:41: error: redeclaration of 'int aa'
   47 |         int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}];
      |                                         ^~
a.cc:47:35: note: 'int aa' previously declared here
   47 |         int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}];
      |                                   ^~
a.cc:47:53: error: redeclaration of 'int bb'
   47 |         int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}];
      |                                                     ^~
a.cc:47:38: note: 'int bb' previously declared here
   47 |         int a=m[{p,c}],b=m[{q,c}],aa,bb,aa=m[{p,0}],bb=m[{q,0}];
      |                                      ^~
Language: C++

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

#define IL inline 
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

const int maxn = 5e5 + 10;
int dis[maxn]; bool flag[maxn];
set<int>F[maxn];
vector<pair<int,int> >e[maxn];

int main() {
	int n = read(), m = read();
	for (int i = 1; i <= m; ++i) {
		int x = read(), y = read(), c = read();
		e[x].push_back(make_pair(y, c)); e[y].push_back(make_pair(x, c));
	}	
	priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > >q;
	q.push(make_pair(0, 1)); 
	memset(dis, 0x3f, sizeof dis); dis[1] = 0;
	while (!q.empty()) {
		int u = q.top().second; q.pop();
c		if (flag[u]) continue;
		flag[u] = 1;
		for (int i = 0; i < e[u].size(); ++i) {
			int v = e[u][i].first; int w = e[u][i].second;
			int c = F[v].count(w) ? 0 : 1;
			if (dis[v] > dis[u] + c) {
				dis[v] = dis[u] + c;
				F[v].clear();
				F[v].insert(w);
				q.push(make_pair(dis[v], v));
			}
			else if (dis[v] == dis[u] + c) F[v].insert(w);
		}
	}
	cout << (dis[n] == 0x3f3f3f3f ? -1 : dis[n]) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:1: error: 'c' was not declared in this scope
   28 | c               if (flag[u]) continue;
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=100005;
int N, M, k;
ll arr[MX];
map<int, int> D[MX];
set<pair<int, pair<int,int> > > st;
vector<pair<int,int> > G[MX];
int main()
{
    scanf("%d%d", &N, &M);
    for(int i=1; i<=M; i++)
    {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        G[a].pb(mp(b, c));
        swap(a, b);
        G[a].pb(mp(b, c));
    }
    st.insert(mp(0, mp(-1, 1)));
    int c=123123;
    D[1][-1]=0;
    int c=3*1e5;
    while(c-- && st.size())
    {
        pair<int, pair<int,int> > cur=*st.begin();
        st.erase(st.begin());
        int node=cur.S.S, color=cur.S.F, w=cur.F;
        if(D[node].find(color) != D[node].end())
        {
            if(D[node][color] < w) continue;
        }

     //  cout<<node<<" "<<w<<"\n";
    ///   break;
        for(int i=0; i<G[node].size(); i++)
        {
            int ch=G[node][i].F, cc=G[node][i].S;
            if(ch == 1) continue;
            int co=0;
            if(cc != color) ++co;
            if(D[ch].find(cc) == D[ch].end())
            {
                //cout<<"here ";
                D[ch][cc]=w+co;
              ///  cout<<ch<<" "<<D[ch][cc]<<"\n";
                st.insert(mp(D[ch][cc], mp(cc, ch)));
            }
            else
            {
                if(D[ch][cc] > w+co)
                {
                    D[ch][cc]=w+co;
                    st.insert(mp(D[ch][cc], mp(cc, ch)));

                }
            }
        }

    }
    int an=1e9;
    map<int,int>::iterator it=D[N].begin();
    while(it != D[N].end())
    {
        an=min(an, it->S);
        it++;
    }
    if(an == 1e9) an-=(1e9+1);
    cout<<an<<"\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: redeclaration of 'int c'
   31 |     int c=3*1e5;
      |         ^
a.cc:29:9: note: 'int c' previously declared here
   29 |     int c=123123;
      |         ^
Language: C++


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+456,M=4e5+325,inf=1e9+7;
int n,m,cnt;
int head[N],dis[N],vis[N];
struct node
{
    int next,to,color;
} edge[M];
struct jxj
{
    int pre,c,val;
    bool operator<(const jxj &a) const
    {
        return val<a.val;
    }
};
unordered_map<ll,int> s;
set<int> ppp[N];
ll gettp(jxj a)
{
    return a.c*1e10+a.pre*1e5+a.val;
}
int read()
{
    int res = 0, flag = 0;
    char ch;
    if((ch = getchar()) == '-') flag = 1;
    else if(ch >= '0' && ch <= '9') res = ch - '0';
    while((ch = getchar()) >= '0' && ch <= '9')
        res = res * 10 + (ch - '0');
    return flag ? -res : res;
}
void addedge(int a,int b,int c)
{
    edge[cnt].to=b;    edge[cnt].next=head[a];
    edge[cnt].color=c; head[a]=cnt++;
    edge[cnt].to=a;    edge[cnt].next=head[b];
    edge[cnt].color=c; head[b]=cnt++;
}
void spfa()
{
    for(int i=1; i<=n; i++)
        dis[i]=inf;
    dis[1]=0;
    jxj mark,next;
    mark.c=0, mark.pre=1, mark.val=0;
    ll tp;
    tp=gettp(mark);
    s[tp]=1;
    priority_queue<jxj> q;
    q.push(mark);
    while(!q.empty())
    {
        jxj now=q.top();
        q.pop();
        tp=gettp(now);
        s[tp]=0;
        for(int i=head[now.pre]; ~i; i=edge[i].next)
        {
            int v=edge[i].to;
            int cost=now.val;
            if(now.c!=edge[i].color)
                cost++;
            if(dis[v]>cost||(dis[v]==cost&&ppp[v].find(edge[i].color)==ppp[v].end()))
            {
                ppp[v].insert(edge[i].color);
                dis[v]=cost;
                next.c=edge[i].color;
                next.pre=v;
                next.val=cost;
                tp=gettp(next);
                if(s[tp]==0)
                {
                    s[tp]=1;
//                    printf("%d %d\n",now.c,next.c);
//                    printf("%d %d %d %d\n",now.pre,next.pre,next.c,next.val);
                    q.push(next);
                }
            }
        }
    }
}
int main()
{
   (n=read(),m=read();
    {
        s.clear();
        cnt=0;
        for(int i=1; i<=n; i++)
            head[i]=-1,ppp[i].clear();
        for(int i=1; i<=m; i++)
        {
            int x,y,z;
            x=read(),y=read(),z=read();
            addedge(x,y,z);
        }
        spfa();
        if(dis[n]==inf)
            puts("-1");
        else
        {
//            for(int i=1; i<=n; i++)
//                printf("%d%c",dis[i],i==n?'\n':' ');
            printf("%d\n",dis[n]);
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:88:22: error: expected ')' before ';' token
   88 |    (n=read(),m=read();
      |    ~                 ^
      |                      )