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

#include <iostream>

using namespace std;

int main()
{
	while(1){
		char input[128];
		int hmMaru = 0,hmKaku = 0;
		bool fAns = true;

		cin >> input;
		if(strcmp(input,".") == 0)
			break;

		for(int i = 0;i < strlen(input);i++)
		{
			bool fEnd = false;
			switch(input[i])
			{
				case '(':
					hmMaru++;
					break;
				case ')':
					hmMaru--;
					if(hmMaru != 0){
						fAns = false;
						fEnd = true;
					}
					break;
				case '[':
					hmKaku++;
					break;
				case ']':
					hmKaku--;
					if(hmKaku != 0){
						fAns = false;
						fEnd = true;
					}
					break;
				case '.':
					fEnd = true;
					break;
			}
			if(fEnd == true){
				if(fAns == true){
					cout << "yes" << endl;
				}else{
					cout << "no" << endl;
				}
			}
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:20: error: 'strcmp' was not declared in this scope
   13 |                 if(strcmp(input,".") == 0)
      |                    ^~~~~~
a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | 
a.cc:16:35: error: 'strlen' was not declared in this scope
   16 |                 for(int i = 0;i < strlen(input);i++)
      |                                   ^~~~~~
a.cc:16:35: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<stack>

using namespace std;

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

int main(){
	
	while(1){
		char str[111];
		gets(str);
		
		if(str[0]=='.' && strlen(str)==1)break;
		
		int valid = 1;
		stack<char> c;
		int n = strlen(str);
		rep(i,n){
			if(str[i]=='(' || str[i]=='['){
				c.push(str[i]);
			}
			if(str[i]==')' || str[i]==']'){
				if(c.empty()){
					valid=0;
					break;
				}
				char s = c.top();
				c.pop();
				
				if((str[i]==')' && s=='[')||
					(str[i]==']' && s=='(')){
					valid=0;
					break;	
				}
			}
		}
		if(!c.empty())valid=0;
		
		if(valid)puts("yes");
		else puts("no");
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
   18 |                 gets(str);
      |                 ^~~~
      |                 getw
a.cc:20:35: error: 'strlen' was not declared in this scope
   20 |                 if(str[0]=='.' && strlen(str)==1)break;
      |                                   ^~~~~~
a.cc:8:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include<stack>
  +++ |+#include <cstring>
    8 | 
a.cc:24:25: error: 'strlen' was not declared in this scope
   24 |                 int n = strlen(str);
      |                         ^~~~~~
a.cc:24:25: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <string>

#include <map>

#include <vector>

#include <iostream>

#include <set>

#include <algorithm>

using namespace std;



char s[150];
int zhan[150];

bool solve(){
	int len,top,i;
	gets(s);
	len=strlen(s);
	if(len==1 && s[0]=='.')return false;
	top=0;
	for(i=0;i<len;++i){
		if(s[i]=='('){
			zhan[++top]=0;
		}else if(s[i]=='['){
			zhan[++top]=1;
		}else if(s[i]==')'){
			if(top==0 || zhan[top]==1){
				printf("no\n");
				return true;
			}
			--top;
		}else if(s[i]==']'){
			if(top==0 || zhan[top]==0){
				printf("no\n");
				return true;
			}
			--top;
		}
	}
	if(top==0)printf("yes\n");else printf("no\n");
	return true;
}


int main(){

	while(solve());

	return 0;

}
束 Back

Compiler output:
a.cc: In function 'bool solve()':
a.cc:28:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   28 |         gets(s);
      |         ^~~~
      |         getw
a.cc: At global scope:
a.cc:63:1: error: '\U0000675f' does not name a type
   63 | 束 Back
      | ^~
Language: C++

#include<iostream>
#include<cstring>
using namespace std;
const int limit=200;
char st[limit];
int a[limit];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int aa;
	gets(st);
	int n=strlen(st);
	while (!((st[0]=='.')&&(n==1)))
	{
		for(int i=0;i<=n;i++)
		{
			if(st[i]=='[') a[++aa]=1;
			else if(st[i]==']') a[++aa]=2;
			else if(st[i]=='(') a[++aa]=3;
			else if(st[i]==')') a[++aa]=4;	
		}	
		bool ok=true;
		while ((ok)&&(aa>0))
		{
			ok=false;
			for (int i=1;i<=aa-1;i++) if(((a[i]==1)&&(a[i+1]==2))||((a[i]==3)&&(a[i+1]==4)))
			{
				for(int j=i;j<=aa-2;j++) a[j]=a[j+2];
				a[aa]=0; a[aa-1]=0;
				aa=aa-2;
				ok=true;
				break;
			}
		}
		if(aa==0) cout<<"yes";
		else cout<<"no";
		cout<<endl;
		for(int i=1;i<=aa;i++) a[i]=0;
		aa=0;
		gets(st);
		n=strlen(st);
	}		
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   12 |         gets(st);
      |         ^~~~
      |         getw
Language: Java

public
class ProbC
{
  private static
  final int ColorNum = 6;

  public static
  void main (
    String args[ ]
    )
  {
    java.util.Scanner scanner
      = new java.util.Scanner ( System.in );

    while ( true )
    {
      int[ ][ ] panel;
      int       h, w, c;

      h = scanner.nextInt ( );
      w = scanner.nextInt ( );
      c = scanner.nextInt ( );
      if ( h == 0 && w == 0 && c == 0 ) break;

      panel = new int[ h ][ w ];
      for ( int j = 0; j < h; ++j )
      for ( int i = 0; i < w; ++i )
      {
        panel[ j ][ i ] = scanner.nextInt ( );
      }

      System.out.format ( "%d\n", solve ( panel, c ) );
    }

    return ;
  }

  public static
  int solve (
    int[ ][ ]   panel,
    int         c
    )
  {
    int[ ]  p = new int[ 5 ];
    int     res = 0;

    p[ 4 ] = c;
    for ( p[ 0 ] = 1; p[ 0 ] <= ColorNum; ++p[ 0 ] )
    for ( p[ 1 ] = 1; p[ 1 ] <= ColorNum; ++p[ 1 ] )
    for ( p[ 2 ] = 1; p[ 2 ] <= ColorNum; ++p[ 2 ] )
    for ( p[ 3 ] = 1; p[ 3 ] <= ColorNum; ++p[ 3 ] )
    {
      int[ ][ ] clone
        = new int[ panel.length ][ ];

      /* Copies panel to clone by deep copy */
      for ( int i = 0; i < panel.length; ++i )
      {
        clone[ i ] = panel[ i ].clone ( );
      }

      res = Math.max ( res, test ( clone, p ) );
    }

    return ( res );
  }

  private static
  int test (
    int[ ][ ]   panel,
    int[ ]      param
    )
  {
    for ( int c : param )
    {
      simulate ( panel, 0, 0, panel[ 0 ][ 0 ], c );
    }

    return
      count ( panel, 0, 0, panel[ 0 ][ 0 ] );
  }

  private static
  void simulate (
    int[ ][ ]   panel,
    int         x,
    int         y,
    int         pc,
    int         nc
    )
  {
    if ( nc == pc )               return ;
    if ( x < 0 || y < 0
      || y >= panel.length
      || x >= panel[ y ].length ) return ;
    if ( panel[ y ][ x ] != pc )  return ;

    panel[ y ][ x ] = nc;

    simulate ( panel, x - 1 , y     , pc, nc );
    simulate ( panel, x     , y - 1 , pc, nc );
    simulate ( panel, x + 1 , y     , pc, nc );
    simulate ( panel, x     , y + 1 , pc, nc );

    return ;
  }

  private static
  int count (
    int[ ][ ]   panel,
    int         x,
    int         y,
    int         c
    )
  {
    int res;

    if ( x < 0 || y < 0
      || y >= panel.length
      || x >= panel[ y ].length ) return ( 0 );
    if ( panel[ y ][ x ] != c )   return ( 0 );

    /* Flags not to recount this point */
    panel[ y ][ x ] = -1;

    res  = 1;
    res += count ( panel, x - 1 , y     , c );
    res += count ( panel, x     , y - 1 , c );
    res += count ( panel, x + 1 , y     , c );
    res += count ( panel, x     , y + 1 , c );

    return ( res );
  }
}

Compiler output:
Main.java:2: error: class ProbC is public, should be declared in a file named ProbC.java
class ProbC
^
1 error
Language: Java

package vol11;

import java.util.Arrays;
import java.util.Scanner;

public class P1174
{
	static int[] D = { 1, 0, -1, 0 };
	static int w, h, c;

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			h = sc.nextInt();
			w = sc.nextInt();
			c = sc.nextInt();
			if ((h|w|c)==0)break;

			int[] board = new int[w * h];
			for (int y = 0; y < h; y++)
			{
				for (int x = 0; x < w; x++)
				{
					board[y * w + x] = sc.nextInt();
				}
			}

			System.out.println(count(board, 5));
		}
	}

	static int count(int[] board, int t)
	{
		if (t == 0)
		{
			return countColor(board);
		}

		int max = 0;
		for (int i = 1; i <= 6; i++)
		{
			if (board[0] == i) continue;
			int[] cb = Arrays.copyOf(board, board.length);
			changeColor(cb, 0, 0, cb[0], i);
			max = Math.max(max, count(cb, t - 1));
		}
		return max;
	}

	static int countColor(int[] board)
	{
		return countColor(board, 0, 0);
	}

	static int countColor(int[] board, int x, int y)
	{
		int count = 0;
		if (0 <= x && x < w && 0 <= y && y < h && board[y * w + x] == c)
		{
			count++;
			board[y * w + x] = 0;
			for (int i = 0; i < 4; i++)
			{
				int x2 = x + D[i];
				int y2 = y + D[(i + 1) % 4];
				count += countColor(board, x2, y2);
			}
		}
		return count;
	}

	static void changeColor(int[] board, int x, int y, int c, int d)
	{
		if (0 <= x && x < w && 0 <= y && y < h && board[y * w + x] == c)
		{
			board[y * w + x] = d;
			for (int i = 0; i < 4; i++)
			{
				int x2 = x + D[i];
				int y2 = y + D[(i + 1) % 4];
				changeColor(board, x2, y2, c, d);
			}
		}
	}
}
/*
3 5 5
1 6 3 2 5
2 5 4 6 1
1 2 4 1 5
4 5 6
1 5 6 1 2
1 4 6 3 2
1 5 2 3 2
1 1 2 3 2
1 1 5
1
1 8 6
1 2 3 4 5 1 2 3
8 1 1
1
2
3
4
5
1
2
3
8 8 6
5 2 5 2 6 5 4 2
4 2 2 2 5 2 2 2
4 4 4 2 5 2 2 2
6 4 5 2 2 2 6 6
6 6 5 5 2 2 6 6
6 2 5 4 2 2 6 6
2 4 4 4 6 2 2 6
2 2 2 5 5 2 2 2
8 8 2
3 3 5 4 1 6 2 3
2 3 6 4 3 6 2 2
4 1 6 6 6 4 4 4
2 5 3 6 3 6 3 5
3 1 3 4 1 5 6 3
1 6 6 3 5 1 5 3
2 4 2 2 2 6 5 3
4 1 3 6 1 5 5 4
0 0 0
*/

Compiler output:
Main.java:6: error: class P1174 is public, should be declared in a file named P1174.java
public class P1174
       ^
1 error
Language: C++

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

int H, W, C;
int field[8][8];
int dh[] = {0, 0, 1, -1};
int dw[] = {1, -1, 0, 0};

void dfs2(int h, int w, int pc, int nc){
    field[h][w] = nc;
    for(int i=0; i<4; i++){
        int nh = h + dh[i];
        int nw = w + dw[i];
        if(0<=nh&&nh<H && 0<=nw&&nw<W && field[nh][nw]==pc && field[nh][nw]!=nc){
            dfs2(nh, nw, pc, nc);
        }
    }
}


int dfs(int deepth, int changes[]){
    int res;
    int tfield[8][8];
    
    memcpy(tfield, field, sizeof(field));
    dfs2(0, 0, field[0][0], changes[deepth]);
    
    if(deepth < 5){
        res = dfs(deepth+1, changes);
    }else{
        res = 0;
        for(int h=0; h<H; h++){
            for(int w=0; w<W; w++){
                if(field[h][w] == changes[deepth]){
                    res ++;
                }
            }
        }
    }
    memcpy(field, tfield, sizeof(field));
    
    return res;
}

void solve(){
    int ans = 0;
    for(int i1=1; i1<=6; i1++){
        for(int i2=1; i2<=6; i2++){
            for(int i3=1; i3<=6; i3++){
                for(int i4=1; i4<=6; i4++){
                    int i5 = C;
                    int chnges[] = {i1, i2, i3, i4, i5};
                    ans = max(ans, dfs(0, chnges));
                }
            }
        }
    }
    cout << ans << endl;
}

int main(int argc, const char * argv[]){
    while(cin >>H>>W>>C, H|W|C){
        for(int h=0; h<H; h++){
            for(int w=0; w<W; w++){
                cin >> field[h][w];
            }
        }
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int*)':
a.cc:26:5: error: 'memcpy' was not declared in this scope
   26 |     memcpy(tfield, field, sizeof(field));
      |     ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int H,W,C;
int tbl[10][10];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
bool visited[10][10];

void paint(int x,int y,int c){
  visited[y][x]=true;
  for(int i=0;i<4;++i){
    int mx = x+dx[i];
    int my = y+dy[i];
    if(mx>=W||my>=H||mx<0||my<0) continue;
    if(visited[my][mx]) continue;
    if(tbl[my][mx]==tbl[0][0]) paint(mx,my,c);
  }
  tbl[y][x]=c;
}

int calc(int x,int y){
  visited[y][x]=true;
  int ret = 1;
  for(int i=0;i<4;++i){
    int mx = x+dx[i];
    int my = y+dy[i];
    if(mx>=W||my>=H||mx<0||my<0) continue;
    if(visited[my][mx]) continue;
    if(tbl[my][mx]==tbl[0][0]) ret+=calc(mx,my);
  }
  return ret;
}

int solve(int depth){
  if(!depth){
    /*
    for(int i=0;i<H;++i){
      for(int j=0;j<W;++j) cout << tbl[i][j];
      cout << endl;
    }
    cout << endl;
    */    
    memset(visited,0,sizeof(visited));
    return calc(0,0);
  }
  int ret = 0;
  for(int i=1;i<=6;++i){
    if(depth==1&&i!=C) continue;
    int tmp[10][10];
    for(int y=0;y<H;++y) for(int x=0;x<W;++x) tmp[y][x]=tbl[y][x];
    memset(visited,0,sizeof(visited));
    paint(0,0,i);
    ret = max(ret,solve(depth-1));
    for(int y=0;y<H;++y) for(int x=0;x<W;++x) tbl[y][x]=tmp[y][x];    
  }
  return ret;
}

int main(){
  while(cin>>H>>W>>C,H||W||C){
    for(int i=0;i<H;++i)
      for(int j=0;j<W;++j) cin>>tbl[i][j];
    cout << solve(5) << endl;
  }
  return 0;
}

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

#include <stdio.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int H, W, c, a[9][9], b[9][9], g[9][9], v[9][9];
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int rec1(int x, int y) {
	int ret = 1; v[y][x] = 1;
	for (int i = 0; i < 4; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (0 <= tx && tx < W && 0 <= ty && ty < H && !v[ty][tx]) ret += rec1(tx, ty);
	}
	return ret;
}
void rec(int x, int y, int e) {
	int w = b[y][x]; b[y][x] = e;
	for (int i = 0; i < 4; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (0 <= tx && tx < W && 0 <= ty && ty < H && b[ty][tx] == w) rec(tx, ty, e);
	}
}
void cpy(int m) {
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			switch (m) {
			case 0: g[i][j] = b[i][j]; break;
			case 1: b[i][j] = g[i][j]; break;
			case 2: v[i][j] = 0; break;
			}
			if (m == ) b[i][j] = g[i][j];
			else g[i][j] = b[i][j];
		}
	}
}
int solve(int d) {
	int ret = 0;
	if (b[0][0] != c) cpy(0), rec(0, 0, c);
	cpy(2), ret = rec1(0, 0), cpy(1);
	if (d < 4) {
		for (int i = 0; i < 6; i++) {
			if (b[0][0] == i) continue;
			cpy(0), rec(0, 0, c);
			ret = max(ret, solve(d + 1)), cpy(1);
		}
	}
	return ret;
}
int main() {
	while (scanf("%d%d%d", &H, &W, &c), H) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) scanf("%d", &a[i][j]), b[i][j] = a[i][j];
		}
		printf("%d\n", solve(0));
	}
	return 0;
}

Compiler output:
a.cc: In function 'void cpy(int)':
a.cc:30:34: error: expected primary-expression before ')' token
   30 |                         if (m == ) b[i][j] = g[i][j];
      |                                  ^
Language: C++

#include <iostream>
#include <vector>
#include <algotithm>
#include <queue>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int dx[4] = {1,-1,1,-1};
const int dy[4] = {-1,-1,1,1};
const int NUMC = 6;
int h,w,c;
vector<vector<int> > mp;
int dfs(int def_i,int def_j,int depth,int col){
	int num_panel[NUMC] = {};
	queue<pair<int,int> > que;
	que.push(i,j);
	while(!que.empty()){
		pair<int,int> P = que.top();
		que.push();
		REP(i,4){
			int y = P.first + dy[i];
			int x = P.second + dx[i];
			if(x<0 || y<0 || x>=w || 
		}
			
	if(depth<5){
		REP(col_i,NUMC){
			if(depth == 4 && col_i+1 != c || depth == 3 && col_i+1 == c)continue;
			num_panel[col_i] = dfs(i,j,depth+1,col_i+1);
		}
		return *max_element(num_panel,num_panel+NUMC);
	}else if(depth == 5){
		return ct;
	}
}

int main(){

	while(cin >> h>>w>>c,h||w||c){
		mp.resize(h,vector<int>(w));
		REP(i,h)
			REP(j,w)cin >> mp[i][j];
		int ans = 0;
		REP(i,h){
			REP(j,w){
				REP(col_i,NUMC){
					ans = max(ans,dfs(i,j,1,col_i+1));
				}
			}
		}

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

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

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

#include <iostReam>
#include <cstring>
#include <algorithm>
using namespace std;

int H,W,C;
int board[8][8];
int b[8][8];
int check[8][8];
int ord[5];
int ans;

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

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

void dfs(int x, int y, int color){
    //cerr << x << " " << y << " " << color << endl;
    check[y][x] = 1;
    for(int k = 0; k < 4; k++){
        int nx = x + dx[k], ny = y + dy[k];
        if(!in(nx, ny) || b[ny][nx] != color || check[ny][nx]) continue;
        dfs(nx, ny, color);
    }
}

int calc(){
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            b[i][j] = board[i][j];
        }
    }
    for(int t = 0; t < 5; t++){
        //cout << ord[t] << endl;
        memset(check, 0, sizeof check);
        dfs(0, 0, b[0][0]);
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(check[i][j]) b[i][j] = ord[t];
            }
        }
    }

    memset(check, 0, sizeof check);
    dfs(0, 0, b[0][0]);
    int ret = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(check[i][j] && b[i][j] == C) ret++;
        }
    }
    return ret;
}

void f(int n){
    if(n == 5){
        ans = max(ans, calc());
        return;
    }
    for(int i = 1; i <= 6; i++){
        ord[n] = i;
        f(n + 1);
    }
}

int main(){
    while(cin >> H >> W >> C, H){
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cin >> board[i][j];
            }
        }
        ans = 0;
        f(0);
        cout << ans <<endl;
    }
}

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

#include <iostReam>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int H,W,C;
int board[8][8];
int b[8][8];
int check[8][8];
int ord[5];
int ans;

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

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

void dfs(int x, int y, int color){
    //cerr << x << " " << y << " " << color << endl;
    check[y][x] = 1;
    for(int k = 0; k < 4; k++){
        int nx = x + dx[k], ny = y + dy[k];
        if(!in(nx, ny) || b[ny][nx] != color || check[ny][nx]) continue;
        dfs(nx, ny, color);
    }
}

int calc(){
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            b[i][j] = board[i][j];
        }
    }
    for(int t = 0; t < 5; t++){
        //cout << ord[t] << endl;
        memset(check, 0, sizeof check);
        dfs(0, 0, b[0][0]);
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(check[i][j]) b[i][j] = ord[t];
            }
        }
    }

    memset(check, 0, sizeof check);
    dfs(0, 0, b[0][0]);
    int ret = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(check[i][j] && b[i][j] == C) ret++;
        }
    }
    return ret;
}

void f(int n){
    if(n == 5){
        ans = max(ans, calc());
        return;
    }
    for(int i = 1; i <= 6; i++){
        ord[n] = i;
        f(n + 1);
    }
}

int main(){
    while(cin >> H >> W >> C, H){
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cin >> board[i][j];
            }
        }
        ans = 0;
        f(0);
        cout << ans <<endl;
    }
}

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

#include <iostream>
#include <algorithm>

// #define DEBUG

using namespace std;

int h, w, c;
int p[9][9];

void Coloring(int y, int x, int c, bool checked[9][9]) {
  if (checked[y][x]) {
    return;
  }
  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1};

  int ret = 0;
  checked[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (ny < 0 || ny >= h) {
      continue;
    }
    if (nx < 0 || nx >= w) {
      continue;
    }
    if (p[y][x] == p[ny][nx]) {
      Coloring(ny, nx, c, checked);
    }
  }
  p[y][x] = c;
  checked[y][x] = false;
}

int Count(int y, int x, bool checked[9][9]) {
  if (checked[y][x]) {
    return 0;
  }
  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1};

  int ret = 0;
  checked[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (ny < 0 || ny >= h) {
      continue;
    }
    if (nx < 0 || nx >= w) {
      continue;
    }
    if (p[y][x] == p[ny][nx]) {
      ret += Count(ny, nx, checked);
    }
  }

  return ret + 1; 
}

int dfs(int limit, int c, int pv[10]) {
  if (limit == 0) {
    if (p[0][0] != c) {
      return 0;
    }
    bool checked[9][9] = { false };
    return Count(0, 0, checked);
  }
  int ret = 0;
  for (int i = 1; i <= 6; i++) {
    int tmp[9][9];
    memcpy(tmp, p, sizeof(p));
    bool checked[9][9] = { false };
    Coloring(0, 0, i, checked);
    int tpv[10] = { 0 };
    int d = dfs(limit - 1, c, tpv);
    memcpy(p, tmp, sizeof(p)); // UNDO
    if (d > ret) {
      ret = d;
      pv[limit] = i;
      for (int j = 0; j < limit; j++) {
        pv[j] = tpv[j];
      }
    }
  }

  return ret;
}

int main() {
  while (true) {
    cin >> h >> w >> c;
    if (h + w + c == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> p[i][j];
      }
    }
    int pv[10] = { 0 };
    cout << dfs(5, c, pv) << endl;
   
#ifdef DEBUG
    for (int i = 0; i < 10; i++) {
      cout << pv[i] << " \n"[i == 9];
    }
  }
#endif
  return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int*)':
a.cc:74:5: error: 'memcpy' was not declared in this scope
   74 |     memcpy(tmp, p, sizeof(p));
      |     ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | 
a.cc: In function 'int main()':
a.cc:113:2: error: expected '}' at end of input
  113 | }
      |  ^
a.cc:92:12: note: to match this '{'
   92 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

// #define DEBUG

using namespace std;

int h, w, c;
int p[9][9];

void Coloring(int y, int x, int c, bool checked[9][9]) {
  if (checked[y][x]) {
    return;
  }
  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1};

  int ret = 0;
  checked[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (ny < 0 || ny >= h) {
      continue;
    }
    if (nx < 0 || nx >= w) {
      continue;
    }
    if (p[y][x] == p[ny][nx]) {
      Coloring(ny, nx, c, checked);
    }
  }
  p[y][x] = c;
  checked[y][x] = false;
}

int Count(int y, int x, bool checked[9][9]) {
  if (checked[y][x]) {
    return 0;
  }
  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1};

  int ret = 0;
  checked[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (ny < 0 || ny >= h) {
      continue;
    }
    if (nx < 0 || nx >= w) {
      continue;
    }
    if (p[y][x] == p[ny][nx]) {
      ret += Count(ny, nx, checked);
    }
  }

  return ret + 1; 
}

int dfs(int limit, int c, int pv[10]) {
  if (limit == 0) {
    if (p[0][0] != c) {
      return 0;
    }
    bool checked[9][9] = { false };
    return Count(0, 0, checked);
  }
  int ret = 0;
  for (int i = 1; i <= 6; i++) {
    int tmp[9][9];
    memcpy(tmp, p, sizeof(p));
    bool checked[9][9] = { false };
    Coloring(0, 0, i, checked);
    int tpv[10] = { 0 };
    int d = dfs(limit - 1, c, tpv);
    memcpy(p, tmp, sizeof(p)); // UNDO
    if (d > ret) {
      ret = d;
      pv[limit] = i;
      for (int j = 0; j < limit; j++) {
        pv[j] = tpv[j];
      }
    }
  }

  return ret;
}

int main() {
  while (true) {
    cin >> h >> w >> c;
    if (h + w + c == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> p[i][j];
      }
    }
    int pv[10] = { 0 };
    cout << dfs(5, c, pv) << endl;
   
#ifdef DEBUG
    for (int i = 0; i < 10; i++) {
      cout << pv[i] << " \n"[i == 9];
    }
  }
#endif
  return 0;
}

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

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int h,w;
int t[10][10];

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

bool in(int x, int y){
    if(0 > x || x >= h) return false;
    if(0 > y || y >= w) return false;
    return true;
}

void change(int c){ //g[0][0]を色cに変える

    int bef = t[0][0];
    if(bef == c)return;
    queue<pii> q;
    q.push(pii(0,0));
    while(q.size()){
        int x = q.front().first;
        int y = q.front().second;

        t[x][y] = c;
        q.pop();
        rep(i,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(in(nx,ny) && t[nx][ny] == bef){
                q.push(pii(nx,ny));
            }
        }
    }
}

int count(int c){ //色cの連結成分の大きさを調べる

    int ret = 0;
    rep(i,h)rep(j,w)if(t[i][j] == c){
        int cnt = 0;
        queue<pii> q;
        q.push(pii(i,j));
        while(q.size()){
            int x = q.front().first;
            int y = q.front().second;
            q.pop();
            if(t[x][y] < 0)continue;

            cnt++;
            t[x][y] = -1;
            rep(k,4){
                int nx = x + dx[k];
                int ny = y + dy[k];
                if(in(nx,ny) && t[nx][ny] == c ){
                    q.push(pii(nx,ny));
                }
            }
        }

        ret = max(ret, cnt);
    }

    return ret;
}

int main(void) {
    int col;
    while(cin >> h >> w >> col, h){
        col--;
        int g[10][10];
        rep(i,h)rep(j,w)cin >> g[i][j],g[i][j]--;
        int ans = 0;
        rep(a,6)rep(b,6)rep(c,6)rep(d,6)rep(e,6){
            rep(i,h)rep(j,w)t[i][j] = g[i][j];
            change(a);
            change(b);
            change(c);
            change(d);
            change(e);
            ans = max(ans, count(col));
        }
        cout << ans << endl;
    }
}
v


Compiler output:
a.cc:117:1: error: 'v' does not name a type; did you mean 'vs'?
  117 | v
      | ^
      | vs
Language: C++

#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
int ans,h,e,w,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int bfs(int s[10][10]){
	int cnp=1;
	bool visit[10][10];
	memset(visit,0,sizeof(visit));
	queue<P> que;
	que.push(P(0,0));
	visit[0][0]=1;
	while(!que.empty()){
		P p=que.front();
		que.pop();
		rep(i,4){
			int nx=p.second+dx[i];
			int ny=p.first+dy[i];
			if(!(nx>=0&&nx<w&&ny>=0&&ny<h)||!(s[ny][nx]==s[0][0])||visit[ny][nx])
			continue;
			que.push(P(ny,nx));
			cnp++;
			visit[ny][nx]=1;
		}
	}
	return cnp;
}
void func(int s[10][10],int now){
	if(now==5){
		if(s[0][0]==e){
			ans=max(ans,bfs(s));
		}
		return;
	}
	int c[10][10];
	bool visit[10][10];

	for(int i=1;i<=6;i++){
		if(i!=s[0][0]){
			rep(k,h)
				rep(j,w)
					c[k][j]=s[k][j];
			queue<P> que;
			que.push(P(0,0));
			visit[0][0]=1;
	memset(visit,0,sizeof(visit));
			while(!que.empty()){
				P p=que.front();
				que.pop();
				c[p.first][p.second]=i;
				rep(z,4){
					int nx=p.second+dx[z];
					int ny=p.first+dy[z];
					if(!(nx>=0&&nx<w&&ny>=0&&ny<h)||!(c[ny][nx]==s[0][0])||visit[ny][nx])
						continue;
					que.push(P(ny,nx));
					visit[ny][nx]=1;
					c[ny][nx]=i;
				}
			}
			func(c,now+1);
		}
	}
}
int main(){
	while(cin>>h>>w>>e,w||h||e){
		int s[10][10];
		ans=0;
		rep(i,h)
			rep(j,w)
				cin>>s[i][j];
		
		func(s,0);
		cout<<ans<<endl;
	
	return 0;
}

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

#include <iostream>
#include <queue>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int h, w, c;
int panel[8][8];

class node {
public:
	int panel[8][8], tmpPanel[8][8];
	int d;
	int area;
	node(int src[8][8]){
		memcpy(panel, src, sizeof(panel));
		memcpy(tmpPanel, panel, sizeof(panel));
		getArea(0, 0, panel[0][0]);
		area = 0;
		d = 0;
	}
	node(int src[8][8], int i, int _d=0){
		memcpy(panel, src, sizeof(panel));
		area = 0;
		flip(0, 0, this->panel[0][0], i);
		memcpy(tmpPanel, panel, sizeof(panel));
		getArea(0, 0, i);
		d = _d;
	}
	void flip(int x, int y, int c1, int c2) {
		this->panel[x][y] = c2;
		for (int i = 0; i < 4; i++) {
			int nextX = x + dx[i];
			int nextY = y + dy[i];
			if (0 <= nextX && nextX < w && 0 <= nextY && nextY < h && this->panel[nextX][nextY] == c1) {
				flip(nextX, nextY, c1, c2);
			}
		}
	}
	void getArea(int x, int y, int c) {
		tmpPanel[x][y] = -1;
		this->area++;
		for (int i = 0; i < 4; i++) {
			int nextX = x + dx[i];
			int nextY = y + dy[i];
			if (0 <= nextX && nextX < w && 0 <= nextY && nextY < h && this->tmpPanel[nextX][nextY] == c) {
				getArea(nextX, nextY, c);
			}
		}
	}
	bool operator < (const node& o) const {
		return this->area < o.area;
	}
};

void debug(node& n){
	cout << "Debug===========================" << endl;
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++)
			cout << n.panel[j][i] << " ";
		cout<< endl;
	}
	cout << n.area << endl;
}

int solve() {
	int maxArea = 0;
	node root(panel);
	priority_queue<node> q;
	q.push(root);
	while (!q.empty()) {
		node current = q.top();q.pop();
		//debug(current);
		if (current.panel[0][0] == c)
			maxArea = max(maxArea, current.area);
		for (int i = 1; i < 7; i++) {
			if (current.d + 1 == 6) continue;
			if (current.panel[0][0] == i) continue;
			if (current.d == 3 && i == c) continue;
			node next(current.panel, i, current.d + 1);
			q.push(next);
		}
	}
	return maxArea;
}

int main() {
	while (cin >> h >> w >> c, h || w || c) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> panel[j][i];
			}
		}
		cout << solve() << endl;
	}
}

Compiler output:
a.cc: In constructor 'node::node(int (*)[8])':
a.cc:15:17: error: 'memcpy' was not declared in this scope
   15 |                 memcpy(panel, src, sizeof(panel));
      |                 ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | using namespace std;
a.cc: In constructor 'node::node(int (*)[8], int, int)':
a.cc:22:17: error: 'memcpy' was not declared in this scope
   22 |                 memcpy(panel, src, sizeof(panel));
      |                 ^~~~~~
a.cc:22:17: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

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

int w,h,Col;
typedef pair<int,int> C;
typedef vector<vector<int> > P;
P V;

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

void on(P N,int count,int c){
	
	if(count==6) return;
	if(count==4)
		c=Col;

	int nc=N[0][0];
	queue<C> Q;
	Q.push(make_pair(0,0));
	bool used[8][8];
	memset(used,false,sizeof(used));

	int tres=0;
	while(!Q.empty()){
		C now=Q.front();
		Q.pop();
		if(used[now.first][now.second]) continue;
		used[now.first][now.second]=true;
		N[now.first][now.second]=c;
		tres++;
		for(int r=0;r<4;r++){
			int ny=now.first+dy[r],nx=now.second+dx[r];
			if(ny<0 || nx<0 || ny>=h || nx>=w) continue;
			if(N[ny][nx]==nc)
				Q.push(make_pair(ny,nx));
		}
		res=max(res,tres);
	}

	for(int i=1;i<=6;i++)
		on(N,count+1,i);
}


void solve(){
	res=0;
	V.clear();
	V.resize(h);

	for(int y=0;y<h;y++)
		for(int x=0;x<w;x++){
			int t;
			cin>>t;
			V[y].push_back(t);
		}
	
	for(int i=1;i<=6;i++){
		 on(V,0,i);
	}

	cout<<res<<endl;

}



int main()
{
	while(cin>>h>>w>>Col){
		if(w==0) break;
		solve();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void on(P, int, int)':
a.cc:26:9: error: 'memset' was not declared in this scope
   26 |         memset(used,false,sizeof(used));
      |         ^~~~~~
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 <iostream>
#include <queue>
#include <cmath>

using namespace std;

typedef struct a
{
	int x; 
	int y;
}coordin;

int h,w,c;
int res = 0;
int maze [8][8];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

void changeColor(int tmp[8][8],int color)
{
	int originColor = tmp[0][0];
	queue <coordin> q;
	coordin cc;
	cc.x = 0; cc.y = 0;

	q.push(cc);
	tmp[0][0] = color;
	
	while (!q.empty())
	{
		cc = q.front();
		q.pop();

		for (int i=0;i<4;++i)
		{
			int tmp_x = cc.x + dx[i];
			int tmp_y = cc.y + dy[i];
			
			if (0<= tmp_x && tmp_x < w && 0<= tmp_y && tmp_y < h)
			{
				if (tmp[tmp_x][tmp_y] == originColor)
				{	
					coordin tmp_cc;
					tmp_cc.x = tmp_x;
					tmp_cc.y = tmp_y;
					if (color != originColor) q.push(tmp_cc);
					tmp[tmp_x][tmp_y] = color;
				}
				
			}
		}
	}
	
	return;
	
}

int cnt(int m[8][8], int x, int y)
{
    int count=1;
    int oc = m[x][y];
    m[x][y] = 0;
    for(int i=0; i<4; i++)
    {
        int tmp_x = x+dx[i];
        int tmp_y = y+dy[i];
        if(0<=tmp_x && tmp_x<w && 0<=tmp_y && tmp_y<h)
        {
            if(m[tmp_x][tmp_y]==oc) count+=cnt(m, tmp_x, tmp_y);
        }
    }
    return count;
}

int dfs(int m[8][8],int depth)
{
	if (depth == 4)
	{
		if(m[0][0]!=c) changeColor(m,c);
		return cnt(m,0,0);
	}
	
	for (int i=1;i<=6;++i)
	{
		int tmp_m[8][8];
		memcpy(tmp_m,m,sizeof(tmp_m));
		
		if (tmp_m[0][0] != i) changeColor(tmp_m,i);
		res = max(res,dfs(tmp_m,depth+1));
	}
	
	return res;
}

int main()
{
	cin>>h>>w>>c;
	
	while (h!=0)
	{
		for (int i=0;i<h;++i)
			for (int j=0;j<w;++j)
				cin>>maze[j][i];
		
		cout<<dfs(maze,0)<<endl;
		res = 0;
		cin>>h>>w>>c;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int (*)[8], int)':
a.cc:86:17: error: 'memcpy' was not declared in this scope
   86 |                 memcpy(tmp_m,m,sizeof(tmp_m));
      |                 ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cmath>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <queue>
#include <iostream>
#include <utility>

using namespace std;

int h,w,c,ans;

void dfs(int dep,int a[][8]){
	int x,y,dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	if(dep==5){
		int t=1;
		if(c==a[0][0]){
			queue<pair<int,int> > q;
			q.push(make_pair(0,0));
			a[0][0]=-1;
			while(!q.empty()){
				x=q.front().first,y=q.front().second,q.pop();
				for(int i=0;i<4;i++){
					int nx=x+dx[i],ny=y+dy[i];
					if(nx<0||nx>=w||ny<0||ny>=h) continue;
					if(nx<0||nx>=w||ny<0||ny>=h||a[ny][nx]!=c) continue;
					t++;
					q.push(make_pair(nx,ny));
					a[ny][nx]=-1;
				}
			}
		}
		ans=max(ans,t);
		return;
	}
	int tmp[8][8];
	memcpy(tmp,a,sizeof(a));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) tmp[i][j]=a[i][j];
	for(int col=1;col<=6;col++){
		if(a[0][0]==col) dfs(dep+1,a);
		else{
			int p = a[0][0];
			a[0][0]=col;
			queue<pair<int,int> > q;
			q.push(make_pair(0,0));
			while(!q.empty()){
				x=q.front().first,y=q.front().second,q.pop();
				for(int i=0;i<4;i++){
					int nx=x+dx[i],ny=y+dy[i];
					if(nx<0||nx>=w||ny<0||ny>=h||a[ny][nx]!=p) continue;
					q.push(make_pair(nx,ny));
					a[ny][nx]=col;
				}
			}
			dfs(dep+1,a);
		}
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) a[i][j]=tmp[i][j];
		//memcpy(tmp,a,sizeof(a));
	}
	return;
}

int main(){
	int a[8][8];
	while(cin>>h>>w>>c,h||w||c){
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[i][j];
		ans=0;
		dfs(0,a);
		cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int (*)[8])':
a.cc:33:29: warning: 'sizeof' on array function parameter 'a' will return size of 'int (*)[8]' [-Wsizeof-array-argument]
   33 |         memcpy(tmp,a,sizeof(a));
      |                            ~^~
a.cc:9:22: note: declared here
    9 | void dfs(int dep,int a[][8]){
      |                  ~~~~^~~~~~
a.cc:33:9: error: 'memcpy' was not declared in this scope
   33 |         memcpy(tmp,a,sizeof(a));
      |         ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <utility>
  +++ |+#include <cstring>
    4 |
Language: C++

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

vector< vector<bool> > getunion(vector< vector<int> >& base){
	vector< vector<bool> > ret;
	stack< pair<int,int> > nxt;
	int xmax=base[0].size();
	int ymax=base.size();
	int tar=base[0][0];
	int curx,cury;
	ret.resize(ymax);
	for(int i=0;i<ymax;i++)ret[i].resize(xmax);
	nxt.push(pair<int,int>(0,0));
	while(!nxt.empty()){
		curx=nxt.top().first;
		cury=nxt.top().second;
		nxt.pop();
		if(base[cury][curx]==tar&&!ret[cury][curx]){
			ret[cury][curx]=true;
			if(curx>0)nxt.push(pair<int,int>(curx-1,cury));
			if(curx<xmax-1)nxt.push(pair<int,int>(curx+1,cury));
			if(cury>0)nxt.push(pair<int,int>(curx,cury-1));
			if(cury<ymax-1)nxt.push(pair<int,int>(curx,cury+1));
		}
	}
	return ret;
}

vector< vector<int> >ccolor(vector< vector<int> >& base,int color){
	vector< vector<int> > ret;
	vector< vector<bool> > uni=getunion(base);;
	int ymax=base.size();
	int xmax=base[0].size();
	ret=base;
	for(int i=0;i<ymax;i++){
		for(int j=0;j<xmax;j++){
			if(uni[i][j])ret[i][j]=color;
		}
	}
	return ret;
}

int score(vector< vector<int> >& base){
	vector< vector<bool> > get=getunion(base);
	int ymax=get.size();
	int xmax=get[0].size();
	int ret=0;
	for(int i=0;i<ymax;i++){
		for(int j=0;j<xmax;j++){
			if(get[i][j])ret++;
		}
	}
	return ret;
}

int cal(vector< vector<int> >& base,int target,int count){
	if(count==1){
		return score(ccolor(base,target));
	}else{
		vector< vector<int> > cald;
		int max=0,get;
		// 最大色数指定
		for(int i=1;i<7;i++){
			if(i!=base[0][0]){
				cald=ccolor(base,i);
				get=cal(cald,target,count-1);
				if(get>max)max=get;
			}
		}
		return max;
	}
}

int main(){
	int xsize,ysize,target;
	vector< vector<int> > base;
	while(true){
		cin>>xsize>>ysize>>target;
		if(xsize==0)break;
		base.resize(ysize);
		for(int i=0;i<ysize;i++){
			base[i].resize(xsize);
			for(int j=0;j<xsize;j++){
				cin>>base[i][j];
			}
		}
		cout<<cal(base,target,5)<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int cal(std::vector<std::vector<int> >&, int, int)':
a.cc:60:36: error: cannot bind non-const lvalue reference of type 'std::vector<std::vector<int> >&' to an rvalue of type 'std::vector<std::vector<int> >'
   60 |                 return score(ccolor(base,target));
      |                              ~~~~~~^~~~~~~~~~~~~
a.cc:45:34: note:   initializing argument 1 of 'int score(std::vector<std::vector<int> >&)'
   45 | int score(vector< vector<int> >& base){
      |           ~~~~~~~~~~~~~~~~~~~~~~~^~~~
Language: C++

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

vector< vector<bool> > getunion(vector< vector<int> >& base){
	vector< vector<bool> > ret;
	stack< pair<int,int> > nxt;
	int xmax=base[0].size();
	int ymax=base.size();
	int tar=base[0][0];
	int curx,cury;
	ret.resize(ymax);
	for(int i=0;i<ymax;i++)ret[i].resize(xmax);
	nxt.push(pair<int,int>(0,0));
	while(!nxt.empty()){
		curx=nxt.top().first;
		cury=nxt.top().second;
		nxt.pop();
		if(base[cury][curx]==tar&&!ret[cury][curx]){
			ret[cury][curx]=true;
			if(curx>0)nxt.push(pair<int,int>(curx-1,cury));
			if(curx<xmax-1)nxt.push(pair<int,int>(curx+1,cury));
			if(cury>0)nxt.push(pair<int,int>(curx,cury-1));
			if(cury<ymax-1)nxt.push(pair<int,int>(curx,cury+1));
		}
	}
	return ret;
}

vector< vector<int> >ccolor(vector< vector<int> >& base,int color){
	vector< vector<int> > ret;
	vector< vector<bool> > uni=getunion(base);;
	int ymax=base.size();
	int xmax=base[0].size();
	ret=base;
	for(int i=0;i<ymax;i++){
		for(int j=0;j<xmax;j++){
			if(uni[i][j])ret[i][j]=color;
		}
	}
	return ret;
}

int score(vector< vector<int> >& base){
	vector< vector<bool> > get=getunion(base);
	int ymax=get.size();
	int xmax=get[0].size();
	int ret=0;
	for(int i=0;i<ymax;i++){
		for(int j=0;j<xmax;j++){
			if(get[i][j])ret++;
		}
	}
	return ret;
}

int cal(vector< vector<int> >& base,int target,int count){
	if(count==1){
		return score(ccolor(base,target));
	}else{
		vector< vector<int> > cald;
		int max=0,get;
		// 最大色数指定
		for(int i=1;i<7;i++){
			if(i!=base[0][0]){
				cald=ccolor(base,i);
				get=cal(cald,target,count-1);
				if(get>max)max=get;
			}
		}
		return max;
	}
}

int main(){
	int xsize,ysize,target;
	vector< vector<int> > base;
	while(true){
		cin>>xsize>>ysize>>target;
		if(xsize==0)break;
		base.resize(ysize);
		for(int i=0;i<ysize;i++){
			base[i].resize(xsize);
			for(int j=0;j<xsize;j++){
				cin>>base[i][j];
			}
		}
		cout<<cal(base,target,5)<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int cal(std::vector<std::vector<int> >&, int, int)':
a.cc:61:36: error: cannot bind non-const lvalue reference of type 'std::vector<std::vector<int> >&' to an rvalue of type 'std::vector<std::vector<int> >'
   61 |                 return score(ccolor(base,target));
      |                              ~~~~~~^~~~~~~~~~~~~
a.cc:46:34: note:   initializing argument 1 of 'int score(std::vector<std::vector<int> >&)'
   46 | int score(vector< vector<int> >& base){
      |           ~~~~~~~~~~~~~~~~~~~~~~~^~~~
Language: C++

#include <iostream>

#define loop(x) for(int x=1;x<=6;x++)

using namespace std;

void change(int[10][10],int,int,int);
int count(int[10][10],int,int);

int main(void){
	for(int h,w,c;cin >> h >> w >> c,h||w||c;){
		int fld[10][10]={0};
		int max=0,tmp;

		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)
				cin >> fld[i][j];

		loop(i){
			int cpy1[10][10];
			memcpy(cpy1,fld,sizeof(fld));
			change(cpy1,1,1,i);
			loop(j){
				int cpy2[10][10];
				memcpy(cpy2,cpy1,sizeof(cpy1));
				change(cpy2,1,1,j);
				loop(k){
					int cpy3[10][10];
					memcpy(cpy3,cpy2,sizeof(cpy2));
					change(cpy3,1,1,k);
					loop(l){
						int cpy4[10][10];
						memcpy(cpy4,cpy3,sizeof(cpy3));
						change(cpy4,1,1,l);
						change(cpy4,1,1,c);
						tmp=count(cpy4,1,1);
						max=max>tmp?max:tmp;
					}
				}
			}

		}
		cout << max << endl;
	}

	return 0;
}

void change(int fld[10][10],int x,int y,int col){
	int cul=fld[x][y];

	if(cul!=col){
		fld[x][y]=col;
		if(fld[x+1][y]==cul)
			change(fld,x+1,y,col);
		if(fld[x-1][y]==cul)
			change(fld,x-1,y,col);
		if(fld[x][y+1]==cul)
			change(fld,x,y+1,col);
		if(fld[x][y-1]==cul)
			change(fld,x,y-1,col);
	}
}

int count(int fld[10][10],int x,int y){
	int c=1,cul=fld[x][y];

	fld[x][y]=-1;
	if(fld[x+1][y]==cul)
		c+=count(fld,x+1,y);
	if(fld[x-1][y]==cul)
		c+=count(fld,x-1,y);
	if(fld[x][y+1]==cul)
		c+=count(fld,x,y+1);
	if(fld[x][y-1]==cul)
		c+=count(fld,x,y-1);

	return c;
}

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

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <utility>

using namespace std;
typedef long long ll;

#define ALL(c) begin((c)), end((c))
#define REP(i,n) for(ll i=0;i<(ll)n;++i)
inline int getInt() { int s; scanf("%d", &s); return s; }

#define SIZE 10
typedef array<array<int, SIZE>, SIZE> Table;

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

void fillColor(Table & state, int from, int to, int x, int y){
	if (from==to) return;
	REP(i, 4){
		if(state[y+dy[i]][x+dx[i]] != from) continue;
		state[y+dy[i]][x+dx[i]] = to;
		fillColor(state, from, to, x+dx[i], y+dy[i]);
	}
}

int countColor(Table & state, int x, int y){
	int cnt = 0;
	REP(i, 4) {
		if (state[y + dy[i]][x + dx[i]] != g_c) continue;
		state[y + dy[i]][x + dx[i]] = -1;
		cnt += 1 + countColor(state, x + dx[i], y + dy[i]);
	}
	return cnt;
}

int recursion(int depth, Table state) {
	if (depth > 5) return countColor(ntable, 1, 1);
	
	int cnt = 1;
	REP(i, 6) {
		if(depth==5 && i != g_c) continue;
		Table ntable = state;
		ntable[1][1] = i;
		fillColor(ntable, state[1][1], i, 1, 1);
		cnt = max(recursion(depth+1, ntable),cnt);
	}
	return cnt;
}

int main() {
	while (true) {
		ll h,w;
		cin >> h >> w 
		if (h == 0) break;
		
		g_c = getInt() - 1;
		Table table;
		REP(y, SIZE) REP(x, SIZE) table[y][x] = -1;
		REP(y, h) REP(x, w) table[y + 1][x + 1] = getInt()-1;
		cout << walk(1, table) << endl;
	}
}

Compiler output:
a.cc: In function 'int recursion(int, Table)':
a.cc:42:42: error: 'ntable' was not declared in this scope; did you mean 'Table'?
   42 |         if (depth > 5) return countColor(ntable, 1, 1);
      |                                          ^~~~~~
      |                                          Table
a.cc: In function 'int main()':
a.cc:58:30: error: expected ';' before 'if'
   58 |                 cin >> h >> w
      |                              ^
      |                              ;
   59 |                 if (h == 0) break;
      |                 ~~            
a.cc:65:25: error: 'walk' was not declared in this scope
   65 |                 cout << walk(1, table) << endl;
      |                         ^~~~