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

#include"dice.h"
#include<algorithm>
#include<map>
#include<stack>
#include<iostream>
#define F(A, B) for(int A=0; A<B; A++)
using namespace std;

enum DICE{
	TOP=0,
	HEIGHT=1
};

enum DIRECTION{
	NORTH=0,
	EAST,
	SORTH,
	WEST
};

int moveh(int map[][200][2], int posx, int posy, int dic){
	switch(dic){
		case(NORTH):
			return map[posx-1][posy][HEIGHT];
		case(SORTH):
			return map[posx+1][posy][HEIGHT];
		case(WEST):
			return map[posx][posy-1][HEIGHT];
		case(EAST):
			return map[posx][posy+1][HEIGHT];
	}
}

void roll(int& posx, int& posy, int& top, int& front, int dic, int* dicface){
	switch(dic){
		case(NORTH):
			front = 7-top;
			top = dicface[SORTH];
			posx -= 1;
			break;
		case(SORTH):
			front = top;
			top = dicface[NORTH];
			posx += 1;
			break;
		case(WEST):
			top = dicface[EAST];
			posy -= 1;
			break;
		case(EAST):
			top = dicface[WEST];
			posy += 1;
			break;
	}
}

int main(){
	int n;
	cin >> n;
	while(n != 0){
		int map[200][200][2]={{ {0, 0} }};
		int *top=new int[n];
		int *front=new int[n];
		F(i, n){
			cin >> top[i] >> front[i];
		}
		F(i, n){
			int posx=100, posy=100;
			while(1){
				int firstdic, seconddic;
				int dicface[4];
				dicface[SORTH] = front[i];
				dicface[EAST ] = dice::ThirdFace[top[i]][front[i]];
				dicface[NORTH] = 7-dicface[SORTH];
				dicface[WEST ] = 7-dicface[EAST ];
				stack<int> FS;
				F(j, 3){
					F(k, 4){
						if(dicface[k] == j+4){
							FS.push(k);
						}
					}
				}
				firstdic	= FS.top(); FS.pop();
				seconddic	= FS.top(); FS.pop();

				//cout << firstdic << ' ' << seconddic << endl;

				if(map[posx][posy][HEIGHT] > moveh(map, posx, posy, firstdic) ){
					//cout << posx << ' ' << posy << ' ' << top[i] << ' ' << front[i] << endl;
					roll(posx, posy, top[i], front[i], firstdic, dicface);
					//cout << posx << ' ' << posy << ' ' << top[i] << ' ' << front[i] << endl;
				}else if(map[posx][posy][HEIGHT] > moveh(map, posx, posy, seconddic) ){
					roll(posx, posy, top[i], front[i], seconddic, dicface);
				}else{
					map[posx][posy][TOP] = top[i];
					map[posx][posy][HEIGHT]++;
					break;
				}
			}
		}
		int cnt[7]={0};
		F(i, 200)F(j, 200){
			if(map[i][j][TOP] > 0){
				cnt[map[i][j][TOP]]++;
			}
		}
		for(int i=1; i<=6; i++){
			if(i >= 2)cout << ' ';
			cout << cnt[i];
		}
		cout << endl;

		cin >> n;
	}

}

Compiler output:
a.cc:1:9: fatal error: dice.h: No such file or directory
    1 | #include"dice.h"
      |         ^~~~~~~~
compilation terminated.
Language: C++


#include <iostream>

using namespace std;


int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };

int tb[7][5] = {
	{},
	{ 3, 5, 4, 2, 6},
	{ 3, 1, 4, 6, 5},
	{ 6, 5, 1, 2, 4},
	{ 1, 5, 6, 2, 3},
	{ 3, 6, 4, 1, 2},
	{ 4, 5, 3, 2, 1},
};

int main()
{

	int n;
	while (cin >> n && n){

		const int M = 110;
		int d[M * 3][M * 3];
		int a[M * 3][M * 3];
		memset(d, 0, sizeof d);
		for (int i = 0; i < n; i++){
			int t, f;
			cin >> t >> f;
			int x = M, y = M;


			while (1){
				int dir;
				for (int j = 0; j < 4; j++){
					if (tb[t][j] == f)dir = j;
				}

				int tj = -1, Max = t;
				for (int j = 0; j < 4; j++){
					if (d[x + dx[j]][y + dy[j]] < d[x][y]){
						if (tb[t][(j + dir) % 4] > Max){
							tj = j;
							Max = tb[t][(j + dir) % 4];
						}
					}
				}

				if (tj == -1){
					d[x][y]++;
					a[x][y] = t;
					break;
				}

				x += dx[tj], y += dy[tj];
				if (tj == 0){
					f = t; t = tb[t][(tj + 2 + dir)%4];
				}
				if (tj == 1){
					t = tb[t][(tj + 2 + dir) % 4];
				}
				if (tj == 2){
					f = tb[t][5]; t = tb[t][(tj + 2 + dir) % 4];
				}
				if (tj == 3){
					t = tb[t][(tj + 2 + dir) % 4];
				}

			}

		}
	}


	return 0;
}

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

4
6 4
6 4
6 4
6 4
2
5 3
5 3
8
4 2
4 2
4 2
4 2
4 2
4 2
4 2
4 2
6
4 6
1 5
2 3
5 3
2 4
4 2
0

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 4
      | ^
Language: C++

int mp[2][31][31]={};
int sai[7][4]= {{0,0,0,0},{3,5,4,2},{1,4,6,3},{1,2,6,5},{5,6,2,1},{3,6,4,1},{2,4,5,3}};
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

void die(int t,int f,int x,int y){
  int i,j,x2,y2,mx=3,f2,t2;
  mp[1][y][x]++;
  for(i=0;i<4;i++){
    if(sai[t][i]==f){
      for(j=i;j<i+4;j++){
	int m=j%4,x1=x+dx[j-i],y1=y+dy[j-i];
	if(mp[1][y][x]-1>mp[1][y1][x1]&&sai[t][m]>mx){
	  mx=sai[t][m];
	  x2=x1,y2=y1;
	  t2=7-mx;
	  if(j-i==2)f2=7-t;
	  else if(j-i==-0)f2=t;
	  else f2=f;
	}
      }
      break;
    }
  }
  if(mx!=3)mp[1][y][x]--,die(t2,f2,x2,y2);
  else mp[0][y][x]=t;
}

int main(){
  while(1){
    int n;cin>>n;if(n==0)break;
    int i,j,t,f,c[7]={};
    for(i=0;i<n;i++){
      cin>>t>>f;
      die(t,f,15,15);
    }
    for(i=0;i<31;i++)
      for(j=0;j<31;j++){
	c[mp[0][i][j]]++;
	mp[0][i][j]=mp[1][i][j]=0;
      }
    for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:11: error: 'cin' was not declared in this scope
   30 |     int n;cin>>n;if(n==0)break;
      |           ^~~
a.cc:41:21: error: 'cout' was not declared in this scope
   41 |     for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
      |                     ^~~~
a.cc:41:37: error: 'cout' was not declared in this scope
   41 |     for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
      |                                     ^~~~
a.cc:41:49: error: 'endl' was not declared in this scope
   41 |     for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
      |                                                 ^~~~
Language: C++

#include<iostream>
using namespace std;
int mp[2][31][31]={};
int sai[7][4]= {{0,0,0,0},{3,5,4,2},{1,4,6,3},{1,2,6,5},{5,6,2,1},{3,6,4,1},{2,4,5,3}};

void die(int t,int f,int x,int y){
  int i,j,x2,y2,mx=3,f2,t2,dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
  mp[1][y][x]++;
  for(i=0;i<4;i++){
    if(sai[t][i]==f){
      for(j=i;j<i+4;j++){
	int m=j%4,x1=x+dx[j-i],y1=y+dy[j-i];
	if(mp[1][y][x]-1>mp[1][y1][x1]&&sai[t][m]>mx){
	  mx=sai[t][m],x2=x1,y2=y1,t2=7-mx;
	  if(j-i==2)f2=7-t;
	  else if(j-i==0)f2=t;
	  else f2=f;
	}
      }
      break;
    }
  }
  if(mx!=3)mp[1][y][x]--,die(t2,f2,x2,y2);
  else mp[0][y][x]=t;
}

int main(){
  while(1){
    int n;cin>>n;if(n==0)break;
    int i,j,t,f,c[7]={};
    for(i=0;i<n;i++)
      cin>>t>>f;
      die(t,f,15,15);
    }
    for(i=0;i<31;i++)
      for(j=0;j<31;j++){
	c[mp[0][i][j]]++;
	mp[0][i][j]=mp[1][i][j]=0;
      }
    for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'i' was not declared in this scope
   35 |     for(i=0;i<31;i++)
      |         ^
a.cc:36:11: error: 'j' was not declared in this scope
   36 |       for(j=0;j<31;j++){
      |           ^
a.cc:37:9: error: 'c' was not declared in this scope
   37 |         c[mp[0][i][j]]++;
      |         ^
a.cc:40:9: error: 'i' was not declared in this scope
   40 |     for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
      |         ^
a.cc:40:27: error: 'c' was not declared in this scope
   40 |     for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
      |                           ^
a.cc:40:43: error: 'c' was not declared in this scope
   40 |     for(i=1;i<6;i++)cout<<c[i]<<" ";cout<<c[6]<<endl;
      |                                           ^
a.cc: At global scope:
a.cc:42:3: error: expected unqualified-id before 'return'
   42 |   return 0;
      |   ^~~~~~
a.cc:43:1: error: expected declaration before '}' token
   43 | }
      | ^
Language: C++

// g++ -std=c++11 temp.cpp
#include <bits/libstdc++.h>
using namespace std;

#define For(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Rep(i,n) For(i,0,n)
#define Each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3;

#define MAX_N 100

int N;
int board[MAX_N*2][MAX_N*2];
int h[MAX_N*2][MAX_N*2];

struct dice{
	int x, xx, y, yy, z, zz;
};
dice d;

void rotation(int *a, int *b, int *c, int *d){
	int t = *a;
	*a = *b;
	*b = *c;
	*c = *d;
	*d = t;
}
void roll_x(){ rotation(&d.x,&d.z,&d.xx,&d.zz); }
void roll_xx(){ rotation(&d.x,&d.zz,&d.xx,&d.z); }
void roll_y(){ rotation(&d.y,&d.z,&d.yy,&d.zz); }
void roll_yy(){ rotation(&d.y,&d.zz,&d.yy,&d.z); }
void roll_xy(){ rotation(&d.x,&d.y,&d.xx,&d.yy); }
void make_dice(int t, int f){
	d.x = 3; d.xx = 4; d.y = 5; d.yy = 2; d.z = 1; d.zz = 6;
	Rep(i,4){
		if(d.z == t) break;
		roll_x();
	}
	Rep(i,4){
		if(d.z == t) break;
		roll_y();
	}
	while(d.x != f){ roll_xy(); }
}

int main(int argc, char const *argv[])
{
	while(1){
		cin >> N;
		if(N == 0) break;
		Rep(i,MAX_N*2)Rep(j,MAX_N*2){
			board[i][j] = 0;
			h[i][j] = 0;
		}
		Rep(i,N){
			int t, f;
			scanf("%d %d", &t, &f);
			make_dice(t,f);
			int dx = 100, dy = 100;
			while(1){
				int maxx = 0;
				if(d.x >= 4 && h[dx][dy] > h[dx+1][dy]){
					if(maxx < d.x) maxx = d.x;
				}
				if(d.y >= 4 && h[dx][dy] > h[dx][dy+1]){
					if(maxx < d.y) maxx = d.y;
				}
				if(d.xx >= 4 && h[dx][dy] > h[dx-1][dy]){
					if(maxx < d.xx) maxx = d.xx;
				}
				if(d.yy >= 4 && h[dx][dy] > h[dx][dy-1]){
					if(maxx < d.yy) maxx = d.yy;
				}
				if(maxx == 0) break;
				if(maxx == d.x){
					roll_x(); dx++;
				}else if(maxx == d.y){
					roll_y(); dy++;
				}else if(maxx == d.xx){
					roll_xx(); dx--;
				}else if(maxx == d.yy){
					roll_yy(); dy--;
				}
			}
			h[dx][dy]++;
			board[dx][dy] = d.z;
		}
		int res[7];
		Rep(i,7) res[i] = 0;
		Rep(i,MAX_N*2)Rep(j,MAX_N*2){
			res[board[i][j]]++;
		}
		cout << res[1];
		For(i,2,7) cout << " " << res[i];
		cout << endl; 
	}
	return 0;
}

Compiler output:
a.cc:2:10: fatal error: bits/libstdc++.h: No such file or directory
    2 | #include <bits/libstdc++.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int side(int up, int front, int n){
	int below = 7 - up;
	int back = 7 - front;
	int right = 0;
	int left;
	
	int kt = up;
	int kf, kr;
	switch(kt){
		case 1:
			kf = 2;
			kr = 3;
			break;
		case 2:
			kf = 6;
			kr = 3;
			break;
		case 3:
			kf = 6;
			kr = 5;
			break;
		case 4:
			kf = 6;
			kr = 2;
			break;
		case 5:
			kf = 6;
			kr = 4;
			break;
		case 6:
			kf = 5;
			kr = 3;
			break;
	}
	while(kf != front){
		int tmp = kr;
		kr = kf;
		kf = 7 - tmp;
	}
	right = kr;
	left = 7 - right;
	
	if(front == 6-n)
		return 3;
	else if(left == 6-n)
		return 0;
	else if(back == 6-n)
		return 1;
	else if(right == 6-n)
		return 2;

	return 4;
}

int main(){
	int field[199][199] = {0};
	int high[199][199] = {0};
	int dice[6] = {0};
	
	int n;
	int t,f;

	do{
		for(auto &h : high){
			for(int &h2 : h){
				h2 = 0;
				if(h2 > 0)
				//cout << h2;
			}
		}
		//cout << "\n";
		cin >> n;
		if(n == 0) break;
		for(int i=0;i<n;i++){
			cin >> t >> f;
			int keept = t, keepf = f;
			high[101][101]++;
			int x = 101, y = 101, nn = 0;
			while(nn < 3){
				int status = side(t, f, nn);
				int nowx = x;
				int nowy = y;
				//??¢??????????????????
				switch(status){
					case 0:
						y--;
						break;
					case 1:
						x++;
						break;
					case 2:
						y++;
						break;
					case 3:
						x--;
						break;
				}
				//??¢???????????????????????´??°??????break
				if(high[nowx][nowy] > 1 && high[x][y] < high[nowx][nowy]-1){
					high[nowx][nowy]--;
					high[x][y]++;
						if(status == 1)
							f = 7-t;
						else if(status == 3)
							f = t;
						t = nn + 1;
						nn = 0;
					//cout << t << " " << f << endl;
					if(high[x][y] == 1)
						break;
				//??¢????????????????????°???????????????????????????
				}else{
					nn++;
					x = nowx;
					y = nowy;
				}
			}
			/*cout << x << y << endl;
			cout << t << "\t" << f << endl;*/
			field[x][y] = t;
		}
		for(auto &cx : field){
			for(int &cy : cx){
				if(cy > 0)
					dice[cy-1]++;
					cy = 0;
			}
		}

		for(int &di : dice){
			cout << di << " ";
			di = 0;
		}
		cout << "\n";
	}while(n > 0);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:25: error: expected primary-expression before '}' token
   75 |                         }
      |                         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;

int dice[6][4]={{1,2,4,3},{0,3,5,2},{0,1,5,4},{0,4,5,1},{0,2,5,3},{1,3,4,2}};
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

void solve(int x,int y,VVI& v,VVI& w,int top,int face){
    //cout<<x<<" "<<y<<" "<<top<<" "<<face<<endl;
    vector<P> vec;
    int var=-1;
    for(int i=0;i<4;i++) if(dice[top][i]==face)var=i;
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(v[nx][ny]<v[x][y] && dice[top][(i+var)%4]>=3){
            vec.push_back(P(dice[top][(i+var)%4],i*11+var));
        }
    }
    if(vec.size()==0){
        v[x][y]++;
        w[x][y]=top;
        return ;
    }
    sort(vec.rbegin(),vec.rend());
    int i=vec[0].second/11,va=vec[0].second%11;
    if(i==0)solve(x+dx[i],y+dy[i],v,w,dice[top][(2+va)%4],top);
    if(i==1)solve(x+dx[i],y+dy[i],v,w,dice[top][(3+va)%4],dice[top][(0+va)%4]);
    if(i==2)solve(x+dx[i],y+dy[i],v,w,dice[top][(0+va)%4],5-top);
    if(i==3)solve(x+dx[i],y+dy[i],v,w,dice[top][(1+va)%4],dice[top][(0+va)%4]);
    return ;
}

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

  int n;
  while(true){
      cin>>n;if(n==0)break;
      std::vector<int> res(6,0);
      VVI top(200,vector<int>(200,-1)),num(200,vector<int>(200,0));
      for(int i=0;i<n;i++){
          int t,f;cin>>t>>f;t--;f--;
          solve(100,100,num,top,t,f);
      }
     for(int i=0;i<200;i++)for(int j=0;j<200;j++) if(top[i][j]!=-1)res[top[i][j]]++;
      for(int i=0;i<6;i++) cout<<res[i];
      if(i==5)cout<<endl;
      else cout<<" ";
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:10: error: 'i' was not declared in this scope
   53 |       if(i==5)cout<<endl;
      |          ^
Language: C++

#include<iostream>
#include<vector>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int n,a[222][222],y,x,t,d[6],b[222][222],f;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
vector<P>v;
void make_dice(){
  d[0]=t;
  d[1]=f;
  d[3]=7-f;
  d[5]=7-t;
  if(t==1){
    if(f==3)d[2]=5,d[4]=2;
    if(f==5)d[2]=4,d[4]=3;
    if(f==4)d[2]=2,d[4]=5;
    if(f==2)d[2]=3,d[4]=4;
  }
  if(t==2){
    if(f==1)d[2]=4,d[4]=3;
    if(f==4)d[2]=6,d[4]=1;
    if(f==6)d[2]=3,d[4]=4;
    if(f==3)d[2]=1,d[4]=6;
  }
  if(t==3){
    if(f==1)d[2]=2,d[4]=5;
    if(f==2)d[2]=6,d[4]=1;
    if(f==6)d[2]=5,d[4]=2;
    if(f==5)d[2]=1,d[4]=6;
  }
  if(t==4){
    if(f==1)d[2]=5,d[4]=2;
    if(f==2)d[2]=1,d[4]=6;
    if(f==6)d[2]=2,d[4]=5;
    if(f==5)d[2]=6,d[4]=1;
  }
  if(t==5){
    if(f==3)d[2]=6,d[4]=1;
    if(f==6)d[2]=4,d[4]=3;
    if(f==4)d[2]=1,d[4]=6;
    if(f==1)d[2]=3,d[4]=4;
  }
  if(t==6){
    if(f==3)d[2]=2,d[4]=5;
    if(f==5)d[2]=3,d[4]=4;
    if(f==4)d[2]=5,d[4]=2;
    if(f==2)d[2]=4,d[4]=3;
  }
}
void rot1(){
  swap(d[1],d[0]);
  swap(d[0],d[3]);
  swap(d[3],d[5]);
}
void rot2(){
  swap(d[2],d[0]);
  swap(d[0],d[4]);
  swap(d[4],d[5]);
}
void rot3(){
  swap(d[4],d[0]);
  swap(d[0],d[2]);
  swap(d[2],d[5]);
}
void rot4(){
  swap(d[3],d[0]);
  swap(d[0],d[1]);
  swap(d[1],d[5]);
}
void rot(int p){
  if(p==0)rot1();
  if(p==1)rot2();
  if(p==2)rot4();
  if(p==3)rot3();
}
void v_set(){
  r(i,4)v.push_back(P(d[i+1],i));
}
int main(){
  while(cin>>n,n){
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    while(n--){
      y=x=100;
      cin>>t>>f;
      make_dice();
      while(1){
	int flag=0;
	v.clear();
        v_set();
	sort(v.begin(),v.end());
	for(int i=3;i>=0;i--)if(v[i].first>3){
	  int xx=x+dx[v[i].second];
	  int yy=y+dy[v[i].second];
	  if(a[yy][xx]<a[y][x]){
	    x=xx,y=yy;
	    rot(v[i].second);
	    flag++;
	    break;
	  }
	}
	if(!flag){
	  a[y][x]++;
	  b[y][x]=d[0];
	  break;
	}
      }
    }
    int ans[6]={};
    r(i,222)r(j,222)if(b[i][j])ans[b[i][j]-1]++;
    cout<<ans[0];
    r(i,5)cout<<' '<<ans[i+1];
    cout<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:5: error: 'memset' was not declared in this scope
   83 |     memset(a,0,sizeof(a));
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<vector>
  +++ |+#include <cstring>
    3 | #define r(i,n) for(int i=0;i<n;i++)
a.cc:93:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   93 |         sort(v.begin(),v.end());
      |         ^~~~
      |         short
Language: C++

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

using namespace std;

int n, m, c, s, g, D[100][100][20], P[20], Q[20][51], R[20][51];//n:駅数,m:路線数,c:会社数,s:スタート,g:ゴール,D:距離,P:運賃規定区間数,Q:運賃増加率変化距離,R:運賃変化率
const int inf = 1001001001;//inf:上限
int K[100];//K:スタートからその駅までのコストを格納・更新
int T[100], U[100];//T:前にどの会社を使ったか,U:連続乗車距離
int W[100][100];//W:作業用配列
int G[100][100][20];//G:グラフ
int buf, bufx, bufy;//buf:一時データ,bufx:一時データ２,bufy:一時データ３

void cost_calc_1(int d,int l){//d:距離,l:会社名・・・連続乗車の場合1/非連続乗車の場合
	bufx = 0;
	for (int o = 1; o < P[l]; o++){
		if (Q[l][o] < d){
			bufx += Q[l][o] * R[l][o];
		}
		else{
			bufx += (d - Q[l][o - 1]) * R[l][o];
			break;
		}
	}
}

void cost_calc_2(int d, int l){//d:距離,l:会社名・・・連続乗車の場合2
	bufy = 0;
	for (int o = 1; o < P[l]; o++){
		if (Q[l][o] < d){
			bufy += Q[l][o] * R[l][o];
		}
		else{
			bufy += (d - Q[l][o - 1]) * R[l][o];
			break;
		}
	}
}

void bellman_ford(int n,int c,int s,int g){
	for (int i = 0; i < n; i++){
		K[i] = inf;
		T[i] = 100;
		U[i] = 0;
	}
	K[s] = 0;
	for (int i = 0; i < n; i++){//コスト更新回数の規定
		for (int j = 0; j < n; j++){
			for (int k = 0; k < n; k++){
				for (int l = 0; l < c; l++){//j,k,l:全ての辺について
					if (G[j][k][l] == 1) {
						if (l == T[j]){//連続乗車の場合
							buf = U[j];
							cost_calc_1(buf, l);
							cost_calc_2(buf + D[j][k][l], l);
							W[j][k] = bufy - bufx;
						}
						else {
							cost_calc_1(D[j][k][l], l);
							W[j][k] = bufx;
						}
						K[k] = min(K[k], K[j] + W[j][k]);
						if (K[j] + W[j][k] < K[k]){
							T[j] = l;
							U[k] = U[j] + D[j][k][l];
						}
					}
				}
			}
		}
	}
}

int main(){
	while (1){
		scanf_s("%d%d%d%d%d", &n, &m, &c, &s, &g); s--; g--;
		if (n == 0 && m == 0 && c == 0 && s == 0 && g == 0) break;
		int x, y, dst, cn;
		for (int i = 0; i < m; i++){
			scanf_s("%d%d%d%d", &x, &y, &dst, &cn);
			D[x][y][cn] = dst;
			D[y][x][cn] = dst;
			G[x][y][cn] = 1;
			G[y][x][cn] = 1;
		}
		for (int i = 0; i < c; i++){
			scanf_s("%d", &buf);
			P[i] = buf;
			Q[i][0] = 0;
		}
		for (int i = 0; i < c; i++){
			for (int j = 1; j < P[i]; j++){
				scanf_s("%d", &buf);
				Q[i][j] = buf;
			}
			for (int j = 1; j < P[i] + 1; j++){
				scanf_s("%d", &buf);
				R[i][j] = buf;
			}
		}
		//データ読み込み完了。
		bellman_ford(n, c, s, g);
		if (K[g] < inf) cerr << K[g] << endl;
		if (K[g] >= inf) cerr << -1 << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   80 |                 scanf_s("%d%d%d%d%d", &n, &m, &c, &s, &g); s--; g--;
      |                 ^~~~~~~
      |                 scanf
Language: C++

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

using namespace std;

int n, m, c, s, g, D[100][100][20], P[20], Q[20][51], R[20][51];//n:駅数,m:路線数,c:会社数,s:スタート,g:ゴール,D:距離,P:運賃規定区間数,Q:運賃増加率変化距離,R:運賃変化率
const int inf = 1001001001;//inf:上限
int K[100];//K:スタートからその駅までのコストを格納・更新
int T[100], U[100];//T:前にどの会社を使ったか,U:連続乗車距離
int W[100][100];//W:作業用配列
int G[100][100][20];//G:グラフ
int buf, bufx, bufy;//buf:一時データ,bufx:一時データ２,bufy:一時データ３

void cost_calc_1(int d,int l){//d:距離,l:会社名・・・連続乗車の場合1/非連続乗車の場合
	bufx = 0;
	for (int o = 1; o < P[l]; o++){
		if (Q[l][o] < d){
			bufx += Q[l][o] * R[l][o];
		}
		else{
			bufx += (d - Q[l][o - 1]) * R[l][o];
			break;
		}
	}
}

void cost_calc_2(int d, int l){//d:距離,l:会社名・・・連続乗車の場合2
	bufy = 0;
	for (int o = 1; o < P[l]; o++){
		if (Q[l][o] < d){
			bufy += Q[l][o] * R[l][o];
		}
		else{
			bufy += (d - Q[l][o-1]) * R[l][o];
			break;
		}
	}
}

void bellman_ford(int n,int c,int s,int g){
	for (int i = 0; i < n; i++){
		K[i] = inf;
		T[i] = 100;
		U[i] = 0;
	}
	K[s] = 0;
	for (int i = 0; i < n; i++){//コスト更新回数の規定
		for (int j = 0; j < n; j++){
			for (int k = 0; k < n; k++){
				for (int l = 0; l < c; l++){//j,k,l:全ての辺について
					if (G[j][k][l] == 1) {
						if (l == T[j]){//連続乗車の場合
							buf = U[j];
							cost_calc_1(buf, l);
							cost_calc_2(buf + D[j][k][l], l);
							W[j][k] = bufy - bufx;
						}
						else {
							cost_calc_1(D[j][k][l], l);
							W[j][k] = bufx;
						}
						K[k] = min(K[k], K[j] + W[j][k]);
						if (K[j] + W[j][k] < K[k]){
							T[j] = l;
							U[k] = U[j] + D[j][k][l];
						}
					}
				}
			}
		}
	}
}

int main(){
	while (1){
		scanf_s("%d%d%d%d%d", &n, &m, &c, &s, &g); s--; g--;
		if (n == 0 && m == 0 && c == 0 && s == 0 && g == 0) break;
		int x, y, dst, cn;
		for (int i = 0; i < m; i++){
			scanf_s("%d%d%d%d", &x, &y, &dst, &cn);
x--; y--;
			D[x][y][cn] = dst;
			D[y][x][cn] = dst;
			G[x][y][cn] = 1;
			G[y][x][cn] = 1;
		}
		for (int i = 0; i < c; i++){
			scanf_s("%d", &buf);
			P[i] = buf;
			Q[i][0] = 0;
		}
		for (int i = 0; i < c; i++){
			for (int j = 1; j < P[i]; j++){
				scanf_s("%d", &buf);
				Q[i][j] = buf;
			}
			for (int j = 1; j < P[i] + 1; j++){
				scanf_s("%d", &buf);
				R[i][j] = buf;
			}
		}
		//データ読み込み完了。
		bellman_ford(n, c, s, g);
		if (K[g] < inf) cerr << K[g] << endl;
		if (K[g] >= inf) cerr << -1 << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   80 |                 scanf_s("%d%d%d%d%d", &n, &m, &c, &s, &g); s--; g--;
      |                 ^~~~~~~
      |                 scanf
Language: C++

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

using namespace std;

int n, m, c, s, g, D[100][100][20], P[20], Q[20][51], R[20][51];//n:駅数,m:路線数,c:会社数,s:スタート,g:ゴール,D:距離,P:運賃規定区間数,Q:運賃増加率変化距離,R:運賃変化率
const int inf = 1001001001;//inf:上限
int K[100];//K:スタートからその駅までのコストを格納・更新
int T[100], U[100];//T:前にどの会社を使ったか,U:連続乗車距離
int W[100][100];//W:作業用配列
int G[100][100][20];//G:グラフ
int buf, bufx, bufy;//buf:一時データ,bufx:一時データ２,bufy:一時データ３

void cost_calc_1(int d,int l){//d:距離,l:会社名・・・連続乗車の場合1/非連続乗車の場合
	bufx = 0;
	for (int o = 1; o < P[l]; o++){
		if (Q[l][o] < d){
			bufx += (Q[l][o] - Q[l][o-1]) * R[l][o];
		}
		else{
			bufx += (d - Q[l][o - 1]) * R[l][o];
			break;
		}
	}
}

void cost_calc_2(int d, int l){//d:距離,l:会社名・・・連続乗車の場合2
	bufy = 0;
	for (int o = 1; o < P[l]; o++){
		if (Q[l][o] < d){
			bufy += (Q[l][o] - Q[l][o-1]) * R[l][o];
		}
		else{
			bufy += (d - Q[l][o - 1]) * R[l][o];
			break;
		}
	}
}

void bellman_ford(int n,int c,int s,int g){
	for (int i = 0; i < n; i++){
		K[i] = inf;
		T[i] = 100;
		U[i] = 0;
	}
	K[s] = 0;
	for (int i = 0; i < n; i++){//コスト更新回数の規定
		for (int j = 0; j < n; j++){
			for (int k = 0; k < n; k++){
				for (int l = 0; l < c; l++){//j,k,l:全ての辺について
					if (G[j][k][l] == 1) {
						if (l == T[j]){//連続乗車の場合
							buf = U[j];
							cost_calc_1(buf, l);
							cost_calc_2(buf + D[j][k][l], l);
							W[j][k] = bufy - bufx;
						}
						else {
							cost_calc_1(D[j][k][l], l);
							W[j][k] = bufx;
						}
						K[k] = min(K[k], K[j] + W[j][k]);
						if (K[j] + W[j][k] < K[k]){
							T[j] = l;
							U[k] = U[j] + D[j][k][l];
						}
					}
				}
			}
		}
	}
}

int main(){
	while (1){
		scanf_s("%d%d%d%d%d", &n, &m, &c, &s, &g); s--; g--;
		int x, y, dst, cn;
		for (int i = 0; i < m; i++){
			scanf_s("%d%d%d%d", &x, &y, &dst, &cn); x--; y--; cn--;
			D[x][y][cn] = dst;
			D[y][x][cn] = dst;
			G[x][y][cn] = 1;
			G[y][x][cn] = 1;
		}
		for (int i = 0; i < c; i++){
			scanf_s("%d", &buf);
			P[i] = buf;
			Q[i][0] = 0;
		}
		for (int i = 0; i < c; i++){
			for (int j = 1; j < P[i]; j++){
				scanf_s("%d", &buf);
				Q[i][j] = buf;
			}
			for (int j = 1; j < P[i] + 1; j++){
				scanf_s("%d", &buf);
				R[i][j] = buf;
			}
		}
		//データ読み込み完了。
		if (n == 0 && m == 0 && c == 0 && s == -1 && g == -1) break;
		bellman_ford(n, c, s, g);
		if (K[g] < inf) cerr << K[g] << endl;
		if (K[g] >= inf) cerr << -1 << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   80 |                 scanf_s("%d%d%d%d%d", &n, &m, &c, &s, &g); s--; g--;
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
using namespace std;
int n,m,c,s,g,A,B,C,D,z[22][22000],r1[22][60],r2[22][60],r0[22],dp[102];
vector<pair<int,int>>X[22][102];
int dist[22][102][102],dist2[102][102];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
void dijkstra(int s1,int s2){
	for(int i=0;i<102;i++)dist[s1][s2][i%102]=1<<30;
	dist[s1][s2][s2]=0;Q.push(make_pair(0,s2));
	while(!Q.empty()){
		int a1=Q.top()first,a2=Q.top().second;Q.pop();
		for(int i=0;i<X[s1][a2].size();i++){
			int to=X[s1][a2][i].first;
			if(dist[s1][s2][to]>a1+X[s1][a2][i].second){
				dist[s1][s2][to]=a1+X[s1][a2][i].second;
				Q.push(make_pair(dist[s1][s2][to],to));
			}
		}
	}
}
int main(){
	while(true){
		for(int i=0;i<10404;i++)dist2[i/102][i%102]=1<<30;
		cin>>n>>m>>c>>s>>g;if(n==0)breakj;
		for(int i=0;i<m;i++){
			cin>>A>>B>>C>>D;
			X[D][A].push_back(make_pair(B,C));
		}
		for(int i=1;i<=c;i++)cin>>r0[i];
		for(int i=1;i<=c;i++){
			for(int j=1;j<r0[i];j++)cin>>r1[i][j];
			for(int j=0;j<r0[i];j++)cin>>r2[i][j];
			int C=0;
			for(int j=0;j<22000;j++){
				z[i][j]=z[i][r1[i][C]]+(j-r1[i][C])*r2[i][C];
				if(C!=r0[i]-1 && r1[i][C+1]<=j)C++;
			}
		}
		for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++)dijkstra(i,j);
		}
		for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					if(dist[i][j][k]>=22000)continue;
					dist2[j][k]=min(dist2[j][k],d[dist[i][j][k]]);
				}
			}
		}
		for(int i=0;i<102;i++){dp[i]=1<<30;}dp[s]=0;
		for(int i=0;i<n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					dp[k]=min(dp[k],dp[j]+dist2[j][k]);
				}
			}
		}
		cout<<dp[g]<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dijkstra(int, int)':
a.cc:15:29: error: cannot convert 'const __gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'const std::pair<int, int>'} to 'int' in initialization
   15 |                 int a1=Q.top()first,a2=Q.top().second;Q.pop();
      |                        ~~~~~^~
      |                             |
      |                             const __gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type {aka const std::pair<int, int>}
a.cc:16:37: error: 'a2' was not declared in this scope; did you mean 'a1'?
   16 |                 for(int i=0;i<X[s1][a2].size();i++){
      |                                     ^~
      |                                     a1
a.cc: In function 'int main()':
a.cc:28:44: error: 'breakj' was not declared in this scope
   28 |                 cin>>n>>m>>c>>s>>g;if(n==0)breakj;
      |                                            ^~~~~~
a.cc:50:69: error: 'd' was not declared in this scope
   50 |                                         dist2[j][k]=min(dist2[j][k],d[dist[i][j][k]]);
      |                                                                     ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
using namespace std;
int n,m,c,s,g,A,B,C,D,z[22][22000],r1[22][60],r2[22][60],r0[22],dp[102];
vector<pair<int,int>>X[22][102];
int dist[22][102][102],dist2[102][102];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
void dijkstra(int s1,int s2){
	for(int i=0;i<102;i++)dist[s1][s2][i%102]=1<<30;
	dist[s1][s2][s2]=0;Q.push(make_pair(0,s2));
	while(!Q.empty()){
		int a1=Q.top().first,a2=Q.top().second;Q.pop();
		for(int i=0;i<X[s1][a2].size();i++){
			int to=X[s1][a2][i].first;
			if(dist[s1][s2][to]>a1+X[s1][a2][i].second){
				dist[s1][s2][to]=a1+X[s1][a2][i].second;
				Q.push(make_pair(dist[s1][s2][to],to));
			}
		}
	}
}
int main(){
	while(true){
		for(int i=0;i<10404;i++)dist2[i/102][i%102]=1<<30;
		cin>>n>>m>>c>>s>>g;if(n==0)breakj;
		for(int i=0;i<m;i++){
			cin>>A>>B>>C>>D;
			X[D][A].push_back(make_pair(B,C));
		}
		for(int i=1;i<=c;i++)cin>>r0[i];
		for(int i=1;i<=c;i++){
			for(int j=1;j<r0[i];j++)cin>>r1[i][j];
			for(int j=0;j<r0[i];j++)cin>>r2[i][j];
			int C=0;
			for(int j=0;j<22000;j++){
				z[i][j]=z[i][r1[i][C]]+(j-r1[i][C])*r2[i][C];
				if(C!=r0[i]-1 && r1[i][C+1]<=j)C++;
			}
		}
		for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++)dijkstra(i,j);
		}
		for(int i=1;i<=c;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					if(dist[i][j][k]>=22000)continue;
					dist2[j][k]=min(dist2[j][k],d[dist[i][j][k]]);
				}
			}
		}
		for(int i=0;i<102;i++){dp[i]=1<<30;}dp[s]=0;
		for(int i=0;i<n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					dp[k]=min(dp[k],dp[j]+dist2[j][k]);
				}
			}
		}
		cout<<dp[g]<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:44: error: 'breakj' was not declared in this scope
   28 |                 cin>>n>>m>>c>>s>>g;if(n==0)breakj;
      |                                            ^~~~~~
a.cc:50:69: error: 'd' was not declared in this scope
   50 |                                         dist2[j][k]=min(dist2[j][k],d[dist[i][j][k]]);
      |                                                                     ^
Language: C++

#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1,0,1,0 }; const int dy[] = { 0,1,0,-1 };


int main() {
	int n, m, c, start, goal;
	while (cin >> n >> m >> c >> start >> goal, n) {
		start--;
		goal--;
		vector<vector<vector<pii>>> E(c, vector<vector<pii>>(n));
		REP(i, m) {
			int x, y, d, co;
			cin >> x >> y >> d >> co;
			x--;
			y--;
			co--;
			E[co][x].push_back({ y,d });
			E[co][y].push_back({ x,d });
		}
		vector<int> num(n);
		REP(i, c) {
			cin >> num[i];
		}

		ll cost[20][20000];
		REP(i, c) {
			vi q(num[i] - 1);
			vi r(num[i]);
			REP(j, num[i] - 1)
				cin >> q[j];
			REP(j, num[i])
				cin >> r[j];
			int qidx = 0;
			int ridx = 0;
			FOR(j, 1, n * 200) {
				cost[i][j] = cost[i][j - 1] + r[ridx];
				if (!q.empty() && qidx < q.size() && j == q[qidx]) {
					qidx++;
					ridx++;
				}
			}
		}
		vvll E2(n, vll(n, 1e16));
		REP(i, c) {
			REP(j, n) {
				vll memo(n, 1e9);//dis
				memo[j] = 0;
				queue<pii> Q;//to,dis
				Q.push({ j,0 });
				while (!Q.empty()) {
					pii q = Q.front(); Q.pop();
					REP(k, E[i][q.first].size()) {
						if (memo[E[i][q.first][k].first] > q.second + E[i][q.first][k].second) {
							memo[E[i][q.first][k].first] = q.second + E[i][q.first][k].second;
							Q.push({ E[i][q.first][k].first,q.second + E[i][q.first][k].second });
						}
					}s
				}
				REP(k, n) {
					if (memo[k] != 1e9)
						E2[j][k] = min(E2[j][k], cost[i][memo[k]]);
				}
			}
		}
		REP(i, n)
			REP(j, n)
			REP(k, n)
			E2[j][k] = min(E2[j][k], E2[j][i] + E2[i][k]);
		if (E2[start][goal] == 1e16)
			cout << -1 << endl;
		else
			cout << E2[start][goal] << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:102:42: error: 's' was not declared in this scope
  102 |                                         }s
      |                                          ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	using T = tuple<int, int, int>;
	for (int N, M, C, s, g; cin >> N >> M >> C >> s >> g&&N;) {
		static int dist[21][101][101], p[21], q[21][51], r[21][51];
		static int fare[21][20001], cost[101][101];
		s--; g--;
		memset(dist, 0x3f, sizeof(dist));
		memset(cost, 0x3f, sizeof(cost));
		rep(i, 0, M) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--; c--;
			chmin(dist[c][x][y], d);
			chmin(dist[c][y][x], d);
		}
		rep(c, 0, C) 
			cin >> p[c];
		rep(c, 0, C)
			rep(i, 0, p[c] - 1) 
				cin >> q[c][i];
			rep(i, 0, p[c]) 
				cin >> r[c][i];
		rep(c, 0, C)rep(k, 0, N)rep(i, 0, N)rep(j, 0, N)
			chmin(dist[c][i][j], dist[c][i][k] + dist[c][k][j]);
		rep(c, 0, C) {
			int idx = 0;
			fare[c][0] = 0;
			rep(i, 0, 20000) {
				if (idx < p[c] - 1 && i == q[c][idx]) idx++;
				fare[c][i + 1] = fare[c][i] + r[c][idx];
			}
		}
		rep(c, 0, C)rep(i, 0, N)rep(j, 0, N)
			if (dist[c][i][j] < INF)
				chmin(cost[i][j], fare[c][dist[c][i][j]]);
		rep(k, 0, N)rep(i, 0, N)rep(j, 0, N)
			chmin(cost[i][j], cost[i][k] + cost[k][j]);
		cout << (cost[s][g] == INF ? -1 : cost[s][g]) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:37: error: 'c' was not declared in this scope
   40 |                         rep(i, 0, p[c])
      |                                     ^
a.cc:10:37: note: in definition of macro 'rep'
   10 | #define rep(i,a,b) for(int i=(a);i<(b);i++)
      |                                     ^
Language: C++

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

int main(){
  int N, M, C, s, g, INF = 1e9;
  while(cin >> N >> M >> C >> s >> g, N){
    --s;--g;
    vector< vector<int> > G(N, vector<int>(N,INF));
    vector< vector< vector<int> > > D(C, G);
    int x, y, d, c;
    for(int i = 0; i < M; ++i){
      cin >> x >> y >> d >> c;
      --x;--y;--c;
      D[c][x][y] = min(D[c][x][y],d);
      D[c][y][x] = d;
    }
    for(int c = 0; c < C; ++c){
      for(int k = 0; k < N; ++k){
        for(int i = 0; i < N; ++i){
          for(int j = 0; j < N; ++j){
            D[c][i][j] = min(D[c][i][j],D[c][i][k]+D[c][k][j]);
          }
        }
      }
    }
    vector<int> P(C);
    for(int i = 0; i < C; ++i) cin >> P[i];
    vector< vector<int> > Q(C), R(C), F(C);
    for(int c = 0; c < C; ++c){
      int q, r;
      Q[c].push_back(0);
      for(int i = 0; i < P[c]-1; ++i){
        cin >> q;
        Q[c].push_back(q);
      }
      for(int i = 0; i < P[c]; ++i){
        cin >> r;
        R[c].push_back(r);
      }
      F[c].push_back(0);
      for(int i = 0; i < P[c]-1; ++i){
        F[c].push_back((Q[c][i+1]-Q[c][i])*R[c][i] + F[c].back());
      }
    }
    for(int c = 0; c < C; ++c){
      for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
          int d = D[c][i][j];
          int t = upper_bound(Q[c].begin(), Q[c].end(), d) - Q[c].begin() - 1;
          //int t = lower_bound(Q[c].begin(), Q[c].end(), d) - Q[c].begin() - 1;
          G[i][j] = min(G[i][j],F[c][t]+R[c][t]*(d-Q[c][t]));
          G[j][i] = G[i][j];
        }
      }
    }
    for(int k = 0; k < N; ++k){
      for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
          G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
        }
      }
    }
    if(G[s][g] >= INF) cout << -1 << endl;
    else cout << G[s][g] << endl;
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:50:19: error: 'upper_bound' was not declared in this scope
   50 |           int t = upper_bound(Q[c].begin(), Q[c].end(), d) - Q[c].begin() - 1;
      |                   ^~~~~~~~~~~
Language: C++

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

using namespace std;

typedef long long ll;

const ll INF = 300000000000;


ll N, M, C, S, g;
ll x[10000], y[10000], D[10000], c[10000];
ll p[20];
ll q[20][50], r[20][50];

ll sum[20][50];

ll money(ll company, ll length) {
  ll u = upper_bound(q[company], q[company] + p[company], length) - q[company];
  u--;
  return sum[company][u] + (length - q[company][u]) * r[company][u];
}

struct edge { ll to, length; };
typedef pair<ll, ll> P;

ll V;
vector<edge> G[100][20];
ll d[100];
priority_queue<P, vector<P>, greater<P> > que;

void dfs(ll from, ll now, ll number, ll length) {
  for (ll i = 0; i < G[now][number].size(); i++) {
    edge e = G[now][number][i];
    ll m = money(number, length + e.length);
    if (d[e.to] > d[from] + m) {
      d[e.to] = d[from] + m;
      que.push(P(d[e.to], e.to));
      dfs(from, e.to, number, length + e.length);
    }
  }
}

void init() {
  for (ll i = 0; i < 100; i++)
    for (ll j = 0; j < 20; j++)
      G[i][j].clear();
  V = N;
  for (ll i = 0; i < C; i++) {
    sum[i][0] = 0;
    for (ll j = 0; j < p[i] - 1; j++) {
      sum[i][j+1] = sum[i][j] + (q[i][j+1] - q[i][j]) * r[i][j];
    }
  }

  for (ll i = 0; i < M; i++) {
    edge e1, e2;
    e1.to = y[i];
    e2.to = x[i];
    e1.length = e2.length = D[i];
    G[x[i]][c[i]].push_back(e1);
    G[y[i]][c[i]].push_back(e2);
  }
}

void dijkstra(ll s) {
  fill(d, d + V, INF);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    for (ll i = 0; i < C; i++) {
      dfs(v, v, i, 0);
    }
  }
}

ll main(){
  while (1) {
    scanf("%lld%lld%lld%lld%lld", &N, &M, &C, &S, &g);
    S--; g--;
    if (N == 0) break;
    for (ll i = 0; i < M; i++) scanf("%lld%lld%lld%lld", &x[i], &y[i], &D[i], &c[i]);
    for (ll i = 0; i < M; i++) x[i]--, y[i]--, c[i]--;
    for (ll i = 0; i < C; i++) scanf("%lld", &p[i]);
    for (ll i = 0; i < C; i++) {
      q[i][0] = 0;
      for (ll j = 0; j < p[i] - 1; j++) scanf("%lld", &q[i][j+1]);
      for (ll j = 0; j < p[i]; j++) scanf("%lld", &r[i][j]);
    }
    init();
    dijkstra(S);
    ll ans = d[g];
    if (ans == INF) ans = -1;
    printf("%lld\n", ans);
  }
}



Compiler output:
a.cc:82:1: error: '::main' must return 'int'
   82 | ll main(){
      | ^~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
 
const int INF=1000000000;
 
using namespace std;
 
struct edge{int to,cost;};
typedef pair<int,int>P;
 
int V,d[101];
vector<edge>G[101];
 
void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> >que;
  fill(d,d+V,INF);
  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;
    que.push(P(d[e.to],e.to));
      }
    }
  }
}
 
int main(void){
 
  int n,m,c,s,g,x,y,D,C;
  int p[21],q[21][51],r[21][51];
  int graph[21][101][101],Cost[21][20001];
   
  while(cin >> n >> m >> c >> s >> g,n|m|c|s|g){
   
    for(int i=0;i<101;i++)G[i].clear();
 
    for(int i=0;i<21;i++)
      for(int j=0;j<101;j++)
    for(int k=0;k<101;k++)
      graph[i][j][k]=INF;
 
    for(int i=0;i<21;i++)
      for(int j=0;j<101;j++)
    graph[i][j][j]=0;
     
    for(int i=0;i<m;i++){
      cin >> x >> y >> D >> C;
      graph[C][x][y]=C[C][y][x]=min(graph[C][x][y],D);
    }
  
    for(int i=1;i<=c;i++)cin >> p[i];
 
    for(int i=1;i<=c;i++){
      for(int j=1;j<p[i];j++)cin >> q[i][j];
      for(int j=1;j<=p[i];j++)cin >> r[i][j];
    }
     
    for(int i=0;i<21;i++)
      for(int j=0;j<20001;j++)
    Cost[i][j]=0;
   
    for(int i=1;i<=c;i++){
      for(int j=1,k=1;j<20001;j++){
    if(k<p[i] && q[i][k]<j)k++;
    Cost[i][j]=Cost[i][j-1]+r[i][k];
      }
    }
     
    for(int l=1;l<=c;l++){
      for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        graph[l][i][j]=min(graph[l][i][j],graph[l][i][k]+graph[l][k][j]);
      }
    }
      }
    }
     
    for(int k=1;k<=c;k++)
      for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      if(graph[k][i][j]!=INF)
        graph[0][i][j]=min(graph[0][i][j],Cost[k][graph[k][i][j]]);
     
 
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
    if(graph[0][i][j]==INF)continue;
    edge e;
    e.to=j;
    e.cost=graph[0][i][j];
    G[i].push_back(e);
      }
    }
     
     
    V=n+1;
    dijkstra(s);
 
    if(d[g]==INF)cout << -1 << endl;
    else cout << d[g] << endl;
  }
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:23: error: invalid types 'int[int]' for array subscript
   59 |       graph[C][x][y]=C[C][y][x]=min(graph[C][x][y],D);
      |                       ^
Language: C++

10
802 0 10
814 0 4
820 1 4
826 1 4
832 3 5
838 5 5
845 7 3
849 10 3
853 14 4
857 18 3
3
0 0 5
8 0 5
8 8 5
3
0 0 5
7 3 6
16 0 5
9
0 3 5
8 0 8
19 2 8
23 14 6
23 21 6
23 28 6
19 40 8
8 42 8
0 39 5
11
0 0 5
8 0 5
18 8 10
8 16 5
0 16 5
0 24 5
3 32 5
10 32 5
17 28 8
27 25 3
30 18 5
0

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 10
      | ^~
Language: C++

10
802 0 10
814 0 4
820 1 4
826 1 4
832 3 5
838 5 5
845 7 3
849 10 3
853 14 4
857 18 3
3
0 0 5
8 0 5
8 8 5
3
0 0 5
7 3 6
16 0 5
9
0 3 5
8 0 8
19 2 8
23 14 6
23 21 6
23 28 6
19 40 8
8 42 8
0 39 5
11
0 0 5
8 0 5
18 8 10
8 16 5
0 16 5
0 24 5
3 32 5
10 32 5
17 28 8
27 25 3
30 18 5
0


Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 10
      | ^~
Language: C++

/* 解答時間→ 101:22(途中) */
#include <cmath>
#include <iostream>		//基本入出力
using namespace std;

double dist2d(double x1, double y1, double x2, double y2){
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main(){
	while(1){
		//入力
		int n;
		cin >> n;
		if(n == 0)
			break;
		double x[25],y[25],r[25];
		for(int i = 0; i < n; i++){
			cin >> x[i] >> y[i] >> r[i];
		}
		int V = n * 2;
		double pos_x[50], pos_y[50];
		pos_x[0] = x[0];
		pos_y[0] = y[0];
		pos_x[V - 1] = x[n - 1];
		pos_y[V - 1] = y[n - 1];
		for(int i = 0; i < n - 1; i++){
			double d = sqrt(1.0 * (x[i] - x[i + 1]) * (x[i] - x[i + 1]) + (y[i] - y[i + 1]) * (y[i] - y[i + 1]));
			double a = (d * d + r[i] * r[i] - r[i + 1] * r[i + 1]) / (d * 2);
			double b = sqrt(-a * a + r[i] * r[i]);
			double va_x = a * (x[i + 1] - x[i]) / d, va_y = a * (y[i + 1] - y[i]) / d;
			double vb_x = b * (y[i] - y[i + 1]) / d, vb_y = b * (x[i + 1] - x[i]) / d;
			pos_x[i * 2 + 1] = va_x + vb_x + x[i];
			pos_y[i * 2 + 1] = va_y + vb_y + y[i];
			pos_x[i * 2 + 2] = va_x - vb_x + x[i];
			pos_y[i * 2 + 2] = va_y - vb_y + y[i];
		}
		//総当りで距離を計算
		double dist[50][50];
		for(int i = 0; i < V; i++){
			for(int j = 0; j < V; j++){
				dist[i][j] = DBL_MAX;
			}
		}
		for(int i = 0; i < V - 1; i++){
			for(int j = i + 1; j < V; j++){
				//交差判定(準備)
				int flg = 1;
				double x1, y1, x2, y2, x3, y3, x4, y4;
				x1 = pos_x[i];
				y1 = pos_y[i];
				x2 = pos_x[j];
				y2 = pos_y[j];
				int pos_ls, pos_lg;
				if(i == 0)
					pos_ls = 1;
				else
					pos_ls = (i + 1) / 2 + 1;
				if(j == V - 1)
					pos_lg = n - 1;
				else
					pos_lg = (j + 1) / 2 - 1;
				//交差判定(本番)
				double ta, tb, tc, td;
				for(int k = pos_ls; k <= pos_lg; k++){
					x3 = pos_x[k * 2 - 1];
					y3 = pos_y[k * 2 - 1];
					x4 = pos_x[k * 2];
					y4 = pos_y[k * 2];
					ta = (x3-x4)*(y1-y3)+(y3-y4)*(x3-x1);
					tb = (x3-x4)*(y2-y3)+(y3-y4)*(x3-x2);
					tc = (x1-x2)*(y3-y1)+(y1-y2)*(x1-x3);
					td = (x1-x2)*(y4-y1)+(y1-y2)*(x1-x4);
					if((tc*td>=0.0)||(ta*tb>=0.0)){
						flg=0;
						break;
					}
				}
				if(flg == 1){
					dist[i][j] = dist2d(pos_x[i], pos_y[i], pos_x[j], pos_y[j]);
					dist[j][i] = dist[i][j];
				}
			}
		}
		//ワーシャル・フロイド法
		for(int i = 0; i < V; i++){
			for(int j = 0; j < V; j++){
				for(int k = 0; k < V; k++){
					if(dist[i][j] > dist[i][k] + dist[k][j])
						dist[i][j] = dist[i][k] + dist[k][j];
				}
			}
		}
		//出力
		cout << dist[0][V - 1] << "\n";
	}
	cout << flush;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:46: error: 'DBL_MAX' was not declared in this scope
   42 |                                 dist[i][j] = DBL_MAX;
      |                                              ^~~~~~~
a.cc:4:1: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
    3 | #include <iostream>             //基本入出力
  +++ |+#include <cfloat>
    4 | using namespace std;