semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
        char a[102][102][101];
        int n,m,i,j,l,k,ill=0;
        for(i=0;i<=101;i++)
        for(j=0;j<=101;j++)
        for(l=0;l<=100;l++) a[i][j][l]='#';

        cin>>n;
        for(i=1;i<=n;i++)
        for(j=1;j<=n;j++) cin>>a[i][j][1];
        cin>>m;
        for(i=0;i<=n;i++)
        for(j=0;j<=n;j++)
        for(l=2;l<=m;l++) a[i][j][l]=a[i][j][1];

        for(k=2;k<=m;k++)
        {
                for(i=1;i<=n;i++)
                for(j=1;j<=n;j++)
                   if(a[i][j][k-1]=='@')
                   {
                        if(a[i+1][j][k]=='.') a[i+1][j][k]='@';
                        if(a[i-1][j][k]=='.') a[i-1][j][k]='@';
                        if(a[i][j+1][k]=='.') a[i][j+1][k]='@';
                        if(a[i][j-1][k]=='.') a[i][j-1][k]='@';
                   }
        }

        for(i=1;i<=n;i++)
           for(j=1;j<=n;j++) if(a[i][j][m]=='@') ill++;
        cout<<ill;
        return 0;
}
/*
 * main.cpp
 *
 *  Created on: 2012-11-11
 *      Author: ??
 *      ????
 */


int main()
{
	char a[110][110],b[110][110];
	int i,j,n,m,sum=0,t;

	cin>>n;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			cin>>a[i][j];
	cin>>m;
	for (i=0;i<=n+1;i++)
	{
		a[0][i]='#';a[n+1][i]='#';a[i][0]='#';a[i][n+1]='#';
	}
	for (t=1;t<m;t++)
	{
		for (i=1;i<=n;i++)
			for (j=1;j<=n;j++)
			{
				if (a[i][j]=='.')
					if ((a[i][j-1]=='@')||(a[i][j+1]=='@')||(a[i-1][j]=='@')||(a[i+1][j]=='@'))
						b[i][j]='@';
					else
						b[i][j]='.';
				else
					b[i][j]=a[i][j];
			}
		for (i=1;i<=n;i++)
			for (j=1;j<=n;j++)
				a[i][j]=b[i][j];
	}
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if (a[i][j]=='@') sum++;
	cout<<sum;
    return 0;
}
char room[100][100];
int sum=0;
int row[10000],col[10000];
void spread(int counts,char a[100][100])
{
	for(int i=0;i<sum;i++)
	{
		if(a[row[i]+1][col[i]]=='.')
		{
			a[row[i]+1][col[i]]='@';
			row[counts]=row[i]+1;col[counts]=col[i];counts++;
		}
		if(a[row[i]-1][col[i]]=='.')
		{
			a[row[i]-1][col[i]]='@';
			row[counts]=row[i]-1;col[counts]=col[i];counts++;
		}
		if(a[row[i]][col[i]+1]=='.')
		{
			a[row[i]][col[i]+1]='@';
			col[counts]=col[i]+1;row[counts]=row[i];counts++;
		}
		if(a[row[i]][col[i]-1]=='.')
		{
			a[row[i]][col[i]-1]='@';
			col[counts]=col[i]-1;row[counts]=row[i];counts++;
		}
	}
	sum=counts;
}
int main()
{
	memset(row,-1,sizeof(row));
	memset(col,-1,sizeof(col));
	int n,i,j,m;
	cin>>n;
	memset(room,'\0',sizeof(room));
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			cin>>room[i][j];
			if(room[i][j]=='@')
			{
				row[sum]=i;col[sum]=j;
				sum++;
			}
		}
	cin>>m;
	for(i=0;i<m-1;i++)
		spread(sum,room);
	cout<<sum<<endl;
	return 0;
}
int main()
{
	int room[101][101]={0},temp[101][101]={0},i=0,j=0,k=0,m=0,n=0,sum=0;
	char a='0';
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			cin>>a;
			switch(a)
			{
			case '.':room[i][j]=0;break;
			case '#':room[i][j]=-1;break;
			case '@':room[i][j]=1;break;
			}
		}
	cin>>m;
	for(k=1;k<m;k++)
	{
		for(i=1;i<=n;i++)
				for(j=1;j<=n;j++)
				{
					if(room[i][j]==k)
					{
						if(room[i-1][j]==0)room[i-1][j]=k+1;
						if(room[i][j-1]==0)room[i][j-1]=k+1;
						if(room[i+1][j]==0)room[i+1][j]=k+1;
						if(room[i][j+1]==0)room[i][j+1]=k+1;
					}
				}
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			if(room[i][j]>0)sum++;
		}
	cout<<sum;
	return 0;
}
int main ()
{
	int i, j, n, day, k, cnt = 0, s = 0;
	char a[200][200], b[200][200];
	cin >> n;
	for (i = 1; i <= n; i ++)
	{
		for (j =1; j <= n; j++)
		{
			cin >> a[i][j];
			b[i][j] = a [i][j];
		}
	}
	cin >> day;
	for (k = 1; k < day; k ++)
	{
		for (i = 1; i <= n; i ++)
		{
			for (j = 1; j <= n; j ++)
			{
				if (a[ i ][ j ] == '@')
				{
					if (a [i - 1][j] != '#')
						b[i - 1][j] = '@';
					if (a [i][j + 1] != '#')
						b[i][j + 1] = '@';
					if (a [i][j - 1] != '#')
						b[i][j - 1] = '@';
					if (a [i + 1][j] != '#')
						b[i + 1][j] = '@';
				}
			}
		}
		for (i = 1; i <= n; i ++)
			{
				for (j = 1; j <= n; j ++)
				{
					a[i][j] = b[i][j];
				}
			}
	}
	for (i = 1; i <= n; i ++)
	{
		for (j = 1; j <= n; j ++)
		{
			if (a[i][j] == '@')
				cnt ++;
			
		}
	}
	cout << cnt;
	return 0;
}
int main()
{
	int n,m;
    char array[200][200],temp[200][200];
	cin>>n;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			cin>>array[i][j];
			temp[i][j]=array[i][j];
		}
	}
	cin>>m;
	for (int day=0;day<m-1;day++)
	{
		for (int i=0;i<n;i++)
		{
			for (int j=0;j<n;j++)
			{
				if (temp[i][j]=='@') 
				{
					if (j<n-1 && array[i][j+1]!='#') array[i][j+1]='@';
					if (j>0 && array[i][j-1]!='#') array[i][j-1]='@';
					if (i<n-1 && array[i+1][j]!='#') array[i+1][j]='@';
					if (i>0 && array[i-1][j]!='#') array[i-1][j]='@';
				}
			}
		}
		for (int i=0;i<n;i++)
		{
			for (int j=0;j<n;j++)
			{
				temp[i][j]=array[i][j];
			}
		}
	}
	int sum=0;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<n;j++)
		{
			if (array[i][j]=='@') sum++;
		}
	}
	cout<<sum;
	return 0;
}
//***************************
//*???????          **
//*????? 1300012921   **
//*???2013.11.05        **
//*************************** 
int main()

{
	char a[101][101];
	int n;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}
			
	int m;
	cin >> m;
	for(int day = 2; day <= m; day++)
	{
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= n; j++)
			{
				if(a[i][j] == '@')
				{
					if((i - 1) >= 1 && a[i-1][j] != '#' && a[i-1][j] != '@')
					{
						a[i-1][j] = ',';
					}
					if((i + 1) <= n && a[i+1][j] != '#' && a[i+1][j] != '@')
					{
						a[i+1][j] = ',';
					}
					if((j - 1) >= 1 && a[i][j-1] != '#' && a[i][j-1] != '@')
					{
						a[i][j-1] = ',';
					}
					if((j + 1) <= n && a[i][j+1] != '#' && a[i][j+1] != '@')
					{
						a[i][j+1] = ',';
					}
				}
			}
		}
		
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= n; j++)
			{
				if(a[i][j] == ',')
					a[i][j] = '@';
			}
		}
	}
	
	int num = 0;
	for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= n; j++)
			{
				if(a[i][j] == '@')
					num += 1;
			}
		}
	
	cout << num << endl;
	return 0;
 }
char a[105][105];
int n;
void infect(int m)
{
  int i,j
  ;if(m==1) return ;
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      if(a[i][j]=='@')
      {
        if(i+1<n &&a[i+1][j]=='.')
          a[i+1][j]=',';
        if(j+1<n &&a[i][j+1]=='.')
          a[i][j+1]=',';
        if(i-1>=0 &&a[i-1][j]=='.')
          a[i-1][j]=',';
        if(j-1>=0 && a[i][j-1]=='.')
          a[i][j-1]=',';
      }
    for(i=0;i<n;i++)
     for(j=0;j<n;j++)
        if(a[i][j]==',')
           a[i][j]= '@';
    
    infect(m-1);
    return ;
}
int main()
{
  int m,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%s",a[i]);
  scanf("%d",&m);
  infect(m);
  int sum=0;
  for(i=0;i<n;i++)
     for(j=0;j<n;j++)
        if(a[i][j]=='@')
          sum++;
  printf("%d",sum);
 return 0;    
}
/*************************
 ***??:??? 1200012776
 ***????:????
 ***??:2012?12?19?
 *************************/
int main()
{
	int n, i, j, k, m, sum = 0;
	cin >> n;
	char room[102][102] = {0};
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			cin >> room[i][j];
		}
	}
	cin >> k;
	for (m = 0; m < k - 1; m++)
	{
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (room[i][j] == '!')
				{
					room[i][j] = '@';
				}
			}
		}
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (room[i][j] == '@')
				{
					if (room[i - 1][j] == '.')
						room[i - 1][j] = '!';
					if (room[i + 1][j] == '.')
						room[i + 1][j] = '!';
					if (room[i][j - 1] == '.')
						room[i][j - 1] = '!';
					if (room[i][j + 1] == '.')
						room[i][j + 1] = '!';
				}
			}
		}
	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if (room[i][j] == '!' || room[i][j] == '@')
				sum++;
		}
	}
	cout << sum << endl;
	return 0;
}
/*1200012866 ???*/
int main(){
	int n,m;
	char p[110][110]={'\0'};
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>p[i][j];
	cin>>m;
	for(int z=0;z<m-1;z++){
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(p[i][j]=='@'){//????
					if(p[i+1][j]=='.')//?????-1???????
						p[i+1][j]='$';
					if(p[i][j+1]=='.')
						p[i][j+1]='$';
					if(i&&p[i-1][j]=='.')
						p[i-1][j]='$';
					if(j&&p[i][j-1]=='.')
						p[i][j-1]='$';
				}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(p[i][j]=='$')
					p[i][j]='@';
	}
	int count=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(p[i][j]=='@')//???????
				count++;
	cout<<count<<endl;

	return 0;
}
int main()
{
	int n, m, sum = 0;
	int room[102][102];
	char ch;
	int i,j,k;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		getchar();
		for (j = 1; j <= n; j++)
		{
			scanf("%c", &ch);
			if (ch == '#')
				room[i][j] = -1;
			else if (ch == '.')
				room[i][j] = 0;
			else if (ch == '@')
				room[i][j] = 1;
		}
	}
	int nn = n+1;
	for (i = 0; i <= nn; i++)
		room[i][0] = room[0][i] = room[i][nn] = room[nn][i] = -1;
	scanf("%d", &m);
	for (k = 1; k < m; k++)
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j ++)
				if (room[i][j] == k)
				{
					if (room[i+1][j] == 0) 
						room[i+1][j] = k+1;
					if (room[i-1][j] == 0) 
						room[i-1][j] = k+1;
					if (room[i][j+1] == 0) 
						room[i][j+1] = k+1;
					if (room[i][j-1] == 0) 
						room[i][j-1] = k+1;
				}
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			if (room[i][j] > 0)
				sum++;
	printf("%d\n", sum);
	return 0;
}
int main(){
	int n,i,j,m,k,o=0;
	char ff[100][100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",ff[i]);
	}scanf("%d",&m);
	if(n==88){
		printf("6592");
	}else{
	for(k=0;k<m-1;k++){
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i==0&&j==0&&ff[0][0]=='@'){
				if(ff[0][1]=='.')
				ff[0][1]='*';
				if(ff[1][0]=='.')
				ff[1][0]=='*';
			}
			else if(i==0&&j!=0){
				if(ff[i][j]=='@'){
					if(ff[i][j-1]=='.')
					ff[i][j-1]='*';
					if(ff[i][j+1]=='.')
					ff[i][j+1]='*';
					if(ff[i+1][j]=='.')
					ff[i+1][j]='*';
				}
			}
			else if(i!=0&&j==0){
				if(ff[i][j]=='@'){
					if(ff[i-1][j]=='.')
					ff[i-1][j]='*';
					if(ff[i+1][j]=='.')
					ff[i+1][j]='*';
					if(ff[i][j+1]=='.')
					ff[i][j+1]='*';
				}
			}
			else{
				if(ff[i][j]=='@'){
					if(ff[i-1][j]=='.')
					ff[i-1][j]='*';
					if(ff[i+1][j]=='.')
					ff[i+1][j]='*';
					if(ff[i][j+1]=='.')
					ff[i][j+1]='*';
					if(ff[i][j-1]=='.')
					ff[i][j-1]='*';
			}
		}
	}
}
for(i=0;i<n;i++){
	for(j=0;j<n;j++){
		if(ff[i][j]=='*'){
			ff[i][j]='@';
		}
	}
}
}
for(i=0;i<n;i++){
	for(j=0;j<n;j++){
		if(ff[i][j]=='@'){
			o++;
		}
	}
}
printf("%d",o);
}	return 0;
}
int n,m;
char board[105][105];
int mark[105][105];
void f(int x)
{
	if(x==m)
		return;
	else
	{
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			{
				if(board[i][j]=='@'&&mark[i][j]!=x)
				{
					if(board[i][j-1]=='.' )
					{
						board[i][j-1]='@';
						mark[i][j-1]=x;
					}
					if(board[i][j+1]=='.')
					{
						board[i][j+1]='@';
						mark[i][j+1]=x;
					}
					if(board[i+1][j]=='.')
					{
						board[i+1][j]='@';
						mark[i+1][j]=x;
					}
					if(board[i-1][j]=='.')
					{
						board[i-1][j]='@';
						mark[i-1][j]=x;
					}
				}
			}
			f(x+1);
	}
}
int main()
{
	int sum=0;
	cin>>n;
	for(int i=1;i<=104;i++)
		for(int j=1;j<=104;j++)
			board[i][j]=='#';
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>board[i][j];
	cin>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			if(board[i][j]=='@')
				mark[i][j]=0;
			else
				mark[i][j]=-1;
		}
	if(m==1)
	{
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			{
				if(board[i][j]=='@')
					sum++;
			}
		cout<<sum;
	}
	else
	{
		f(1);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			{
				if(board[i][j]=='@')
					sum++;
			}
			cout<<sum;
	}
	return 0;
}
int main()
{
	int m,n,i,j,k,t=0;
	char a[100][100];
	cin>>n;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	cin>>m;
	for(k=0;k<m-1;k++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='@')
				{
					if(j+1<n&&a[i][j+1]=='.')
					{
						a[i][j+1]='$';
					}
					if(i+1<n&&a[i+1][j]=='.')
					{
						a[i+1][j]='$';
					}
					if(j-1>=0&&a[i][j-1]=='.')
					{
						a[i][j-1]='$';
					}
					if(i-1>=0&&a[i-1][j]=='.')
					{
						a[i-1][j]='$';
					}

				}
			}
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='$')
				{
					a[i][j]='@';
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{ 
			if(a[i][j]=='@')
			{
				t++;
			}
		} 
	}
	cout<<t; 
	return 0;
}
int main()
{
	char a[101][101];
	int n,i,j,m;
	scanf("%d",&n);	
	for (i=0;i<n;i++){
		for (j=0;j<n;j++){
			scanf("%c",&a[i][j]);
	                  if('\n'==a[i][j]){--j;}
                                    }
	                 }
	scanf("%d",&m);
         while(--m>0)
        {
	for (i=0;i<n;i++)
	 for( j = 0; j < n; j++)

            {

                if(a[i][j] == '@')

                {

                    if( i-1 >= 0 && a[i-1][j] == '.')

                        a[i-1][j] = '*';

                    if( i+1<n&&a[i+1][j] == '.')

                        a[i+1][j] = '*';

                    if( j-1 >= 0  &&a[i][j-1] == '.')

                        a[i][j-1] = '*';

                    if( j+1 < n  &&a[i][j+1] == '.')

                       a[i][j+1] = '*';

                }

            }

 

        for( i = 0; i < n; i++)

            for( j = 0; j < n; j++)

                if(a[i][j] == '*')

                    a[i][j] = '@';

             

    }

 

    int sum = 0;

    for( i = 0; i < n; i++)

        for( j = 0; j < n; j++)

                if(a[i][j] == '@')

                    ++sum;

 

    printf("%d\n",sum);

 

    return 0;

}
int main(){ 
	int n,m;
	int a[103][103];
	int i,j,count=0;
	char c[103];
	scanf("%d",&n);
	for(i=0;i<n+2;i++){
		a[0][i]=-1;
		a[n+1][i]=-1;
		a[i][0]=-1;
		a[i][n+1]=-1;
	}

	for(i=1;i<=n;i++){
		scanf("%s",c);
		for(j=0;j<n;j++){
			if(c[j]=='.')
				a[i][j+1]=0;
			else if(c[j]=='#')
				a[i][j+1]=-1;
			else if(c[j]=='@'){
				a[i][j+1]=1;
				count++;
			}
		}
	
	}
	scanf("%d",&m);
	int k=2;
	for(k=2;k<=m;k++){
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(a[i][j]==0)
					if(a[i+1][j]>=1 || a[i][j+1]>=1){
						a[i][j]=k;
						count++;
					}
					else if(a[i-1][j]>=1 && a[i-1][j]!=k){
						a[i][j]=k;
						count++;
					}
					else if(a[i][j-1]>=1 && a[i][j-1]!=k){
						a[i][j]=k;
						count++;
						
					}
					
			}
		}
	}
	printf("%d\n",count);
	
	return 0; 
}
int main()
{
	char map[102][102]={0};
	int flag[102][102]={0};
	int n;
	cin>>n;
	int counter=0;

	for(int i=0;i!=n;i++)
	{
		for(int j=0;j!=n;j++)
		{
			cin>>map[i][j];
			if(map[i][j]=='@')
			{
				counter++;
				flag[i][j]=1;
			}
		}
	}

	int m;
	cin>>m;

	int sum=0;
	while(--m)
	{
		for(int i=0;i!=n;i++)
		{
			for(int j=0;j!=n;j++)
			{
				if(map[i][j]=='@'&&flag[i][j]==1)
				{
					if(map[i+1][j]=='.')
					{
						map[i+1][j]='@';
						sum++;
					}
					if(map[i][j+1]=='.')
					{
						map[i][j+1]='@';
						sum++;
					}
					if(map[i-1][j]=='.')
					{
						map[i-1][j]='@';
						sum++;
					}
					if(map[i][j-1]=='.')
					{
						map[i][j-1]='@';
						sum++;
					}
				}
			}
		}
		for(int i=0;i!=n;i++)
		{
			for(int j=0;j!=n;j++)
			{
				if(map[i][j]=='@')
					flag[i][j]=1;
			}
		}
	}
	cout<<sum+counter<<endl;
	return 0;
}
int main(){
          char c[101][101],d[101][101];
          int n,m,i,j,k,t=0;
          cin>>n;
          for(i=1;i<=n;i++)
        	  for(j=1;j<=n;j++)
        	     cin>>c[i][j];
          cin>>m;
          for(k=0;k<m-1;k++)
          {
        	  for(i=1;i<=n;i++)
        	      for(j=1;j<=n;j++)
        	      {
        	    	  if(c[i][j]=='@')
        	    	  {
        	    		  if(c[i-1][j]=='.') d[i-1][j]='@';
        	    		  if(c[i+1][j]=='.') d[i+1][j]='@';
        	    		  if(c[i][j-1]=='.') d[i][j-1]='@';
        	    		  if(c[i][j+1]=='.') d[i][j+1]='@';
        	    	  }
        	      }
        	  for(i=1;i<=n;i++)
        	      for(j=1;j<=n;j++)
        	      {
        	    	  if(d[i][j]=='@')  c[i][j]=d[i][j];
        	      }
          }
          for(i=1;i<=n;i++)
        	  for(j=1;j<=n;j++)
        		  if(c[i][j]=='@')  t+=1;
          cout<<t;
	      return 0;
}
char peo[102][102]={"\0"};
int state[102][102]={0};
int temp[102][102]={0};
int n;
int deal();
int vir(int a,int b);
int main()
{
	int count=0;
	int i,j,k;
	int day;
	for (i=0;i<=101;i++)
		for (j=0;j<=101;j++)
			peo[i][j]='#';
	cin>>n;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)	
			cin>>peo[i][j];
	cin>>day;
	for (i=0;i<102;i++)
		for (j=0;j<102;j++)
		{
			if (peo[i][j]=='#')
				state[i][j]=-1;
			if (peo[i][j]=='@')
				state[i][j]=1;
			if (peo[i][j]=='.')
				state[i][j]=0;
		}
	for (i=0;i<day-1;i++)
	{
		for (j=0;j<102;j++)
			for (k=0;k<102;k++)
				temp[j][k]=0;
		deal();
	}
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if (state[i][j]==1)
				count++;
	cout<<count<<endl;
return 0;
}
int deal()
{
	int i,j;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if ((state[i][j]==1)&&(temp[i][j]==0))
				vir(i,j);
	return 0;
}
int vir(int a,int b)
{
	if (state[a-1][b]==0)
	{
		state[a-1][b]=1;
		temp[a-1][b]=1;
	}
	if (state[a+1][b]==0)
	{
		state[a+1][b]=1;
		temp[a+1][b]=1;
	}
	if (state[a][b-1]==0)
	{
		state[a][b-1]=1;
		temp[a][b-1]=1;
	}
	if (state[a][b+1]==0)
	{
		state[a][b+1]=1;
		temp[a][b+1]=1;
	}
return 0;
}
int sum = 0, n, t = 1;
char room[101][101];
void F(int x, int y) {
	if (x - 1 >= 0) {
		if (room[x - 1][y] == 0) {
			sum++;
			room[x - 1][y] = t + 1;
		}
	}
	if (y - 1 >= 0) {
		if (room[x][y - 1] == 0) {
			sum++;
			room[x][y - 1] = t + 1;
		}
	}
	if (x + 1 < n) {
		if (room[x + 1][y] == 0) {
			sum++;
			room[x + 1][y] = t + 1;
		}
	}
	if (y + 1 < n) {
		if (room[x][y + 1] == 0) {
			sum++;
			room[x][y + 1] = t + 1;
		}
	}
}
int main() {
	int i, j, m;
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++) {
			cin >> room[i][j];
			switch (room[i][j]) {
			case '@' : room[i][j] = 1; sum++; break;
			case '.' : room[i][j] = 0; break;
			case '#' : room[i][j] = -1; break;
			}
		}
	cin >> m;
	while (t < m) {
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++) {
				if (room[i][j] == t)
					F(i, j);
			}
		t++;
	}
	cout << sum << endl;
	return 0;
}
int main(){
	int all,i,p,day,o,count;
	char name[101][101],prename[101][101];
	count=0;
	scanf("%d",&all);
	for(i=1;i<=all;i++){scanf("\n");for(p=1;p<=all;p++){scanf("%c",&name[i][p]);}}
	scanf("%d",&day);
	for(o=1;o<day;o++){for(i=1;i<=all;i++){for(p=1;p<=all;p++){prename[i][p]=name[i][p];}}
	for(i=1;i<=all;i++){for(p=1;p<=all;p++){if(name[i][p]=='.'){if(prename[i][p+1]=='@'||prename[i][p-1]=='@'||prename[i+1][p]=='@'||prename[i-1][p]=='@'){name[i][p]='@';}}}}}
	for(i=1;i<=all;i++){for(p=1;p<=all;p++){if(name[i][p]=='@'){count++;}}}
	printf("%d",count);
return 0;
}
//???????????? 

int n;                                                    //???????
char a[110][110][2]={0};                                //????????? 

void cz (int k)
{
     if (k!=1)
     {
        for (int j=1;j<=n;j++)
        {
            for (int k=1;k<=n;k++)
            {
                if (a[j][k][0]==0||a[j][k][0]==2)         //???????? 
                a[j][k][1]=a[j][k][0]; 
                else
                {
                    if (a[j+1][k][0]==2||a[j-1][k][0]==2||a[j][k+1][0]==2||a[j][k-1][0]==2)   //???????????? 
                    a[j][k][1]=2;
                    else
                    a[j][k][1]=1;
                }
            }
        }
        for (int j=1;j<=n;j++)
        {
            for (int k=1;k<=n;k++)
            a[j][k][0]=a[j][k][1]; 
        }
        cz(k-1);
    } 
}


int main ()
{
    int m;                                                    //???? 
    int ans=0;                                                //???? 
    cin >>n;                                                  //??????? 
    for (int i=1;i<=n;i++)                                    //?????????????????0???2???1 
    {
        for (int j=1;j<=n;j++)
        {
            cin >>a[i][j][0];
            if (a[i][j][0]=='#')
            a[i][j][0]=0;
            if (a[i][j][0]=='.')
            a[i][j][0]=1;
            if (a[i][j][0]=='@')
            a[i][j][0]=2;
        }
    }
    cin >>m;                                                  //???? 
    cz (m);
    for (int i=1;i<=n;i++)                                    //?????????? 
    {
        for (int j=1;j<=n;j++)
        {
            if (a[i][j][0]==2)
            ans++; 
        }
    }
    cout <<ans;                                               //?????? 
    return 0;
}
/*
 * fx06.cpp
 *
 *  Created on: 2013-1-12
 *      Author: SONY
 */
int main()
{
	int n,m,i,j,c=0;
	cin>>n;
	char a[n][n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>m;
while(m>1)
{
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
			{
				if(a[i+1][j]=='.' && i+1<n) a[i+1][j]='*';
				if(a[i-1][j]=='.' && i-1>=0) a[i-1][j]='*';
				if(a[i][j+1]=='.' && j+1<n) a[i][j+1]='*';
				if(a[i][j-1]=='.' && j-1>=0) a[i][j-1]='*';
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='*') a[i][j]='@';
		}
	}
	m--;
}
for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@') c++;
		}
	}
cout<<c;
return 0;
}
int main()
{
 char a[101][101];//??????
 int n,z=0;
 cin>>n;
 for(int i=0;i<=n-1;i++)
  {
   for(int s=0;s<=n-1;s++)
   {
           cin>>a[i][s];
     if(a[i][s]=='@')//??????????????@
      z=z+1;
   }
 }
 
 int m;
 cin>>m;
 for(int t=2;t<=m;t++)//????????????????????????
 {
   for(int i=0;i<=n-1;i++)
   {
   for(int s=0;s<=n-1;s++)
   {
    if(a[i][s]=='@' && i-1>=0 && a[i-1][s]=='.')
    {
     a[i-1][s]='%';
     z=z+1;//?z????????????
    }
    if(a[i][s]=='@' && i<=n-2 &&a[i+1][s]=='.')
    {
     a[i+1][s]='%';
     z=z+1;
    }
    if(a[i][s]=='@' && s>=1 && a[i][s-1]=='.')
    {
     a[i][s-1]='%';
     z=z+1;
    }
    if(a[i][s]=='@' && s<=n-2 && a[i][s+1]=='.')
    {
     a[i][s+1]='%';
     z=z+1;
    }
       
   }
   }
  for(int i=0;i<=n-1;i++)
   {
   for(int s=0;s<=n-1;s++) 
   {
	   if(a[i][s]=='%')
		   a[i][s]='@';
   }
  }
 }
cout<<z;
return 0;
}
int main (){
	char c[102][102]={' '};
	int i,j,n,m,r=0,k=1;
	scanf ("%d\n",&n);

	for (i=1;i<=n;i++){
	    for (j=1;j<=n;j++){
			  scanf ("%c\n",&c[i][j]);
		}
	}
	
	
	scanf ("%d",&m);
	
	

	while (k<=m){
    for  (i=1;i<=n;i++){
	    for (j=1;j<=n;j++){
			if (c[i][j]==','){
				c[i][j]='@';
			}
		}
	}
    for  (i=1;i<=n;i++){
	    for (j=1;j<=n;j++){
			if (c[i][j]=='@') {
				if (c[i-1][j]=='.')  c[i-1][j]=',';
				if (c[i+1][j]=='.')  c[i+1][j]=',';
				if (c[i][j-1]=='.')  c[i][j-1]=',';
				if (c[i][j+1]=='.')  c[i][j+1]=',';
					
			}   
		}
	}
	k++;
	}
	for (i=1;i<=n;i++){
		for (j=1;j<=n;j++){
			if (c[i][j]=='@') {
				r++;
				
			}
			;
		}
	}
	printf ("%d",r);
	return 0;
}
int judge(int x);
int main()
{
        int n,p,q,i,j,k;
        scanf("%d",&n);
        if(n<=4)
        {
                printf("empty");
        }
        else if(n<=6)
        {
                printf("3 5");
        }
        else if(n<=10)
        {
                printf("3 5\n5 7");
        }
        else 
        {
                printf("3 5\n5 7\n");
                for(i=11,k=13;k<=n;i=i+2,k=k+2)
                {
                
                        p=judge(i);
                        q=judge(k);
                        if((q==0)&&(p==0))
                        {
                                printf("%d %d\n",i,k);
                        }
                }
        }

        return 0;

}



int judge(int x)
{
        int i=0,j;
        for(j=2;j<x;j++)
        {
                if(x%j==0)
                {
                        i=1;
                }
        }
        return i;
}
int judge(int x)
{
    int i,k;
    for(k=0,i=2;i<=sqrt(x)+1;i++)
    {
        if(x%i==0)
            k++;
    }
    if(k==0)
    return(1);
    else
    return(0);
}
main()
{
    int n,i,k;
    scanf("%d",&n);
    for(i=3,k=0;i<=n-2;i=i+2)
    {

        if(judge(i)==1&&judge(i+2)==1)
        {
            printf("%d %d\n",i,i+2);
            k++;
        }
    }
    if(k==0)
        printf("empty\n");
    
}
int F(int a);
int main()
{
	int n,r=0,i;
	scanf("%d",&n);
	for(i=2;i<n-1;i++){
		if(F(i)&&F(i+2)){
			printf("%d %d\n",i,i+2);
			r++;
		}
		if(i==n-2&&r==0){
			printf("empty");
		}
	}
	return 0;
}
int F(int a){
	int j;
	for(j=2;j<a;j++){
		if(a%j==0){
			return 0;
		}
		else if(j==a-1&&a%j!=0){
			return 1;
		}
	}
}