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

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

#include<map>
typedef pair<int,int> P;

//vector<vector<P> >v;//辺リスト(v[i]には辺が詰まっている
vector<P> v[500010];
unordered_map<int,int> u[100010];//頂点リスト(u[頂点][路線]==vでの番号)

priority_queue<P,vector<P>,greater<P> >Q;
int dis[500010];

int main(){
	vector<P> emptyvector;
	//v.push_back(emptyvector);
	
	int n,m;
	cin>>n>>m;
	int vsize=1;
	for(int i=1;i<=n;i++){
		//v.push_back(emptyvector);
		u[i][-1]=vsize;
		vsize++;
	}
	while(m--){
		int a,b,train;
		cin>>a>>b>>train;
		lol(p,2){
			if(u[a][train]==0){
				//v.push_back(emptyvector);
				v[vsize].push_back(make_pair(a,0));
				v[a].push_back(make_pair(vsize,1));
				
				u[a][train]=vsize;
				a=vsize;
				vsize++;
			}
			else{
				a=u[a][train];
			}
			swap(a,b);
		}
		v[a].push_back(make_pair(b,0));
		v[b].push_back(make_pair(a,0));
	}
	
	//↓ Dijkstra ↓
	lol(i,vsize)dis[i]=mod;
	Q.push(make_pair(1,0));
	while(!Q.empty()){
		int a=Q.top().first,b=Q.top().second;
		Q.pop();
		if(dis[a]<=b)continue;
		dis[a]=b;
		for(int i=0;i<v[a].size();i++){
			int pnt=v[a][i].first,cost=v[a][i].second+b;
			if(dis[pnt]<=cost)continue;
			Q.push(make_pair(v[a][i].first,v[a][i].second+b));
		}
	}
	int tmp=dis[u[n][-1]];
	cout<<(tmp==mod?-1:tmp)<<endl;
	return 0;
}


Compiler output:
a.cc:15:1: error: 'unordered_map' does not name a type
   15 | unordered_map<int,int> u[100010];//頂点リスト(u[頂点][路線]==vでの番号)
      | ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:29:17: error: 'u' was not declared in this scope
   29 |                 u[i][-1]=vsize;
      |                 ^
a.cc:36:28: error: 'u' was not declared in this scope
   36 |                         if(u[a][train]==0){
      |                            ^
a.cc:68:21: error: 'u' was not declared in this scope
   68 |         int tmp=dis[u[n][-1]];
      |                     ^
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
int n,m,x,y,z,dist[111111];
vector<pair<int,int> > g[111111];
queue<pair<int,int> > q;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		g[x].push_back(make_pair(y,z));
		g[y].push_back(make_pair(x,z));  
	}
	for (int i=1;i<=n;i++) dist[i]=1e9;
	dist[1]=0;
	for (int i=0;i<g[1].size();i++)
	{
		int =g[1][i].first,val=g[1][i].second;
		dist[to]=1;
		q.push(make_pair(to,val)); 
	}
	while(!q.empty())
	{
		int x=q.front().first,val=q.front().second;
		q.pop();
		for (int i=0;i<g[x].size();i++)
		{
			int to=g[x][i].first,k=g[x][i].second;
			if (k==val && dist[to]>dist[x])
			{
				dist[to]=dist[x];
				q.push(make_pair(to,val)); 
			}
			else if (dist[to]>dist[x]+1)
			{
				dist[to]=dist[x]+1;
				q.push(make_pair(to,k)); 
			}
		}
	}
	if (dist[n]==1e9) printf("-1\n");
	else printf("%d\n",dist[n]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:21: error: expected unqualified-id before '=' token
   22 |                 int =g[1][i].first,val=g[1][i].second;
      |                     ^
a.cc:23:22: error: 'to' was not declared in this scope; did you mean 'tm'?
   23 |                 dist[to]=1;
      |                      ^~
      |                      tm
a.cc:24:37: error: 'val' was not declared in this scope
   24 |                 q.push(make_pair(to,val));
      |                                     ^~~
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#include <functional>

using ll=long long int;

constexpr int MAX_N=(int)1e5,

constexpr ll INF=(ll)1e9;

struct edge{

    int to,com;

    edge()=default;

    edge(int _t,int _c) : to(_t),com(_c) {}
};

struct Node{

    int v,com;

    ll cost;

    Node()=default;

    Node(int _v,ll _cost,int _com) : v(_v),cost(_cost),com(_com) {}

    bool operator< (const Node& rhs) const{

        return cost<rhs.cost;
    }

    bool operator> (const Node& rhs) const{

        return cost>rhs.cost;
    }
};

int n,m;

std::vector<edge> G[MAX_N];

ll d[MAX_N];

ll dijkstra(int s,int g){

    for(int i=0;i<n;++i)
        d[i]=INF;

    std::priority_queue<Node,std::vector<Node>,std::greater<Node>> que;

    que.emplace(s,d[s]=0,0);

    while(!que.empty()){

        Node node=que.top();

        que.pop();

        if(node.v==g)
            return d[g];

        if(node.cost>d[node.v])
            continue;
        
        for(auto& e : G[node.v]) {

            int cost=(e.com!=node.com);

            if(d[e.to]>d[node.v]+cost){

                d[e.to]=d[node.v]+cost;

                que.emplace(e.to,d[e.to],e.com);
            }
        }
    }
    return -1;
}

int main() {

    std::cin>>n>>m;

    int p,q,c;

    for(int i=0;i<m;++i) {

        std::cin>>p>>q>>c;

        G[p-1].emplace_back(q-1,c);

        G[q-1].emplace_back(p-1,c);
    }

    ll ans=dijkstra(0,n-1);

    std::cout<<ans<<std::endl;

    return 0;
}

Compiler output:
a.cc:10:1: error: expected unqualified-id before 'constexpr'
   10 | constexpr ll INF=(ll)1e9;
      | ^~~~~~~~~
a.cc: In function 'll dijkstra(int, int)':
a.cc:51:14: error: 'INF' was not declared in this scope
   51 |         d[i]=INF;
      |              ^~~
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#include <functional>

using ll=long long int;

constexpr int MAX_N=(int)1e5,

constexpr ll INF=(ll)1e9;

struct edge{

    int to,com;

    edge()=default;

    edge(int _t,int _c) : to(_t),com(_c) {}
};

struct Node{

    int v,com;

    ll cost;

    Node()=default;

    Node(int _v,ll _cost,int _com) : v(_v),cost(_cost),com(_com) {}

    bool operator< (const Node& rhs) const{

        return cost<rhs.cost;
    }

    bool operator> (const Node& rhs) const{

        return cost>rhs.cost;
    }
};

int n,m;

std::vector<edge> G[MAX_N];

ll d[MAX_N];

ll dijkstra(int s,int g){

    std::fill(d,d+n,INF);

    std::priority_queue<Node,std::vector<Node>,std::greater<Node>> que;

    que.emplace(s,d[s]=0,0);

    while(!que.empty()){

        Node node=que.top();

        que.pop();

        if(node.v==g)
            return d[g];

        if(node.cost>d[node.v])
            continue;
        
        for(auto& e : G[node.v]) {

            int cost=(e.com!=node.com);

            if(d[e.to]>d[node.v]+cost){

                d[e.to]=d[node.v]+cost;

                que.emplace(e.to,d[e.to],e.com);
            }
        }
    }
    return -1;
}

int main() {

    std::cin>>n>>m;

    int p,q,c;

    for(int i=0;i<m;++i) {

        std::cin>>p>>q>>c;

        G[p-1].emplace_back(q-1,c);

        G[q-1].emplace_back(p-1,c);
    }

    ll ans=dijkstra(0,n-1);

    std::cout<<ans<<std::endl;

    return 0;
}

Compiler output:
a.cc:10:1: error: expected unqualified-id before 'constexpr'
   10 | constexpr ll INF=(ll)1e9;
      | ^~~~~~~~~
a.cc: In function 'll dijkstra(int, int)':
a.cc:50:21: error: 'INF' was not declared in this scope
   50 |     std::fill(d,d+n,INF);
      |                     ^~~
Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
 struct Z2 {
	public int x, y;
	public Z2(int x, int y){
		this.x = x; this.y = y;
	}
}
 
public class A {
	
	int MAX_N = 100008;
	int MAX_M = 200008;
    int INF = 2000000;
	int N,M;
	
	List<Z2>[] edges;
	
	
	public A(){
		edges = new List<Z2>[MAX_N];
		for(int i=0;i<MAX_N;i++) edges[i] = new List<Z2>();
	}
	
	string[] Rs(){
		return Console.ReadLine().Split(' ');
	}
	public void run(){
		string[] str = Rs();
		N = int.Parse(str[0]); M = int.Parse(str[1]);
		for(int i=0;i<M;i++){
			int[] inp = Rs().Select( x => int.Parse(x)-1 ).ToArray();
			edges[ inp[0] ].Add( new Z2(inp[1],inp[2]) );
			edges[ inp[1] ].Add( new Z2(inp[0],inp[2]) );
		}
		
		Dictionary<long, long> dis = new Dictionary<long,long>(3*MAX_M);
		
		Queue<Z2> que = new Queue<Z2>();
		
		que.Enqueue(new Z2(0, -1) ); // (position, company)
		dis.Add(-1, 0);
		
		while(que.Count != 0){
			Z2 n = que.Dequeue();
			if(n.x == N-1){ 
				Console.WriteLine(dis[n.x*INF+n.y]);
				return;
			}
			
			Queue<int> que2 = new Queue<int>();
			que2.Enqueue(n.x);
			while(que2.Count!=0){
				int now = que2.Dequeue();
				foreach(Z2 e in edges[now]){
					Z2 cd = new Z2(now, n.y);
					if(e.x==N-1 && e.y==n.y){
						Console.WriteLine(dis[n.x*INF+n.y]);
						return;
					}
					if(e.y == n.y){
						if( !dis.ContainsKey(e.x*INF+e.y) ){
							que2.Enqueue(e.x);
							dis.Add(e.x*INF+e.y, dis[cd.x*INF+cd.y]);
						} else if(dis[e.x*INF+e.y] > dis[cd.x*INF+cd.y]){
							que2.Enqueue(e.x);
							dis[e.x*INF+e.y] =  dis[cd.x*INF+cd.y];
						}
					} else {
						if( !dis.ContainsKey(e.x*INF+e.y) ){
							que.Enqueue(e);
							dis.Add(e.x*INF+e.y, dis[n.x*INF+n.y]+1);
						} else if( dis[e.x*INF+e.y] > dis[n.x*INF+n.y]+1){
							que.Enqueue(e);
							dis[e.x*INF+e.y] = dis[n.x*INF+n.y]+1;
						}
					}
				}
			}
		} 
		Console.WriteLine("-1");
	}
}
 
public class Program {
	static void Main(string[] args){
		A a = new A();
		a.run();
	}
}

Compiler output:
a.cc:4:1: error: extended character   is not valid in an identifier
    4 |  struct Z2 {
      | ^
a.cc:10:1: error: extended character   is not valid in an identifier
   10 |  
      | ^
a.cc:85:1: error: extended character   is not valid in an identifier
   85 |  
      | ^
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:1: error: '\U000000a0struct' does not name a type; did you mean 'struct'?
    4 |  struct Z2 {
      | ^~~~~~~
      | struct
a.cc:10:1: error: '\U000000a0' does not name a type
   10 |  
      | ^
a.cc:85:1: error: '\U000000a0' does not name a type
   85 |  
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <queue>

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vpl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define forn1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forn11(i, n) for (int i = 1; i < (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#define prOk(ok) cout << ((ok) ? "Yes" : "No")
#define in insert
#define rem remove

#define linf ((ll) 1e9)
#define inf ((int) 1e5)



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

	ll numSta, numLine;
	cin >> numSta >> numLine;

	static vpl g[linf];				//graph as connectivity list
	map<pl, ll> ids;

	ll lastId = numSta;

	forn(i, numLine)
	{
		int a,b, com;
		cin >> a >> b >> com;
		a--; b--; com--;	//zero based

		ll ida, idb;

		if(ids.count(mp(a, com)) == 0)
		{
			ids[mp(a, com)] = ida = lastId++;
			g[a].pb(mp(ida, 1));
			g[ida].pb(mp(a, 0));
		}
		else
			ida = ids[mp(a, com)];

		if(ids.count(mp(b, com)) == 0)
		{
			ids[mp(b, com)] = idb = lastId++;
			g[b].pb(mp(idb, 1));
			g[idb].pb(mp(b, 0));
		}
		else
			idb = ids[mp(b, com)];

		g[ida].pb(mp(idb, 0));
		g[idb].pb(mp(ida, 0));
	}

	//SPFA for shortest path - https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm

	vl dist(linf, linf);
	dist[0] = 0;

	queue<ll> q;
	set<ll> inQ;

	q.push(0);
	inQ.insert(0);

	while(!q.empty())
	{
		ll u = q.front();
		q.pop();
		inQ.erase(u);

		for(auto e : g[u])
		{
			ll alt = dist[u] + e.second;
			if(alt < dist[e.first])
			{
				dist[e.first] = alt;
				if(inQ.count(e.first) == 0)
				{
					q.push(e.first);
					inQ.insert(e.first);
				}
			}
		}
	}

	if(dist[numSta-1] == linf)
		cout << -1;
	else
		cout << dist[numSta-1];

	return 0;
}

Compiler output:
/tmp/ccgQGI9M.o: in function `main':
a.cc:(.text+0x9f): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0xaf): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x10b): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status
Language: C++

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

typedef pair<int,int> P;

int nextInt() {
  int x; scanf("%d", &x); return x;
}

const int MAX_N = 100000 + 10;

map<P, vector<int> > g;
vector<P> es[MAX_N];

struct State {
  int pos;
  int pc;
  int cost; 
  State(int a, int b, int c) : pos(a), pc(b), cost(c) {}
};

int main() {
  int N = nextInt();
  int M = nextInt();

  vector<L> vl;
  for (int i = 0; i < M; i++) {
    int p = nextInt() - 1;
    int q = nextInt() - 1;
    int c = nextInt();
    es[p].emplace_back(q, c);
    es[q].emplace_back(p, c);
    g[P(p,c)].push_back(q);
    g[P(q,c)].push_back(p);
  }

  int ans = -1;
  map<P, int> memo; // 0なら存在しないノード、最小値は 1 
  deque<State> pq;
  pq.emplace_back(0, 0, 1); // 今いる駅, 最後に使った会社, コスト
  memo[P(0,0)] = 1;
  while (!pq.empty()) {
    const State state = pq.front();
    pq.pop_front();
    const int cost = memo[P(state.pos, state.pc)];
    if (state.cost != cost) continue;
    const int cost = state.cost;
    if (state.pos == N - 1 && state.pc == -1) {
      ans = cost - 1;
      break;
    }

    if (state.pc == -1) {
      for (P e : es[state.pos]) {
        int next_cost = cost + 1;
        auto f = memo.find(e);
        if (f == memo.end() || f->second > next_cost) {
          memo[e] = next_cost;
          pq.emplace_back(e.first, e.second, next_cost);
        }
      }
    }
    else
    {
      for (int next_pos : g[P(state.pos, state.pc)]) {
        P e(next_pos, state.pc);
        int next_cost = cost;
        auto f = memo.find(e);
        if (f == memo.end() || f->second > next_cost) {
          memo[e] = next_cost;
          pq.emplace_front(e.first, e.second, next_cost);
        }
      }
      {
        int next_pos = state.pos;
        int next_pc = -1;
        P e(next_pos, next_pc);
        int next_cost = cost ;
        auto f = memo.find(e);
        if (f == memo.end() || f->second > next_cost) {
          memo[e] = next_cost;
          pq.emplace_front(e.first, e.second, next_cost);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:10: error: 'L' was not declared in this scope
   26 |   vector<L> vl;
      |          ^
a.cc:26:11: error: template argument 1 is invalid
   26 |   vector<L> vl;
      |           ^
a.cc:26:11: error: template argument 2 is invalid
a.cc:47:15: error: redeclaration of 'const int cost'
   47 |     const int cost = state.cost;
      |               ^~~~
a.cc:45:15: note: 'const int cost' previously declared here
   45 |     const int cost = memo[P(state.pos, state.pc)];
      |               ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <queue>

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    for(int N,M; std::cin >> N >> M; ) {
        typedef std::pair<int,int> G;
        std::vector<std::vector<int>> g(N,std::vector<int>());
        typedef std::pair<int,int> T;
        std::priority_queue<T,std::vector<T>,std::greater<T>> q;
        std::vector<G> i2t; i2t.reserve(M*2);
        {
            std::map<G,int> t2i;
            auto add = [&t2i,&i2t](const G&t) {
                if(!t2i.count(t)) {
                    t2i[t]=i2t.size();
                    i2t.emplace_back(t);
                }
            };
            G S(0,-1); add(S);
            std::vector<std::array<int,3>> pqc(M);
            for(auto&a:pqc) {
                for(auto&v:a) std::cin >> v;
                if(--a[0]<--a[1]) std::swap(a[0],a[1]);
            }
            std::sort(pqc.rbegin(),pqc.rend());
            for(auto&a:pqc) {
                const auto p=a[0],q=a[1],c=a[2];
                const G tq(p,c),tp(q,c);
                add(tp); g[p].emplace_back(t2i[tp]);
                add(tq); g[q].emplace_back(t2i[tq]);
            }
            q.emplace(0,t2i[S]);
        }
        std::vector<bool> u(i2t.size(),false);
        std::vector<int> v(N,N+1);
        int r=-1;
        while(!q.empty()) {
            int d,t,p,c;
            std::tie(d,t) = q.top(); q.pop();
            std::tie(p,c) = i2t[t];
            if(p == N-1){ r=d; break; }
            if(u[t] || v[p]<d) continue;
            u[t]=true;
            v[p]=d;
            for(const auto& w:g[p]) {
                auto e = d+(c==i2t[w].second?0:1);
                if(u[w] || v[i2t[w].first]<e) continue;
                q.emplace(e,w);
            }
        }
        std::cout << r << std::endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:18: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   30 |             std::sort(pqc.rbegin(),pqc.rend());
      |                  ^~~~
      |                  qsort
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;


int main(){
	int N,M; cin >> N >> M;
	vector<set<int>> st2ln(N+1);
	vector<set<int>> adj(M+1);

	set<int> start,end;

	rep(i,M){
		int p,q,c; cin >> p >> q >> c;
		if(p == 1 || q == 1)
			start.insert(c);
		if(p == N || q == N)
			end.insert(c);
		auto itr = st2ln[p].find(c);
		if(st2ln[p].empty()){
			st2ln[p].insert(c);
			continue;
		}
		else if(itr == st2ln[p].end()){
			for(auto itr = st2ln[p].begin(); itr != st2ln[p].end(); itr++){
				adj[c].insert(*itr);
				adj[*itr].insert(c);
				st2ln[p].insert(c);
			}
		}

		auto itr = st2ln[q].find(c);
		if(st2ln[q].empty()){
			st2ln[q].insert(c);
			continue;
		}
		else if(itr == st2ln[q].end()){
			for(auto itr = st2ln[q].begin(); itr != st2ln[q].end(); itr++){
				adj[c].insert(*itr);
				adj[*itr].insert(c);
				st2ln[q].insert(c);
			}
		}
	}

	if(start.empty() || end.empty()){
		cout << -1 << endl;
		return 0;
	}

	queue<int> que;
	vector<int> time(M+1, 1000000);
	int res = - 1;
	for(auto itr = start.begin(); itr != start.end(); itr++){
		time[*itr] = 0;
		que.push(*itr);
		if(end.find(*itr) != end.end()){
			cout << 1 << endl;
			return 0;
		}
	}
	while(!que.empty()){
		int proc = que.front();
		que.pop();
		for(auto itr = adj[proc].begin(); itr != adj[proc].end(); itr++){
			if(time[*itr] == 1000000){
				time[*itr] = time[proc] + 1;
				que.push(*itr);
				if(end.find(*itr) != end.end()){
					res = time[*itr];
					break;
				}
					
			}
		}
	}
	if(res == -1)
		cout << -1 << endl;
	else
		cout << res + 1<< endl;
	

	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:22: error: conflicting declaration 'auto itr'
   42 |                 auto itr = st2ln[q].find(c);
      |                      ^~~
a.cc:29:22: note: previous declaration as 'std::_Rb_tree_const_iterator<int> itr'
   29 |                 auto itr = st2ln[p].find(c);
      |                      ^~~
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;


int main(){
	int N,M; cin >> N >> M;
	vector<set<int>> st2ln(N+1);
	vector<set<int>> adj(M+1);

	set<int> start,end;

	rep(i,M){
		int p,q,c; cin >> p >> q >> c;
		if(p == 1 || q == 1)
			start.insert(c);
		if(p == N || q == N)
			end.insert(c);
		auto itr = st2ln[p].find(c);
		if(st2ln[p].empty()){
			st2ln[p].insert(c);
			continue;
		}
		else if(itr == st2ln[p].end()){
			for(auto itr = st2ln[p].begin(); itr != st2ln[p].end(); itr++){
				adj[c].insert(*itr);
				adj[*itr].insert(c);
				st2ln[p].insert(c);
			}
		}

		auto itr = st2ln[q].find(c);
		if(st2ln[q].empty()){
			st2ln[q].insert(c);
			continue;
		}
		else if(itr == st2ln[q].end()){
			for(auto itr = st2ln[q].begin(); itr != st2ln[q].end(); itr++){
				adj[c].insert(*itr);
				adj[*itr].insert(c);
				st2ln[q].insert(c);
			}
		}
	}

	if(start.empty() || end.empty()){
		cout << -1 << endl;
		return 0;
	}

	queue<int> que;
	vector<int> time(M+1, 1000000);
	int res = - 1;
	for(auto itr = start.begin(); itr != start.end(); itr++){
		time[*itr] = 0;
		que.push(*itr);
		if(end.find(*itr) != end.end()){
			cout << 1 << endl;
			return 0;
		}
	}
	while(!que.empty()){
		int proc = que.front();
		que.pop();
		for(auto itr = adj[proc].begin(); itr != adj[proc].end(); itr++){
			if(time[*itr] == 1000000){
				time[*itr] = time[proc] + 1;
				que.push(*itr);
				if(end.find(*itr) != end.end()){
					res = time[*itr];
					break;
				}
					
			}
		}
	}
	if(res == -1)
		cout << -1 << endl;
	else
		cout << res + 1<< endl;
	

	/*
	vector<int> time(M+1, 1000000);
	set<int> taboo;
	time[start] = 0;
	int prv_mini = start;
	rep(i,M){
		if(start == end){
			time[end] = 0;
			break;
		}
		auto mini = min_element(time.begin(), time.end());
		int min_st = mini - time.begin();
		if(min_st == end)
			break;
		if(*mini == 1000000)
			break;
		taboo.insert(min_st);
		for(auto itr = adj[min_st].begin(); itr != adj[min_st].end(); itr++){
			if(taboo.find(*itr) != taboo.end()){
				time[*itr] = min(time[*itr], time[min_st] + 1)
			}
		}
	}
	*/
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:22: error: conflicting declaration 'auto itr'
   42 |                 auto itr = st2ln[q].find(c);
      |                      ^~~
a.cc:29:22: note: previous declaration as 'std::_Rb_tree_const_iterator<int> itr'
   29 |                 auto itr = st2ln[p].find(c);
      |                      ^~~
Language: C++

#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int int32_t
#define REP(i, a, b) for (int32_t i = (int32_t)(a); i < (int32_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
using namespace std;


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

	int N,M;
	cin >> N >> M;
	vector<vector<array<int, 2>>>subway(N);
	rep(i, M) {
		int p, q, c;
		cin >> p >> q >> c;
		p--; q--; c--;
		subway[p].push_back({ q,c });
		subway[q].push_back({ p,c });
	}
	//subway[i]:={町iから行ける駅、その鉄道会社}の集合
	
	typedef array<int, 3> arr;//移動コスト、現在地、現在の鉄道会社
	priority_queue<arr, vector<arr>, greater<arr>>D;
	vector<unordered_map<int, int>>cost(N);
	vector<int>min_cost(N, 99999999);
	D.push({ 0,0,1111111 });
	while (!D.empty()) {
		const auto a = D.top(); D.pop();
		const int now_cost = a[0];
		const int pos = a[1];
		const int kaisha = a[2];
		if (min_cost[pos] + 2 <= now_cost)continue;
		min_cost[pos] = min(min_cost[pos], now_cost);
		if (pos == N - 1)break;
		auto itr = cost[pos].find(kaisha);
		if (itr != cost[pos].end())continue;
		cost[pos][kaisha] = now_cost;
		rep(i,subway[pos].size()) {
			auto next = subway[pos][i];
			if (next[pos][i][0] == 99999999)continue;
			const int next_kaisha = next[1];
			const int next_cost = now_cost + (next_kaisha == kaisha ? 0 : 1);
			const int next_pos = next[0];

			if (min_cost[next_pos] + 2 <= next_cost)continue;
			auto nitr = cost[next_pos].find(next_kaisha);
			if (nitr != cost[next_pos].end())continue;

			D.push({ next_cost,next_pos,next_kaisha });
			subway[pos][i][0] = 99999999;
		}
	}
	if (min_cost[N - 1] == 99999999)cout << -1 << endl;
	else cout << min_cost[N - 1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:38: error: invalid types 'std::array<int, 2>::value_type {aka int}[int32_t {aka int}]' for array subscript
   61 |                         if (next[pos][i][0] == 99999999)continue;
      |                                      ^
Language: C++

//by tzupengwang™
#include<set>
#include<algorithm>
#include<cstdio>
#include<queue>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n , m ;
ii edg[ 400005 ] ;
int cpy[ 400005 ] ;
vector< int > v[ 100005 ] ;
set< int > st[ 100005 ] ;
int dis[ 400005 ] ;

void init() {
  scanf( "%d%d" , &n , &m ) ;
  for ( int i = 0 ; i < m ; i ++ ) {
    int x , y , z ;
    scanf( "%d%d%d" , &x , &y , &z ) ;
    edg[ i * 2 ] = ii( x , y ) ;
    cpy[ i * 2 ] = z ;
    v[ x ].push_back( i * 2 ) ;
    edg[ i * 2 + 1 ] = ii( y , x ) ;
    cpy[ i * 2 + 1 ] = z ;
    v[ y ].push_back( i * 2 + 1 ) ;
  }
}

priority_queue< ii , vector< ii > , greater< ii > > pq ;

void process() {
  memset( dis , -1 , sizeof dis ) ;
  for ( int id : v[ 1 ] ) {
    pq.push( ii( 1 , id ) ) ;
  }
  while ( !pq.empty() ) {
    ii nnw = pq.top() ; pq.pop() ;
    int nid = nnw.second , dss = nnw.first ;
    int now = edg[ nid ].second ;
    int nwc = cpy[ nid ] ;
    if ( now == n ) {
      printf( "%d\n" , dss ) ;
      return ;
    }
    if ( dis[ nid ] != -1 ) continue ;
    dis[ nid ] = dss ;
    if ( st[ now ].count( nwc ) ) continue ;
    if ( st[ now ].size() == 0 ) {
      for ( int id : v[ now ] ) if ( dis[ id ] == -1 ) {
        if ( nwc == cpy[ id ] ) {
          pq.push( ii( dss , id ) ) ;
        } else {
          pq.push( ii( dss + 1 , id ) ) ;
        }
      }
    } else {
      for ( int id : v[ now ] ) if ( dis[ id ] == -1 ) {
        if ( nwc == cpy[ id ] ) {
          pq.push( ii( dss , id ) ) ;
        }
      }
    }
    st[ now ].insert( cpy[ nid ] ) ;
  }
  printf( "-1\n" ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Compiler output:
a.cc: In function 'void process()':
a.cc:36:3: error: 'memset' was not declared in this scope
   36 |   memset( dis , -1 , sizeof dis ) ;
      |   ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include<queue>
  +++ |+#include <cstring>
    6 | using namespace std;
Language: C++

#include <queue>
#include <vector>

using namespace std;
bool seen[500005];
int N, M;

vector<int> adj[200005];
vector<pair<int,int>> e;

int bfs() {

    deque<pair<int, int>> q;
    q.push_back({0,0});
    while(!q.empty()) {
        pair<int, int> cur = q.front(); q.pop_front();
        int eID = cur.first;
        int dist = cur.second;

        int at = e[eID].first;
        int col = e[eID].second;
        if(seen[eID]) {
            continue;
        }
        seen[eID] = true;
        if(at == N) {
            return dist;
        }
        for(auto edge: adj[at]) {
            int to = e[edge].first;
            int tocol = e[edge].second;
            if(seen[edge]) {
                continue;
            }
            if(tocol == col) {
                q.push_front({edge,dist});
            } else {
                q.push_back ({edge,dist+1});
            }
        }
    }
    return -1;
}


int main() {
    cin >> N >> M;
    e.push_back({1,-1});
    for(int i = 1; i <= M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        e.push_back({b,c});
        adj[a].push_back(e.size()-1);
        e.push_back({a,c});
        adj[b].push_back(e.size()-1);
    }
    cout << bfs() << "\n";
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:47:5: error: 'cin' was not declared in this scope
   47 |     cin >> N >> M;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <queue>
  +++ |+#include <iostream>
    2 | #include <vector>
a.cc:57:5: error: 'cout' was not declared in this scope
   57 |     cout << bfs() << "\n";
      |     ^~~~
a.cc:57:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for(LL i=(a);i<(LL)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define FF first
#define SS second
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const ut INF=1LL<<30;
const int SIZE=5+1e5;
map<LL,LL> searched;
Vpr edge[SIZE];
VI miniumed[SIZE];
LL minium[SIZE];
LL p[SIZE],q[SIZE],c[SIZE];
int main(){
	int N,M;
	cin.tie(0);
	cin >> N >> M;
	FOR(i,1,N+1) minium[i]=INF;
	REP(i,M){
		cin >> p[i] >> q[i] >> c[i];
		edge[p[i]].PB(pr(c[i],q[i]));
		edge[q[i]].PB(pr(c[i],p[i]));
	}
	FOR(i,1,N+1){
		sort(ALL(edge[i]));
		miniumed[i].PB(INF);
	}
	PQ qu;
	qu.push(pr(0,1));
	while(!qu.empty()){
		LL dist=qu.top().first,now=qu.top().second;
		qu.pop();
		if(miniumed[now]) continue;
		searched[now]=true;
		sort(ALL(miniumed[now]));
		int ces=0;
		REP(i,edge[now].size()){
			int next=edge[now][i].second;
			int nuse=edge[now][i].first;
			while(miniumed[now][ces]<nuse) ces++;
			LL ndist=dist+(nuse!=miniumed[now][ces]);
			if(minium[next]>=ndist){
				if(minium[next]>ndist)
					miniumed[next].clear();
				minium[next]=ndist;
				miniumed[next].PB(nuse);
				qu.push(pr(ndist,next));
			}
		}
	}
	if(minium[N]==INF) cout << -1 << endl;
    else cout << minium[N] << endl;
	

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:32: error: could not convert 'miniumed[now]' from 'VI' {aka 'std::vector<long long int>'} to 'bool'
   45 |                 if(miniumed[now]) continue;
      |                    ~~~~~~~~~~~~^
      |                                |
      |                                VI {aka std::vector<long long int>}
Language: C++

#include<stdio.h>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
using namespace std;
int n,m;
map<int,vector<int> > e[111111];
int len[111111];
bool trans[111111];
map<int,set<int> > a[111111];

int q[111111],op,cl;
int main(){
	memset(len,-1,sizeof(len));
	scanf("%d%d",&n,&m);
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		if(x>y)swap(x,y);
		e[x][z].push_back(y);
		e[y][z].push_back(x);
		if(x == 1){
			len[y] = 1;
			a[1][z].insert(y);
		}
	}
	len[1] = 0;
	trans[1] = true;
	
	for(int step=1;;step++){

		if(a[step].empty()){
			puts("-1");
			return 0;
		}

		//same color.
		for(map<int,set<int> >::iterator it = a[step].begin(); it != a[step].end(); it++){
			op=cl=0;
			for(set<int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++)
				q[op++]=*it2;
			int col = it->first;
			while(cl<op){
				int y = q[cl++];
				if(!e[y].count(col))continue;
				for(vector<int>::iterator it2 = e[y][col].begin(); it2 != e[y][col].end(); it2++){
					int to = *it2;
					if(len[to] != -1 && len[to] < step)continue;
					if(a[step][col].count(to))continue;
					a[step][col].insert(to);
					q[op++]=to;
					len[to]=step;
				}
			}
		}

		//different color
		for(map<int,set<int> >::iterator it = a[step].begin(); it != a[step].end(); it++){
			for(set<int>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++){
				int y = *it2;
				if(trans[y])continue;
				for(map<int,vector<int> >::iterator it3 = e[y].begin(); it3 != e[y].end(); it3++)
					for(vector<int>::iterator it4 = it3->second.begin(); it4 != it3 ->second.end(); it4++){
						int to = *it4;
						if(len[to] != -1 && len[to] <= step)continue;
						len[to] = step+1;
						a[step+1][it3->first].insert(to);
					}
			}
		}

		if(len[n]!=-1){
			printf("%d\n",len[n]);
			return 0;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'memset' was not declared in this scope
   16 |         memset(len,-1,sizeof(len));
      |         ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include<queue>
  +++ |+#include <cstring>
    7 | using namespace std;
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
vector<pii> g[125252];
unordered_map<int,int> typedeg[125252];
unordered_set<int> visited[125252];
int dist[125252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int p,q,c;
    scanf("%d%d%d",&p,&q,&c);
    --p;--q;
    g[p].push_back(pii(q,c));
    g[q].push_back(pii(p,c));
    typedeg[p][c] += 1;
    typedeg[q][c] += 1;
  }
  // -dist,pos,type
  priority_queue<pair<int,pii>> Q;
  const int INF = 830252521;
  REP(i,n)dist[i]=INF;
  dist[0] = 0;
  Q.push(make_pair(0,pii(0,-1)));
  while(!Q.empty()){
    pair<int,pii> P = Q.top(); Q.pop();
    int d = -P.first;
    int pos = P.second.first;
    int type = P.second.second;
    for(const pii& T:g[pos]){
      int to = T.first;
      int totype = T.second;
      int ndist = d + (type==totype ? 0 : 1);
      if(ndist > dist[to])continue;
      if(ndist == dist[to] && visited[to].count(totype))continue;
      if(ndist == dist[to] && typedeg[to][totype]==1)continue;
      // go
      dist[to] = ndist;
      visited[to].insert(totype);
      if(to==n-1){
        Q.clear();
        break;
      }
      Q.push(make_pair(-ndist,pii(to,totype)));
    }
  }
  int ans = dist[n-1];
  if(dist[n-1]==INF){
    ans = -1;
  }
  printf("%d\n",ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:11: error: 'class std::priority_queue<std::pair<int, std::pair<int, int> > >' has no member named 'clear'
   73 |         Q.clear();
      |           ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std ;
const int mod = 1e9 + 7 ;
const int N = 900010 ;
#define ll long long 
int n , m , k ;
ll fac[ N ] , ifac[ N ] , p[ N ] ; 

ll mul( ll x , ll  y ) {
    return ( 1ll * x * y ) % mod ;
}
ll add( ll x , ll y ) {
    return ( x + y ) % mod ;
}
ll power( ll a , ll b ) {
    int ans = 1 , base = a ;
    while( b ) {
        if( b&1 ) ans = mul( ans , base ) ;
        base = mul( base , base ) ; 
        b >>= 1 ;
    }
    return ans ;
}
ll inv( ll x ) {
    return power( x , mod - 2 ) % mod ;
}
ll C( ll x , ll y ) {
    return ( fac[ x ] * ifac[ y ] % mod * ifac[ x - y ] % mod ) % mod ;
}
int main() {
    scanf( "%d%d%d" , &n , &m , &k ) ;
    fac[ 0 ] = 1ll ;
    p[ 0 ] = 1ll ;
    for( int i = 1 ; i < N ; i ++ ) {
        fac[ i ] = fac[ i - 1 ] * i % mod ;
        p[ i ] = p[ i - 1 ] * 3ll % mod ;
    }
    for( int i = 0 ; i < N ; i ++ ) {
        ifac[ i ] = inv( fac[ i ] ) ;
    }
    ll ans = 0 , x = 1ll ;
    n -- ;
    for( int i = 0 ; i <= m + k ; i ++ ) {
        ans = ( ans + C( n + i , n ) * p[ m + k - i ] % mod * x )  % mod  ;
        if( i < k ) x = ( x * 2ll ) % mod ;
        else if( i < m ) x = ( x * 2ll - C( i , k ) ) % mod ;
        else  x = ( x * 2ll - C( i , k ) - C( i , m ) ) % mod ;
    }
    printf( "%lld\n" , add( ans , mod ) ) ;
    return 0 ;
} 

满分做法

Compiler output:
a.cc:53:1: error: '\U00006ee1\U00005206\U0000505a\U00006cd5' does not name a type
   53 | 满分做法
      | ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define N 300005
#define mod 1000000007
#define ll long long
using namespace std;
ll up,n,m,k;
ll ans=0,fac[N*3],ifac[N*3],mul[N*3];
inline ll calc(int a,int b){return fac[a]*ifac[b]%mod*ifac[a-b]%mod;}
inline ll ksm(ll x,int p){
	ll ret=1;
	while(p){
		if(p&1)ret=ret*x%mod;
		x=x*x%mod,p>>=1;
	}
	return ret;
}
int main(){
	cin>>n>>m>>k,up=n+m+k,fac[0]=mul[0]=ifac[1]=ifac[0]=1;
	for(ll i=2;i<=up;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;
	for(ll i=1;i<=up;++i)mul[i]=mul[i-1]*3%mod,(ifac[i]*=ifac[i-1])%=mod,fac[i]=fac[i-1]*i%mod;
	if(m<k)m^=k,k^=m,m^=k;
	for(ll i=0,j=1;i<=m+k;++i){
		(ans+=calc(n-1+i,n-1)*mul[m+k-i]%mod*j%mod)%=mod;
		if(i<k)(j<<=1)%=mod;
		else if(i>=m)(j+=j-calc(i,k)-calc(i,i-m))%=mod;
		else (j+=j-calc(i,k))%=mod;
	}
	cout<<(ans+mod)%mod;
	return 0;
}

---------------------

本文来自 dreaming__ldx 的CSDN 博客 ，全文地址请点击：https://blog.csdn.net/dreaming__ldx/article/details/82778499?utm_source=copy 

Compiler output:
a.cc:32:1: error: expected unqualified-id before '--' token
   32 | ---------------------
      | ^~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

#define fi(a,b) for(int i=a;i<b;++i)
typedef long long ll;
///////////////////

int const N = 3e3 + 41;
int const MOD = 1e9 + 7;

int n, m, k;
int f[N], invf[N];
int th[N];
int ans;

void add(int &a, int b){
	a += b;
	while(a >= MOD) a -= MOD;
	while(a < 0) a += MOD;
}

int mul(int a, int b){
	return (ll) a * b % MOD;
}

int bp(int x, int d){
	int res = 1;
	while(d){
		if(d&1) res = mul(res, x);
		d >>= 1;
		x = mul(x, x);
	}
	return res;
}

int inv(int x){
	return bp(x, MOD-2);
}

void init(){
	f[0] = 1;
	fi(1, N) f[i] = mul(f[i-1], i);
	fi(0, N) invf[i] = inv(f[i]);
	th[0] = 1;
	fi(1, N) th[i] = mul(th[i-1], 3);
}

int getc(int n, int k){
	if(k > n) return 0;
	int res = f[n];
	res = mul(res, invf[k]);
	res = mul(res, invf[n-k]);
	return res;
}

int dg[N];

int getg(int x){
	if(dg[x] != -1) return dg[x];
	int res = 0;
	fi(0, k+1){
		int y = x - i;
		if(y > m) continue;
		int v = getc(x, i);
		add(res, v);
	}
	dg[x] = res;
	return res;
}

void solve(){
	int x = n + m + k;
	memset(dg, 255, sizeof(dg));
	fi(1, x+1){
		int f = getc(i-1, n-1);
		int g = getg(i-n);
		int t = th[x-i];
		add(ans, mul(f, mul(g, t)));
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	init();

	scanf("%d %d %d",&n,&m,&k);

	solve();

	printf("%d\n",ans);

	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:76:9: error: 'memset' was not declared in this scope
   76 |         memset(dg, 255, sizeof(dg));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<vector>
  +++ |+#include <cstring>
    4 |
Language: C++

#include<bits/stdc++.h>

using namespace std;

int N, M, K, v[600009];
const int mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

int fac[1000009], inv[1000009], p3[1000009];
void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int main ()
{
/freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &N, &M, &K), Prec (900003), p3[0] = 1;
for (int i=1; i<=900000; i++)
    p3[i] = add (add (p3[i - 1], p3[i - 1]), p3[i - 1]);
/*for (int i=0; i<=M; i++)
    for (int j=0; j<=K; j++)
        adto (v[i + j], comb (i + j, i));*/
/*
sa consideram un dreptunghi cu un colt in (0, 0) si unul in (M, K)
pentru fiecare diagonala secundara, vrem sa stim numarul de drumuri
care duc in diagonala aia
*/
v[0] = 1;
if (M > K) swap (M, K); ///M <= K
for (int i=1; i<=M + K; i++)
{
    v[i] = add (v[i - 1], v[i - 1]);
    if (i > M) v[i] = subtract (v[i], comb (i - 1, M));
    if (i > K) v[i] = subtract (v[i], comb (i - 1, K));
}
int ans = 0;
for (int i=0; i<=M + K; i++)
{
    v[i] = mul (v[i], p3[M + K - i]);
    adto (ans, mul (v[i], comb (i + N - 1, N - 1)));
}
printf ("%d\n", ans);
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:1: error: expected primary-expression before '/' token
   31 | /freopen ("input", "r", stdin);
      | ^
Language: Java

import java.awt.geom.Point2D;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.*;

 
 
 
public class Main {
	public static long C(int n, int r)
	{
		if(n < 0 || r < 0 || r > n)return 0;
		if(r > n / 2)r = n - r;
		return FACT[n]*IFACT[n-r]%mod*IFACT[r]%mod;
	}
	long extGcd()
	 
	static long[] FACT, IFACT;
	static long  get_gcd(long  n, long  m) {
		  if (n < m) {
			  long tmp = n;
			  n = m;
			  m = tmp;
		  }
		  while (m != 0) {
			  long tmp = n;
			  n = m;
			  m = tmp;
		    m %= n;
		  }
		  return n;
		}

	public static long  modinv(long  x, long  m) {
	    long  s, t;
	    s = get_gcd(x, m);
	    
	    return (m+s) % m;
	}
	 
		
	static int MOD = 1000000007;
	static int mod = MOD;
	public static void main(String[] args) {
		int n = 900000;
		FACT = new long[n+1];
		IFACT = new long[n+1];
		FACT[0] = 1;
		IFACT[0] = 1;
		
		for(int i = 1;i <= n;i++){
			FACT[i] = FACT[i-1] * i % mod;
			IFACT[i] = new BigInteger(String.valueOf(FACT[i])).modInverse(new BigInteger(String.valueOf(mod))).longValue();
		}
		Scanner sc = new Scanner(System.in);
		PrintStream out = new PrintStream(System.out);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();
		long ans = 0;
		
		for(int i = N; i <= N + M + K; i++) {
			int retA = modPow(3,N + M + K - i);
			
			int retB = (int)C(i-1,N-1);
			int kMax = Math.max(0, i - N-K);
			int kMin = Math.min(i - N, M);
			long sum = 0;
			for(int k = kMax; k <= kMin; k++) {
				sum += (int)C(i - N, k) % MOD;
				sum %= MOD;
			}
			long ansA = ((long)(retA) * (long)(retB)) % MOD;
			ansA *= sum % MOD;
			ansA %= MOD;
			ans += ansA;
			ans %= MOD;
		}
		System.out.println(ans);
	}
	public static int modPow(int a, int b) {
		if(b == 0) return 1 % MOD;
		if(b == 1) return a % MOD;
		
		if(b % 2 == 0) {
			long ret = modPow(a % MOD,b / 2) % MOD;
			return (int)((ret * ret) % MOD);
		}
		else {
			long ret = (a * (long)modPow(a % MOD,b-1)) % MOD;
			return (int)(ret % MOD);
		}
	}
	public static int comb(int n, int k) {
		if(k == 0) return 1;
		long AA = 1;
		for(int i = 0; i < k; i++) {
			AA *= (long)n - i;
			AA %= MOD;
		}
		for(int i = 1; i <= k; i++) {
			AA *= new BigInteger(String.valueOf(i)).modInverse(new BigInteger(String.valueOf(MOD))).longValue();
			AA %= MOD;
		}
		return (int)(AA % MOD);
	}


}

Compiler output:
Main.java:17: error: ';' expected
	long extGcd()
	             ^
1 error
Language: C++

import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static long MOD = 1_000_000_007;
	static long[] pow3 = new long[1_000_000];
	static long[] fact = new long[1_000_000];
	static long[] finv = new long[1_000_000];
	static int N, M, K;

	public static void main(String[] args) {
		N = sc.nextInt();
		M = sc.nextInt();
		K = sc.nextInt();
		if (N > 1000 || M > 1000 || K > 1000) return;
		pow3[0] = 1;
		fact[0] = 1;
		finv[0] = inv(1);
		for (int i = 1; i < pow3.length; ++i) {
			pow3[i] = pow3[i - 1] * 3 % MOD;
			fact[i] = fact[i - 1] * i % MOD;
			finv[i] = inv(fact[i]);
		}
		long ans = 0;
		for (int i = 0; i <= M; ++i) {
			for (int j = 0; j <= K; ++j) {
				ans += solve(i, j);
				ans %= MOD;
			}
		}
		System.out.println(ans);
	}

	static long solve(int b, int c) {
		long ret = pow3[M - b] * pow3[K - c] % MOD;
		ret *= fact[N - 1 + b + c];
		ret %= MOD;
		ret *= finv[N - 1];
		ret %= MOD;
		ret *= finv[b];
		ret %= MOD;
		ret *= finv[c];
		ret %= MOD;
		return ret;
	}

	static long inv(long v) {
		return pow(v, MOD - 2);
	}

	static long pow(long v, long p) {
		if (p == 0) return 1;
		if (p == 1) return v;
		long ret = pow(v, p / 2);
		ret *= ret;
		ret %= MOD;
		if (p % 2 == 1) {
			ret *= v;
			ret %= MOD;
		}
		return ret;
	}

}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

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

typedef long long ll;

const ll INF = 1e18;
const int N = 2010;

ll n, x, a[N], ans, dp[N][2];

void init() {
	for (ll i = 0; i < n; i++)
		dp[i][0] = dp[i][1] = INF;
}

ll get(ll start) {
	init();
	dp[start][0] = a[start];
	for (ll step = 1; step < n; step++) {
		ll i = (start + step) % n, prev = (i - 1 + n) % n;
		dp[i][0] = min(dp[prev][0], dp[prev][1]) + a[i];
		dp[i][1] = min(dp[prev][0], dp[prev][1]) + a[start] + x;
	}	
	ll prev = (start - 1 + n) % n;
	return min(dp[prev][0], dp[prev][1]);
}

int main() {
	cin >> n >> x;
	for (ll i = 0; i < n; i++)
		cin >> a[i];
  	reverse(a.begin(), a.end());
	ans = INF;
	for (int i = 0; i < n; i++)
		ans = min(ans, get(i));
	cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:19: error: request for member 'begin' in 'a', which is of non-class type 'll [2010]' {aka 'long long int [2010]'}
   32 |         reverse(a.begin(), a.end());
      |                   ^~~~~
a.cc:32:30: error: request for member 'end' in 'a', which is of non-class type 'll [2010]' {aka 'long long int [2010]'}
   32 |         reverse(a.begin(), a.end());
      |                              ^~~
Language: C++

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;

    long long all = a*b*c;
    if (all % 2LL == 0) cout << 0 << endl;
    else {
        long long ans = min(a*b, b*c, c*a);
        cout << ans << endl;
    }
}

Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:11:28:   required from here
   11 |         long long ans = min(a*b, b*c, c*a);
      |                         ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: C++

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

int main() {
    ll edge[3];
    bool even = false;
    for (int i = 0; i < 3; ++i) {
        cin >> edge[i];
        if (edge[i] % 2 == 0) even = true;
    }
    sort(edge, edge + 3);
    cout << (even ? 0 : edge[0] * edge[1]) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'll' was not declared in this scope
    5 |     ll edge[3];
      |     ^~
a.cc:8:16: error: 'edge' was not declared in this scope
    8 |         cin >> edge[i];
      |                ^~~~
a.cc:11:10: error: 'edge' was not declared in this scope
   11 |     sort(edge, edge + 3);
      |          ^~~~