semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/*
 * END4.cpp
 * ????
 *  Created on: 2013-1-11
 *      Author: Administrator
 *      ???????m???????
 */
char state[100][100];
int sum=0,m,n;
void spread(int x,int y){
	if(x==-1 || x==n || y==-1 || y==n)//??
	{return;
	}
	if(state[x][y]=='.' ) {state[x][y]='@';}
/*	else if(state[x][y]=='#')*/
}
int main(){

	int i,j,k;
	cin>>n;
	for(i=0;i<n;i++)//?
		for(j=0;j<n;j++)//?
			cin>>state[i][j];
	cin>>m;
	for(k=1;k<m;k++)//??
	{ for(i=0;i<n;i++)//?
			for(j=0;j<n;j++)//?
			if(state[i][j]=='@')
					{state[i][j]='*';}
    	for(i=0;i<n;i++)//?
    		for(j=0;j<n;j++)//?
    			if(state[i][j]=='*'){
					spread(i-1,j);spread(i+1,j);spread(i,j-1);spread(i,j+1);}//4???
	   for(i=0;i<n;i++)
				for(j=0;j<n;j++)
					if(state[i][j]=='*')state[i][j]='@';}

	for(i=0;i<n;i++)//?
				for(j=0;j<n;j++)//?
					sum+=(state[i][j]=='@');
	cout<<sum<<endl;
	return 0;
}
int main ()
{
    
    int m;
    int n;
    int i , j ,d;
    int count = 0;
    cin >> n;
    char a[n+2][n+2];
    char b[n+2][n+2];
    for ( i = 0; i <= n+1; i++ )
    {
        for ( j = 0; j <= n+1 ; j++ )
        {
            a[i][j] = '#';
            b[i][j] = '#';
        }
    }
    
    
    
    for ( i = 1; i <= n; i++ )
    {
        for ( j = 1; j <= n; j++ )
        {
            cin >> a[i][j];
            b[i][j] = a[i][j];
        }
    }
    
    cin >> m;
    
    for ( d = 1; d <= m; d++ )
    {
        if ( d % 2 == 1 )
        {
             for ( i = 1; i <= n; i++ )
             {
                 for ( j = 1; j <= n; j++ )
                 {
                     if ( a[i][j] == '@' )
                     {
                          b[i][j] = '@';
                          if ( b[i-1][j] != '#' )
                               b[i-1][j] = '@';
                          if ( b[i+1][j] != '#' )
                               b[i+1][j] = '@';
                          if ( b[i][j-1] != '#' )
                               b[i][j-1] = '@';
                          if ( b[i][j+1] != '#' )
                               b[i][j+1] = '@';
                     }
                 }
             }
        }
        if ( d % 2 == 0 )
        {
             for ( i = 1; i <= n; i++ )
             {
                 for ( j = 1; j <= n; j++ )
                 {
                     if ( b[i][j] == '@' )
                     {
                          a[i][j] = '@';
                          if ( a[i-1][j] != '#' )
                               a[i-1][j] = '@';
                          if ( a[i+1][j] != '#' )
                               a[i+1][j] = '@';
                          if ( a[i][j-1] != '#' )
                               a[i][j-1] = '@';
                          if ( a[i][j+1] != '#' )
                               a[i][j+1] = '@';
                     }
                 }
             }
        }
    }
    
    for ( i = 1; i <= n; i++ )
    {
        for ( j = 1; j <= n; j++ )
        {
            if ( m % 2 == 1 )
            {
                 if ( a[i][j] == '@' )
                      count++;
            }
            if ( m % 2 == 0 )
            {
                 if ( b[i][j] == '@' )
                      count++;
            }
        }
    }
    
    cout << count << endl;

    
}
int main()
{
	int n,i,j,m,b[101][101],k,s=0;
	char a[101][101];
	for(i=0;i<=100;i++)
	{
		for(j=0;j<=100;j++)
		{
			a[i][j]='#';
			b[i][j]=0;
		}
	}
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	cin>>m;
	for(k=1;k<=m-1;k++)
	{

		for(i=0;i<=100;i++)
	{
		for(j=0;j<=100;j++)
		{
			if(a[i][j]=='@')
			{
				b[i][j]=1;
			}
			
		}
	}

		for(i=0;i<=100;i++)
	{
		for(j=0;j<=100;j++)
		{
			if(b[i][j]==1)
			{
				if(a[i+1][j]=='.')
				{
					a[i+1][j]='@';
				}

				if(a[i-1][j]=='.')
				{
					a[i-1][j]='@';
				}
				if(a[i][j+1]=='.')
				{
					a[i][j+1]='@';
				}
				if(a[i][j-1]=='.')
				{
					a[i][j-1]='@';
				}
				b[i][j]=0;
			}
			
		}
	}
	}
	s=0;
for(i=0;i<=100;i++)
	{
		for(j=0;j<=100;j++)
		{
			if(a[i][j]=='@')
			{
				s++;
			}
			
		}
	}
cout<<s;
	return 0;
}
int main()
{	
	int n, m, num = 0;
	char h[100][100];
	int i, j, k;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			cin >> h[i][j];
		}
	}
	cin >> m;
	for (k = 0; k < m - 1 ; k++)
	{
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				if (h[i][j] == '@')
				{
					if ((h[i][j + 1] == '.') && j != n - 1)
					{
						h[i][j + 1] = '*';
					}
					if ((h[i][j - 1] == '.') && j != 0)
					{
						h[i][j - 1] = '*';
					}
					if ((h[i + 1][j] == '.') && i != n - 1)
					{
						h[i + 1][j] = '*';
					}
					if ((h[i - 1][j] == '.') && i != 0)
					{
						h[i - 1][j] = '*';
					}
				}
			}
		}
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				if (h[i][j] == '*')
				{
					h[i][j] = '@';
				}
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			 if (h[i][j] == '@')
			 {num++;}
		}
	}
	cout << num << endl;
	return 0;
}
int main (){
    int n,b,j,i,k;
    scanf ("%d",&n);    
    char c[102][102],d[102][102],ttt;
scanf ("%c",&ttt);
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++)
        {
            scanf ("%c",&c[i][j]);
        }
        scanf ("%c",&ttt);
    }
    scanf ("%d",&b);
    for (i=1;i<=n;i++)
        {
            for (j=1;j<=n;j++)
            {
                d[i][j]=c[i][j];
            }
        }
    for (k=1;k<b;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++)
            {
                c[i][j]=d[i][j];
            }
        }
    }   
    int js=0;
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++)
        {
            if (c[i][j]=='@')
            js++;
        }
    }
    printf ("%d",js);
    return 0;
}
//********************************
//*???????   **
//*?????? 1300012713 **
//*???2013.11.04  **
//********************************
int main() 
{ 
	char a[100][100]; //??????a
	int m, n, num = 0; //?????
	cin >> n; //??????n
	for(int i = 1; i <= n; i++) //??????
	{
		for(int j = 1; j <= n; j++)
		{
			cin >> a[i-1][j-1];
		}
	}
	cin >> m; //?????? 
	for(int k = 1; k <= m-1; k++) //?????? ??????
	{
		for(int x = 0; x < n; x++)
		{
			for(int y = 0; y < n; y++)
			{
				if(a[x][y] == '@') //??????
				{
					if(a[x-1][y] == '.' && x != 0) //??????????
						a[x-1][y] = '!';
					if(a[x+1][y] == '.' && x != n-1)
						a[x+1][y] = '!';
					if(a[x][y-1] == '.' && y != 0)
						a[x][y-1] = '!';
					if(a[x][y+1] == '.' && y != n-1)
						a[x][y+1] = '!';			
				}
			}
		}
        for(int z = 1; z <= n; z++)
		{
			for(int t = 1; t <= n; t++)
			{
				if(a[z-1][t-1] == '!') //???????????
					a[z-1][t-1] = '@';
			}
		}

	}

	for(int p = 1; p <= n; p++)
	{
		for(int q = 1; q <= n; q++)
		{
			if(a[p-1][q-1] == '@')
				num = num + 1; //???????
		}
	}
	cout << num << endl; //????
	return 0;
}
/* Name        : ????
 * Version     : 1.0
 * Date        : 2013-01-11
 * New         : 
 * Description : 
 * State       : Design
 */
int main()
{
    int N=0,D=0,Sum=0;
    char Room[100][101]={0};
    cin>>N;
    for (int i=0;i<N;i++)
        for (int j=0;j<N;j++) cin>>Room[i][j];
    cin>>D;
    for (int d=1;d<D;d++)
    {
        for (int i=0;i<N;i++)
            for (int j=0;j<N;j++)
                if (Room[i][j]=='@')
                {
                    if (j>0  &&Room[i][j-1]=='.') Room[i][j-1]='&';
                    if (j<N-1&&Room[i][j+1]=='.') Room[i][j+1]='&';
                    if (i>0  &&Room[i-1][j]=='.') Room[i-1][j]='&';
                    if (i<N-1&&Room[i+1][j]=='.') Room[i+1][j]='&';
                }
        for (int i=0;i<N;i++)
            for (int j=0;j<N;j++)
                if (Room[i][j]=='&') Room[i][j]='@';
    }
    for (int i=0;i<N;i++)
        for (int j=0;j<N;j++)
            if (Room[i][j]=='@'||Room[i][j]=='&') Sum++;
    cout<<Sum;
    return 0;
}
char a[101][101];
int n,k;
int num=0;
int b[101][101];
int search()
{
	int i,j;
	for(i=0;i<n;i++)
	{for(j=0;j<n;j++)
		if((b[i-1][j]==2||b[i+1][j]==2||b[i][j-1]==2||b[i][j+1]==2)&&b[i][j]==0)
		{b[i][j]=1;num=num+1;}}
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			if(b[i][j]==1)
				b[i][j]=2;
			
			return 0;
}
int main()
{
	
	cin>>n;
	int i,j,l;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='.')
				b[i][j]=0;
			else if(a[i][j]=='@')
			{b[i][j]=2;num=num+1;}
			else if(a[i][j]=='#')
				b[i][j]=-1;
		}
	cin>>k;
	for(l=0;l<k-1;l++)
		search();
	cout<<num<<endl;
return 0;
}
int main()
{
	int i=0,j=0,k=0,n,m,num,c,b[10000][2];
	char a[110][110];
	for(i=0;i<110;i++)
		for(j=0;j<110;j++)
			a[i][j]=' ';
	cin>>n;
	for(i=1;i<=n;i++)
	    for(j=1;j<=n;j++)
	cin>>a[i][j];
	cin>>m;
	for(k=1;k<m;k++)
	{
		c=0;num=0;
	  for(i=1;i<=n;i++)
	{for(j=1;j<=n;j++)
	{if(a[i][j]=='@')
	{
		if(a[i-1][j]=='.'){
		b[c][0]=i-1;b[c][1]=j;c++;num=c;
		}
		if(a[i+1][j]=='.'){
		b[c][0]=i+1;b[c][1]=j;c++;num=c;
		}
		if(a[i][j-1]=='.'){
		b[c][0]=i;b[c][1]=j-1;c++;num=c;
		}
		if(a[i][j+1]=='.'){
		b[c][0]=i;b[c][1]=j+1;c++;num=c;
		}}}}
	for(c=0;c<num;c++)
		a[b[c][0]][b[c][1]]='@';
}
	num=0;
	for(i=1;i<=n;i++)
	{for(j=1;j<=n;j++)
	{
         if(a[i][j]=='@')	
			 num++;
	}}
	cout<<num<<endl;
	return 0;
}
int main() {
	int n, i, j, k, count = 0, x, y, m;
	char area[100][100];
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cin >> area[i][j];
	cin >> m;
	for (k = 0; k < m-1; k++){
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				if (area[i][j] =='@') {
					x = i;
					y = j;
					if ((y - 1 >= 0) && (area[x][y - 1] == '.') ) {
						area[x][y - 1] = '*';
					}
					if ((y + 1 < n)&&(area[x][y + 1] == '.') ) {
						area[x][y + 1] = '*';
					}
					if ((x - 1 >= 0)&&(area[x - 1][y] == '.') ) {
						area[x - 1][y] = '*';
					}
					if ((x + 1 < n) && (area[x + 1][y] == '.') ) {
						area[x + 1][y] = '*';
					}
				}
			}
		}
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				if(area[i][j]=='*')  area[i][j]='@';
	}
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			if(area[i][j]=='@')
				count++;
	cout<<count<<endl;
	return 0;
}
int main()
{
	int n,m,i,j,k,sum=0;
	char x[100][100],y[100][100];
	cin>>n;                                   //??n
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>x[i][j];            //?????????
			y[i][j]=x[i][j];
		}
	}
	cin>>m;
	for(k=1;k<m;k++)
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(x[i][j]=='@')
				{
					if(i>1&&x[i-1][j]=='.') y[i-1][j]='@';
					if(i<n&&x[i+1][j]=='.') y[i+1][j]='@';
					if(j<n&&x[i][j+1]=='.') y[i][j+1]='@';
					if(j>1&&x[i][j-1]=='.') y[i][j-1]='@';                                                //??????????
				}
			}
		}
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				x[i][j]=y[i][j];    //??????????????
			}
		}
	}
	for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(x[i][j]=='@') sum++;    //?????
			}
	}
	cout<<sum<<endl;
	return 0;
}
int main(){
	int n,i,p,t;
	scanf("%d\n",&n);
	char a[101][101];
	for(i=0;i<n;i++){
		scanf("%s\n",a[i]);
	}
	int q,w;
	int c[10000],b[10000];
	scanf("%d",&p);
	int j;
	for(i=1;i<p;i++){
		w=0;
		for(t=0;t<n;t++){
			for(q=0;q<n;q++){
				if(a[t][q]=='@'){
					c[w]=t;
					b[w]=q;
					w++;
				}
			}
		}
		for(j=0;j<w;j++){
			if(a[c[j]+1][b[j]]!='#'&&c[j]+1<n){
				a[c[j]+1][b[j]]='@';
			}if(a[c[j]][b[j]+1]!='#'&&b[j]+1<n){
				a[c[j]][b[j]+1]='@';
			}if(a[c[j]-1][b[j]]!='#'&&c[j]-1>=0){
				a[c[j]-1][b[j]]='@';
			}if(a[c[j]][b[j]-1]!='#'&&b[j]-1>=0){
				a[c[j]][b[j]-1]='@';
			}
		}
	}
	int y=0;
	for(i=0;i<n;i++){
		for(t=0;t<n;t++){
			if(a[i][t]=='@'){
				y++;
			}
		}
	}
	printf("%d",y);
	return 0;
}
int main()
{
	int a[102][102]={0},s[102][102]={0};
	int n,m,count=0;//?????.?1 ?????#?0 ???@?3
	char x;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			cin>>x;
			if(x=='.')
				{
					a[i][j]=1;
					s[i][j]=1;
				}
			if(x=='#')
				{
					a[i][j]=0;
					s[i][j]=0;
			    }
			if(x=='@')
				{
					a[i][j]=3;
					count++;
				}
		}
	cin>>m;
	for(int l=1;l<=m-1;l++)
	{
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			{
				if(a[i][j]==1&&(a[i-1][j]==3||a[i+1][j]==3||a[i][j+1]==3||a[i][j-1]==3))
				{
					s[i][j]=3;
					count++;
				}	
			}
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			{
				a[i][j]=s[i][j];
			}
	}
	cout<<count<<endl;
	return 0;
}
char room[101][101];
int po[10000][2];
int m,n,num = 0;
int flu(int day,int n)
{
	int count = 0,flunum = 0,x,y;
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < n;j++)
		{
			if(room[i][j] == '@')
			{
				po[flunum][0] = i;
				po[flunum][1] = j;
				flunum++;
			}
		}
	}

	for(int k = 0;k < flunum;k++)
	{
		x = po[k][0];
		y = po[k][1];
		if(x > 0 && room[x-1][y] == '.')
		{
			room[x-1][y] = '@';
			count++;
		}
		if(x < n && room[x+1][y] == '.')
		{
			room[x+1][y] = '@';
			count++;
		}
		if(y > 0 && room[x][y-1] == '.')
		{
			room[x][y-1] = '@';
			count++;
		}
		if(y < n && room[x][y+1] == '.')
		{
			room[x][y+1] = '@';
			count++;
		}
	}
	if(day == 1)return count;
	else return count + flu(day-1,n);
}
int main()
{
	cin>>n;
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < n;j++)
		{
			cin>>room[i][j];
			if(room[i][j] == '@')
				num++;
		}
	}
	cin>>m;
	cout<<num+flu(m-1,n)<<endl;
	return 0;
}
int main(){
	int map[200][200],b[200][200];
	int dx[4]={0,-1,0,1};
	int dy[4]={-1,0,1,0};
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			char ch;
			cin>>ch;
			if(ch=='.')map[i][j]=0;
			else if(ch=='#')map[i][j]=-1;
			else map[i][j]=1;
		}
	cin>>m;
	m--;
	while(m){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				b[i][j]=map[i][j];
		m--;

		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++){
				if(map[i][j]==1){
					for(int k=0;k<4;k++){
						int tx=i+dx[k],ty=j+dy[k];
						if(map[tx][ty]==0)b[tx][ty]=1;
					}
				}		
			}
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				map[i][j]=b[i][j];
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(map[i][j]==1)ans++;
	cout<<ans<<endl;
	return 0;
}
int n,m,i=0,j=0,t=0;
	char a[100][100];
void number(int x)
{   
	
	if(x==1)
	{   t=0;
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
		    	if(a[i][j]=='@')
		    	t++;
			}
		}
	}
	if(x>1)
	{
		number(x-1);
		for(i=0;i<n;i++)
	    {
	    	for(j=0;j<n;j++)
		    {
			   if(a[i][j]=='@')
			   {
					if(a[i][j+1]=='.'&&j<n-1)
					{
						a[i][j+1]='$';
						
					}
					if(a[i][j-1]=='.'&&j>0)
					{
						a[i][j-1]='$';
					}
					if(a[i-1][j]=='.'&&i>0)
					{
                          a[i-1][j]='$';
                     }
                     if(a[i+1][j]=='.'&&i<n-1)
                     {
                           a[i+1][j]='$';
                     }
                                      
					
				}
			}
		}
		t=0;
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{   
				if(a[i][j]=='$')
				a[i][j]='@';
		    	if(a[i][j]=='@'||a[i][j]=='$')
		    	t++;
			}
		}
	
	}
}
							
int main()
{
	

	cin>>n;
	for(i=0;i<n;i++)
	{
		 cin>>a[i];
     }
     cin>>m;
     number(m);
     cout<<t<<endl;
      return 0;
}
void main()
{
    char a[100][100],b[100][100];
	int n,i,k,q,j,w,e;
	scanf("%d",&n);
	for(i=0;i<n;i++) 
		scanf("%s",a[i]);
	scanf("%d",&k);
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
				b[i][j]=a[i][j];
	int empty=0;
	for(i=0;i<n;i++)
	{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='#') empty++;
			}
	}
	int num=n*n-empty;
	for(q=1;q<k;q++)
	{
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
					if(i>0&&a[i][j]=='@'&&a[i-1][j]=='.') b[i-1][j]='@';
					if(j>0&&a[i][j]=='@'&&a[i][j-1]=='.') b[i][j-1]='@';
					if(j<n&&a[i][j]=='@'&&a[i][j+1]=='.') b[i][j+1]='@';
					if(i<n&&a[i][j]=='@'&&a[i+1][j]=='.') b[i+1][j]='@';
					if(a[i][j]=='@') b[i][j]='@';
			}
		for(w=0;w<n;w++)
			for(e=0;e<n;e++)
				a[w][e]=b[w][e];
	}
	int x=0;
	for(i=0;i<n;i++)
	{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='@') x=x+1;
			}
	}
	 
		printf("%d",x);


	
}
void main()
{
	void f(int n,char str[][101],int a[][101]);
	int n,m,i,j,s=0;
	char str[101][101];
	int a[101][101];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(j!=n-1) scanf("%c",&str[i][j]);
			else scanf("%c\n",&str[i][j]);
            a[i][j]=0;
		}
	}
	scanf("%d",&m);
	while(m>1)
	{
		f(n,str,a);
		m--;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(str[i][j]=='@') s++;
		}
	}
	printf("%d",s);
}
void f(int n,char str[][101],int a[][101])
{
	int i,j;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(str[i][j]=='@'&&a[i][j]==0) 
			{
				if(i+1<n&&str[i+1][j]=='.') {str[i+1][j]='@';a[i+1][j]=1;}
				if(j+1<n&&str[i][j+1]=='.') {str[i][j+1]='@';a[i][j+1]=1;}
				if(i-1>=0&&str[i-1][j]=='.') {str[i-1][j]='@';a[i-1][j]=1;}
				if(j-1>=0&&str[i][j-1]=='.') {str[i][j-1]='@';a[i][j-1]=1;}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(str[i][j]=='@') 
			{
				a[i][j]=0;
			}
		}
	}
}
int A[110][110];
int day;int n;
void F(int x)
{
	
	if(x==day)
	{
		return ;
	}
    for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(A[i][j]>=0)
			{
				if(A[i-1][j]==-1||A[i-1][j]>A[i][j]+1)
				{
					A[i-1][j]=A[i][j]+1;
				}
				if(A[i+1][j]==-1||A[i+1][j]>A[i][j]+1)
				{
					A[i+1][j]=A[i][j]+1;
				}
				if(A[i][j+1]==-1||A[i][j+1]>A[i][j]+1)
				{
					A[i][j+1]=A[i][j]+1;
				}
				if(A[i][j-1]==-1||A[i][j-1]>A[i][j]+1)
				{
					A[i][j-1]=A[i][j]+1;
				}
			}
		}
	}
	F(x+1);
}
int main()
{
	
	cin>>n;
	char p;


	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
              cin>>p;
			  if(p=='@')
			  {
				  A[i][j]=0;
			  }
			  else if(p=='.')
			  {
				  A[i][j]=-1;
			  }
			  else
			  {
				  A[i][j]=-2;
			  }
			
		}
	}
	cin>>day;

	F(1);
	int num=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(A[i][j]<day&&A[i][j]>=0)
			{
				num++;
			}
		}
	}
	cout<<num;
	return 0;
}
int main ()
{
	int n, i = 0, j = 0, m, num = 0;
	char grid[100][100];
	cin >> n;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			cin >> grid[i][j];
			if (grid[i][j] == '.')
				grid[i][j] = 0;
			if (grid[i][j] == '#')
				grid[i][j] = 1;
			if (grid[i][j] == '@')
				grid[i][j] = 2;
		}
	}
	cin >> m;
	while (m != 1)
	{
		for (i = 0; i < n; i++)
		{
		    for (j = 0; j < n; j++)
			{
			    if (grid[i][j] == 2)
				{
					if (grid[i - 1][j] == 0)
						grid[i - 1][j] = 3;
                    if (grid[i + 1][j] == 0)
						grid[i + 1][j] = 3;
					if (grid[i][j - 1] == 0)
						grid[i][j - 1] = 3;
					if (grid[i][j + 1] == 0)
						grid[i][j + 1] = 3;
				}

			}
		}
		
		for (i = 0; i < n; i++)
		{
		    for (j = 0; j < n; j++)
			{
			    if (grid[i][j] == 3)
				{
					grid[i][j] = 2;
				}
			}
		}
		m--;
	}
	for (i = 0; i < n; i++)
	{
		 for (j = 0; j < n; j++)
		{
			 if (grid[i][j] == 2)
			 {
				num++;
			}
		}
	}
	cout << num << endl;

return 0;

}
int main()
{
	int num=0;
	int n,m;
	int i,j;
	char a[110][110],b[110][110];
	cin>>n;
	for(i=0;i<=n-1;++i)
	{
		for(j=0;j<=n-1;++j)
		{
			cin>>a[i][j];
		}
	}
	for(cin>>m;m>=2;--m)
	{
		for(i=0;i<=n-1;++i)
		{
			for(j=0;j<=n-1;++j)
			{
				b[i][j]=a[i][j];
			}
		}
		for(i=0;i<=n-1;++i)
		{
			for(j=0;j<=n-1;++j)
			{
				if(a[i][j]=='@')
				{
					if(a[i-1][j]=='.')
						b[i-1][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]='@';
				}
			}
		}
		for(i=0;i<=n-1;++i)
		{
			for(j=0;j<=n-1;++j)
			{
				if(b[i][j]=='@')
					a[i][j]='@';
			}
		}	
	}
	for(i=0;i<=n-1;++i)
	{
		for(j=0;j<=n-1;++j)
		{
			if(a[i][j]=='@')
			{
				num++;
			}
		}
	}
	cout<<num;
	return 0;
}
int main()
{char a[102][102][102],now;
 int yes[102][102],i,j,k,n,m,sum;
 cin>>n;
 memset(a,'.',sizeof(a));
 memset(yes,0,sizeof(yes));
 for (i=1;i<=n;i++)
      for (j=1;j<=n;j++)
           {
            cin>>a[1][i][j];
            }
 cin>>m;
 for (k=1;k<m;k++)
     {

     for (i=1;i<=n;i++)
           for (j=1;j<=n;j++)
                { if (a[k][i][j]=='@')
                    { a[k+1][i][j]=a[k][i][j];
                      if (a[k][i-1][j]!='#')
                          a[k+1][i-1][j]='@';
                      if (a[k][i][j-1]!='#')
                          a[k+1][i][j-1]='@';
                      if (a[k][i+1][j]!='#')
                          a[k+1][i+1][j]='@';
                      if (a[k][i][j+1]!='#')
                          a[k+1][i][j+1]='@';
                    }
                  if (a[k][i][j]=='#')
                      a[k+1][i][j]=a[k][i][j];
                }
       //for (i=1;i<=n;i++)
        //  {for (j=1;j<=n;j++)
         //        cout<<a[k+1][i][j];
         //  cout<<endl;
        //  }
     }
 sum=0;
 for (i=1;i<=n;i++)
      for (j=1;j<=n;j++)
           if (a[m][i][j]=='@')
               sum++;
 cout<<sum<<endl;
 return 0;

}
int main()
{
    char a[150][150];
    char b[150][150];
    int n, m, count = 0;
    cin >> n;
    for (int q = 0 ; q <= 149; q++)
        for (int w = 0; w <= 149; w++)
        {
            a[q][w] = '#';
            b[q][w] = a[q][w];
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            cin >> a[i][j];
            b[i][j] = a[i][j];
        }
    cin >> m;
    for (int k = 2; k <= m; k++)
    {
        for (int e = 1; e <= n; e++)
            for (int r = 1; r <= n; r++)
                {
                     if (a[e][r] == '@')
                    {
                        if (a[e][r + 1] == '.')
                            b[e][r + 1] = '@';
                        if (a[e][r - 1] == '.')
                            b[e][r - 1] = '@';
                        if (a[e + 1][r] == '.')
                            b[e + 1][r] = '@';
                        if (a[e - 1][r] == '.')
                            b[e - 1][r] = '@';
                    }
                }
        for(int z = 1; z <= n; z++)
            for (int x = 1; x <= n; x++)
                a[z][x] = b[z][x];
    }
    for (int t = 1; t <= n; t++)
        for (int y = 1; y <= n; y++)
            if (a[t][y] == '@')
                count++;
    cout << count << endl;
    return 0;
}
int main()
{
    int n,p[102][102],p1[102][102];
    const int dx[4]={1,0,-1,0};
    const int dy[4]={0,1,0,-1};
    for (int i=0;i<=n+1;i++)
        for (int j=0;j<=n+1;j++)
        p[i][j]=-1;//initializer
    char c;
    cin>>n;       
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
        {
            cin>>c;
            if (c=='.') p[i][j]=0;
            else if (c=='@') p[i][j]=1;
        }
    int day;
    cin>>day;
    for (int k=1;k<day;k++)
    {
        for (int i=0;i<=n+1;i++)
            for (int j=0;j<=n+1;j++)
            p1[i][j]=p[i][j]; //p1 temp
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
            {
                if (p[i][j]==1)
                   for (int t=0;t<4;t++)
                   if (p[i+dx[t]][j+dy[t]]==0) p1[i+dx[t]][j+dy[t]]=1;//4 directions
            }
        for (int i=0;i<=n+1;i++)
            for (int j=0;j<=n+1;j++)
            p[i][j]=p1[i][j];        
    }
    int num=0;
    for (int i=1;i<=n;i++)
       for (int j=1;j<=n;j++)
       if (p[i][j]==1) num++;
    cout<<num;

    return 0;
}