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

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;

ll gcd (ll a,ll b){
	if(b==0) return a;
	return gcd (b,a%b);
}

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}

int main(void){
	int n;
	ll runner[10][2];
	ll change[10];
	while(cin >> n,n){
		rep(i,n) cin >> runner[i][0] >> runner[i][1];
		rep(i,n) {
			ll tmp=gcd(runnner[i][0],runnner[i][1]);
			runnner[i][0]/=tmp;
			runnner[i][1]/=tmp;
		}
		ll l=runner[0][1];
		rep(i,n-1) l=lcm(l,runner[i+1][1]);
		rep(i,n) change[i]=l/runner[i][1]*runner[i][0];
		l=change[0];
		rep(i,n-1) l=lcm(l,change[i+1]);
		rep(i,n) cout << l/change[i] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:36: error: 'runnner' was not declared in this scope; did you mean 'runner'?
   67 |                         ll tmp=gcd(runnner[i][0],runnner[i][1]);
      |                                    ^~~~~~~
      |                                    runner
Language: C++


import java.util.*;
import java.io.*;
import java.math.BigInteger;

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			BigInteger[] d = new BigInteger[n], v = new BigInteger[n];
			d[0] = new BigInteger(sc.next()); v[0] = new BigInteger(sc.next());
			
			BigInteger div = gcd(d[0], v[0]);
			d[0] = d[0].divide(div); v[0] = v[0].divide(div);
			
			BigInteger nume = new BigInteger("" + d[0]), deno = new BigInteger("" + v[0]);
			for(int i=1;i<n;i++) {
				d[i] = new BigInteger(sc.next()); v[i] = new BigInteger(sc.next());
				div = gcd(d[i], v[i]);
				d[i] = d[i].divide(div); v[i] = v[i].divide(div);
				nume = lcm(nume, d[i]);
				deno = gcd(deno, v[i]);
			}
			for(int i=0;i<n;i++) {
				System.out.println(nume.divide(d[i]).multiply(v[i]).divide(deno) );				
			}
		}
	}
	
	BigInteger lcm(BigInteger x, BigInteger y) {
		return x.divide(gcd(x, y)).multiply(y);
	}
	
	BigInteger gcd(BigInteger x, BigInteger y) {
		if(y.equals(new BigInteger("0"))) return x;
		return gcd(y, x.divideAndRemainder(y)[1]);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.math.BigInteger;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import static java.util.Arrays.*;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import static java.util.Collections.*;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
    8 | import static java.lang.Math.*;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: expected unqualified-id before 'public'
   10 | public class Main {
      | ^~~~~~
Language: C

#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <utility>
#include <functional>
using namespace std;

#define INF 19980725

/** 割引券の枚数 */
static int c;
#define C 10
/** 町の数 */
static int n;
#define N 100
/** 路線数 */
static int m;
#define M 500
/** 出発地 */
static int s;
/** 目的地 */
static int d;

/** 路線情報 */
static int map[ N ][ N ];

/** 各探索先における状態 */
struct stat
{
  /** 到達先の町 */
  int pos;
  /** 現時点までの費用 */
  int cost;
  /** 割引券の残枚数 */
  int rem;

  stat (
    )
  {
    this->cost = INF;
    this->rem  = 0;
  }
  stat (
    int pos,
    int cost,
    int rem
    )
  {
    this->pos  = pos;
    this->cost = cost;
    this->rem  = rem;
  }
  bool operator> (
    const stat &a
    )
  const
  {
    return ( cost > a.cost
          || ( cost == a.cost && rem < a.rem ) );
  }
};

int
main (
  int   argc,
  char *argv[ ]
  )
{
  for ( ; ; )
  {
    /** 探索キュー */
    priority_queue<stat, vector<stat>, greater<stat> > lis;
    /** s->k への最小費用res[ k ] */
    int res[ N ];
    int i, j;

    /* 基本情報読み込み */
    scanf ( "%d%d%d%d%d", &c, &n, &m, &s, &d );
    if ( !( c | n | m | s | d ) ) break ;
    --s; --d;

    /* 路線情報初期化 */
    for ( i = 0; i < n; ++i )
    for ( j = 0; j < n; ++j )
      map[ i ][ j ] = INF;

    /* 路線情報読み込み */
    for ( i = 0; i < m; ++i )
    {
      int a, b, f;

      scanf ( "%d%d%d", &a, &b, &f );
      --a; --b;
      map[ a ][ b ] =
      map[ b ][ a ] = f;
    }

    /* s->d に対してダイクストラ法を適用 */
    fill ( res, res + n, INF );
    lis.push ( stat ( s, 0, c ) );
    while ( !lis.empty ( ) )
    {
      const stat st = lis.top ( );
      lis.pop ( );

      /* 結果が既に求まっていれば処理しない */
      if ( res[ st.pos ] != INF )
        continue ;
      res[ st.pos ] = st.cost;

      for ( i = 0; i < n; ++i )
      {
        /* st.pos からi への経路が存在しなければ処理しない */
        if ( map[ st.pos ][ i ] == INF )
          continue ;

        /* 隣接する町の探索を予約する．割引券が使えればその探索も予約する． */
        lis.push ( stat ( i, st.cost + map[ st.pos ][ i ], st.rem ) );
        if ( st.rem > 0 )
          lis.push ( stat ( i, st.cost + map[ st.pos ][ i ] / 2, st.rem - 1 ) );
      }
    }
    printf ( "%d\n", res[ d ] );
  }

  return ( EXIT_SUCCESS );
}

Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<string.h>
#include<utility>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 100000000
int C,N,M,S,D,g1[101][101],g2[101][101],s,t,c,d[101],u[101];
typedef struct P{int p,c,t;}P;
struct Order
{
	bool operator ()(P const& a, P const& b) const
	{
		return a.c==b.c?a.t<b.t:a.c>b.c;
	}
};

P tmp,tmp2;
priority_queue<P,vector<P>,Order>Q;
int main()
{
	for(;scanf("%d%d%d%d%d",&C,&N,&M,&S,&D),C;)
	{
		for(int i=0;i<=N;i++)
		{
			d[i]=INF;
			for(int j=0;j<=N;j++)
				g1[i][j]=g2[i][j]=INF;
		}
		for(int i=0;i<N;i++)
		{
			scanf("%d%d%d",&s,&t,&c);
			g1[s][t]=g1[t][s]=c;
			g2[s][t]=g2[t][s]=c/2;
		}
		d[S]=0;
		tmp.c=0;tmp.p=S;tmp.t=C;
		Q.push(tmp);
		for(;!Q.empty();)
		{
			tmp=Q.top(),Q.pop();
			for(int i=1;i<=N;i++)
			{
				int nc=d[tmp.p]+g1[tmp.p][i];
				if((d[i]==nc&&u[i]>tmp.p)||d[i]>nc)
				{
					tmp2.c=d[i]=d[tmp.p]+g1[tmp.p][i];
					tmp2.p=i;
					tmp2.t=tmp.t;
					Q.push(tmp2);
				}
				nc=d[tmp.p]+g2[tmp.p][i];
				if(tmp.t>0&&((d[i]==nc&&u[i]>tmp.p-1)||d[i]>nc))
				{
					tmp2.c=d[i]=d[tmp.p]+g2[tmp.p][i];
					tmp2.p=i;
					tmp2.t=tmp.t-1;
					Q.push(tmp2);
				}
			}
		}
		printf("%d\n",d[D]);
	}
}

Compiler output:
main.c:3:9: fatal error: utility: No such file or directory
    3 | #include<utility>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <queue>
#include <algorithm>

#define MAX 1000000000
#define Debug(X) debug( __LINE__, X )
template<class T>
void debug( int line, T dbg ){
	std::cout << line << ": " << dbg << std::endl;
}

class State{
public:
	int p, s, c;
	State():p(0), s(0), c(0){}
	State(int P, int S, int C):p(P), s(S), c(C){}
	bool operator < (const State &s) const{
		return c > s.c;
	}
};

int c, n, m, s, d;
int route[101][101];
std::priority_queue<State> que;
bool used[101];


int main(){
	while( std::cin >> c >> n >> m >> s >> d, c * n * m * s * d ){
		for( int i = 0; i < 101 * 101; ++i )
			route[i / 101][i % 101] = MAX;
		
		memset( used, 0, sizeof( used ) );
		que = std::priority_queue<State>();

		int tmp[3];
		while( m-- ){
			int cnt = 3;
			while( cnt-- ) std::cin >> tmp[2 - cnt];

			route[tmp[0]][tmp[1]] = tmp[2];
			route[tmp[1]][tmp[0]] = tmp[2];
		}

		que.push(State( c, s, 0 ));

		while( true ){
			State data = que.top(); que.pop();

			if( used[data.s] )continue;
			used[data.s] = 1;

			if( data.s == d ){
				std::cout << data.c << std::endl;
				break;
			}

			for( int i = 1; i <= n; ++i ){
				if( i == data.s || route[data.s][i] == MAX )continue;

				if( data.p > 0 )
					que.push( State( data.p - 1, i, data.c + route[data.s][i] / 2 ) );

				que.push( State( data.p, i, data.c + route[data.s][i] ) );				
			}

		}

	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:17: error: 'memset' was not declared in this scope
   33 |                 memset( used, 0, sizeof( used ) );
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 |
Language: C++

#include<iostream>
using namespace std;
#include<vector>
#include<queue>
#include<math.h>
struct crq{
	int cost;
	int ticket;
	int now;

	bool operator >(const crq& p) const{
	return cost > p.cost;
	}
};//cost root que
struct root{
	int s;
	int g;
	int cost;
};

priority_queue<crq,vector<crq>,greater<crq>> q;
vector<root> vr;
int c;
int n;
int m;
int s;
int d;
int ans;
bool townSearched[100];
unsigned int townMin[100][11];
int main(){
	while(cin>>c>>n>>m>>s>>d, c|n|m|s|d){
		vr.clear();
		ans=INT_MAX;
		while(!q.empty())q.pop();
		for(int  i=0;i<100;i++){
			townSearched[i]=false;
			for(int  j=0;j<11;j++)townMin[i][j]=INT_MAX;
		}
		for(int i=0;i<m;i++){
			root r;
			cin>>r.s;
			r.s--;
			cin>>r.g;
			r.g--;
			cin>>r.cost;
			vr.push_back(r);
		}
		townMin[s-1][c]=0;
		crq start;
		start.cost=0;
		start.ticket=c;
		start.now=s-1;
		q.push(start);
		while(1){
			crq crq2=q.top();q.pop();
			if(crq2.now==d-1){
				ans=crq2.cost;
				break;
			}
			

			for(int i=0;i<m;i++){
				if(vr.at(i).s==crq2.now){
					if(!townSearched[vr.at(i).g]&&townMin[vr.at(i).g][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).g]&&crq2.ticket>0&&townMin[vr.at(i).g][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
				if(vr.at(i).g==crq2.now){
					if(!townSearched[vr.at(i).s]&&townMin[vr.at(i).s][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).s]&&crq2.ticket>0&&townMin[vr.at(i).s][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
			}
			townSearched[crq2.now]=true;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:21: error: 'INT_MAX' was not declared in this scope
   34 |                 ans=INT_MAX;
      |                     ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<math.h>
  +++ |+#include <climits>
    6 | struct crq{
Language: C++

#include<iostream>
using namespace std;
#include<vector>
#include<queue>
//#include<math.h>
struct crq{
	int cost;
	int ticket;
	int now;

	bool operator >(const crq& p) const{
	return cost > p.cost;
	}
};//cost root que
struct root{
	int s;
	int g;
	int cost;
};

priority_queue<crq,vector<crq>,greater<crq>> q;
vector<root> vr;

int c;
int n;
int m;
int s;
int d;
int ans;
bool townSearched[100];
int townMin[100][11];

int main(){
	while(cin>>c>>n>>m>>s>>d, c|n|m|s|d){
		vr.clear();
		ans=INT_MAX;
		while(!q.empty())q.pop();
		for(int  i=0;i<100;i++){
			townSearched[i]=false;
			for(int  j=0;j<11;j++)townMin[i][j]=INT_MAX;
		}
		for(int i=0;i<m;i++){
			root r;
			cin>>r.s;
			r.s--;
			cin>>r.g;
			r.g--;
			cin>>r.cost;
			vr.push_back(r);
		}
		townMin[s-1][c]=0;
		crq start;
		start.cost=0;
		start.ticket=c;
		start.now=s-1;
		q.push(start);
		while(1){
			crq crq2=q.top();q.pop();
			if(crq2.now==d-1){
				ans=crq2.cost;
				break;
			}
			

			for(int i=0;i<m;i++){
				if(vr.at(i).s==crq2.now){
					if(!townSearched[vr.at(i).g]&&townMin[vr.at(i).g][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).g]&&crq2.ticket>0&&townMin[vr.at(i).g][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
				if(vr.at(i).g==crq2.now){
					if(!townSearched[vr.at(i).s]&&townMin[vr.at(i).s][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).s]&&crq2.ticket>0&&townMin[vr.at(i).s][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
			}
			townSearched[crq2.now]=true;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:21: error: 'INT_MAX' was not declared in this scope
   36 |                 ans=INT_MAX;
      |                     ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<queue>
  +++ |+#include <climits>
    5 | //#include<math.h>
Language: C++

#include<iostream>
using namespace std;
#include<vector>
#include<queue>
//#include<math.h>
struct crq{
	int cost;
	int ticket;
	int now;

	bool operator > (const crq& p) const{
	return cost > p.cost;
	}
};//cost root que
struct root{
	int s;
	int g;
	int cost;
};



vector<root> vr;

int c;
int n;
int m;
int s;
int d;
int ans;
bool townSearched[100];
int townMin[100][11];

int main(){
	while(cin>>c>>n>>m>>s>>d, c|n|m|s|d){
		vr.clear();
		ans=INT_MAX;
		priority_queue<crq,vector<crq>,greater<crq>> q;
		while(!q.empty())q.pop();
		for(int  i=0;i<100;i++){
			townSearched[i]=false;
			for(int  j=0;j<11;j++)townMin[i][j]=INT_MAX;
		}
		for(int i=0;i<m;i++){
			root r;
			cin>>r.s;
			r.s--;
			cin>>r.g;
			r.g--;
			cin>>r.cost;
			vr.push_back(r);
		}
		townMin[s-1][c]=0;
		crq start;
		start.cost=0;
		start.ticket=c;
		start.now=s-1;

		q.push(start);
		while(1){
			crq crq2=q.top();q.pop();
			if(crq2.now==d-1){
				ans=crq2.cost;
				break;
			}
			

			for(int i=0;i<m;i++){
				if(vr.at(i).s==crq2.now){
					if(!townSearched[vr.at(i).g]&&townMin[vr.at(i).g][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).g]&&crq2.ticket>0&&townMin[vr.at(i).g][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
				if(vr.at(i).g==crq2.now){
					if(!townSearched[vr.at(i).s]&&townMin[vr.at(i).s][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).s]&&crq2.ticket>0&&townMin[vr.at(i).s][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
			}
			townSearched[crq2.now]=true;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:21: error: 'INT_MAX' was not declared in this scope
   37 |                 ans=INT_MAX;
      |                     ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<queue>
  +++ |+#include <climits>
    5 | //#include<math.h>
Language: C++

#include<iostream>
using namespace std;
#include<vector>
#include<queue>
//#include<math.h>
struct crq{
	int cost;
	int ticket;
	int now;

	bool operator > (const crq& p) const{
	return cost > p.cost;
	}
};//cost root que
struct root{
	int s;
	int g;
	int cost;
};



vector<root> vr;

int c;
int n;
int m;
int s;
int d;
int ans;
bool townSearched[100];
int townMin[100][11];

int main(){
	while(cin>>c>>n>>m>>s>>d, c|n|m|s|d){
		vr.clear();
		ans=0;
		priority_queue<crq,vector<crq>,greater<crq>> q;
		while(!q.empty())q.pop();
		for(int  i=0;i<100;i++){
			townSearched[i]=false;
			for(int  j=0;j<11;j++)townMin[i][j]=INT_MAX;
		}
		for(int i=0;i<m;i++){
			root r;
			cin>>r.s;
			r.s--;
			cin>>r.g;
			r.g--;
			cin>>r.cost;
			vr.push_back(r);
		}
		townMin[s-1][c]=0;
		crq start;
		start.cost=0;
		start.ticket=c;
		start.now=s-1;

		q.push(start);
		while(1){
			crq crq2=q.top();q.pop();
			if(crq2.now==d-1){
				ans=crq2.cost;
				break;
			}
			

			for(int i=0;i<m;i++){
				if(vr.at(i).s==crq2.now){
					if(!townSearched[vr.at(i).g]&&townMin[vr.at(i).g][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).g]&&crq2.ticket>0&&townMin[vr.at(i).g][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).g;
						townMin[vr.at(i).g][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
				if(vr.at(i).g==crq2.now){
					if(!townSearched[vr.at(i).s]&&townMin[vr.at(i).s][crq2.ticket]>crq2.cost+vr.at(i).cost){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost;
						add.ticket=crq2.ticket;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost;
						q.push(add);
					}

					if(!townSearched[vr.at(i).s]&&crq2.ticket>0&&townMin[vr.at(i).s][crq2.ticket-1]>crq2.cost+vr.at(i).cost/2){
						crq add;
						add.cost=crq2.cost+vr.at(i).cost/2;
						add.ticket=crq2.ticket-1;
						add.now=vr.at(i).s;
						townMin[vr.at(i).s][crq2.ticket]=crq2.cost+vr.at(i).cost/2;
						q.push(add);
					}

				}
			}
			townSearched[crq2.now]=true;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:61: error: 'INT_MAX' was not declared in this scope
   42 |                         for(int  j=0;j<11;j++)townMin[i][j]=INT_MAX;
      |                                                             ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<queue>
  +++ |+#include <climits>
    5 | //#include<math.h>
Language: C++

#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>

const int MAX_V = 100;
const int INF = 0x3f3f3f3f;

//??? T???cap??????rev????????°???????????§?????£???????????????
struct Edge{
	int to;
	int cost;
	Edge(int to_, int cost_) :to(to_), cost(cost_){}
};

std::vector<Edge > G[MAX_V]; //??£??\?????????

int d[11][MAX_V]; //[?????¨???????????±??????????????°][?????????]
int pre[MAX_V];

void AddEdge(int from, int to, int cost){
	G[from].push_back(Edge(to, cost));
}

void ClearEdge(){
	for (int i = 0; i < MAX_V; ++i) G[i].clear();
	memset(d, 0, sizeof(d));
	memset(pre, -1, sizeof(pre));
}

void Dijkstra(int c, int s){
	typedef std::pair<int, int> P; //first:???????????¢, second:????????????

	std::priority_queue<P, std::vector<P>, std::greater<P> > q;
	std::fill(d[c], d[c] + MAX_V, INF);
	memset(pre, -1, sizeof(pre));
	d[c][s] = 0;
	q.push(P(0, s));

	while (!q.empty()){
		P p = q.top(); q.pop();
		int from = p.second;
		if (d[c][from] < p.first) continue;
		for (Edge e : G[from]){
			int dmin;
			if (c == 0)
				dmin = d[c][from] + e.cost;
			else
				dmin = std::min(d[c][from] + e.cost, d[c - 1][from] + e.cost / 2);

			if (d[c][e.to] > dmin){
				d[c][e.to] = dmin;
				q.push(P(d[c][e.to], e.to));
				pre[e.to] = from;
			}
		}
	}
}

std::vector<int> GetPath(int t){
	std::vector<int> path;
	for (; t != -1; t = pre[t]) path.push_back(t);
	std::reverse(path.begin(), path.end());

	return path;
}

using namespace std;

int main(void){
	int c, n, m, s, g;
	while (1){
		cin >> c >> n >> m >> s >> g;
		if (c == n && n == m && m == s && s == g && g == 0) return 0;
		int a, b, f;
		for (int i = 0; i < n; ++i){
			cin >> a >> b >> f;
			AddEdge(a, b, f);
			AddEdge(b, a, f);
		}
		for (int i = 0; i <= c; ++i){
			Dijkstra(i, s);
		}
		cout << d[c][g] << endl;
		ClearEdge();
	}
}

Compiler output:
a.cc: In function 'void ClearEdge()':
a.cc:27:9: error: 'memset' was not declared in this scope
   27 |         memset(d, 0, sizeof(d));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 | 
a.cc: In function 'void Dijkstra(int, int)':
a.cc:36:9: error: 'memset' was not declared in this scope
   36 |         memset(pre, -1, sizeof(pre));
      |         ^~~~~~
a.cc:36:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
typedef vector<int> Vi;
const int INF = (1<<25);
const int MAX_V = 101;
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

struct edge {
  int to, cost;
  edge(int _to, int _cost) {
    to = _to; cost = _cost;
  }
};

int dij(int s, int c, int g) {
  priority_queue<Pip, vector<Pip>, greater<Pip> > q;

  int d[11][101];
  for(int i=0; i<11; i++) {
    for(int j=0; j<101; j++) {
      d[i][j] = INF;
    }
  }

  d[c][s] = 0;
  q.push(Pip(0, Pii(s, c)));

  int result = INF;
  while( !q.empty() ) {
    Pip p = q.top(); q.pop();
    int now_cost = p.fr;
    int v = p.sc.fr;
    int c = p.sc.sc;

    if( v == g ) {
      result = now_cost;
      break;
    }

    for(int i=0; i<G[v].size(); i++) {
      edge e = G[v][i];

      int next_cost = d[c][v] + e.cost;
      if( next_cost < d[c][e.to] ) {
	d[c][e.to] = next_cost;
      }
      if( c ) {
	next_cost = d[c][v] + e.cost/2;
	if( next_cost < d[c-1][e.to] ) {
	  d[c-1][e.to] = next_cost;
	  q.push(Pip(next_cost, Pii(e.to, c-1)));
	}
      }
    }
  }
  return result;
}

int main() {
  int c, n, m, s, g;
  while( cin >> c >> n >> m >> s >> g, c || n || m || s || g ) {
    init(n);
    s--; g--;
    for(int i=0; i<m; i++) {
      int u, v, cost;
      cin >> u >> v >> cost;
      u--; v--;
      G[u].pb(edge(v, cost));
      G[v].pb(edge(u, cost));
    }
    int ans = dij(s, c, g);
    cout << ans << endl;
  }
}

Compiler output:
a.cc: In function 'int dij(int, int, int)':
a.cc:45:20: error: 'G' was not declared in this scope
   45 |     for(int i=0; i<G[v].size(); i++) {
      |                    ^
a.cc: In function 'int main()':
a.cc:67:5: error: 'init' was not declared in this scope; did you mean 'int'?
   67 |     init(n);
      |     ^~~~
      |     int
a.cc:73:7: error: 'G' was not declared in this scope
   73 |       G[u].pb(edge(v, cost));
      |       ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<queue>
#include<map>
#define P pair<int,int>
using namespace std;

struct K {
	int basho, nokori, mincost;
};
bool operator<(K a, K b) {
	return a.mincost > b.mincost;
}
int main() {
	int cost[100][11];//n???????????°????????§m????????????????°????
	int B, c, d, e, f;
	while (scanf("%d%d%d%d%d", &B, &c, &d, &e, &f), B || c || d || e || f) {
		vector<P>a[100]{};
		memset(cost, 0x3f, sizeof(cost));
		e--; f--; cost[e][B] = 0;
		priority_queue<K>Q;
		K g;
		g.basho = e; g.nokori = B; g.mincost = 0;
		Q.push(g);
		for (int h = 0; h < d; h++) {
			int i, j, k;
			scanf("%d%d%d", &i, &j, &k);
			i--; j--;
			a[i].push_back(P(k, j));
			a[j].push_back(P(k, i));
		}
		while (Q.size()) {
			K l = Q.top(); Q.pop();
			int m = l.mincost, n = l.nokori, b = l.basho;
			if (cost[b][n] < m)continue;
			for (P o : a[b]) {
				if (cost[o.second][n] > cost[b][n] + o.first) {
					cost[o.second][n] = cost[b][n] + o.first;
					K xx;
					xx.basho = o.second;
					xx.mincost = cost[o.second][n];
					xx.nokori = n;
					Q.push(xx);
				}
				if (n&&cost[o.second][n-1] > cost[b][n] + o.first / 2) {
					cost[o.second][n - 1] = cost[b][n] + o.first / 2;
					K yy;
					yy.basho = o.second;
					yy.nokori = n - 1;
					yy.mincost = cost[o.second][n - 1];
					Q.push(yy);
				}
			}
		}
		int MINCOST = 1 << 29;
		for (int sss = 0; sss < 11; sss++) {
			MINCOST = min(MINCOST, cost[f][sss]);
		}
		cout << MINCOST << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'memset' was not declared in this scope
   21 |                 memset(cost, 0x3f, sizeof(cost));
      |                 ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include<map>
  +++ |+#include <cstring>
    7 | #define P pair<int,int>
Language: C++

#pragma once

#include <vector>
#include <queue>
#include <algorithm>
#include <string.h>
template <size_t N, typename COST_T>
class Dijkstra
{
public:
	struct Path
	{
		int connectingIndex;
		COST_T cost;
	};

	struct Agent
	{
		int index;
		int prev_index;
		COST_T cost;

		bool operator<(const Agent& rhs) const
		{
			return cost > rhs.cost;
		}
	};

	Dijkstra()
	{
		init_paths();
	}

	void init_paths()
	{
		edges.assign(N, std::vector<Path>());
	}

	void add_path(int from, int to, COST_T cost)
	{
		edges[from].push_back(Path{ to, cost });
	}

	void add_path_undirected(int node1, int node2, COST_T cost)
	{
		edges[node1].push_back(Path{ node2, cost });
		edges[node2].push_back(Path{ node1, cost });
	}

	// returns cost
	// returns -1 if there is no reachable path
	COST_T find_shortest_path(int start, int goal)
	{
		// initialize
		que = std::priority_queue<Agent>();
		this->start = start;
		this->goal = goal;
		memset(defined, 0, sizeof defined);

		que.push(Agent{ start });
		while (!que.empty())
		{
			Agent agent = que.top(); que.pop();
				
			if (defined[agent.index])
			{
				continue;
			}
			defined[agent.index] = true;
			prev_node[agent.index] = agent.prev_index;

			if (agent.index == goal)
			{
				return agent.cost;
			}

			for (auto path : edges[agent.index])
			{
				if (!defined[path.connectingIndex])
				{
					que.push(Agent{ path.connectingIndex,
					                agent.index,
					                agent.cost + path.cost });
				}
			}
		}

		return -1;
	}

	std::vector<int> get_shortest_path() const
	{
		std::vector<int> path;
		int agent = goal;
		while (agent != start)
		{
			path.push_back(agent);
			agent = prev_node[agent];
		}
		path.push_back(start);
		std::reverse(path.begin(), path.end());
		return path;
	}

	std::vector<std::vector<Path>> edges;
	std::priority_queue<Agent> que;
	int start;
	int goal;
	int prev_node[N];
	bool defined[N];
};

Compiler output:
a.cc:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include "bits/stdc++.h"
using namespace std;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T> void dbg(T x) { cout << x << "\n"; }
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }


int n, m;

// O(n^2)
using Dist = int;
const int VMAX = 110;
Dist cost[VMAX][VMAX];
Dist d[12][VMAX];
void dijkstra(int s, int a) {
    d[a][s] = 0;
    vector<int> used(n, 0);
    while (1) {
        int v = -1;
        for (int to = 0; to < n; to++) {
            if (used[to]) continue;
            if (v == -1 || d[a][to] < d[a][v]) v = to;
        }
        if (v == -1) break;
        used[v] = 1;
        for (int to = 0; to < n; to++) {
            Dist nd = d[a][v] + cost[v][to];
            if (a > 0) chmin(nd, d[a - 1][v] + cost[v][to] / 2);
            if (nd < d[a][to]) d[a][to] = nd;
        }
    }
}

void init() {
    fill_n(*d, 12 * VMAX, INF);
    fill_n(*cost, VMAX * VMAX, INF);
}

int main() {
    int c, s, t;
    while (cin >> c >> n >> m >> s >> t, c) {
        init();
        s--; t--;
        rep(i, m) {
            int a, b, f; cin >> a >> b >> f;
            a--; b--;
            cost[a][b] = cost[b][a] = f;
        }
        rep(a, c + 1) dijkstra(s, a);
        cout << d[c][t] << "\n";
    }

    return 0;
}



Compiler output:
a.cc:3:54: error: 'll' does not name a type
    3 | const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
      |                                                      ^~
Language: C++

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

using namespace std;

typedef pair<int,pair<int,int> >P;

struct Edge{
  int to,cost;
  Edge(int _to, int _cost):to(_to), cost(_cost){};
};

int minCost[101][11];
vector<Edge> edge[101];
static const int INF = INT_MAX;

int c,n,m,s,d;

int dijkstra(void){
  priority_queue<P, vector<P>, greater<P> >que;
  que.push(make_pair(0,make_pair(s,c)));

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

  while(!que.empty()){
    P p = que.top();
    que.pop();

    if(p.second.first==d)return p.first;

    for(int i=0;i<edge[p.second.first].size();i++){
      Edge e = edge[p.second.first][i];
      que.push(make_pair(p.first+e.cost,make_pair(e.to,p.second.second)));
    }
    if(p.second.second==0)continue;
    
    for(int j=0;j<edge[p.second.first].size();j++){
      Edge e = edge[p.second.first][j];
      que.push(make_pair(p.first+e.cost/2,make_pair(e.to,p.second.second-1)));
    }
  }
  return -1;
}

int main(void){
  int a,b,f;

  while(cin >> c >> n >> m >> s >> d,c|n|m|s|d){

    for(int i=0;i<=n;i++)edge[i].clear();

    for(int i=0;i<m;i++){
      cin >> a >> b >> f;
      edge[a].push_back(Edge(b,f));
      edge[b].push_back(Edge(a,f));
    }

    cout << dijkstra() << endl;
  }

  return 0;
}

Compiler output:
a.cc:17:24: error: 'INT_MAX' was not declared in this scope
   17 | static const int INF = INT_MAX;
      |                        ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include<queue>
  +++ |+#include <climits>
    5 |
Language: C++

#include <map>
#include <vector>
#include <cstdio>
using namespace std;
int cost[101][11];
int main(){
	int c,N,m,s,d,i,j,k,x;
	for(;scanf("%d%d%d%d%d",&c,&N,&m,&s,&d),N;){
		vector<map<int,int> >dist(N+1);
		memset(cost,99,sizeof(cost));
		for(k=0;k<m;k++){
			scanf("%d%d%d",&i,&j,&x);dist[i][j]=dist[j][i]=x;
		}
		for(i=0;i<=c;i++)cost[s][i]=0;
		for(;~c;c--){
			vector<bool>used(N+1);
			for(;;){ //dijkstra
				int m=9999999;
				for(i=0;i<N;i++)if(!used[i]&&m>cost[i][c])m=cost[i][c];
				if(m==9999999)break;
				for(j=0;j<N;j++)if(m==cost[j][c]){
					map<int,int>::iterator it=dist[j].begin();
					for(used[j]=1;it!=dist[j].end();it++){
						if(cost[it->first][c]>it->second+cost[j][c])cost[it->first][c]=it->second+cost[j][c];
						if(c&&cost[it->first][c-1]>it->second/2+cost[j][c])cost[it->first][c-1]=it->second/2+cost[j][c];
					}
				}
			}
		}
		printf("%d\n",cost[d][0]);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:17: error: 'memset' was not declared in this scope
   10 |                 memset(cost,99,sizeof(cost));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdio>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

/*
 * アルゴリズムとしてはチケットの枚数分のネットワークをレイヤ構造で持ち
 * 各々のレイヤから上位レイヤへはチケットを使った場合に遷移するようにする
 * 上位レイヤから下位レイヤには遷移することができないようにし，
 * 最下位レイヤの始点から終点と同じ点を表すすべてのレイヤの点までの最短経路を求める．
 *
 * (イメージ)
 *      T`T`T`  
 *      |/|/|   S=始点, o=点, T`=終点 |=辺 /=レイヤ下位から上位への有効辺
 *      o o o   
 *      |/|/|   S->T`までの距離で最短のものを求め出力する
 *      S o o   
 *Layer 0 1 2   
 *
 **/

#include <iostream>
#include <map>

#define rep(i,s,t) for(int i=s;i<t;i++)

using namespace std;

//c層目のid値を返す関数
int id2cid(int c,int id){
	return c*1000+id;
}

//dijkstraアルゴリズム
//特に無加工，距離を持った隣接を表すgraphと各点までの距離を保持するdis,始点ssを入力
//計算結果はdisに保持し，返り値は無し
void dijkstra(map<int,map<int,int> > &graph,map<int,int>  &dis,int ss){
	//未確定点を保持する集合multimap，距離をkey,点idをvalueとする
	multimap<int, int> min;
	//注目する点pのid値
	int pid;
	//始点をまず入力する
	min.insert(make_pair(0,ss));
	//未確定点がなくなるまで
	while(!min.empty()){
		//未確定の中で一番距離が小さい要素(mapの先頭)を取得し注目点pを得る
		pid=(*(min.begin())).second;
		//点pを未確定点集合から削除する
		min.erase(min.begin());

		//pに隣接する点について
		for(map<int,int>::iterator it=graph[pid].begin();it!=graph[pid].end();it++){
			//隣接点のid値cidとその点までの距離distを取得
			int cid=(*it).first;
			int dist=(*it).second;
			//隣接点が未確定点集合に含まれない，もしくは暫定の距離より小さい場合
			//未確定点集合の隣接点の距離を始点から注目点までの距離＋注目点からの距離に更新する
			if((dis.find(cid)!=dis.end() &&  dis[cid]>dis[pid]+dist) ||
				dis.find(cid)==dis.end()){
					min.insert(make_pair(dis[pid]+dist,cid));			
					dis[cid]=dis[pid]+dist;
			}
		}
	}
}

int main(void){
	
	int c,n,m,s,d;
	while(cin >> c >> n >> m >> s >> d){
		if(c==0) break;

		//グラフ構造用意
		//mapを用いて辺i,jのコストcで隣接関係を表現
		map<int,map<int,int> > graph;

		//m路線に対して
		rep(i,0,m){
			int a,b,f;
			cin >> a >> b >> f;

			//グラフをc+1個の層構造とする
			rep(j,0,c+1){
				//j層目のグラフでは通常料金の移動コストで辺を張る
				//id2cid(j,id)でj層目の点idを示すid値に変換する
				//点は最大でも500点しかないため，1000桁目以上がn層目とする.
				//ex(0層目の点125は id=125,8層目の点125は8125)となる．
				graph[id2cid(j,a)][id2cid(j,b)]=f;
				graph[id2cid(j,b)][id2cid(j,a)]=f;
				//j層目からj+1層目へは割引料金を用いた移動コストの辺を張る
				//j層目からj-1層目への辺がないため階層が上がるに連れて下がることはできない
				//j層目はすなわちj回チケットを利用した枚数に相当する．
				if(j<c){
					graph[id2cid(j,a)][id2cid(j+1,b)]=f/2;
					graph[id2cid(j,b)][id2cid(j+1,a)]=f/2;
				}
			}
		}
		//各点の最短距離を保持するmap
		map<int,int>  dis;
		//通常のダイクストラで始点sからの各点への最短距離を求め，計算結果を変数disに保持する
		dijkstra(graph,dis,id2cid(0,s));

		//求め終わると終点dと同じ点である点すべての中から最小値を求める

Compiler output:
a.cc: In function 'int main()':
a.cc:97:49: error: expected '}' at end of input
   97 |                 dijkstra(graph,dis,id2cid(0,s));
      |                                                 ^
a.cc:65:44: note: to match this '{'
   65 |         while(cin >> c >> n >> m >> s >> d){
      |                                            ^
a.cc:97:49: error: expected '}' at end of input
   97 |                 dijkstra(graph,dis,id2cid(0,s));
      |                                                 ^
a.cc:62:15: note: to match this '{'
   62 | int main(void){
      |               ^
Language: C++

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

using namespace std;

struct edge{ int to, cost; };
typedef pair<int, int> P;
const int INF = INT_MAX / 4;

int V;
vector<edge> G[100];
int D[100];
int pre[100];

int c, n, m, s, d;

void dijkstra(int s)
{
	priority_queue<P, vector<P>, greater<P> > que;
	fill(D, D + 100, INF);
	fill(pre, pre + 100, -1);
	D[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;
		if (D[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++)
		{
			edge e = G[v][i];
			if(D[e.to] > D[v] + e.cost)
			{
				D[e.to] = D[v] + e.cost;
				pre[e.to] = v;
				que.push(P(D[e.to], e.to));
			}
		}
	}
}

int solve()
{
	dijkstra(s - 1);
	vector<int> vec;
	for (int t = d - 1; pre[t] != -1 ; t = pre[t])
	{
		for (int i = 0; i < G[t].size(); i++)
		{
			if(pre[t] == G[t][i].to)
			{
				vec.push_back(G[t][i].cost);
				break;
			}
		}
	}
	sort(vec.begin(), vec.end(), greater<int>());
	for (int i = 0; i < c && i < vec.size(); i++)
	{
		vec[i] = vec[i] / 2;
	}
	return accumulate(vec.begin(), vec.end(), 0);
}

int main()
{
	while (cin >> c >> n >> m >> s >> d && c && n && m && s && d)
	{
		for (int i = 0; i < 100; i++)
		{
			G[i] = vector<edge>();
		}
		for (int i = 0; i < m; i++)
		{
			int a, b, f;
			cin >> a >> b >> f;
			edge e;
			e.to = b - 1;
			e.cost = f;
			G[a - 1].push_back(e);
			e.to = a - 1;
			e.cost = f;
			G[b - 1].push_back(e);
		}
		cout << solve() << endl;
	}
	return 0;
}

Compiler output:
a.cc:12:17: error: 'INT_MAX' was not declared in this scope
   12 | const int INF = INT_MAX / 4;
      |                 ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <numeric>
  +++ |+#include <climits>
    7 |
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;

struct edge{ int to, cost; };
typedef pair<int, int> P;
const int INF = INT_MAX / 4;

int V;
vector<edge> G[100];
int D[100];
int pre[100];

int c, n, m, s, d;

void dijkstra(int s)
{
	priority_queue<P, vector<P>, greater<P> > que;
	fill(D, D + 100, INF);
	fill(pre, pre + 100, -1);
	D[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;
		if (D[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++)
		{
			edge e = G[v][i];
			if(D[e.to] > D[v] + e.cost)
			{
				D[e.to] = D[v] + e.cost;
				pre[e.to] = v;
				que.push(P(D[e.to], e.to));
			}
		}
	}
}

int solve()
{
	dijkstra(s - 1);
	vector<int> vec;
	for (int t = d - 1; pre[t] != -1 ; t = pre[t])
	{
		for (int i = 0; i < G[t].size(); i++)
		{
			if(pre[t] == G[t][i].to)
			{
				vec.push_back(G[t][i].cost);
				break;
			}
		}
	}
	sort(vec.begin(), vec.end(), greater<int>());
	for (int i = 0; i < c && i < vec.size(); i++)
	{
		vec[i] = vec[i] / 2;
	}
	return accumulate(vec.begin(), vec.end(), 0);
}

int main()
{
	while (cin >> c >> n >> m >> s >> d && c && n && m && s && d)
	{
		for (int i = 0; i < 100; i++)
		{
			G[i] = vector<edge>();
		}
		for (int i = 0; i < m; i++)
		{
			int a, b, f;
			cin >> a >> b >> f;
			edge e;
			e.to = b - 1;
			e.cost = f;
			G[a - 1].push_back(e);
			e.to = a - 1;
			e.cost = f;
			G[b - 1].push_back(e);
		}
		cout << solve() << endl;
	}
	return 0;
}

Compiler output:
a.cc:13:17: error: 'INT_MAX' was not declared in this scope
   13 | const int INF = INT_MAX / 4;
      |                 ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <limits>
  +++ |+#include <climits>
    8 |
Language: Java


import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

import scala.languageFeature.postfixOps;
import sun.tools.jar.resources.jar;
import lombok.Data;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			n = scanner.nextInt();
			if ((w | h | n) == 0)
				break;
			size = new int[n + 1];
			pos = new int[n + 1][2];
			for (int i = 0; i < n; i++) {
				int b = scanner.nextInt();
				int k = scanner.nextInt();
				size[b] = k;
			}
			m = new int[h][w];
			
			for (int[] a : m)
				Arrays.fill(a, -1);
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					int x = scanner.nextInt();
					m[i][j] = x;
					if (x > 0) {
						pos[x][0] = i;
						pos[x][1] = j;
					}
				}
			}
			assign = new int[n + 1][4];
			c = 0;
			ans = new int[h][w];
			f(1);
			if (c == 1) {
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (j > 0)
							System.out.print(" ");
						System.out.print(ans[i][j]);
					}
					System.out.println();
				}
			} else {
				System.out.println("NA");
			}

		}
	}

	private void f(int k) {
		if (k == n + 1) {
			c++;
			if (c == 2)
				return;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					int a = m[i][j];
					ans[i][j] = a >= 100 ? a / 100 : a;
				}
			}
			return;
		}
		int s = size[k];
		for (int x = 1; x <= s; x++) {
			if (s % x != 0)
				continue;
			for (int lj = pos[k][1] + 1 - x; lj <= pos[k][1]; lj++) {
				if (lj < 0 || lj > w)
					continue;
				loop: for (int li = pos[k][0] + 1 - s / x; li <= pos[k][0]; li++) {
					if (li < 0 || li > h)
						continue;
					int rj = lj + x;
					int ri = li + s / x;
					if (rj > w)
						continue;
					if (ri > h)
						continue;
					for (int i = li; i < ri; i++) {
						for (int j = lj; j < rj; j++) {
							if (m[i][j] != 0 && m[i][j] != k)
								continue loop;

						}
					}
					for (int i = li; i < ri; i++) {
						for (int j = lj; j < rj; j++) {
							if (m[i][j] != k)
								m[i][j] = k * 100;
						}
					}
					f(k + 1);
					if (c == 2)
						return;
					for (int i = li; i < ri; i++) {
						for (int j = lj; j < rj; j++) {
							if (m[i][j] != k)
								m[i][j] = 0;
						}
					}
				}
			}

		}

	}

	int[][] m;
	int[] size;
	int[][] pos;
	int[][] assign;
	int w, h, n, c;
	int[][] ans;
}

Compiler output:
Main.java:9: error: package scala.languageFeature does not exist
import scala.languageFeature.postfixOps;
                            ^
Main.java:10: error: package sun.tools.jar.resources is not visible
import sun.tools.jar.resources.jar;
                    ^
  (package sun.tools.jar.resources is declared in module jdk.jartool, which does not export it)
Main.java:11: error: package lombok does not exist
import lombok.Data;
             ^
3 errors
Language: C++

#include<cstdio>
#include<vector>

#define	mp	make_pair
#define	pb	push_back

using namespace std;

typedef	pair<int,int>	pii;
typedef	vector<pii>		vpii;

vector<vpii> rect;
int w,h,n,land[50][50],test[50][50],ans[50][50];

bool search(int i0,int j0){
//printf("i0=%d, j0=%d\n",i0,j0);
//for(int a=0;a<h;a++){for(int b=0;b<w;b++)printf("%d ",test[a][b]);puts("");}puts("");

	for(int i=i0;i<h;i++){
		for(int j=(i==i0?j0:0);j<w;j++){
if(i<0 || h<=i || j<0 || w<=j)	exit(0);
			int id=land[i][j];
			if(id==0)	continue;
if(id<0 || n<id)	while(1)puts("@@@@@@");
			// try to put a rectangle
			int cnt=0;
			for(int k=0;k<rect[id].size();k++){
				int rh=rect[id][k].first,rw=rect[id][k].second;
				for(int y=i-rh+1;y<=i;y++){
					for(int x=j-rw+1;x<=j;x++){
						if(!(0<=y && y+rh<=h && 0<=x && x+rw<=w))	continue;
						bool canput=true;
						for(int yy=y;yy<y+rh;yy++)for(int xx=x;xx<x+rw;xx++){
if(yy<0 || h<=yy || xx<0 || w<=xx)	while(1);
							if(test[yy][xx]!=0
							||(land[yy][xx]!=0 && land[yy][xx]!=id))	canput=false;
						}
						if(!canput)	continue;
						for(int yy=y;yy<y+rh;yy++)for(int xx=x;xx<x+rw;xx++){
if(yy<0 || h<=yy || xx<0 || w<=xx)	while(1);
							test[yy][xx]=id;
						}
						cnt+=search(i,j+1);
						for(int yy=y;yy<y+rh;yy++)for(int xx=x;xx<x+rw;xx++){
if(yy<0 || h<=yy || xx<0 || w<=xx)	while(1);
							test[yy][xx]=0;
						}
						if(cnt>=2)	return false;
					}
				}
			}

			return (cnt==1)?true:false;
		}
	}

	bool suc=true;
	for(int i=0;i<h;i++){for(int j=0;j<w;j++){
		if(test[i][j]==0)	suc=false;
	}}
	if(suc){
		for(int i=0;i<h;i++){for(int j=0;j<w;j++)	ans[i][j]=test[i][j];}
		return true;
	}
	return false;
}

int main(){
	for(;scanf("%d%d%d",&w,&h,&n),w;){
		rect=vector<vpii>(n+1);

		for(int i=0;i<n;i++){
			int id,area;	scanf("%d%d",&id,&area);
			for(int j=1;j<=area;j++){
				if(area%j==0)	rect[id].pb(mp(j,area/j));
			}
		}
		for(int i=0;i<h;i++){for(int j=0;j<w;j++)	scanf("%d",&land[i][j]);}

		if(search(0,0)){
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){	printf("%s%d",(j?" ":""),ans[i][j]);}
				putchar('\n');
			}
		}
		else	puts("NA");
	}

	return 0;
}

Compiler output:
a.cc: In function 'bool search(int, int)':
a.cc:21:33: error: 'exit' was not declared in this scope
   21 | if(i<0 || h<=i || j<0 || w<=j)  exit(0);
      |                                 ^~~~
a.cc:3:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    2 | #include<vector>
  +++ |+#include <cstdlib>
    3 |