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

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

typedef pair<double,int> P;


int H,W;
string str;

vector <P> u;
char t[600][600];

char T(int y,int x){
  if(y<0||x<0)return '.';
  if(y>=H||x>=W)return '.';
  return t[y][x];
}
int main(){

  double a,x,y;

  while(cin>>H>>W){
    u.clear();
    for(int i=H-1;i>=0;i--){
      cin>>str;
      for(int j=0;j<W;j++){
	t[i][j]=str[j];
      }
    }
    
    
    for(int i=-1;i<H;i++){
      for(int j=-1;j<W;j++){
	if(T(i,j)=='#'&&T(i+1,j)=='#'&&T(i,j+1)=='.'&&T(i+1,j+1)=='#'){
	  x=j+1;y=i+1;
	  a=acos( (x)/(sqrt(x*x+y*y)) );
	  u.push_back(P(a,-1));
	}
	if(T(i,j)=='.'&&T(i+1,j)=='#'&&T(i,j+1)=='.'&&T(i+1,j+1)=='.'){
	  x=j+1;y=i+1;
	  a=acos( (x)/(sqrt(x*x+y*y)) );
	  u.push_back(P(a,1));
	}
	if(T(i,j)=='#'&&T(i+1,j)=='.'&&T(i,j+1)=='#'&&T(i+1,j+1)=='#'){
	  x=j+1;y=i+1;
	  a=acos( (x)/(sqrt(x*x+y*y)) );
	  u.push_back(P(a,1));
	}
	if(T(i,j)=='.'&&T(i+1,j)=='.'&&T(i,j+1)=='#'&&T(i+1,j+1)=='.'){
	  x=j+1;y=i+1;
	  a=acos( (x)/(sqrt(x*x+y*y)) );
	  u.push_back(P(a,-1));
	}
      }
    }
    
    int cnt=1,ans=1;
    sort(u.begin(),u.end());
    for(int i=0;i<(int)u.size();i++){
      
      cnt+=u[i].second;
      ans=max(ans,cnt);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   60 |     sort(u.begin(),u.end());
      |     ^~~~
      |     sqrt
Language: Java

import java.util.Scanner;


public class DessertWitch {
	Scanner in = new Scanner(System.in);
	char[][] map = new char[10][10];
	boolean flag = true;
	int[] dirx = {-1, 0, 1, -1, 1, -1, 0, 1};
	int[] diry = {-1, -1, -1, 0, 0, 1, 1, 1};
	
	int put(char color, int y, int x) {
		int ret = 0;
		if (map[y][x] != '.') return ret;
		for (int i = 0; i < dirx.length; i++) {
			int stoneNum = checkDir(color, x, y, i);
			ret += stoneNum;
		}
		return ret;
	}
	
	int checkDir(char color, int x, int y, int dir) {
		char c = map[y+diry[dir]][x+dirx[dir]];
		if (c == 0 || c == '.' || c == color) return 0;
		else {
			for (int j = 2; j < dirx.length; j++) {
				c = map[y+diry[dir]*j][x+dirx[dir]*j];
				if (c == 0 || c == '.') return 0;
				else if (c == color) return j - 1;
				else continue;
			}
		}
		return 0;
	}
	
	void flip(char color, int x, int y) {
		for (int i = 0; i < dirx.length; i++) {
			int stoneNum = checkDir(color, x, y, i);
			for (int k = stoneNum; k >= 0; k--) {
				map[y+diry[i]*k][x+dirx[i]*k] = color;
			}
		}
	}
	
	public void run() {
		for (int i = 1; i <= 8; i++) {
			String s = in.next();
			for (int j = 0; j < 8; j++) {
				map[i][j+1] = s.charAt(j);
			}
		}
		
		int max;
		int x, y;
		while (flag) {
			flag = false;
			max = 0;
			x = -1; y = -1;
			for (int i = 1; i <= 8; i++) {
				for (int j = 1; j <= 8; j++) {
					if (max < put('o', i, j)) {
						y = i; x = j;
						max = put('o', i, j);
					}
				}
			}
			if (max != 0) {
				flip('o', x, y);
				flag = true;
			}
			max = 0;
			x = -1; y = -1;
			for (int i = 8; i > 0; i--) {
				for (int j = 8; j > 0; j--) {
					if (max < put('x', i, j)) {
						y = i; x = j;
						max = put('x', i, j);
					}
				}
			}
			if (max != 0) {
				flip('x', x, y);
				flag = true;
			}
		}
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				System.out.print(map[i][j]);
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new DessertWitch().run();
	}

}

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

#include<stdio.h>
using namespace std;

int di[]={-1,0,1,0,-1,1,1,-1};
int dj[]={0,1,0,-1,1,1,-1,-1};

char t[8][8],ch,turn='o';

char u[8][8];

int calc(int I,int J,char turn){
  u[I][J]=turn;
  int i,j,k,l,sum=0,cnt;
  for(k=0;k<8;k++){
    i=I;
    j=J;
    cnt=0;
    while(1){
      i+=di[k];
      j+=dj[k];      
      if(i<0||j<0||i>=8||j>=8||t[i][j]=='.'){
        cnt=0;
        break;
      }
      if(t[i][j]==turn){
        break;
      }
      cnt++;
    }
    sum+=cnt;
    i=I;
    j=J;
    for(l=0;l<cnt;l++){
      i+=di[k];
      j+=dj[k];      
      u[i][j]=turn;
    }
  }
  return sum;
}

int func(){
  int i,j,I,J,X;
  int ci,cj,maxm=0;

  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      I=i;
      J=j;
      if(turn=='x'){
        I=7-i;
        J=7-j;
      }
      if(t[I][J]!='.')continue;
      X=calc(I,J,turn);    
      if(X <= maxm)continue;
      maxm=X;
      ci=I;
      cj=J;
    }
  }

  if(maxm==0)return 0;
  
  for(i=0;i<8;i++)for(j=0;j<8;j++)u[i][j]=t[i][j];
  calc(ci,cj,turn);
  for(i=0;i<8;i++)for(j=0;j<8;j++)t[i][j]=u[i][j];
  
  return 1;
}

int main(){
  int i,j;
  for(i=0;i<8;i++){
    for(j=0;j<8;j++)scanf("%c",&t[i][j]);
    scanf("%c",&ch);
  }
  int c=0;
  while(1){
    if(c==2)break;
    int x=func();
    if(x==0)c++;
    else c=0;
    if(turn=='o')turn='x';
    else turn='o';
  }
  
  for(i=0;i<8;i++){
    for(j=0;j<8;j++)printf("%c",t[i][j]);
    printf("\n");
  }
  return 0;
}

Compiler output:
main.c:2:1: error: unknown type name 'using'
    2 | using namespace std;
      | ^~~~~
main.c:2:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    2 | using namespace std;
      |                 ^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <functional>
using namespace std;
typedef tuple<int,int,int> tiii;

typedef struct{
	int x;
	int y;
}dir;
vector<dir>D={
	{-1,-1},{0,-1},{1,-1},
	{-1,0},{1,0},
	{-1,1},{0,1},{1,1},
};

const int H=8,W=8;
vector<function<bool(tiii&,tiii&)> >sorter={
	[](tiii &a,tiii &b)->bool{
		if(get<0>(a)<get<0>(b))return true;
		if(get<0>(a)>get<0>(b))return false;
		if(get<2>(a)>get<2>(b))return true;
		if(get<2>(a)<get<2>(b))return false;
		if(get<1>(a)>get<1>(b))return true;
		if(get<1>(a)<get<1>(b))return false;
		return false;
	},
	[](tiii &a,tiii &b)->bool{
		if(get<0>(a)<get<0>(b))return true;
		if(get<0>(a)>get<0>(b))return false;
		if(get<2>(a)<get<2>(b))return true;
		if(get<2>(a)>get<2>(b))return false;
		if(get<1>(a)<get<1>(b))return true;
		if(get<1>(a)>get<1>(b))return false;
		return false;
	}
};

int check2(int color,dir&d,int x,int y,vector<string>&m){
	if(x<0||W<=x||y<0||H<=y||m[y][x]=='.')return -1;
	if(m[y][x]==color)return 0;
	int r=check2(color,d,x+d.x,y+d.y,m);
	if(r<0)return r;
	return r+1;
}
int check1(int color,int x,int y,vector<string>&m){
	int R=-1;
	for(auto &d:D){
		int r=check2(color,d,x+d.x,y+d.y,m);
		if(r>0){
			if(R<0)R=0;
			R+=r;
		}
	}
	return R;
}

int fill2(int color,dir&d,int x,int y,vector<string>&m){
	if(x<0||W<=x||y<0||H<=y||m[y][x]=='.')return -1;
	if(m[y][x]==color)return 0;
	int r=fill2(color,d,x+d.x,y+d.y,m);
	if(r<0)return r;
	m[y][x]=color;
	return r+1;
}
void fill1(int color,int x,int y,vector<string>&m){
	for(auto &d:D){
		fill2(color,d,x+d.x,y+d.y,m);
	}
}

int main(){
	string color="ox";
	vector<string>m(H);
	for(int h=0;h<H;h++)cin>>m[h];
	int turn=0,pass=0;
	for(;;){
		vector<tiii>v;
		for(int y=0;y<H;y++)for(int x=0;x<W;x++)if(m[y][x]=='.'){
			int r=check1(color[turn],x,y,m);
			if(r>0)v.push_back(make_tuple(r,x,y));
		}
		if(v.empty()){
			pass++;
			if(pass>1)break;
		}else{
			pass=0;
			sort(v.begin(),v.end(),sorter[turn]);
			tiii &t=*v.rbegin();
			fill1(color[turn],get<1>(t),get<2>(t),m);
			m[get<2>(t)][get<1>(t)]=color[turn];
		}
		turn^=1;
	}
	for(int h=0;h<H;h++)cout<<m[h]<<endl;
	return 0;
}

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

#include <cmath>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
const int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
char c[8][9];
int place(int x, int y, char t, bool m) {
	int ret = 0;
	for (int i = 0; i < 8; i++) {
		int px = x + dx[i], py = y + dy[i];
		bool flag = false;
		while (0 <= px && px < 8 && 0 <= py && py < 8) {
			if (c[py][px] == '.') break;
			if (c[py][px] == t) {
				flag = true; break;
			}
			px += dx[i];
			py += dy[i];
		}
		if (flag) {
			ret += max(abs(x - px) - 1, abs(y - py) - 1);
			if (m) {
				int qx = x, qy = y;
				while (qx != px || qy != py) {
					c[qy][qx] = t;
					qx += dx[i];
					qy += dy[i];
				}
			}
		}
	}
	return ret;
}
int main() {
	for (int i = 0; i < 8; i++) scanf("%s", &c[i]);
	int t = 0, v = 0;
	while (true) {
		int x = -1, y = -1, r = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (c[i][j] == '.') {
					int p = place(j, i, t % 2 == 0 ? 'o' : 'x', false);
					if (p >= r && p >= 1 && t % 2 == 1) { x = j; y = i; r = p; }
					else if (p > r && p >= 1) { x = j; y = i; r = p;
				}
			}
		}
		if (r == 0) {
			if (v == 0) { v = 1; t++; continue; }
			break;
		}
		else { place(x, y, t++ % 2 == 0 ? 'o' : 'x', true); v = 0; }
	}
	for (int i = 0; i < 8; i++) printf("%s\n", c[i]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:2: error: expected '}' at end of input
   58 | }
      |  ^
a.cc:36:12: note: to match this '{'
   36 | int main() {
      |            ^
Language: C++

#include <iostream> 
using namespace std;
int board[10][10];
int dx[] = {0,1,0,-1,1,-1,1,-1};
int dy[] = {1,0,-1,0,1,-1,-1,1};

int rev(int c,int x,int y,int d ,int depth,int flag){
	if(depth == 0 && board[y][x] != -1 && flag == 0) return 0;
	//cout << x << " " << y << " " << board[y][x] << endl;
	if(depth != 0 && board[y][x] == -1) return 0;
	if(depth == 1 && board[y][x] == c) return 0;
	if(depth >= 2 && c == board[y][x]){ return depth-1; }
	int r = rev(c,x+dx[d],y+dy[d],d,depth+1,flag);
	if(r){
		if(flag) board[y][x] = c;
		
		return r;
	}
	return 0;
	
}

int ableCnt(int c,int x,int y,bool flag){
	int cnt = 0;
	rep(i,8){
		cnt += rev(c,x,y,i,0,flag);
	}
	return cnt;
}


int main(){
	int turn = 0;
	rep(i,10)rep(j,10)board[i][j] = -1;
	for(int i = 1 ; i <= 8 ; i++)
	for(int j = 1 ; j <= 8 ; j++){char c; cin >> c; board[i][j] = c == '.' ? -1 : c == 'o' ? 0 : 1;}
	bool prev_passed = 0;

	while(1){
		int mx = -1 , px = -1, py = -1;
		if(turn == 0){
			rep(i,8)rep(j,8){
				 int get = ableCnt(turn,j+1,i+1,0);
				 if( mx < get){
					mx = get;
					px = j+1;
					py = i+1;
				 }
			}
		}else{
			for(int i = 7 ; i >= 0 ; i--){
				for(int j = 7 ; j >= 0 ; j--){
				 int get = ableCnt(turn,j+1,i+1,0);
				 if( mx < get){
					mx = get;
					px = j+1;
					py = i+1;
				 }
				}
			}
		}
		
		if(mx == 0){
			if(prev_passed)break;
			else prev_passed = true;
		}else{
			ableCnt(turn,px,py,1);
			prev_passed = false;
		}
		turn ^= 1;
	}
	rep(i,8){ rep(j,8) cout << (board[i+1][j+1]==-1?'.':board[i+1][j+1]==0?'o':'x');cout << endl;}
}

Compiler output:
a.cc: In function 'int ableCnt(int, int, int, bool)':
a.cc:25:13: error: 'i' was not declared in this scope
   25 |         rep(i,8){
      |             ^
a.cc:25:9: error: 'rep' was not declared in this scope; did you mean 'rev'?
   25 |         rep(i,8){
      |         ^~~
      |         rev
a.cc: In function 'int main()':
a.cc:34:13: error: 'i' was not declared in this scope
   34 |         rep(i,10)rep(j,10)board[i][j] = -1;
      |             ^
a.cc:34:9: error: 'rep' was not declared in this scope; did you mean 'rev'?
   34 |         rep(i,10)rep(j,10)board[i][j] = -1;
      |         ^~~
      |         rev
Language: C++

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

vector< vector<char> >V(8,vector<char>(8));
int dx[8]={-1,1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};

bool update;
int idx,idy,count;
bool can[8];

bool in(int x,int y){
	return x>=0 && y>=0 && x<8 && y<8;
}

void check(int k){
	char me,you;
	bool tcan[8];
	count=0;
	memset(can,false,sizeof(can));
	if(k==0){me='o';you='x';}
	else{me='x';you='o';}
	if(k==0){
	for(int y=0;y<8;y++){
		int tcount,ttcount;
		for(int x=0;x<8;x++){
			tcount=0;
			memset(tcan,false,sizeof(tcan));
			if(V[y][x]!='.')
				continue;
			for(int d=0;d<8;d++){
				int nx=x+dx[d],ny=y+dy[d];
				ttcount=0;
				while(in(nx,ny)&&V[ny][nx]==you){
					nx+=dx[d];ny+=dy[d];ttcount++;
				}
				if(in(nx,ny) && V[ny][nx]==me &&ttcount>0){
					tcount+=ttcount;
					update=true;
					tcan[d]=true;
				}
			}
			if(tcount>count){
				idx=x;idy=y;count=tcount;update=true;
				for(int i=0;i<8;i++) can[i]=tcan[i];
			}
		}
	}
	}
	else{
	for(int y=7;y>=0;y--){
		int tcount,ttcount;
		for(int x=7;x>=0;x--){
			tcount=0;
			memset(tcan,false,sizeof(tcan));
			if(V[y][x]!='.')
				continue;
			for(int d=0;d<8;d++){
				int nx=x+dx[d],ny=y+dy[d];
				ttcount=0;
				while(in(nx,ny)&&V[ny][nx]==you){
					nx+=dx[d];ny+=dy[d];ttcount++;
				}
				if(in(nx,ny) && V[ny][nx]==me &&ttcount>0){
					tcount+=ttcount;
					update=true;
					tcan[d]=true;
				}
			}
			if(tcount>count){
				idx=x;idy=y;count=tcount;update=true;
				for(int i=0;i<8;i++) can[i]=tcan[i];
			}
		}
	}
	}
}

void put(int k){
	char me,you;
	if(count==0)
		return;
	if(k==0){me='o';you='x';}
	else{me='x';you='o';}
	V[idy][idx]=me;
	for(int d=0;d<8;d++){
		if(can[d]){
			int nx=idx+dx[d],ny=idy+dy[d];
			while(in(nx,ny) && V[ny][nx]==you){
				V[ny][nx]=me;nx+=dx[d];ny+=dy[d];
			}
		}
	}
}

void print(){
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++)
			cout<<V[y][x];
		cout<<endl;
	}
}


int main()
{
	for(int y=0;y<8;y++)
		for(int x=0;x<8;x++)
			cin>>V[y][x];

	update=true;
	while(update){
		update=false;
		check(0);
		put(0);
		check(1);
		put(1);
	}
	print();
	return 0;
}

Compiler output:
a.cc: In function 'void check(int)':
a.cc:22:9: error: 'memset' was not declared in this scope
   22 |         memset(can,false,sizeof(can));
      |         ^~~~~~
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 | #include<string>
Language: C++

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

typedef long long ll;
typedef vector<int> vint;
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define mins(x,y) x=min(x,y)

ll dp[2010][2010];
ll s[100010];
int L;

ll sum(int a,int b){
	return (s[b]-(a?:s[a-1]:0))/L;
}

int main(){
	int n,m;
	cin>>n>>m>>L;
	vint v(n);
	rep(i,n) cin>>v[i],v[i]--;
	sort(ALL(v));
	vint w(m);
	rep(i,m) cin>>w[i];
	rep(i,m){
		if(!i){
			s[i]=w[i];
		}
		else{
			s[i]=s[i-1]+w[i];
		}
	}
	rep(i,2010) rep(j,2010) dp[i][j]=INFL;
	dp[0][0] = 0;
	dp[1][0] = sum(v[0],v[1]);
	rep(i,n-1){
		rep(j,i){
			mins(dp[i+1][j],dp[i][j]+sum(v[i],v[i+1]));
			mins(dp[i+1][i],dp[i][j]+sum(v[j],v[i+1]));
		}
	}
	ll ans = INFL;
	rep(i,n){
		mins(ans,dp[n-1][i]+sum(v[i],v[n-1]));
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'll sum(int, int)':
a.cc:17:32: error: expected ')' before ':' token
   17 |         return (s[b]-(a?:s[a-1]:0))/L;
      |                      ~         ^
      |                                )
a.cc:17:38: error: expected ')' before ';' token
   17 |         return (s[b]-(a?:s[a-1]:0))/L;
      |                ~                     ^
      |                                      )
Language: C++

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

using namespace std;

using ll = long long;
constexpr int MAX = 2525;

int N, M, L;
ll memo[MAX][MAX];
vector<ll> K, sum;

ll calc(int l, int r)
{
    return (sum[K[r] + 1] - sum[K[l]]) / L;
}

ll solve(int l, int r)
{    
    ll& res = memo[l][r];
    if (res != -1) return res;

    int n = max(l, r) + 1;
    if (n == N - 1) {
        return calc(l, n) + calc(r, n);
    }
    res = min(solve(n, r) + calc(l, n),
              solve(l, n) + calc(r, n));    
    return res;
}

int main()
{    
    cin >> N >> M >> L;
    K.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> K[i]; K[i]--;
    }
    sort(K.begin(), K.end());
    
    vector<int> S(M);
    for (int i = 0; i < M; i++) {
        cin >> S[i];
    }
    
    sum.resize(M + 1);
    for (int i = 0; i < M; i++) {
        sum[i + 1] = sum[i] + S[i];
    }
    
    memset(memo, -1, sizeof(memo));
    cout << solve(0, 0) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:5: error: 'memset' was not declared in this scope
   52 |     memset(memo, -1, sizeof(memo));
      |     ^~~~~~
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>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int N,M,L;
  vector<int>K,S;
  long long int ans=LLONG_MAX;
  cin>>N>>M>>L;
  K.resize(N);
  S.resize(M);
  for(int i=0;i<N;i++)cin>>K[i];
  for(int i=0;i<M;i++)cin>>S[i];
  sort(K.begin(),K.end());
  do{
    long long int sum=0;
    for(int i=0;i<N;i++){
      long long int tmp=0;
      int a=K[i],b=K[(i+1)%N];
      if(a>b)swap(a,b);
      for(int j=a;j<=b;j++){tmp+=S[j-1];}
      tmp/=L;
      sum+=tmp;
    }
    ans=ans<sum?ans:sum;
  }while(next_permutation(K.begin(),K.end()));
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:21: error: 'LLONG_MAX' was not declared in this scope
    9 |   long long int ans=LLONG_MAX;
      |                     ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<algorithm>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

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

using namespace std;

typedef long long ll;

int N,M,L;
int K[2001];
int S[100001];
pair<int,int> Onpu[2001];

ll dp[2001][2001];
ll sums[100001];

ll dfs(int a,int b){
    if(a==N-1||b==N-1){
        if(a<b)swap(a,b);
        return (sums[K[a]+1]-sums[K[b]])/L;
    }
    else if(dp[a][b]!=-1)return dp[a][b];
    int nxtIdx=max(a,b)+1;
    ll tmp=(sums[K[nxtIdx]+1]-sums[K[a]])/L;
    ll res=dfs(nxtIdx,b)+tmp;
    res=min(res,dfs(a,nxtIdx)+(sums[K[nxtIdx]+1]-sums[K[b]])/L);
    return dp[a][b]=res;
}
int main(){

    while(cin>>N>>M>>L&&(N|M|L)){
        for(int i=0;i<N;i++){
            cin>>K[i];
            K[i]--;
        }
        for(int i=0;i<M;i++){
            cin>>S[i];
            sums[i+1]=sums[i]+S[i];
        }
        for(int i=0;i<N;i++){
            Onpu[i].first=S[K[i]];
            Onpu[i].second=K[i];
        }
        sort(Onpu,Onpu+N);
        for(int i=0;i<N;i++)K[i]=Onpu[i].second;
        memset(dp,-1,sizeof(dp));
        ll res=dfs(0,0);
        cout<<res<<endl;
    }

    return 0;
}

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

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int N, M, L;
ll K[2048];
ll Sum[100001];
ll memo[2048][2048];

ll pls(int r, int l)
{
	return ((SSum[r] - SSum[l]) / (ll)L);
}

ll saveSayaka(int l, int r)
{
	int next = max(l, r) + 1;
	
	if (memo[l][r] >= 0){
		return (memo[l][r]);
	}
	
	if (next == N - 1){
		return (pls(K[next], K[l] - 1) + pls(K[next], K[r] - 1));
	}
	
	ll left = saveSayaka(next, r) + pls(K[next], K[l] - 1);
	ll right = saveSayaka(l, next) + pls(K[next], K[r] - 1);
	
	return (memo[l][r] = min(left, right));
}

int main(void)
{
	scanf("%d %d %d", &N, &M, &L);
	
	for (int i = 0; i < N; i++){
		scanf("%d", &K[i]);
	}
	
	for (int i = 0; i < M; i++){
		int s;
		scanf("%d", &s);
		SSum[i + 1] = SSum[i] + s;
	}
	
	sort(K, K + N);
	memset(memo, -1, sizeof(memo));
	
	printf("%lld\n", saveSayaka(0, 0));
}

Compiler output:
a.cc: In function 'll pls(int, int)':
a.cc:16:18: error: 'SSum' was not declared in this scope; did you mean 'Sum'?
   16 |         return ((SSum[r] - SSum[l]) / (ll)L);
      |                  ^~~~
      |                  Sum
a.cc: In function 'int main()':
a.cc:48:17: error: 'SSum' was not declared in this scope; did you mean 'Sum'?
   48 |                 SSum[i + 1] = SSum[i] + s;
      |                 ^~~~
      |                 Sum
Language: C++

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct State{
  int low, high;
  ll cost;
  State(int low, int high, ll cost) : low(low), high(high), cost(cost) {}
  bool operator < (const State& s) const {
    return cost > s.cost; // reversed!!!
  };
};
ll get_cost(int from, int to, int L, const vector<ll>& accumulation){
  ll sum = accumulation[to] - accumulation[from - 1];
  return sum / L;
}

int main(){
  int N, M, L;
  while(cin >> N >> M >> L && N){
    vector<int> K(N);
    vector<int> S(M);
    REP(i, N) cin >> K[i];
    REP(i, M) cin >> S[i];

    vector<ll> accumulation(M + 1);
    REP(i, M) accumulation[i + 1] = accumulation[i] + S[i];

    sort(K.begin(), K.end());
    priority_queue<State> que;
    static ll dist[2000][2000];
    REP(i, N)REP(j, N) dist[i][j] = LONG_LONG_MAX;
    que.push(State(0, 1, get_cost(K[0], K[1], L, accumulation)));
    dist[0][1] = get_cost(K[0], K[1], L, accumulation);
    while(!que.empty()){
      State s = que.top(); que.pop();
      if(dist[s.low][s.high] < s.cost) continue;
      if(s.high + 1 == N){
        cout << s.cost << endl;
        break;
      }else if(s.high + 1 == N - 1){
        ll cost1 = get_cost(K[s.low], K[s.high + 1], L, accumulation);
        ll cost2 = get_cost(K[s.high], K[s.high + 1], L, accumulation);
        State next(s.high + 1, s.high + 1, s.cost + cost1 + cost2);
        if(dist[next.low][next.high] > next.cost){
          dist[next.low][next.high] = next.cost;
          que.push(next);
        }
      }else{
        State next(s.low, s.high + 1,
            s.cost + get_cost(K[s.high], K[s.high + 1], L, accumulation));
        if(dist[next.low][next.high] > next.cost){
          dist[next.low][next.high] = next.cost;
          que.push(next);
        }
        next = State(s.high, s.high + 1,
            s.cost + get_cost(K[s.low], K[s.high + 1], L, accumulation));
        if(dist[next.low][next.high] > next.cost){
          dist[next.low][next.high] = next.cost;
          que.push(next);
        }
      }
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:37: error: 'LONG_LONG_MAX' was not declared in this scope
   58 |     REP(i, N)REP(j, N) dist[i][j] = LONG_LONG_MAX;
      |                                     ^~~~~~~~~~~~~
Language: C++

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

using namespace std;

int N,M,L,K[2001],sum[100001],dp[2001][2001];

int func(int l,int r){

  if(dp[l][r]>-1)return dp[l][r];

  int n=max(l,r)+1;
  if(n==N)return (sum[K[n]]-sum[K[l]-1])/L+(sum[K[n]]-sum[K[r]-1])/L;

  int lf=func(n,r)+(sum[K[n]]-sum[K[l]-1])/L;
  int rt=func(l,n)+(sum[K[n]]-sum[K[r]-1])/L;

  return dp[l][r]=min(lf,rt);
}

int main(void){

  cin >> N >> M >> L;

  for(int i=1;i<=N;i++)cin >> K[i];
  
  sort(K+1,K+N+1);

  for(int i=1;i<=M;i++){
    cin >> sum[i];
    sum[i]+=sum[i-1];
  }

  memset(dp,-1,sizeof(dp));

  cout << func(1,1) << endl;

  return 0;
}

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

#include<iostream>
using namespace std;
#define MAX_V 500
#define INF 1e9
#define f(i,n) for(int i=0;i<n;i++)
#define memu memset(used,0,sizeof(used))
int G[MAX_V][MAX_V],V,E,Q,F,T,m,a,b;
bool used[MAX_V];
void add_edge(int from,int to){
    G[from][to]=1;
    G[to][from]=1;
}
void erase_edge(int from,int to){
    G[from][to]=0;
    G[to][from]=0;
}
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    f(i,V){
        int &c = G[v][i];
        if(!used[i]&&c>0){
            int d=dfs(i,t,min(f,c));
            if(d>0){
                c-=d;
                G[i][v]+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        memu;
        int f=dfs(s,t,INF);
        if(f==0)return flow;
        flow += f;
    }
}
int main(){
    cin>>V>>E>>Q;
    f(i,E){
        cin>>F>>T;
        add_edge(F-1,T-1);
    }
    int now=max_flow(0,V-1);
    f(i,Q){
        cin>>m>>a>>b;
        a--,b--;
        if(m==1){
            add_edge(a, b);
        } else {
            int c=G[a][b];
            erase_edge(a, b);
            if(c>1){
                swap(a,b);
            }
            if(c!=1){
                memu;
                int f=dfs(a,b,1);
                if(f==0){
                    memu;
                    dfs(a, 0, 1);
                    memu;
                    dfs(b,V-1,1);
                    now--;
                }
            }
        }
        cout<<now<<endl;
    }
}

Compiler output:
a.cc: In function 'int max_flow(int, int)':
a.cc:6:14: error: 'memset' was not declared in this scope
    6 | #define memu memset(used,0,sizeof(used))
      |              ^~~~~~
a.cc:36:9: note: in expansion of macro 'memu'
   36 |         memu;
      |         ^~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc: In function 'int main()':
a.cc:6:14: error: 'memset' was not declared in this scope
    6 | #define memu memset(used,0,sizeof(used))
      |              ^~~~~~
a.cc:61:17: note: in expansion of macro 'memu'
   61 |                 memu;
      |                 ^~~~
a.cc:6:14: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #define memu memset(used,0,sizeof(used))
      |              ^~~~~~
a.cc:61:17: note: in expansion of macro 'memu'
   61 |                 memu;
      |                 ^~~~
Language: C++

#include<stdio.h>
#include<string.h>
using namespace std;
#define MAX_V 500
#define INF 1e9
#define f(i,n) for(int i=0;i<n;i++)
#define memu memset(used,0,sizeof(used))
int G[MAX_V][MAX_V],V,E,Q,F,T,m,a,b;
bool used[MAX_V];
void add_edge(int from,int to){
    G[from][to]=G[to][from]=1;
}
void erase_edge(int from,int to){
    G[from][to]=G[to][from]=0;
}
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    f(i,V){
        if(!used[i]&&G[v][i]>0){
            int d=dfs(i,t,min(f,G[v][i]));
            if(d>0){
                G[v][i]-=d;
                G[i][v]+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        memu;
        int f=dfs(s,t,INF);
        if(f==0)return flow;
        flow += f;
    }
}
int main(){
    scanf("%d%d%d",&V,&E,&Q);
    f(i,E){
        scanf("%d%d",&F,&T);
        add_edge(F-1,T-1);
    }
    int now=max_flow(0,V-1);
    f(i,Q){
        scanf("%d%d%d",&m,&a,&b);
        a--,b--;
        if(m==1){
            add_edge(a, b);
            now+=max_flow(0,V-1);
        } else {
            int c=G[a][b];
            erase_edge(a, b);
            if(c>1){
                swap(a,b);
            }
            if(c!=1){
                memu;
                int f=dfs(a,b,1);
                if(f==0){
                    memu;
                    dfs(a, 0, 1);
                    memu;
                    dfs(V-1,b,1);
                    now--;
                }
            }
        }
        printf("%d\n",now);
    }
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:21:27: error: 'min' was not declared in this scope
   21 |             int d=dfs(i,t,min(f,G[v][i]));
      |                           ^~~
a.cc: In function 'int main()':
a.cc:57:17: error: 'swap' was not declared in this scope
   57 |                 swap(a,b);
      |                 ^~~~
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int n, m, q, a, b, come[1050], used[1050][1050], res;

int dfs(int s, int g, int cp){
	if(s == g)return 1;
	come[s] = 1;
	for(int i = 0;i <= n;i++){
		if(come[i])continue;
		if(used[s][i] <= cp)continue;
		if(dfs(i, g)){
			used[i][s]++;
			used[s][i]--;
			return 1;
		}
	}
	return 0;
}

int flow(int s, int g, int cp = 0){
	fill(come, come + 1000, 0);
	return dfs(s, g, cp);
}

int main(){
	cin >> n >> m >> q;
	while(m--){
		cin >> a >> b;
		used[a][b] = used[b][a] = 1;
	}
	for(int i = 0;i < q;i++){
		cin >> m >> a >> b;
		if(m == 1){
			used[a][b] = used[b][a] = 1;
		}
		else{
			if(used[a][b] == 2){
				res--;
				if(!flow(n, a, 1))return 0;
				if(!flow(b, 1, 1))return 1;
			}
			else if(used[b][a] == 2){
				res--;
				if(!flow(n, b, 1))return 0;
				if(!flow(a, 1, 1))return 0;		
			}		
			used[a][b] = used[b][a] = 0;
		}
		while(flow(1, n))res++;
		cout << res << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:14:23: error: too few arguments to function 'int dfs(int, int, int)'
   14 |                 if(dfs(i, g)){
      |                    ~~~^~~~~~
a.cc:8:5: note: declared here
    8 | int dfs(int s, int g, int cp){
      |     ^~~
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int n, m, q, a, b, come[1050], used[1050][1050], res, ok[1050][1050];

int dfs(int s, int g, int cp){
	if(s == g)return 1;
	come[s] = 1;
	for(int i = 0;i <= n;i++){
		if(come[i])continue;
		if(used[s][i] <= 0)continue;
		if(ok[j][i] < cp)continue;
		if(dfs(i, g, cp)){
			used[i][s]++;
			used[s][i]--;
			return 1;
		}
	}
	return 0;
}

int flow(int s, int g, int cp = 0){
	fill(come, come + 1000, 0);
	return dfs(s, g, cp);
}

void color(){
	for(inti = 0;i <= n;i++)
		for(int j = 0;j <= n;j++)
			ok[i][j] = used[i][j] != used[j][i];
}

int main(){
	cin >> n >> m >> q;
	while(m--){
		cin >> a >> b;
		used[a][b] = used[b][a] = 1;
	}
	for(int i = 0;i < q;i++){
		cin >> m >> a >> b;
		if(m == 1){
			used[a][b] = used[b][a] = 1;
		}
		else{
			if(used[a][b] == 2){
				color();
				res--;
				if(!flow(n, a, 1))return 1;
				if(!flow(b, 1, 1))return 1;
			}
			else if(used[b][a] == 2){
				color();
				res--;
				if(!flow(n, b, 1))return 1;
				if(!flow(a, 1, 1))return 1;		
			}		
			used[a][b] = used[b][a] = 0;
		}
		while(flow(1, n))res++;
		cout << res << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:14:23: error: 'j' was not declared in this scope
   14 |                 if(ok[j][i] < cp)continue;
      |                       ^
a.cc: In function 'void color()':
a.cc:30:13: error: 'inti' was not declared in this scope; did you mean 'int'?
   30 |         for(inti = 0;i <= n;i++)
      |             ^~~~
      |             int
a.cc:30:22: error: 'i' was not declared in this scope
   30 |         for(inti = 0;i <= n;i++)
      |                      ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int n, m, q, a, b, come[1050], used[1050][1050], res, ok[1050][1050];

int dfs(int s, int g, int cp){
	if(s == g)return 1;
	come[s] = 1;
	for(int i = 0;i <= n;i++){
		if(come[i])continue;
		if(used[s][i] <= 0)continue;
		if(ok[j][i] < cp)continue;
		if(dfs(i, g, cp)){
			used[i][s]++;
			used[s][i]--;
			return 1;
		}
	}
	return 0;
}

int flow(int s, int g, int cp = 0){
	fill(come, come + 1000, 0);
	return dfs(s, g, cp);
}

void color(){
	for(int i = 0;i <= n;i++)
		for(int j = 0;j <= n;j++)
			ok[i][j] = used[i][j] != used[j][i];
}

int main(){
	cin >> n >> m >> q;
	while(m--){
		cin >> a >> b;
		used[a][b] = used[b][a] = 1;
	}
	for(int i = 0;i < q;i++){
		cin >> m >> a >> b;
		if(m == 1){
			used[a][b] = used[b][a] = 1;
		}
		else{
			if(used[a][b] == 2){
				color();
				res--;
				if(!flow(n, a, 1))return 1;
				if(!flow(b, 1, 1))return 1;
			}
			else if(used[b][a] == 2){
				color();
				res--;
				if(!flow(n, b, 1))return 1;
				if(!flow(a, 1, 1))return 1;		
			}		
			used[a][b] = used[b][a] = 0;
		}
		while(flow(1, n))res++;
		cout << res << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:14:23: error: 'j' was not declared in this scope
   14 |                 if(ok[j][i] < cp)continue;
      |                       ^
Language: C++

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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
typedef vector<int> state;

enum { EMPTY = -3, WHITE, ROOT };

inline bool not_black(const int x) {
	return x == EMPTY || x == WHITE;
}

inline int find(state &uf, const int x) {
	return uf[x] == ROOT ? x : uf[x] = find(uf, uf[x]);
}

inline bool unite(state &uf, int x, int y) {
	x = find(uf, x);
	y = find(uf, y);
	if(x == y) return false;

	uf[y] = x;
	return true;
}

inline void change_root(state &uf, const int x) {
	if(find(uf, x) != x) return;

	int r = -1;
	for(int i = 0; i < uf.size(); ++i) {
		if(x != i && !not_black(uf[i]) && x == find(uf, i)) r = i;
	}

	assert(r != -1);

	for(int i = 0; i < uf.size(); ++i) {
		if(x == uf[i]) uf[i] = r;
	}
	uf[x] = r;
	uf[r] = ROOT;
}

inline int cardinality(state &uf, int x) {
	int res = 0;
	x = find(uf, x);

	for(int i = 0; i < uf.size(); ++i) {
		if(!not_black(uf[i]) && x == find(uf, i)) ++res;
	}
	return res;
}

inline int number_of_sets(const state &uf) {
	return count(begin(uf), end(uf), ROOT);
}

int solve() {
	int h, w;
	cin >> h >> w;

	vector<string> field(h);
	for(auto &e : field) cin >> e;

	if(w == 1) {
		if(h == 2) {
			if(field.front()[0] == '.' && field.back()[0] == '.') return -1;
			if(field.front()[0] == '.' || field.back()[0] == '.') return 1;
			return 2;
		}

		for(int i = 1; i < h - 1; ++i) {
			if(field[i][0] == '.') return -1;
		}
		int res = h;
		if(field.front()[0] == '.') --res;
		if(field.back()[0] == '.') --res;
		return res;
	}

	if(h == 1) {
		const string &s = field.front();
		if(w == 2) {
			if(s.front() == '.' && s.back() == '.') return -1;
			if(s.front() == '.' || s.back() == '.') return 1;
			return 2;
		}

		for(int i = 1; i < w - 1; ++i) {
			if(s[i] == '.') return -1;
		}
		int res = w;
		if(s.front() == '.') --res;
		if(s.back() == '.') --res;
		return res;
	}

	map<state, int> dp;
	dp[state(w, EMPTY)] = 0;

	for(const auto &row : field) {
		for(int x = 0; x < w; ++x) {
			map<state, int> next_dp;

			if(row[x] != '.') { // black
				for(const auto &e : dp) {
					state s = e.first;
					if(not_black(s[x])) s[x] = ROOT;
					if(x > 0 && !not_black(s[x - 1]) && !unite(s, x - 1, x)) continue;
					chmax(next_dp[s], e.second + 1);
				}
			}

			if(row[x] != '#') { // white
				for(const auto &e : dp) {
					state s = e.first;
					if(s[x] == WHITE) continue;
					if(x > 0 && s[x - 1] == WHITE) continue;
					if(s[x] != EMPTY) {
						if(cardinality(s, x) == 1) continue;
						change_root(s, x);
					}
					s[x] = WHITE;
					chmax(next_dp[s], e.second);
				}
			}

			dp = move(next_dp);
		}
	}

	int res = -1;
	for(const auto &e : dp) {
		if(number_of_sets(e.first) == 1) chmax(res, e.second);
	}
	return res;
}

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

	cout << solve() << endl;

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int number_of_sets(const state&)':
a.cc:57:16: error: 'count' was not declared in this scope
   57 |         return count(begin(uf), end(uf), ROOT);
      |                ^~~~~
Language: C++

#include<bits/stdc++.h>
#include"../matrix.cpp"
using namespace std;
using namespace ProconLib;

int main(){
    int s,n,k;
    cin>>s>>n>>k;
    if(n==1 && s%k!=0){
        cout<<-1<<endl;
        return 0;
    }
    int sz=n*k+1;
    
    vector<vector<double>> dp(k+1,vector<double>(sz));
    dp[0][0]=1;
    for(int i=0;i<k;i++){
        for(int j=0;j<sz;j++){
            for(int k=1;k<=n;k++){
                if(j+k<sz) dp[i+1][j+k]+=dp[i][j]/n;
            }
        }
    }
    
    Matrix<double> B(sz,sz+1);
    {
        B[0][0]=1;
        B[0][sz]=0;
        for(int i=1;i<sz;i++){
            B[i][i]=-1;
            for(int j=0;j<sz;j++){
                // i to j
                int d=i-j;
                if(0<=d && d<sz){
                    B[i][j]+=dp[k][d];
                    B[i][sz]-=dp[k][d];
                }
                d=i+j;
                if(j!=0 && 0<=d && d<sz){
                    B[i][j]+=dp[k][d];
                    B[i][sz]-=dp[k][d];
                }
            }
        }
    }
    B=gaussianElimination(B);
    Vector<double> vec(sz+1);
    for(int i=sz-1;i>=0;i--){
        for(int j=0;j<i;j++){
            B[j][sz]-=B[j][i]/B[i][i]*B[i][sz];
            B[j][i]=0;
        }
    }
    for(int i=0;i<sz;i++){
        vec[sz-i-1]=B[i][sz]/B[i][i];
    }
    vec[sz]=1;

    Matrix<double> A(sz+1,sz+1);
    for(int i=1;i<sz;i++){
        A[i][i-1]=1;
    }
    A[sz][sz]=1;
    for(int i=0;i<sz;i++){
        int d=i+1;
        if(d<sz) A[0][i]=dp[k][d];
        if(d<sz) A[0][sz]+=dp[k][d];
    }
    A=pow(A,abs(s));
    double res=0;
    for(int i=0;i<=sz;i++){
        res+=A[sz-1][i]*vec[i];
    }
    cout<<fixed<<setprecision(10);
    cout<<res<<endl;

    return 0;
}


Compiler output:
a.cc:2:9: fatal error: ../matrix.cpp: No such file or directory
    2 | #include"../matrix.cpp"
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 500000
long long s[MAX_N][2], t[MAX_N];
long long n, m, sum;
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i][0] >> s[i][1];
	}
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		sort(s[i], s[i] + 2);
	}
	sort(t, t + m);
	for (int i = 0; i < n; i++) {
		if (t[0] > s[i][1] || t[m - 1] < s[i][0]) { sum += s[i][1] - s[i][0]; goto E; }
		long long a = lower_bound(t, t + m, s[i][0]) - t;
		long long b = upper_bound(t, t + m, s[i][1]) - t;
		sum += t[a] - s[i][0];
		sum += s[i][1] - t[b - 1];
	E:;
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: jump to label 'E'
   25 |         E:;
      |         ^
a.cc:20:92: note:   from here
   20 |                 if (t[0] > s[i][1] || t[m - 1] < s[i][0]) { sum += s[i][1] - s[i][0]; goto E; }
      |                                                                                            ^
a.cc:22:27: note:   crosses initialization of 'long long int b'
   22 |                 long long b = upper_bound(t, t + m, s[i][1]) - t;
      |                           ^
a.cc:21:27: note:   crosses initialization of 'long long int a'
   21 |                 long long a = lower_bound(t, t + m, s[i][0]) - t;
      |                           ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 500000
long long s[MAX_N][2], t[MAX_N];
long long n, m, sum, a, b;
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i][0] >> s[i][1];
	}
	for (int i = 1; i <= m; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		sort(s[i], s[i] + 2);
	}
	t[0] = 0LL; t[m + 1] = 1200000000LL;
	sort(t, t + m + 2);
	for (int i = 0; i < n; i++) {
		a = lower_bound(t, t + m + 2, s[i][0]) - t;
		b = upper_bound(t, t + m + 2, s[i][1]) - t;
		if (a > b - 1) { goto E; }
		sum += t[a] - s[i][0];
		sum += s[i][1] - t[b - 1];
	E:;
	E:;
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: duplicate label 'E'
   27 |         E:;
      |         ^
Language: C++

#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct event{
    int x;
    int type; //0:cut +:テ・ツァツ凝ァツつケ -:テァツオツづァツつケ
    event(int type, int x){
        this->type=type; this->x=x;
    }
    bool operator<(const event&b) const{
        return x!=b.x?x<b.x:type<b.type;
    }
    bool operator>(const event&b) const{
        return x!=b.x?x>b.x:type>b.type;
    }
};

struct section{
    int s, t;
    bool on;
};

int main(){
    int N,M;
    cin>>N>>M;
    vector<event> E1,E2;
    section S[N+1];
    for(int i=1;i<=N;i++){
        cin>>S[i].s>>S[i].t;
        if(S[i].s<S[i].t){
            E1.push_back(event(i,S[i].s));
            E1.push_back(event(-i,S[i].t));
        }else{
            E2.push_back(event(i,S[i].s));
            E2.push_back(event(-i,S[i].t));
        }
    }
    for(int i=0;i<M;i++){
        int x;
        cin>>x;
        E1.push_back(event(0,x));
        E2.push_back(event(0,x));
    }
    sort(E1.begin(),E1.end());
    sort(E2.begin(),E2.end(),greater<event>());
    int sum=0;
    set<int> I;
    for(auto& i:S)i.on=true;
    for(auto& e:E1){
        if(e.type>0){
            I.insert(e.type);
        }else if(e.type<0){
            if(S[-e.type].on)sum+=S[-e.type].t-S[-e.type].s;
            I.erase(-e.type);
        }else{
            for(auto& i:I){
                if(S[i].on){
                    S[i].on=false;
                    sum+=e.x-S[i].s;
                    S[i].s=e.x;
                }else{
                    S[i].on=true;
                    S[i].s=e.x;
                }
            }
        }
    }
    for(auto& i:I){
        if(S[i].on)sum+=S[i].t-S[i].s;
    }
    I.clear();

    for(auto& e:E2){
        if(e.type>0){
            I.insert(e.type);
        }else if(e.type<0){
            if(S[-e.type].on)sum+=-S[-e.type].t+S[-e.type].s;
            I.erase(-e.type);
        }else{
            for(auto& i:I){
                if(S[i].on){
                    S[i].on=false;
                    sum+=-e.x+S[i].s;
                    S[i].s=e.x;
                }else{
                    S[i].on=true;
                    S[i].s=e.x;
                }
            }
        }
    }
    for(auto& i:I){
        if(S[i].on)sum+=-S[i].t+S[i].s;
    }
    I.clear();
    cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   47 |     sort(E1.begin(),E1.end());
      |     ^~~~
      |     short
Language: C

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

using namespace std;

int dp[301];
int to[1001];
vector<int> from[1001];

const int INF=1000000000;
int main(){
  int n,e,t;
  while(cin>>n>>e>>t&&(n|e|t)){
    for(int i=0;i<1001;i++)from[i].clear();
    for(int i=1;i<=n;i++){
      cin>>dp[i];
      if(dp[i]==0)dp[i]=INF;
    }
    for(int i=0;i<e;i++){
      int g,c;
      cin>>g>>c;
      to[i]=g;
      for(int j=0;j<c;j++){
	int s;
	cin>>s;
	from[i].push_back(s);
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<e;j++){
	int d[11];
	// cost of moving before
	for(int k=0;k<from[j].size();k++)
	  d[k]=dp[from[j][k]];
	// sort with ordering acending
	sort(d,d+(int)from[j].size(),greater<int>());
	int maxc=0;
	for(int k=0;k<from[j].size();k++)
	  maxc=max(maxc,k+d[k]);
	dp[to[j]]=min(dp[to[j]],maxc);	
      }
    }
    if(dp[t]==INF)cout<<-1<<endl;
    else cout<<dp[t]<<endl;
  }

  return 0;
}

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

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m,t;
  cin>>n>>m>>t;
  t--;
  vector<Int> w(n);
  for(Int i=0;i<n;i++) cin>>w[i];

  vector<Int> g(m);
  vector<vector<Int> > R;
  for(Int i=0;i<m;i++){
    Int c;
    cin>>g[i]>>c;
    g[i]--;
    R.emplace_back(vector<Int>(c));
    for(Int j=0;j<c;j++)
      cin>>R.back()[j],R.back()[j]--;
  }
  const Int INF = 1e9;
  vector<Int> dp(n,INF);
  for(Int i=0;i<n;i++) if(w[i]) dp[i]=1;

  auto comp=[&](Int i,Int j){return dp[i]>dp[j];};
  while(1){
    Int flg=0;
    for(Int i=0;i<m;i++){
      Int ok=1;
      for(auto x:R[i]) ok&=dp[x]<INF;
      if(!ok) continue;
      Int tmp=0;
      sort(R[i].begin(),R[i].end(),comp);
      for(Int j=0;j<(Int)R[i].size();j++)
	chmax(tmp,j+dp[R[i][j]]);g
      
      if(tmp<dp[g[i]]){
	dp[g[i]]=tmp;
	flg=1;
      }
    }
    if(!flg) break;
  }
  
  if(dp[t]>=INF) dp[t]=-1;
  cout<<dp[t]<<endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:40:35: error: expected ';' before 'if'
   40 |         chmax(tmp,j+dp[R[i][j]]);g
      |                                   ^
      |                                   ;
   41 | 
   42 |       if(tmp<dp[g[i]]){
      |       ~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N, E, T;
  cin >> N >> E >> T;
  vector<int> W(N);
  for(int i = 0; i < N; ++i) cin >> W[i];
  vector<int> G(E), C(E);
  vector<vector<int>> S(E);
  for(int i = 0; i < E; ++i){
    cin >> G[i] >> C[i];
    for(int j = 0; j < C[i]; ++j){
      int s;
      cin >> s;
      S[i].push_back(s);
    }
  }

  for(int i = 0; i < N; ++i)
    if(not W[i])
      W[i] = 1e9;
  
  vector<bool> checked(E,false);
  int c = 0;
  for(int i = 0; i < E; ++i){
    for(int j = 0; j < E; ++j){
      if(checked[j]) continue;
      bool f = true;
      for(int k = 0; k < C[j]; ++k)
        if(W[S[j][k]] >= INF){
          f = false;
          break;
        }
      if(not f) continue;
      vector<int> T;
      for(int k = 0; k < C[j]; ++k){
        T.push_back(W[S[j][k]]);
      }
      sort(T.begin(),T.end());
    }
  }
}
#error "G"


Compiler output:
a.cc:45:2: error: #error "G"
   45 | #error "G"
      |  ^~~~~
a.cc: In function 'int main()':
a.cc:32:26: error: 'INF' was not declared in this scope
   32 |         if(W[S[j][k]] >= INF){
      |                          ^~~
Language: C++

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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

constexpr int MAX_N = 300;
constexpr int INF = (1 << 29);

int N, E, T;
bool w[MAX_N];

vector<vector<int>> G[MAX_N];

int memo[MAX_N];

int dfs(int v) {
	int &res = memo[v];
	if(res != -1) return res;

	if(w[v]) {
		res = 1;
	}
	else {
		res = INF;

		for(const auto &nodes : G[v]) {
			vector<int> need;
			need.reserve(nodes.size());

			for(const auto &c : nodes) {
				need.emplace_back(dfs(c));
			}

			sort(need.rbegin(), need.rend());

			int tmp = 0;
			for(int i = 0; i < static_cast<int>(nodes.size()); ++i) {
				chmax(tmp, need[i] + i);
			}

			chmin(res, tmp);
		}

	}

	return res;
}

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

	cin >> N >> E >> T;

	for(int i = 0; i < N; ++i) {
		cin >> w[i];
	}

	for(int i = 0; i < E; ++i) {
		int g, c;
		cin >> g >> c;

		vector<int> material(c);
		for(auto &e : material) {
			cin >> e;
			--e;
		}

		G[g - 1].emplace_back(move(material));
	}

	memset(memo, -1, sizeof(memo));
	const int ans = dfs(T - 1);
	cout << (ans == INF ? -1 : ans) << endl;

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:37:25: error: 'sort' was not declared in this scope; did you mean 'short'?
   37 |                         sort(need.rbegin(), need.rend());
      |                         ^~~~
      |                         short
a.cc: In function 'int main()':
a.cc:75:9: error: 'memset' was not declared in this scope
   75 |         memset(memo, -1, sizeof(memo));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 | using namespace std;