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

#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
#define INF (1 << 25)
using namespace std;

int main(){
  int n, m, tmp;
  while(1){
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0)return 0;
    int dp[3][10][100];
    memset(dp, 0, sizeof(dp));
    vector< pair<int, int> >stones[n];
    for(int i = 0;i < n;i++){
      int k, l, m;
      scanf("%d", &k);
      for(int j = 0;j < k;j++){
	scanf("%d %d", &l, &m);
	stones[i].push_back(make_pair(l, m));
      }
    }
    for(int i = 0;i < n;i++){
      int ind = i%3, prev = (i - 1) % 3, prepre = (i - 2) % 3;

      for(int j = 0;j < stones[i].size();j++)
	for(int k = 0;k <= m;k++)
	  dp[ind][j][k] = INF;

      for(int j = 0;j < stones[i].size();j++){
	if(i == 0)dp[ind][j][m] = 0;
	else if(i == 1 && m - 1 >= 0)dp[ind][j][m - 1] = 0;
      }
      for(int j = 0;j < stones[i].size();j++){
	for(int k = 0;k <= m;k++){
	  for(int l = 0;i > 0 && l < stones[i - 1].size();l++){
	    dp[ind][j][k] = min(dp[ind][j][k],
				dp[prev][l][k] + abs(stones[i - 1][l].first - stones[i][j].first) * (stones[i - 1][l].second + stones[i][j].second));
	  }
	  for(int l = 0;i > 1 && k < m && l < stones[i - 2].size();l++){
	    dp[ind][j][k] = min(dp[ind][j][k],
				dp[prepre][l][k + 1] + abs(stones[i - 2][l].first - stones[i][j].first) * (stones[i - 2][l].second + stones[i][j].second));
	  }
	}
      }
    }
    int res = INF;
    for(int i = 0;i < stones[n - 1].size();i++){
      for(int j = 0;j <= m;j++){
	res = min(res, dp[(n - 1) % 3][i][j]);
      }
    }
    if(n - 2 >= 0){
      for(int i = 0;i < stones[n - 2].size();i++){
	for(int j = 1;j <= m;j++){
	  res = min(res,dp[(n - 2) % 3][i][j];
	}
      }
    }
    printf("%d\n", res);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:46: error: expected ')' before ';' token
   58 |           res = min(res,dp[(n - 2) % 3][i][j];
      |                    ~                         ^
      |                                              )
Language: C++

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;

int n,m;
int a,b;
int fie[210][4];	// 行、マス
int dp[210][210][4];// x回目１こ飛ばし、行、マス

void calc(int u)
{
	u *= 2;
	u++;
	for(int i = u-1; i <= n; i++){
		for(int j = 0; j < 4; j++){		// 現在の立ち位置
			for(int k = 0; k < 4; k++){	// 次の場所
				for(int add = 0; add <= 1; add++){
					if(add+((u/2) > m)
						break;
					if(fie[i][j] >= 0 && fie[i+1+add][k] >= 0){
						int nowRisk = (fie[i][j] + fie[i+1+add][k])*abs(j-k)+dp[u/2][i][j];
						if(dp[u/2][i][j] == -1)
							nowRisk += 1;

//						cout << nowRisk << endl ;
						if(dp[u/2+add][i+1+add][k] >= 0)
							dp[u/2+add][i+1+add][k] = min(dp[u/2+add][i+1+add][k], nowRisk);
						else
							dp[u/2+add][i+1+add][k] = nowRisk;
					}
				}
			}
		}
	}
}



void solve()
{
	int ans = (1 << 25);

	for(int i = 1; i <= n; i++){
		cin >> a;
		for(int j = 0; j < a; j++){
			cin >> b;
			b--;
			cin >> fie[i][b];
		}
	}


	for(int i = 0; i <= m; i++){
		calc(i);
		
		for(int j = 0; j < 4; j++){
			if(dp[i][n+1][j] >= 0)
				ans = min(ans,dp[i][n+1][j]);
			if(dp[i][n+2][j] >= 0)
				ans = min(ans,dp[i][n+2][j]);
		}
	}

/*	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 4; j++){
			cout << dp[0][i][j] << ' ';
		}
		cout << endl;
	}
*/
	cout << ans << endl;


	
}

int main(void)
{

	while(cin >> n >> m, n | m){
		fill(fie[1], fie[1]+(200-1)*4, -1);
		fill(dp[0][0], dp[0][0] + 200*200*4, -1);
		for(int i = 0; i < 4; i++)
			fie[n+1][i] = 0;

		solve();
	}
}

Compiler output:
a.cc: In function 'void calc(int)':
a.cc:20:59: error: expected ';' before 'break'
   20 |                                         if(add+((u/2) > m)
      |                                                           ^
      |                                                           ;
   21 |                                                 break;
      |                                                 ~~~~~      
a.cc:22:41: error: expected primary-expression before 'if'
   22 |                                         if(fie[i][j] >= 0 && fie[i+1+add][k] >= 0){
      |                                         ^~
a.cc:21:55: error: expected ')' before 'if'
   21 |                                                 break;
      |                                                       ^
      |                                                       )
   22 |                                         if(fie[i][j] >= 0 && fie[i+1+add][k] >= 0){
      |                                         ~~             
a.cc:20:43: note: to match this '('
   20 |                                         if(add+((u/2) > m)
      |                                           ^
a.cc:33:33: error: expected primary-expression before '}' token
   33 |                                 }
      |                                 ^
Language: C++

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

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

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

	for(int n, m; cin >> n >> m, n;) {
		vector<vector<int> > pos(n), danger(n);
		vector<vector<vector<int> > > dp(n, vector<vector<int> >(m + 1));
		for(int i = 0; i < n; ++i) {
			int num;
			cin >> num;

			for(int j = 0; j < m + 1; ++j)
				dp[i][j].resize(num, INT_MAX);

			for(int j = 0; j < num; ++j) {
				int x, d;
				cin >> x >> d;
				pos[i].push_back(x);
				danger[i].push_back(d);
			}
		}

		for(int i = 0; i < m + 1; ++i)
			for(int j = 0; j < dp[0][i].size(); ++j)
				dp[0][i][j] = 0;

		int ans = INT_MAX;

		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < m + 1; ++j) {
				for(int k = 0; k < dp[i][j].size(); ++k) {
					if(dp[i][j][k] == INT_MAX)
						continue;

					if(j) {
						if(i + 2 >= n)
							chmin(ans, dp[i][j][k]);
						else
							for(int l = 0; l < dp[i + 2][j - 1].size(); ++l)
								chmin(dp[i + 2][j - 1][l], dp[i][j][k] + (danger[i][k] + danger[i + 2][l]) * abs(pos[i][k] - pos[i + 2][l]));
					}

					if(i + 1 >= n)
						chmin(ans, dp[i][j][k]);
					else
						for(int l = 0; l < dp[i + 1][j].size(); ++l)
							chmin(dp[i + 1][j][l], dp[i][j][k] + (danger[i][k] + danger[i + 1][l]) * abs(pos[i][k] - pos[i + 1][l]));
				}
			}
		}

		cout << ans << endl;
	}


	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:54: error: 'INT_MAX' was not declared in this scope
   20 |                                 dp[i][j].resize(num, INT_MAX);
      |                                                      ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | using namespace std;
a.cc:34:27: error: 'INT_MAX' was not declared in this scope
   34 |                 int ans = INT_MAX;
      |                           ^~~~~~~
a.cc:34:27: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define INF (1<<27)
int K[150]; //K[i]::=i行目に何個の石があるか
int X[10][150]; //X[i][j]::=j列目のi個目が何列目か
int D[10][150]; //D[i][j]::=j列目のi個目のすべりやすさ
int DP[10][150][80]; //DP[i][j][k]::=j列目のi個目にいて、あとk回ジャンプできる
int main() {
	int N,M;
	while(scanf("%d %d",&N,&M),N|M) {
		memset(K,0,sizeof(K));
		memset(X,0,sizeof(X));
		memset(D,0,sizeof(D));
		for(int y=0;y<N;y++) {
			scanf("%d",&K[y]);
			for(int x=0;x<K[y];x++) {
				scanf("%d %d",&X[x][y],&D[x][y]);
			}
		}
		fill((int*)DP,(int*)(DP+10),INF);
		for(int x=0;x<K[0];x++) DP[x][0][M]=0;
		for(int x=0;x<K[1];x++) DP[x][1][M-1]=0;
		for(int y=1;y<N;y++) for(int x=0;x<K[y];x++) {
			for(int xx=0;xx<K[y-1];xx++) for(int m=0;m<=M;m++) {
				DP[x][y][m]=min(DP[x][y][m],DP[xx][y-1][m]+(D[x][y]+D[xx][y-1])*abs(X[x][y]-X[xx][y-1]));
			}
			if(y==1) continue;
			for(int xx=0;xx<K[y-2];xx++) for(int m=0;m<=M;m++) {
				DP[x][y][m]=min(DP[x][y][m],DP[xx][y-2][m+1]+(D[x][y]+D[xx][y-2])*abs(X[x][y]-X[xx][y-2]));
			}
		}
		int ans=INF;
		for(int x=0;x<K[N-2];x++) for(int m=1;m<=M;m++) {
			ans=min(ans,DP[x][N-2][m]);
		}
		for(int x=0;x<K[N-1];x++) for(int m=0;m<=M;m++) {
			ans=min(ans,DP[x][N-1][m]);
		}
		printf("%d\n",ans);
	}
}

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

//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
//番号とx座標と滑りやすさ
vector<P1>s[155];
//滑りやすさ、x座標、y座標
P1 d[1505];
int n,m;
//石番号と残り数を状態にもつdijkstra用配列
int di[1505][76];
//beatmania iidx楽しい!!の部分文字列ではなくindexの部分文字列
int idx=0;
int main()
{
	scanf("%d %d",&n,&m);
	
	for(int i=1;i<=n;i++)
	{
		int k;
		scanf("%d",&k);
		for(int j=0;j<k;j++)
		{
			int a,b;
			scanf("%d %d",&a,&b);
			
			s[i].pb(mp(idx,mp(a,b)));
			d[idx++]=mp(b,mp(a,i));
		}
	}
	for(int i=0;i<1505;i++)for(int j=0;j<76;j++) di[i][j]=1e9;
	priority_queue<P1,vector<P1>,greater<P1> >que;
	for(int i=0;i<s[1].size();i++)
	{
		P1 p=s[1][i];
		di[p.first][m]=0;
		que.push(mp(0,mp(p.first,m)));
	}
	for(int i=0;m>0 && i<s[2].size();i++)
	{
		P1 p=s[2][i];
		di[p.first][m-1]=0;
		que.push(mp(0,mp(p.first,m-1)));
	}
	while(!que.empty())
	{
		P1 p=que.top();
		que.pop();
		int idd=p.second.first;
		int slip1=d[idd].first;
		int x=d[idd].second.first;
		int y=d[idd].second.second;
		int zan=p.second.second;
		
		for(int i=0;i<s[y+1].size();i++)
		{
			P1 p=s[y+1][i];
			int slip2=p.second.second;
			int x2=p.second.first;
			if(di[p.first][zan]>p.first+(slip1+slip2)*abs(x-x2))
			{
				di[p.first][zan]=p.first+(slip1+slip2)*abs(x-x2);
				que.push(mp(di[p.first][zan],mp(p.first,zan)));
			}
		}
		
		for(int i=0;zan>0 && <s[y+2].size();i++)
		{
			P1 p=s[y+2][i];
			int slip2=p.second.second;
			int x2=p.second.first;
			if(di[p.first][zan]>p.first+(slip1+slip2)*abs(x-x2))
			{
				di[p.first][zan]=p.first+(slip1+slip2)*abs(x-x2);
				que.push(mp(di[p.first][zan],mp(p.first,zan)));
			}
		}
	}
	
	int ret=INF;
	for(int j=0;j<s[n].size();j++) for(int i=0;i<76;i++) ret=min(ret,di[s[n][j].first][i]);
	for(int j=0;j<s[n-1].size();j++) for(int i=1;i<76;i++) ret=min(ret,di[s[n-1][j].first][i]);
	
	printf("%d\n",ret);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:38: error: expected primary-expression before '<' token
   87 |                 for(int i=0;zan>0 && <s[y+2].size();i++)
      |                                      ^
Language: C++

//滑りやすさ>=0なら大丈夫.3Dにすると、メモリがたくさんいるので、2つのナップザックを使いまわす。
#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;

int N,M;
int pos[151][10];		//石のある場所(x座標)
int list[151][10];		//石の滑りやすさ
int minest[2][151][10];	//危険度ナップザック(探索用)

void ainst(int *a,int index,int num){
	for(int i = 0;i < index;i++){
		a[i] = num;
	}s
}
void acopy(int *a,int *b,int index){
	for(int i = 0;i < index;i++){
		a[i] = b[i];
	}
}
int amin(int *a,int index){
	int min = a[0];
	for(int i = 1;i < index;i++){
		if(min > a[i])
			min = a[i];
	}
	return min;
}
int nap(int n,int mode){	//mode:0のときは一行飛ばし可能、1のときは不可能
	int i,j,l;
	int min = 2000000000;
	for(i = 0;i < n-1;i++){
		for(j = 0;j < 10;j++){
			if(pos[i][j] == -1)
				break;
			if(i+2 >= n && mode == 0){
				if(min > minest[0][i][j])
					min = minest[0][i][j];
			}
			for(l = 0;l < 10;l++){
				switch(mode){
				case 0:
					if(i+2 < n && pos[i+2][l] >= 0){
						if(minest[1][i+2][l] == -1 || minest[1][i+2][l] > minest[0][i][j]+(list[i][j]+list[i+2][l])*abs(pos[i][j]-pos[i+2][l])){
							minest[1][i+2][l] = minest[0][i][j]+(list[i][j]+list[i+2][l])*abs(pos[i][j]-pos[i+2][l]);
						}
					}
				case 1:
					if(pos[i+1][l] >= 0){
						if(minest[0][i+1][l] == -1 || minest[0][i+1][l] > minest[0][i][j]+(list[i][j]+list[i+1][l])*abs(pos[i][j]-pos[i+1][l])){
							minest[0][i+1][l] = minest[0][i][j]+(list[i][j]+list[i+1][l])*abs(pos[i][j]-pos[i+1][l]);
						}
					}
					break;
				}
			}
		}
	}
	for(i = 0;i < 10;i++){
		if(minest[0][n-1][i] != -1 && min > minest[0][n-1][i])
			min = minest[0][n-1][i];
	}
	return min;
}
int main(){
	int i,j,k;
	int mcor,now,saisyo[1000];
	int saicor = 0;
	while(1){
		cin >> N >> M;
		if(N == 0 && M == 0)
			break;
		saisyo[saicor] = 2000000000;
		for(i = 0;i < N;i++){
			ainst(pos[i],10,-1);
			ainst(list[i],10,-1);
			ainst(minest[0][i],10,-1);
			ainst(minest[1][i],10,-1);
			cin >> k;
			for(j = 0;j < k;j++){
				cin >> pos[i][j] >> list[i][j];
			}
		}
		ainst(minest[0][0],10,0);
		ainst(minest[1][0],10,0);
		//探索開始
		for(mcor = 0;mcor <= M;mcor++){
			if(mcor < M)
				now = nap(N,0);
			else
				now = nap(N,1);
			if(saisyo[saicor] > now)
				saisyo[saicor] = now;
			for(i = 0;i < N;i++){
				acopy(minest[0][i],minest[1][i],10);
				ainst(minest[1][i],10,-1);
			}
			ainst(minest[0][0],10,0);
			ainst(minest[1][0],10,0);
		}
		saicor++;
	}
	for(i = 0;i < saicor;i++){
		cout << saisyo[i] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void ainst(int*, int, int)':
a.cc:15:10: error: 's' was not declared in this scope
   15 |         }s
      |          ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define rep(i,n) REP(i,0,n)
#define f first
#define s second
#define mpi(l,m,n,o) make_pair(make_pair(l,m),make_pair(n,o))
#define pi pair<pair<int,int>,pair<int,int> >
using namespace std;
int in(){int x; scanf("%d",&x); return x;}
int main(void){
   int n,m;
   while(scanf("%d%d",&n,&m),n+m){
      vector<vector<int> > pos(150);
      vector<vector<int> > cos(150);
      int flag[151][11][76] = {0};

      rep(i,n){
         int x = in();
         rep(j,x){
            pos[i].push_back(in());
            cos[i].push_back(in());
         }
      }

      rep(i,pos[0].size()){
         Q.push(mpi(0,0,i,0));
      }
      rep(i,pos[1].size()){
         if(m != 0){
            Q.push(mpi(0,1,i,1));
         }
      }

      priority_queue<pi,vector<pi >,greater<pi > >Q;//cost,y,x,slip
      int ans = 0;
      while(Q.size()){
         pi p = Q.top(); Q.pop();
         if(p.f.s == n-1){ans = p.f.f; break;}
         if(p.f.s == n-2 && m > p.s.s){ans = p.f.f; break;}

         if(flag[p.f.s][pos[p.f.s][p.s.f]][p.s.s] == 1) continue;
         flag[p.f.s][pos[p.f.s][p.s.f]][p.s.s] = 1;

         rep(i,pos[p.f.s+1].size()){
            Q.push(mpi(p.f.f+(cos[p.f.s][p.s.f]+cos[p.f.s+1][i])*abs(pos[p.f.s][p.s.f]-pos[p.f.s+1][i]),p.f.s+1,i,p.s.s));
         }

         rep(i,pos[p.f.s+2].size()){
            if(p.s.s < m) Q.push(mpi(p.f.f+(cos[p.f.s][p.s.f]+cos[p.f.s+2][i])*abs(pos[p.f.s][p.s.f]-pos[p.f.s+2][i]),p.f.s+2,i,p.s.s+1));
         }
      }
      printf("%d\n",ans);
   }
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:10: error: 'Q' was not declared in this scope
   29 |          Q.push(mpi(0,0,i,0));
      |          ^
a.cc:33:13: error: 'Q' was not declared in this scope
   33 |             Q.push(mpi(0,1,i,1));
      |             ^
Language: C

#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define maxn 1005
#define INF 0x3f3f3f3f3f
#define eps 1e-6
using namespace std;
typedef long long ll;

int w, h, n, ans, tx, ty;
int lx[maxn], ly[maxn], rx[maxn], ry[maxn];
int hx[maxn], hy[maxn];
int fld[maxn * 2][maxn * 2];
int pos[4][2] = { 1,0,0,1,-1,0,0,-1 };
struct node
{
	int x, y;
};

bool judge(int x, int y)
{
	if (x < 0 || y < 0 || x >= w || y >= h)return false;
	if (fld[x][y] > 0)return false;
	return true;
}

void imos()
{
	memset(fld, 0, sizeof(fld));
	for (int i = 1; i <= n; i++)
	{
		fld[lx[i]][ly[i]]++;
		fld[lx[i]][ry[i]]--;
		fld[rx[i]][ly[i]]--;
		fld[rx[i]][ry[i]]++;
	}
	for (int i = 0; i < w; i++)
	{
		for (int j = 1; j < h; j++)
			fld[i][j] += fld[i][j - 1];
	}
	for (int j = 0; j < h; j++)
	{
		for (int i = 1; i < w; i++)
			fld[i][j] += fld[i - 1][j];
	}
}

void bfs(int sx, int sy)
{
	ans++;
	node st, now, nxt;
	queue<node>q;
	st.x = sx, st.y = sy;
	fld[sx][sy] = 1;
	q.push(st);
	while (!q.empty())
	{
		now = q.front();
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			nxt.x = now.x + pos[i][0];
			nxt.y = now.y + pos[i][1];
			if (judge(nxt.x, nxt.y))
			{
				q.push(nxt);
				fld[nxt.x][nxt.y] = 1;
			}
		}
	}
}

int main()
{
	while (scanf("%d%d", &w, &h))
	{
		if (w == 0 && h == 0)break;
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%d%d%d%d", &lx[i], &ly[i], &rx[i], &ry[i]);
		tx = ty = 0;
		for (int i = 1; i <= n; i++)
		{
			hx[++tx] = lx[i], hx[++tx] = rx[i];
			hy[++ty] = ly[i], hy[++ty] = ry[i];
		}
		hx[++tx] = 0, hx[++tx] = w;
		hy[++ty] = 0, hy[++ty] = h;
		sort(hx + 1, hx + tx + 1);
		sort(hy + 1, hy + ty + 1);
		w = unique(hx + 1, hx + tx + 1) - (hx + 1);
		h = unique(hy + 1, hy + ty + 1) - (hy + 1);
		for (int i = 1; i <= n; i++)
		{
			lx[i] = lower_bound(hx + 1, hx + w + 1, lx[i]) - hx - 1;
			rx[i] = lower_bound(hx + 1, hx + w + 1, rx[i]) - hx - 1;
			ly[i] = lower_bound(hy + 1, hy + h + 1, ly[i]) - hy - 1;
			ry[i] = lower_bound(hy + 1, hy + h + 1, ry[i]) - hy - 1;
		}
		w--, h--;
		imos();
		ans = 0;
		for (int i = 0; i < w; i++)
		{
			for (int j = 0; j < h; j++)
			{
				if (fld[i][j] == 0)
					bfs(i, j);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int,int> P;
#define MAX_N 1000
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int W,H,N;
int X1[MAX_N],X2[MAX_N],Y1[MAX_N],Y2[MAX_N];

bool fld[MAX_N*6][MAX_N*6];

int compress(int *x1,int *x2,int w){
  vector<int> xs;
  for(int i=0;i<N;i++){
    for(int d=-1;d<=1;d++){
      int tx1=x1[i]+d,tx2=x2[i]+d;
      if(1<=tx1&&tx1<=w)xs.push_back(tx1);
      if(1<=tx2&&tx2<=w)xs.push_back(tx2);
    }
  }
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  
  for(int i=0;i<N;i++){
    x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
    x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
  }
  
  return xs.size();

}

void solve(){


  W = compress(X1,X2,W);
  H = compress(Y1,Y2,H);
  

  memset(fld,0,sizeof(fld));
  
  for(int i=0;i<N;i++){
    for(int y=Y1[i];y<=Y2[i];y++){
      for(int x=X1[i];x<=X2[i];x++){
	fld[y][x]=true;
      }
    }
  }
  /*
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<fld[i][j];
    }
    cout<<endl;
  }
  */
  int ans=0;
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      if(fld[y][x])continue;
      ans++;
      queue< P > que;
      que.push(P(x,y));
      while(!que.empty()){
	int sx=que.front().first;
	int sy=que.front().second;
	que.pop();
	for(int i=0;i<4;i++){
	  int tx=sx+dx[i],ty=sy+dy[i];
	  if(tx<0||W<=tx)continue;
	  if(ty<0||H<=ty)continue;
	  if(fld[ty][tx])continue;
	  que.push(P(tx,ty));
	  fld[ty][tx]=true;
	}
      }
    }
  }
  cout<<ans<<endl;
}

int main(){
  while(1){
    cin>>W>>H;
    if(W==0&&H==0)break;
    cin>>N;
    for(int i=0;i<N;i++){
      cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
      X1[i]++;
      Y1[i]++;
    }
    solve();
  }
  return 0;
}

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

#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctYpe>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <compleX>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int w,h;
vector<int> Xs;
vector<int> Ys;
int n;
int X1[1000];
int Y1[1000];
int X2[1000];
int Y2[1000];
int table[2002][2002];
void dfs(int i, int j){
	table[i][j]=1;
	int dX=1,dY=0;
	for(int k=0;k<4;k++,swap(dX,dY),dX=-dX){
		int X=i+dX;
		int Y=j+dY;
		if(0<=X&&X<Xs.size()&&0<=Y&&Y<Ys.size()&&table[X][Y]==0){
			dfs(X,Y);
		}
	}
}
int main() {
while(1){
	cin >> w >> h;
	if(w==0&&h==0){
		return 0;
	}
	memset(table,0,sizeof(table));
	Xs.clear();
	Xs.push_back(0);
	Ys.push_back(0);
	Xs.push_back(w-1);
	Ys.push_back(h-1);
	Ys.clear();
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		Xs.push_back(X1[i]);
		Xs.push_back(X2[i]);
		Ys.push_back(Y1[i]);
		Ys.push_back(Y2[i]);
	}
	sort(Xs.begin(),Xs.end());
	Xs.resize(unique(Xs.begin(),Xs.end())-Xs.begin());
	sort(Ys.begin(),Ys.end());
	Ys.resize(unique(Ys.begin(),Ys.end())-Ys.begin());
	for(int i=0;i<n;i++){
		int s=lower_bound(Xs.begin(),Xs.end(),X1[i])-Xs.begin();
		int t=lower_bound(Ys.begin(),Ys.end(),Y1[i])-Ys.begin();
		int u=lower_bound(Xs.begin(),Xs.end(),X2[i])-Xs.begin();
		int v=lower_bound(Ys.begin(),Ys.end(),Y2[i])-Ys.begin();
		table[s][t]++;
		table[s][v]--;
		table[u][t]--;
		table[u][v]++;
	}
	if(Xs.back()>=w)Xs.pop_back();
	if(Ys.back()>=h)Ys.pop_back();
	for(int i=0;i<Xs.size();i++){
		for(int j=1;j<Ys.size();j++){
			table[i][j]+=table[i][j-1];
		}
	}
	for(int i=1;i<Xs.size();i++){
		for(int j=0;j<Ys.size();j++){
			table[i][j]+=table[i-1][j];
		}
	}
	/*
	for(int j=Ys.size()-1;j>=0;j--){
		for(int i=0;i<Xs.size();i++){
			cout << table[i][j];
		}
		cout << endl;
	}*/
	int ret=0;
	for(int i=0;i<Xs.size();i++){
		for(int j=0;j<Ys.size();j++){
			if(table[i][j]==0){
				//cout << i << ", " << j << endl;
				dfs(i,j);
				ret++;
			}
		}
	}
	cout << ret << endl;

}
}

Compiler output:
a.cc:15:10: fatal error: cctYpe: No such file or directory
   15 | #include <cctYpe>
      |          ^~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>

using namespace std;

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

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

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

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

int n;
int w,h;
int x1[1010],x2[1010];
int y1[1010],y2[1010];
bool board[6000][6000];

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

int compress(int* z1,int* z2,int len){
	vi zs;
	rep(i,n)for(int d=-1;d<=1;d++){
		int tz1=z1[i]+d,tz2=z2[i]+d;
		if(0<=tz1&&tz1<=len) zs.pb(tz1);
		if(0<=tz2&&tz2<=len) zs.pb(tz2);
	}
	sort(zs.begin(),zs.end());
	zs.erase(unique(zs.begin(),zs.end()),zs.end());
	rep(i,n){
		z1[i]=find(zs.begin(),zs.end(),z1[i])-zs.begin();
		z2[i]=find(zs.begin(),zs.end(),z2[i])-zs.begin();
	}
	return zs.size();
}

int main(void){
	while(cin >> w >> h){
		if(w==0||h==0)
			break;
		cin >> n;
		rep(i,n) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
		rep(i,n) x2[i]--,y2[i]--;
		w=compress(x1,x2,w-1);
		h=compress(y1,y2,h-1);
		clr(board,0);
		rep(i,n){
			for(int y=y1[i];y<=y2[i];y++)
				for(int x=x1[i];x<=x2[i];x++)
					board[y][x]=true;
		}

		int ans=0;
		rep(y,h)rep(x,w){
			if(board[y][x])
				continue;
			ans++;

			queue<pii> q;
			q.push(mp(x,y));
			while(!q.empty()){
				int sx=q.front().first;
				int sy=q.front().second;
				q.pop();
				rep(i,4){
					int nx=sx+dx[i];
					int ny=sy+dy[i];
					if(nx<0||w<=nx||ny<0||h<=ny) continue;
					if(board[ny][nx]) continue;
					board[ny][nx]=true;
					q.push(mp(nx,ny));
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc:35:20: error: 'acos' was not declared in this scope
   35 | const double pi  = acos(-1.0);
      |                    ^~~~
a.cc:42:5: warning: built-in function 'y1' declared as non-function [-Wbuiltin-declaration-mismatch]
   42 | int y1[1010],y2[1010];
      |     ^~
Language: C++

#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>

using namespace std;

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

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

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

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

int n;
int w,h;
int x1[1010],x2[1010];
int yy1[1010],y2[1010];
bool board[6000][6000];

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

int compress(int* z1,int* z2,int len){
	vi zs;
	rep(i,n)for(int d=-1;d<=1;d++){
		int tz1=z1[i]+d,tz2=z2[i]+d;
		if(0<=tz1&&tz1<=len) zs.pb(tz1);
		if(0<=tz2&&tz2<=len) zs.pb(tz2);
	}
	sort(zs.begin(),zs.end());
	zs.erase(unique(zs.begin(),zs.end()),zs.end());
	rep(i,n){
		z1[i]=find(zs.begin(),zs.end(),z1[i])-zs.begin();
		z2[i]=find(zs.begin(),zs.end(),z2[i])-zs.begin();
	}
	return zs.size();
}

int main(void){
	while(cin >> w >> h){
		if(w==0||h==0)
			break;
		cin >> n;
		rep(i,n) cin >> x1[i] >> yy1[i] >> x2[i] >> y2[i];
		rep(i,n) x2[i]--,y2[i]--;
		w=compress(x1,x2,w-1);
		h=compress(yy1,y2,h-1);
		clr(board,0);
		rep(i,n){
			for(int y=yy1[i];y<=y2[i];y++)
				for(int x=x1[i];x<=x2[i];x++)
					board[y][x]=true;
		}

		int ans=0;
		rep(y,h)rep(x,w){
			if(board[y][x])
				continue;
			ans++;

			queue<pii> q;
			q.push(mp(x,y));
			while(!q.empty()){
				int sx=q.front().first;
				int sy=q.front().second;
				q.pop();
				rep(i,4){
					int nx=sx+dx[i];
					int ny=sy+dy[i];
					if(nx<0||w<=nx||ny<0||h<=ny) continue;
					if(board[ny][nx]) continue;
					board[ny][nx]=true;
					q.push(mp(nx,ny));
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc:35:20: error: 'acos' was not declared in this scope
   35 | const double pi  = acos(-1.0);
      |                    ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int W,H,N;
int X1[5000];int X2[5000];
int Y1[5000];int Y2[5000];
int field[5001][5001];
bool Field[5001][5001];
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};
bool FX[1000005];bool FY[1000005];
int Num_X[5000];int Num_Y[5000];
queue<pair<int,int> >que;
int main()
{
	while(true){
		que.clear();
		for(int i=0;i<5001;i++)for(int j=0;j<5001;j++)field[i][j]=0;
		scanf("%d%d",&W,&H);
		if(W==0&&H==0)return 0;
		scanf("%d",&N);
		for(int i=0;i<N;i++)scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
		for(int i=0;i<N;i++){
			X1[i]++;X2[i]++;Y1[i]++;Y2[i]++;
			if(X1[i]!=1)FX[X1[i]-1]=true;
			FX[X1[i]]=true;
			if(X2[i]!=W+1)FX[X2[i]]=true;
			FX[X2[i]-1]=true;
			FY[Y1[i]]=true;
			if(Y1[i]!=1)FY[Y1[i]-1]=true;
			if(Y2[i]!=H+1)FY[Y2[i]]=true;
			FY[Y2[i]-1]=true;
		}
		int cou1=0,cou2=0;
		for(int i=0;i<=W+1;i++){
			if(FX[i]){
				Num_X[cou1]=i;
				cou1++;
				
			}
		}
		for(int i=0;i<=H+1;i++){
			if(FY[i]){
				Num_Y[cou2]=i;
				cou2++;
				
			}
		}
		//for(int i=0;i<cou1;i++)printf("%d:%d\n",i,Num_X[i]);
		//for(int i=0;i<cou2;i++)printf("%d:%d\n",i,Num_Y[i]);
		for(int i=0;i<N;i++){
			for(int j=0;j<cou1;j++){
				if(Num_X[j]==X1[i])X1[i]=j;
				if(Num_X[j]==X2[i])X2[i]=j;
			}
			if(X2[i]>=cou1)X2[i]=cou1+1;
			for(int j=0;j<cou2;j++){
				if(Num_Y[j]==Y1[i])Y1[i]=j;
				if(Num_Y[j]==Y2[i])Y2[i]=j;
			}
			if(Y2[i]>=cou2)Y2[i]=cou2+1;
		}
		for(int i=0;i<N;i++){
			field[X1[i]][Y1[i]]++;
			field[X2[i]][Y2[i]]++;
			field[X1[i]][Y2[i]]--;
			field[X2[i]][Y1[i]]--;
			//printf("%d\n",i);
		}
		for(int i=1;i<cou1;i++){
			for(int j=0;j<cou2;j++){
				field[i][j]+=field[i-1][j];
			}
		}
		for(int i=0;i<cou1;i++){
			for(int j=1;j<cou2;j++){
				field[i][j]+=field[i][j-1];
			}
		}
		
		for(int i=0;i<cou1;i++){
			for(int j=0;j<cou2;j++){
				if(field[i][j]<=0)Field[i][j]=true;
				else Field[i][j]=false;
			}
		}
		
		/*for(int i=0;i<cou2;i++){
			for(int j=0;j<cou1;j++){
				printf("%d ",Field[j][i]);
			}
			printf("\n");
		}*/
		int ans=0;
		for(int i=0;i<cou1;i++){
			for(int j=0;j<cou2;j++){
				if(!Field[i][j])continue;
				ans++;
				que.push(make_pair(i,j));
				while(!que.empty()){
					pair<int,int> P=que.front();que.pop();
					int pf=P.first;int ps=P.second;
					if(!Field[pf][ps])continue;
					Field[pf][ps]=false;
					for(int k=0;k<4;k++){
						if(pf+dx[k]<0)continue;
						if(pf+dx[k]>=cou1)continue;
						if(ps+dy[k]<0)continue;
						if(ps+dy[k]>=cou2)continue;
						if(!Field[pf+dx[k]][ps+dy[k]])continue;
						que.push(make_pair(pf+dx[k],ps+dy[k]));
					}
				}
			}
		}
		printf("%d\n",ans);
		
	}
	return 0;
}

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

#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int W, H, N;
int X1[1000], X2[1000], Y1[1000], Y2[1000];

bool fld[1000 * 6][1000 * 6];

int compress(int *x1, int *x2, int w) {
  vector<int> xs;

  for(int i = 0; i < N; i++) {
    for(int d = -1; d <= 1; d++) {
      int tx1 = x1[i] + d, tx2 = x2[i] + d;
      if(1 <= tx1 && tx1 <= W) xs.push_back(tx1);
      if(1 <= tx2 && tx2 <= W) xs.push_back(tx2);
    }
  }
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());

  for(int i = 0; i < N; i++) {
    x1[i] = find(xs.begin(),xs.end(),x1[i]) - xs.begin();
    x2[i] = find(xs.begin(),xs.end(),x2[i]) - xs.begin();
  }
  return xs.size();
}

void solve() {
  W = compress(X1,X2,W);
  H = compress(Y1,Y2,H);

  memset(fld,0,sizeof(fld));
  for(int i = 0; i < N; i++) {
    for(int y = Y1[i]; y <= Y2[i]; y++) {
      for(int x = X1[i]; x <= X2[i]; x++) {
        fld[y][x] = true;
      }
    }
  }

  int ans = 0;
  for(int y = 0; y < H; y++) {
    for(int x = 0; x < W; x++) {
      if(fld[y][x]) continue;
      ans++;

      queue<pair<int,int> > que;
      que.push(make_pair(x,y));
      while(!que.empty()) {
        int sx = que.front().first, sy = que.front().second;
        que.pop();

        for(int i = 0; i < 4; i++) {
          int tx = sx + dx[i], ty = sy + dy[i];
          if(tx < 0 || ty < 0 || tx >= W || ty >= H) continue;
          if(fld[ty][tx]) continue;
          que.push(make_pair(tx,ty));
          fld[ty][tx] = true;
        }
      }
    }
  }
  printf("%d\n",ans-1);
}


int main() {
  while(1) {
    scanf("%d %d",&W,&H);
    if(W == 0 && H == 0) break;
    W++;
    H++;
    scanf("%d",&N);
    for(int i = 0; i < N; i++) {
      scanf("%d %d %d %d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
      X1[i]++;
      Y1[i]++;
      X2[i]++;
      Y2[i]++;
    }
    solve();
  }
}

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

#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;

#define MAX_N 2400

pair<int, int>X[MAX_N];
pair<int, int>Y[MAX_N];
int x[MAX_N][2], y[MAX_N][2], h, w, n, a, b, c, d, A, B, cnt;
int col[MAX_N][MAX_N];
int z[MAX_N][MAX_N];
queue<int>Q;

int main() {
	while (true) {
		memset(X, 0, sizeof(X));
		memset(Y, 0, sizeof(Y));
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		memset(col, 0, sizeof(col));
		memset(z, 0, sizeof(z));
		cin >> h >> w;
		if (h == 0 && w == 0) { break; }
		cin >> n;
		for (int j = 0; j < n; j++) {
			cin >> a >> b >> c >> d;
			X[j * 2].first = a; X[j * 2].second = j;
			X[j * 2 + 1].first = c; X[j * 2 + 1].second = j;
			Y[j * 2].first = b; Y[j * 2].second = j;
			Y[j * 2 + 1].first = d; Y[j * 2 + 1].second = j;
		}
		sort(X, X + n * 2);
		sort(Y, Y + n * 2);
		for (int i = 0; i < n * 2; i++){
			if (x[X[i].second][0] == 0) {
				x[X[i].second][0] = i + 1;
			}
			else {
				x[X[i].second][1] = i + 1;
			}
		}
		for (int i = 0; i < n * 2; i++) {
			if (y[Y[i].second][0] == 0) {
				y[Y[i].second][0] = i + 1;
			}
			else {
				y[Y[i].second][1] = i + 1;
			}
		}
		for (int i = 0; i < n; i++){
			for (int j = x[i][0]; j < x[i][1]; j++) {
				for (int k = 0; k < y[i][0]; k < y[i][1]; k++) {
					z[j][k] = 1;
				}
			}
		}
		//bfs.
		cnt = 0;
		for (int i = 0; i < MAX_N; i++) {
			for (int j = 0; j < MAX_N; j++) {
				if (z[i][j] == 0 && col[i][j] == 0) {
					Q.push(i * 10000 + j);
					cnt++;
					col[i][j] = cnt;
					while (!Q.empty()) {
						A = Q.front() / 10000;
						B = Q.front() % 10000;
						if (A + 1 < MAX_N) {
							if (z[A + 1][B] == 0 && col[A + 1][B] == 0) {
								col[A + 1][B] = cnt;
								Q.push(Q.front() + 10000);
							}
						}
						if (B + 1 < MAX_N) {
							if (z[A][B + 1] == 0 && col[A][B + 1] == 0) {
								col[A][B + 1] = cnt;
								Q.push(Q.front() + 1);
							}
						}
						if (A - 1 >= 0) {
							if (z[A - 1][B] == 0 && col[A - 1][B] == 0) {
								col[A - 1][B] = cnt;
								Q.push(Q.front() - 10000);
							}
						}
						if (B - 1 >= 0) {
							if (z[A][B - 1] == 0 && col[A][B - 1] == 0) {
								col[A][B - 1] = cnt;
								Q.push(Q.front() - 1);
							}
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:73: error: expected ')' before ';' token
   54 |                                 for (int k = 0; k < y[i][0]; k < y[i][1]; k++) {
      |                                     ~                                   ^
      |                                                                         )
a.cc:54:75: error: 'k' was not declared in this scope
   54 |                                 for (int k = 0; k < y[i][0]; k < y[i][1]; k++) {
      |                                                                           ^
Language: C++

#include <iostream>
#include <queue>

using namespace std;
typedef pair<int, int> P;

void seach(int x,int y,int X,int Y);

int speace[1000000][1000000],n;

int main(){
	int X,Y,N,x1,y1,x2,y2;
	while(1){
	cin >> X >> Y;
		if(X==0&&Y==0){
			break;
		}
	cin >> N;
	n=0;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			speace[i][j]=-1;
		}
	}
	for(int i=0;i<N;i++){
		cin >> x1>>y1>>x2>>y2;
		for(int j=x1;j<x2;j++){
			for(int k=y1;k<y2;k++){
				speace[j][k]=n;
			}
		}
	}
	n++;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			if(speace[i][j]==-1){
				seach(i,j,X,Y);n++;
				
			}
		}
	}
		/*cout << "\n";
		for(int i=0;i<X;i++){
			for(int j=0;j<Y;j++){
				cout << speace[i][j] << " ";
			}
			cout << "\n";
		}*/
	cout << n-1 <<"\n";
	}
	return 0;
}

void seach(int x,int y,int X,int Y){
	int dx[4]={-1,0,0,1},dy[4]={0,1,-1,0};
	queue<P> que;
	que.push(P(x,y));
	while(que.size()){
		P p=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			if(0<=p.first+dx[i]&&p.first+dx[i]<X&&0<=p.second+dy[i]&&p.second+dy[i]<Y){
				if(speace[p.first+dx[i]][p.second+dy[i]]==-1){
					speace[p.first+dx[i]][p.second+dy[i]]=n;
					que.push(P(p.first+dx[i],p.second+dy[i]));
				}
			}
		}
	}
}
			
	

Compiler output:
/tmp/ccBBCILT.o: in function `main':
a.cc:(.text+0x5a): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
a.cc:(.text+0x121): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
a.cc:(.text+0x177): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
a.cc:(.text+0x180): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
a.cc:(.text+0x1d7): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
a.cc:(.text+0x1e0): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
a.cc:(.text+0x1fe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
/tmp/ccBBCILT.o: in function `seach(int, int, int, int)':
a.cc:(.text+0x3ed): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccBBCILT.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#define MAX_N 1010

using namespace std;

static int X1[1010], Y1[1010], X2[1010], Y2[1010], fld[MAX_N * 2][MAX_N * 2],
dx[4] = { -1, 0, 0, 1 }, dy[4] = { 0, -1, 1, 0 };

static int compress(int *const, int *const, const int, const int);
static int bfs(const int, const int);
void imos(const int, const int, const int);

int main(void)
{
	int W, H, N;

	std::ios::sync_with_stdio(false);
	//freopen("D:\\input.txt", "r", stdin);
	while (1)
	{
		cin >> W >> H;
		if (W == 0 && H == 0)
			break;
		cin >> N;
		for (int i = 0; i < N; i++)
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		W = compress(X1, X2, W, N);
		H = compress(Y1, Y2, H, N);

		imos(W, H, N);
		cout << bfs(W, H) << endl;
	}
	return EXIT_SUCCESS;
}

static int compress(int *const s1, int *const s2, const int W, const int N)
{
	//???????????£???
	vector<int>xs;

	for (int i = 0; i < N; i++)
	{
		if (0 < s1[i] && s1[i] < W) xs.push_back(s1[i]);
		if (0 < s2[i] && s2[i] < W) xs.push_back(s2[i]);
	}
	xs.push_back(0);
	xs.push_back(W);//?????????????????¶
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	for (int i = 0; i < N; i++)
	{
		s1[i] = find(xs.begin(), xs.end(), s1[i]) - xs.begin();
		s2[i] = find(xs.begin(), xs.end(), s2[i]) - xs.begin();
	}
	return xs.size() - 1;
}

static int bfs(const int W, const int H)
{
	int ans = 0;
	for (int i = 0; i < W; i++)
		for (int j = 0; j < H; j++)
		{
			if (fld[i][j])continue;//????´¢?????????????????????
			ans++;

			queue<pair<int, int>>que;
			que.push(make_pair(i, j));
			while (!que.empty())
			{
				int tx = que.front().first, ty = que.front().second;
				que.pop();
				for (int i = 0; i < 4; i++)
				{
					int ttx = tx + dx[i], tty = ty + dy[i];
					if (0 <= ttx && ttx <= W
						&& 0 <= tty && tty <= H
						&& !fld[ttx][tty])
					{
						que.push(make_pair(ttx, tty));
						fld[ttx][tty] = 1;
					}
				}
			}
		}
	return ans;
}

void imos(const int W, const int H, const int N)
{
	//imos??????????????´
	memset(fld, 0, sizeof(fld));

	for (int i = 0; i < N; i++)//????????±??????
	{
		fld[X1[i]][Y1[i]]++;
		fld[X1[i]][Y2[i]]--;
		fld[X2[i]][Y1[i]]--;
		fld[X2[i]][Y2[i]]++;
	}
	for (int i = 0; i < W; i++)//?´?????¨????
		for (int j = 1; j < H; j++)
			fld[i][j] += fld[i][j - 1];

	for (int j = 0; j < H; j++)//?´??????????
		for (int i = 1; i < W; i++)
			fld[i][j] += fld[i - 1][j];
	//?????¶??¨????°±????????????????????????
}

Compiler output:
a.cc: In function 'void imos(int, int, int)':
a.cc:97:9: error: 'memset' was not declared in this scope
   97 |         memset(fld, 0, sizeof(fld));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <queue>
  +++ |+#include <cstring>
    6 | #define MAX_N 1010
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
int compress(int *, int *, int);
void bfs(int, int);
int n, W, H;
int xa[1000], xb[1000], ya[1000], yb[1000];
bool pt[5000][5000] = {};
int main() {
	int w, h, ans = 0;
	while (cin >> w >> h&&w&&h) {
		cin >> n;
		memset(pt, 0, sizeof(pt));
		for (int i = 0; i < n; i++) {
			scanf("%d%d%d%d", &xa[i], &ya[i], &xb[i], &yb[i]);
		}
		W = compress(xa, xb, w);
		H = compress(ya, yb, h);
		for (int i = 0; i < n; i++) {
			for (int j = xa[i]; j < xb[i]; j++) {
				for (int k = ya[i]; k < yb[i]; k++) {
					pt[k][j] = 1;
				}
			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (!pt[i][j]) {
					bfs(i, j);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

int compress(int *x1, int *x2, int lim) {
	vector<int> vec;
	for (int i = 0; i < n; i++) {
		for (int j = -1; j <= 1; j++) {
			int a = x1[i] + j, b = x2[i] + j;
			if (a >= 0 && a < lim) vec.push_back(a);
			if (b >= 0 && b < lim) vec.push_back(b);
		}
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	for (int i = 0; i < n; i++) {
		x1[i] = find(vec.begin(), vec.end(), x1[i]) - vec.begin();
		x2[i] = find(vec.begin(), vec.end(), x2[i]) - vec.begin();
	}
	return vec.size();
}

void bfs(int x, int y) {
	queue<P> que;
	que.push(P(x, y));
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		for (int i = -1; i <= 1; i++) {
			if (i) {
				int a = p.first + i, b = p.second + i;
				if (a >= 0 && a < H && !pt[a][p.second]) {
					pt[a][p.second] = 1;
					que.push(P(a, p.second));
				}
				if (b >= 0 && b < W && !pt[p.first][b]) {
					pt[p.first][b] = 1;
					que.push(P(p.first, b));
				}
			}
		}
	}
}

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


#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int compress(vector<int>&a_, vector<int>&b_,int c_)
{
	vector<int> ret;
	for (int ap : a_)
	{
		if(ap != 0)ret.push_back(ap - 1);
		ret.push_back(ap);
		if (ap != c_)ret.push_back(ap + 1);
	}
	for (int bp : b_)
	{
		if (bp != 0)ret.push_back(bp - 1);
		ret.push_back(bp);
		if (bp != c_)ret.push_back(bp + 1);
	}
	sort(ret.begin(), ret.end());
	ret.erase(unique(ret.begin(), ret.end()), ret.end());
	for (int &ap : a_)
	{
		ap = find(ret.begin(), ret.end(), ap) - ret.begin();
	}
	for (int &bp : b_)
	{
		bp = find(ret.begin(), ret.end(), bp) - ret.begin();
	}
	return ret.size() - 1;
}

bool fld[1234][1234];

int main()
{
	for (;;)
	{
		int w, h;
		int n;
		vector<int>vx1, vx2, vy1, vy2;
		scanf("%d %d", &w, &h);
		scanf("%d", &n);
		if (w == 0)break;
		for (int i = 0; i < n; ++i)
		{
			int x1_, y1_, x2_, y2_;
			scanf("%d %d %d %d", &x1_, &y1_, &x2_, &y2_);
			vx1.push_back(x1_);
			vx2.push_back(x2_);
			vy1.push_back(y1_);
			vy2.push_back(y2_);
		}
		vx1.push_back(0);
		vx2.push_back(w);
		vy1.push_back(0);
		vy2.push_back(h);
		w = compress(vx1, vx2, w);
		h = compress(vy1, vy2, h);
		memset(fld, false, sizeof(fld));
		//?´?????????§??????????????£??????TLE?
		for (int i = 0; i < n; ++i)
		{
			for (int y = vy1[i]; y < vy2[i]; ++y)
			{
				for (int x = vx1[i]; x < vx2[i]; ++x)
				{
					fld[y][x] = true;
				}
			}
		}
		int ans = 0;

		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)printf("%d",fld[i][j]);
			printf("\n");
		}
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				if (fld[i][j])continue;
				++ans;
				queue<pair<int,int>>que;
				que.emplace(i,j);
				int dx[4] = {0,0,1,-1};
				int dy[4] = {1,-1,0,0};
				while (!que.empty())
				{
					pair<int,int> p = que.front(); que.pop();
					for (int d = 0; d < 4; ++d)
					{
						int y = p.first + dy[d];
						int x = p.second + dx[d];
						if (0 <= x && x < w && 0 <= y && y < h && !fld[y][x])
						{
							que.emplace(y,x);
							fld[y][x] = true;
						}
					}
				}
			}
		}
		printf("%d\n", ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:17: error: 'memset' was not declared in this scope
   64 |                 memset(fld, false, sizeof(fld));
      |                 ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <queue>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>

using namespace std;

int compress(int *x1,int *x2,int w){
  vector<int> xs;

  for(int i=0;i<N;i++){
    for(int d=-1;d<=1;d++){
      int tx1=x1[i]+d,tx2=x2[i]+d;
      if(1<=tx1&&tx1<=W) xs.push_back(tx1);
      if(1<=tx2&&tx2<=W) xs.push_back(tx2);
    }
  }

  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());

  for(int i=0; i<N; i++){
    x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
    x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
  }

  return xs.size();
}

int main(){

while(1){

int W,H,N;
int X1[1000],X2[1000],Y1[1000],Y2[1000];

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

bool fld[6000][6000];

 scanf("%d%d",&W,&H);

 if(W==0) break;

 scanf("%d",&N);

 for(int i=0; i<N; i++){
  scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
 }

 W=compress(X1,X2,W);
 H=compress(Y1,Y2,H);

 memset(fld,0,sizeof(fld));
 for(int i=0;i<N;i++){
  for(int y=Y1[i];y<=Y2[i];y++){
   for(int x=X1[i];x<=X2[i];x++){
      fld[y][x]=true;
   }
  }
 }

 int ans=0;
 for(int y=0;y<H;y++){
  for(int x=0;x<W;x++){
    if(fld[y][x]) continue;
    ans++;

    queue<pair<int,int> > que;
    que.push(make_pair(x,y));
   while(!que.empty()){
    int sx=que.front().first,sy=que.front().second;
    que.pop();

    for(int i=0; i<4; i++){
      int tx=sx+dx[i],ty=sy+dy[i];
      if(tx<0||W<=tx||ty<0||H<=ty) continue;
      if(fld[ty][tx]) continue;
      que.push(make_pair(tx,ty));
      fld[ty][tx]=true;
    }
   }
  }
 }

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

   return 0;

}

Compiler output:
a.cc: In function 'int compress(int*, int*, int)':
a.cc:23:17: error: 'N' was not declared in this scope
   23 |   for(int i=0;i<N;i++){
      |                 ^
a.cc:26:23: error: 'W' was not declared in this scope
   26 |       if(1<=tx1&&tx1<=W) xs.push_back(tx1);
      |                       ^
a.cc:27:23: error: 'W' was not declared in this scope
   27 |       if(1<=tx2&&tx2<=W) xs.push_back(tx2);
      |                       ^
a.cc:34:18: error: 'N' was not declared in this scope
   34 |   for(int i=0; i<N; i++){
      |                  ^