semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/*
 * lixurong5.cpp
 *
 *  Created on: 2012-11-11
 *      Author: a
 */


int main()
{
    int n;//????
    cin >> n;//??
    char a[n][n];//????
    int b[n][n];//????
    for( int i=0; i<n; i++ )//????
    {
    	for( int j=0; j<n; j++ )
    	{
    		cin >> a[i][j];
    		if( a[i][j] =='.' )//??????????
    			b[i][j]=1;
    		else if( a[i][j]=='@' )
    			b[i][j]=-1;
    		else
    			b[i][j]=0;

    	}
    }


    int m;//????
    cin >> m;
    for( int x=1; x<m; x++ )//????
    {
    	for( int i=0; i<n; i++ )//??
    	{
    		for( int j=0; j<n; j++ )
    		{
    			if( b[i][j]==(0-x) )
    			{
    				if( b[i][j+1]==1 && j+1<n)//???1?????????
    					b[i][j+1]=0-x-1;
    				if( b[i][j-1]==1 && j-1>=0)
    				    b[i][j-1]=0-x-1;
    				if( b[i+1][j]==1 && i+1<n)
    				    b[i+1][j]=0-x-1;
    				if( b[i-1][j]==1 && i-1>=0)
    				    b[i-1][j]=0-x-1;

    			}
    		}
    	}

    }
    int s=0;
    for( int i=0; i<n; i++ )//???????
    {
    	for( int j=0; j<n; j++ )
    	{
    		if( b[i][j]<0 )
    			s++;
    	}
    }
    cout << s;//??


	return 0;
}
int main()
{
	int n,m,a,b;
	int sum=0;
	int i,j,k;
	char kg;
	char sz[200][200];
	scanf("%d",&n);

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

	scanf("%d",&m);

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



		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(sz[i][j]=='r')
				{sz[i][j]='@';}
			}
		}



	}





	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(sz[i][j]=='@')
			{sum++;}
		}
	}


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








	return 0;
}
int main(){
char a[100][100];
int j,i,n,m,s=0,p;
scanf("%d\n",&n);
for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
        scanf("%c ",&a[i][j]);
    }
 }   
for(i=0;i<=n+1;i++){
    a[i][0]='#';
    a[i][n+1]='#';
}
for(j=1;j<=n;j++){
    a[0][j]='#';
    a[n+1][j]='#';
}
scanf("%d\n",&m);
for(p=0;p<m-1;p++){
    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]='t';
                }
                if(a[i][j+1]=='.'){
                    a[i][j+1]='t';
                }
                if(a[i-1][j]=='.'){
                    a[i-1][j]='t';
                }
                if(a[i+1][j]=='.'){
                    a[i+1][j]='t';
                }
            }
       }
  }
        for(i=1;i<=n;i++){
         for(j=1;j<=n;j++){
           if(a[i][j]=='t'){
           a[i][j]='@';
       }
     }
  } 
}   
 for(i=1;i<=n;i++){
   for(j=1;j<=n;j++){
       if(a[i][j]=='@'){
           s=s+1;
       }
     }
  } 


printf("%d",s);    
    
    return 0;
}
int main()
{
    char a[100][100];//a?????????
    /*i,j,k?????n????????n2????????m????num?????
      ,emp??????
    */
    int i, j, k, n, n2, m, num = 0, emp = 0;

    cin >> n;
    n2 = n * n;
    //???????????????????
    for (i = 0; i < n; i++)
	for (j = 0; j < n; j++)
	{	
	    cin >> a[i][j];
	    if (a[i][j] == '@')
                num++;
            if (a[i][j] == '#')
                emp++;
        }
    cin >> m;
    //?????m-1???????? 
    for (k = 1; k < m; k++)
    {    
	 if (num >= n2 - emp)
	     break;//????????????????????????
         /*???????????????????????????????????           ????????????????????????????'*'
         */
	 for (i = 0; i < n; i++)
	      for (j = 0; j < n; j++)
		  if (a[i][j] == '@')
		  {   
		      if (i > 0 && a[i - 1][j] == '.')
		      {	 
                          a[i - 1][j] = '*';
			  num++;
		      }
		      if (j > 0 && a[i][j - 1] == '.')
		      {	 
                          a[i][j - 1] = '*';
			  num++;
		      }
		      if (i < n - 1 && a[i + 1][j] == '.' )
		      {	 
                          a[i + 1][j] = '*';
			  num ++;
		      }
		      if (j < n - 1 && a[i][j + 1] == '.' )
		      {
                          a[i][j + 1] = '*';
			  num ++;
		      }
	           }
        //????????????????'@'	
        for (i = 0; i < n; i++)
	    for (j = 0; j < n; j++)
		if (a[i][j] == '*')
		    a[i][j] = '@';
				 
	}

    cout << num << endl;
	
    return 0;
}
int main(){
	int n,i,j,m,k,s=0;
	char a[100][100],b[100][100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("\n");
		for(j=0;j<n;j++){
			scanf("%c",&a[i][j]);
		}
	}
	scanf("%d",&m);
	for(k=1;k<m;k++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				b[i][j]=a[i][j];
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
		if(b[i][j]=='@'){
			if(i>0&&b[i-1][j]=='.')
				a[i-1][j]='@';
			if(i<n-1&&b[i+1][j]=='.')
				a[i+1][j]='@';
			if(j>0&&b[i][j-1]=='.')
				a[i][j-1]='@';
			if(j<n-1&&b[i][j+1]=='.')
				a[i][j+1]='@';
		}
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i][j]=='@')
				s+=1;
		}
	}
	printf("%d",s);
	return 0;
}
int main()
{
	int n,i,j;
	cin>>n;
	char r[100][100];
	int a[100][100];
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>r[i][j];
			if(r[i][j]=='.')a[i][j]=1;
			else if(r[i][j]=='#')a[i][j]=0;
			else a[i][j]=-1;
		}
	}
	for(i=0;i<=n+1;i++)
	{
		a[i][0]=0;
		a[i][n+1]=0;
	}
	for(j=0;j<=n+1;j++)
	{
		a[0][j]=0;
		a[n+1][j]=0;
	}
	int m,k;
	int b[100][100];
	cin>>m;
	for(i=0;i<=n+1;i++)
	{
		for(j=0;j<=n+1;j++)
		{
			b[i][j]=a[i][j];
		}
	}
	for(k=0;k<m-1;k++)
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(a[i][j]==1&&(a[i+1][j]==-1||a[i-1][j]==-1||a[i][j+1]==-1||a[i][j-1]==-1||a[i][j]==-1)&&a[i][j]!=0)
				{
					b[i][j]=-1;

				}
			}
		}

		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				a[i][j]=b[i][j];
			}
		}
	}
	int num=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(a[i][j]==-1)num++;
		}
	}
	cout<<num<<endl;
	return 0;
}
int main(){
	int n,i,j,m,k,p,q;
	p=0;
	q=0;
	char a[102][102];
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++){
			cin>>a[i][j];
			if(a[i][j]=='@')
				p++;
			if(a[i][j]=='#')
				q++;
		}
	cin>>m;
	for(i=0;i<=n+1;i++)
		for(j=0;j<=n+1;j++)
			if(i==0||j==0||i==n+1||j==n+1)
				a[i][j]='#';
	for(k=0;k<m-1;k++){
	    for(i=1;i<=n;i++)
		    for(j=1;j<=n;j++)
			    if((a[i][j]=='.')&&((a[i-1][j]=='@')||(a[i+1][j]=='@')||(a[i][j-1]=='@')||(a[i][j+1]=='@'))){
			    	a[i][j]='*';
			    	p++;
			    }
	    for(i=1;i<=n;i++)
	    	for(j=1;j<=n;j++)
	    		if(a[i][j]=='*')
	    			a[i][j]='@';
	}
	cout<<p<<endl;
	return 0;
}
/*************************
*????EX1_05.cpp
*??????1100019007?
*???2012-11-11
*???????
**************************/ 
char rooms[100][100];
int main(int argc, char *argv[])
{
    int n,m,i,j,d;//???? 
    int count=0;
    cin>>n;//??n
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin>>rooms[i][j]; 
        }
    }
    cin>>m;//??m 
    for(d=0;d<m-1;d++)
    {
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(rooms[i][j]=='@')
                {
                    if(i>0)
                    {
                        if(rooms[i-1][j]=='.')rooms[i-1][j]='+';
                    }
                    if(i<n-1)
                    {
                        if(rooms[i+1][j]=='.')rooms[i+1][j]='+';
                    }
                    if(j>0)
                    {
                        if(rooms[i][j-1]=='.')rooms[i][j-1]='+';
                    }
                    if(j<n-1)
                    {
                        if(rooms[i][j+1]=='.')rooms[i][j+1]='+';
                    }//??????
                }
            }
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(rooms[i][j]=='+')rooms[i][j]='@';
            }
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(rooms[i][j]=='@')count++;//???? 
        }
    }
    cout<<count<<endl;//???? 
    return 0;
}
/*
 * patient.cpp
 *
 *  Created on: 2012-11-12
 *      Author: ThinkPad
 */
int main(){
	char a[100][100];
	int line[10000],row[10000];
	int i,n,j,day,m,k,sum;
	cin>>n;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>a[i][j];
	cin>>m;
	for(day=1;day<=m-1;day++)
	{
		k=0;sum=0;
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='@'){line[k]=i;row[k]=j;
				k=k+1;}
			}
		for(i=0;i<k;i++)
		{

			if(a[line[i]-1][row[i]]!='#')a[line[i]-1][row[i]]='@';
			if(a[line[i]+1][row[i]]!='#')a[line[i]+1][row[i]]='@';
			if(a[line[i]][row[i]-1]!='#')a[line[i]][row[i]-1]='@';
			if(a[line[i]][row[i]+1]!='#')a[line[i]][row[i]+1]='@';

		}
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='@')sum=sum+1;
			}
	}
	if(m==1){for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@'){line[k]=i;row[k]=j;
			k=k+1;}
		}cout<<k;}
	else cout<<sum;
	return 0;
}
int number;
char roms[MAXN][MAXN];

void days_go();
int count();

int main()
{
    int renshu;
    int iter;
    int days;
    scanf("%d",&number);
    for(iter = 0 ; iter != number ;++iter)
    {
        scanf("%s",roms[iter]);
    }
    scanf("%d",&days);
    for(iter = 1 ; iter != days ; ++iter)
    {
        days_go();
    }
    renshu = count();
    printf("%d",renshu);
    return 0;
}

void days_go()
{
    int iterout , iterin;
    int i,j;
    for(iterout = 0 ; iterout != number ; ++iterout)
    {
        for(iterin = 0 ; iterin != number ; ++iterin)
        {
     if('@' == roms[iterout][iterin])
        {
         i= iterout-1;
      if(-1 !=j)
         {
       j= iterin;
          if('.' == roms[i][j])
         {
       roms[i][j] = '!';
                    }
                }
     i = iterout;
      j= iterin-1;
    if(-1 != j)
        {
              if('.' == roms[i][j])
             {
            roms[i][j] = '!';
                    }
           }
     j= iterin+1;
        if(number != j)
     {
   if('.' == roms[i][j])
        {
     roms[i][j] = '!';
          }
    }
    i= iterout+1;
  if(number != i)
            {
                    j = iterin;
            if('.' == roms[i][j])
             {
         roms[i][j] = '!';
     }
}
    }
    }
    }
    for(iterout = 0 ; iterout != number ; ++iterout)
    {
   for(iterin = 0 ; iterin != number ; ++iterin)
    {
 if('!' == roms[iterout][iterin])
      {
                roms[iterout][iterin] = '@';
       }
  }
  }
}

int count()
{
 int total = 0;
 int iterout , iterin;
 for(iterout = 0 ; iterout != number ; ++iterout)
    {
     for(iterin = 0 ; iterin != number ; ++iterin)
 {
 if('@' == roms[iterout][iterin])
 {
      ++total;
     }
  }
}
    return total;
}
int main ()
{
	int n,m,num=0;
	char a[110][110],myroom[110][110];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	cin>>m;
	for(int i=1;i<m;i++)
	{
		for(int l=0;l<n;l++)
			for(int k=0;k<n;k++)
				myroom[l][k]=a[l][k];
	    for(int i=0;i<n;i++)
	    {
		    for(int j=0;j<n;j++)
		    {
			if(myroom[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(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(a[i][j]=='@')
				num++;
	cout<<num<<endl;
	return 0;
}
int main()
{
	int n , m ;
	char c ;
	cin >> n ;
	int a[n][n] ;
	for( int i = 0 ; i < n ; i ++ )
	{
		getchar() ;
		for( int j = 0 ; j < n ; j ++ )
		{
			cin.get( c ) ;
			if( c == '.' ) a[i][j] = 1 ;
			if( c == '#' ) a[i][j] = 0 ;
			if( c == '@' ) a[i][j] = 2 ;
		}
	}
	cin >> m ;
	for( int i = 2 ; i < 1 + m ; i ++ )
	{
		for( int j = 0 ; j < n ; j ++ )
			for( int k = 0 ; k < n ; k ++ )
			{
				if( a[j][k] == i )
				{
					if( a[j-1][k] == 1 && j > 0 ) a[j-1][k] = i + 1 ;
					if( a[j+1][k] == 1 && j < n - 1 ) a[j+1][k] = i + 1 ;
					if( a[j][k-1] == 1 && k > 0 ) a[j][k-1] = i + 1 ;
					if( a[j][k+1] == 1 && k < n - 1 ) a[j][k+1] = i + 1 ;
				}
			}
	}
	m = 0 ;
	for( int i = 0 ; i < n ; i ++ )
		for( int j = 0 ; j < n ; j ++ )
		{
			if( a[i][j] > 1 ) m ++ ;
		}
	cout << m ;
	return 0 ;
}
int main()
{
	char a[102][102] , b[102][102];
	int n , i ,j;
	cin >> n;
	for (i = 0; i<= 101; i++)
		for (j = 0; j <= 101; j++)
		{
			a[i][j] = '#';
			b[i][j] = '#';
		}
	for (i = 1; i<=n ; i++)
		for (j = 1; j <= n; j++)
			cin >> a[i][j];
	int day , d;
	
	cin >> day;
	for (d = 2; d <= day; d++)
		if (d % 2 == 0)
			for (i = 1; i <= n ; i++)
				for (j = 1; j <= n; j++)
					if (a[i][j] != '#')
						if (a[i-1][j] == '@' || a[i+1][j] == '@' || a[i][j - 1] == '@'||a[i][j + 1] == '@'||a[i][j] == '@')
							b[i][j] = '@';
						else b[i][j] = '.';
					else b[i][j] = '#';
		else
			for (i = 1; i <= n ; i++)
				for (j = 1; j <= n; j++)
					if (b[i][j] != '#')
						if (b[i-1][j] == '@' || b[i+1][j] == '@' || b[i][j - 1] == '@'||b[i][j + 1] == '@'||b[i][j] == '@')
							a[i][j] = '@';
						else a[i][j] = '.';
					else a[i][j] = '#';
	int sum = 0;
	if (day % 2 == 0)
		for (i = 1; i <= n ; i++)		
			for (j = 1; j <= n; j++)
			{
				
				if (b[i][j] == '@')	
				sum ++;
				
			}
	else
		for (i = 1; i <= n ; i++)		
			for (j = 1; j <= n; j++)
			{
				
				if (a[i][j] == '@')	
				sum ++;
				
			}
	cout << sum << endl;
					





			




	return 0;





}
int main()
{
    int i,j,k,n,count,time;
	// ?????
    char a[2][100][101]; //????'\0'???????
    scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++){
		gets(a[0][i]);
		strcpy(a[1][i],a[0][i]);
	}
	scanf("%d",&time);
	for(k=0;k<(time-1);k++){ //???????time?1
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(a[0][i][j]=='@'){
					if(i+1<n){ //???????????????
						if(a[0][i+1][j]=='.'){
							a[1][i+1][j]='@';  //????????????????
						}
					}
					if(i-1>=0){ 
						if(a[0][i-1][j]=='.'){
							a[1][i-1][j]='@';
						}
					}
					if(j+1<n){ 
						if(a[0][i][j+1]=='.'){
							a[1][i][j+1]='@';
						}
					}
					if(j-1>=0){ 
						if(a[k%2][i][j-1]=='.'){
							a[1][i][j-1]='@';
						}
					}
				}
			}
		}
		for(i=0;i<n;i++){
			strcpy(a[0][i],a[1][i]);   //?????????????????
		}
	}
	// ?????????????????
	count=0;
	for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(a[0][i][j]=='@'){
					count++;
				}
			}
	}
	printf("%d",count);
    return 0;
}
int main()
{
	int n,m,i,j,k;
	char a[100][101][101];
	cin>>n;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>a[0][i][j];
	for(m=0;m<100;m++)
		for(i=0;i<n;i++)
				for(j=0;j<n;j++)
					a[m][i][j]=a[0][i][j];
	cin>>m;
	for(k=0;k<m;k++)
	{
		for(i=0;i<n;i++)
				for(j=0;j<n;j++)
					if(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]='@';
					}
	}
	int q=0;
	for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			if(a[m-1][i][j]=='@')
				q++;
	cout<<q;
	return 0;
}
/*
 *@file 5.cpp
 *@author ???
 *@date 11?3?
 *@description ????
 */

int main ()
{
	int n, m;
	char a[200][200], b[200][200];
	int i, j, k, count = 0;
	cin >> n;
	for (i = 0; i <= n; i++)
    {
		for (j = 0; j <= n; j++)
		{
			b[i][j] = '0';
		}
	}

	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}

	cin >> m;
	m--;
	while (m--)
	{
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				b[i][j] = a[i][j];
			}
		}
		
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (b[i][j] == '.' && (b[i-1][j] == '@' 
					|| b[i+1][j] == '@' || b[i][j-1] == '@' 
					|| b[i][j+1] == '@' || b[i][j-1] == '@'))
					a[i][j] = '@';
			}
		}
	}

	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if (a[i][j] == '@')
				count++;
		}
	}
	cout << count << endl;
	return 0;
}
int main(){
char fj2[100][100];
int n,a,b,i,k,fj[100][100],fj3[100][100],peo,m,day;
scanf("%d",&n);
peo=0;
for(i=0;i<n;i++){
scanf("%s",fj2[i]);}

for(i=0;i<n;i++){
for(k=0;k<n;k++){
if (fj2[i][k]=='.'){fj[i][k]=1,fj3[i][k]=1;}
else if(fj2[i][k]=='#'){fj[i][k]=0,fj3[i][k]=0;}
else if(fj2[i][k]=='@'){fj[i][k]=2,fj3[i][k]=2;}}}
scanf("%d",&m);
for(day=2;day<=m;day++){
for(i=0;i<n;i++){
for(k=0;k<n;k++){
if(fj[i][k]==2){
if(fj[i-1][k]==1){fj3[i-1][k]=2;}
if(fj[i+1][k]==1){fj3[i+1][k]=2;}
if(fj[i][k-1]==1){fj3[i][k-1]=2;}
if(fj[i][k+1]==1){fj3[i][k+1]=2;}}}}
for(a=0;a<n;a++){
for(b=0;b<n;b++){
fj[a][b]=fj3[a][b];
}}}

for(i=0;i<n;i++){
for(k=0;k<n;k++){
if(fj[i][k]==2){peo=peo+1;}}}
printf("%d",peo);
return 0;}
int flag[100][100] = {0},  n;	
char a[100][100];
int chuan(int i, int j, int count)
{
	if(flag[i][j + 1] == 0 && j < n - 1)
	{
		count++;
		flag[i][j + 1] = 3;
	}
	if(flag[i][j - 1] == 0 && j > 0)
	{
		count++;
		flag[i][j - 1] = 1;
	}
	if(flag[i - 1][j] == 0 && i > 0)
	{
		count++;
		flag[i - 1][j] = 1;
	}
	if(flag[i + 1][j] == 0 && i < n - 1)
	{
		count++;
		flag[i + 1][j] = 3;
	}
	return count;
}
int main()
{
	int i, j, k, m,count = 0;

	cin >> n;
	for (i = 0; i < n; i ++)
		for (j = 0; j < n; j++)
		{
			cin >> a[i][j];
			if (a[i][j] == '#')
				flag[i][j] = 2;
			if(a[i][j] == '@')
			{
				flag[i][j] = 1;
				count++;
			}
		}
	cin >> m;
	for(i = 1; i < m; i++)
	{
		for(j = 0; j < n; j++)
			for (k = 0; k < n; k++)
			{
				if(flag[j][k] == 1)
					count = chuan(j, k, count);
			}
		for (j = 0; j < n; j++)
			for (k = 0; k < n; k++)
				if (flag[j][k] == 3)
					flag[j][k] = 1;
	}
	cout << count << endl;
	return 0;
}
char a[103][200][200];
int main(){
	int n,m,day=1;
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[1][i][j];
	cin>>m;
	while(m>day){
		day++;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				if(a[day-1][i][j]=='#')a[day][i][j]='#';
				else if(a[day-1][i][j]=='@'||i>0&&a[day-1][i-1][j]=='@'||i<n-1&&a[day-1][i+1][j]=='@'||j>0&&a[day-1][i][j-1]=='@'||j<n-1&&a[day-1][i][j+1]=='@')a[day][i][j]='@';
				else a[day][i][j]='.';
			}
	}
	int count=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(a[m][i][j]=='@')count++;
	cout<<count<<endl;
	return 0;
}
//********************************
//*??  ????            *****
//*????? 1300012753     ***** 
//*???2013.10.31          *****   
//********************************
int main()
{
	int n, m, sum = 0;
	cin >> n;
	char a[100][100];
	for(int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		cin >> a[i][j];
	}
	cin >> m;
	for (int i = 2; i <= m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			for (int k = 0; k < n; k++)
			{
				if (a[j][k] == '@')
				{
					if (a[j - 1][k] == '.'&& j - 1 >= 0)
					a[j - 1][k] = 'x';
					if (a[j + 1][k] == '.' && j + 1 < n)
					a[j + 1][k] = 'x';
					if (a[j][k - 1] == '.' && k - 1 >= 0)
					a[j][k - 1] = 'x';
					if (a[j][k + 1] == '.' && k + 1 < n)
					a[j][k + 1] = 'x';
				}
			}
		}
		for (int p = 0; p < n; p++)
		{
			for (int q = 0; q < n; q++)
			{
				if (a[p][q] == 'x')
				a[p][q] = '@'; 
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (a[i][j] == '@')
			sum++;
		}
	}
	cout << sum;
	return 0; 
}
int n,m,i,j,t,p,x,y,q;
 char c[2][100][100];

int main()
{
 p=0;
 cin>>n;
 for (i=1;i<=n;i++)
  for (j=1;j<=n;j++)
   cin>>c[p][i][j];
   cin>>m;m--;
 while (m>0)
   {
     q=1-p;
      for(i=1;i<=n;i++)
       for (j=1;j<=n;j++)
        {
         if (c[p][i][j]=='@')
           {
            x=i-1;y=j;
            if (c[p][x][y]!='#')c[q][x][y]='@';
            x=i+1;y=j;
            if (c[p][x][y]!='#')c[q][x][y]='@';
            x=i;y=j-1;
            if (c[p][x][y]!='#')c[q][x][y]='@';
            x=i;y=j+1;
            if (c[p][x][y]!='#')c[q][x][y]='@';
           } 
         if(
         (c[p][i][j]=='@')||(c[p][i][j]=='#'))
         c[q][i][j]=c[p][i][j];
        }
     p=q;
     m--;
   }
 t=0;
 for(i=1;i<=n;i++)
  for (j=1;j<=n;j++)
   if(c[p][i][j]=='@') t++;
 cout<<t;    
 cin>>t;
 return 0;
}
int main(){
int n,t,i,m,k,c;
m=0;
c=0;
scanf("%d\n",&n);
char a[100][100]={'.'};
for(i=1;i<=n;i++){
for(t=1;t<=n-1;t++){scanf("%c",&a[i][t]);}
if(t==n){scanf("%c\n",&a[i][t]);}
}
scanf("%d",&m);
for(k=1;k<m;k++){
for(i=1;i<=n;i++){
for(t=1;t<=n;t++){
if(a[i][t]=='@'&&a[i][t-1]=='.'){
a[i][t-1]='A';}
if(a[i][t]=='@'&&a[i-1][t]=='.'){
a[i-1][t]='A';}
if(a[i][t]=='@'&&a[i][t+1]=='.'){
a[i][t+1]='A';}
if(a[i][t]=='@'&&a[i+1][t]=='.'){
a[i+1][t]='A';}
}}
for(t=1;t<=n;t++){
for(i=1;i<=n;i++){if(a[i][t]=='A'){a[i][t]='@';}
}}
}
for(t=1;t<=n;t++){
for(i=1;i<=n;i++){if(a[i][t]=='@'){c++;}
}}
printf("%d",c);
return 0;
}
int main()
{
	int n,k,i,j,l,count = 0;
	char a[100][100];
	int flag[100][100]= {0};
	cin >> n;
	for (i = 0;i < n;i++)
		for (j = 0;j < n;j++)
		{
			cin >> a[i][j];
			if (a[i][j] == '@')
				count ++;
		}
	cin >> k;
	for (l = 1;l < k;l++)
	{
		for (i = 0;i < n;i++)
			for (j = 0;j < n;j++)
				flag[i][j] = 0;
		for (i = 0;i < n;i++)
		     for (j = 0;j < n;j++)
			 {
				 if (a[i][j] == '@' && flag[i][j] == 0)
				 {
					 if (j + 1 < n && a[i][j+1] == '.')
					 {
						 a[i][j+1] = '@';
						 flag[i][j+1] = 1;
						 count++;
					 }
					 if (i + 1 < n && a[i+1][j] == '.')
					 {
						 a[i+1][j] = '@';
						 flag[i+1][j] = 1;
						 count++;
					 }
					 if (j - 1 >= 0 && a[i][j-1] == '.')
					 {
						 a[i][j-1] = '@';
						 flag[i][j - 1] = 1;
						 count++;
					 }
					 if (i- 1 < n && a[i-1][j] == '.')
					 {	 
						 a[i-1][j] = '@';
						 flag[i-1][j] = 1;
					     count++;
					 }
				 }
			 }
	}
	cout << count;
	return 0;
}
/* ??5?????    */
/* ??????       */
/* ???1200012834   */

int main()
{
	int m, n, i, j, day, total = 0;
	int date[103][103];   // date?????????????????
	char room[103][103];
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> room[i];
	}
	cin >> m;
	for (i = n-1; i >= 0; i--)
	{
		for (j = n-1; j >= 0; j--)
		{
			room[i+1][j+1] = room[i][j];  // ?????????????????????
		}
	}
	for (i = 0; i <= n + 1; i = i + n + 1)
	{
		for (j = 0; j <= n + 1; j++)
		{
			room[i][j] = '#';
			room[j][i] = '#';   // ????????????"#"?????
		}
	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			date[i][j] = 1;    // ?date???????????1
		}
	}
	for(day = 1; day < m; day++)
	{
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (room[i][j] == '@' && date[i][j] == day)  // ????date????day????
					                                         // ?????????
				{
					if (room[i+1][j] == '.')
					{
						room[i+1][j] = '@';
						date[i+1][j] = day + 1;  // ??????????date?????day+1?
						                         // ??????????????????????
					}
					if (room[i-1][j] == '.')
					{
						room[i-1][j] = '@';
						date[i-1][j] = day + 1;
					}
					if (room[i][j+1] == '.')
					{
						room[i][j+1] = '@';
						date[i][j+1] = day + 1;
					}
					if (room[i][j-1] == '.')
					{
						room[i][j-1] = '@';
						date[i][j-1] = day + 1;
					}
				}
			}
		}
	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if(room[i][j] == '@')
			{
				total ++;
			}
		}
	}
	cout << total << endl;
	return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	char s[200][200];
	int i,j;
	for(i=1;i<=n;i++)
	{
		getchar();
		for(j=1;j<=n;j++)
		{
			
			scanf("%c",&s[i][j]);
			
		}

	}
	
	int m;
	scanf("%d",&m);
	int k;
	for(k=1;k<m;k++)
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
		   		if(s[i][j]=='@')
		        {
			         if(i-1>=1&&s[i-1][j]!='#'&&s[i-1][j]!='@')
			        {
				            s[i-1][j]='0';

			         }
			         if(i+1<=n&&s[i+1][j]!='#'&&s[i+1][j]!='@')
			         {
				          s[i+1][j]='0';
			         }
			         if(j-1>=1&&s[i][j-1]!='#'&&s[i][j-1]!='@')
			        {
				         s[i][j-1]='0';
			        }
			         if(j+1<=n&&s[i][j+1]!='#'&&s[i][j+1]!='@')
			       {  
				        s[i][j+1]='0';
			        }
		         }
				

			}
		}
		
		for(i=1;i<=n;i++)
	   { 
		   for(j=1;j<=n;j++)
		   {
			   if(s[i][j]=='0')
			   {
				   s[i][j]='@';
			   }
		   }
		   

	   }
	}
	int num=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(s[i][j]=='@')
			{
				num++;

			}
		}
	}
	printf("%d",num);
	
	return 0;
	

}