semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//  ????
//  main.cpp
//  Homework
//
//  Created by ??? on 13-10-31.
//  Copyright (c) 2013? ???. All rights reserved.
//


int main()
{
    int n,m,total=0;
    
    cin>>n;
    char student[n];
    double dorm[n+2][n+2],tempdorm[n+2][n+2];//?????????????
    for(int i=1;i<n+1;i++)
    {
        cin>>student;
        for(int s=1;s<n+1;s++)
        {
            if(student[s-1]=='.')
                dorm[i][s]=1;
            if(student[s-1]=='#')
                dorm[i][s]=0;//0???????0 ????????
            if(student[s-1]=='@')
                dorm[i][s]=2;
        }
    }
    
    for(int i=1;i<n+1;i++)
        for(int j=1;j<n+1;j++)
            tempdorm[i][j]=dorm[i][j];
    
    cin>>m;//????
    for(int d=1;d<m;d++)
    {
        for(int i=1;i<n+1;i++)
            for(int j=1;j<n+1;j++)
            if(dorm[i][j]>1)
                {
                    tempdorm[i-1][j]=dorm[i-1][j]*dorm[i][j];//?tempdorm????????dorm??????????????????????????????????
                    tempdorm[i+1][j]=dorm[i+1][j]*dorm[i][j];
                    tempdorm[i][j-1]=dorm[i][j-1]*dorm[i][j];
                    tempdorm[i][j+1]=dorm[i][j+1]*dorm[i][j];
                }
        for(int i=1;i<n+1;i++)
            for(int j=1;j<n+1;j++)
                if(tempdorm[i][j]>1)
                    dorm[i][j]=2;
    }
    
    for(int i=1;i<n+1;i++)//????
        for(int j=1;j<n+1;j++)
            if(dorm[i][j]>1)
                total++;
    
    cout<<total<<endl;
    return 0;
}
// * * * * * * * * * * * * * * *
// *???????             *
// *??????  1300013011   *
// *???2013.11.7            *
// * * * * * * * * * * * * * * *
int main()
{
	char str[101][101];
	int n, m, a[100][100], num = 0;
	int i, j;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			cin >> str[i][j];
			if (str[i][j] == '#')
				a[i][j] = 0;
			else if (str[i][j] == '.')
				a[i][j] = 1;
			else if (str[i][j] == '@')
				a[i][j] = 2;
			else
				a[i][j] = 0;
		}
	}
	cin >> m;
	for (int k = 2; k <= m; k++)
	{
		for (int h = 0; h < n; h++)
		{
			for (int l = 0; l < n; l++)
			{
				if ((h > 0) && (str[h][l] == '@') && (str[h-1][l] == '.'))
					a[h-1][l] *= 2;
				if ((h < n-1) && (str[h][l] == '@') && (str[h+1][l] == '.'))
					a[h+1][l] *= 2;
				if ((l > 0) && (str[h][l] == '@') && (str[h][l-1] == '.'))
					a[h][l-1] *= 2;
				if ((l < n-1) && (str[h][l] == '@') && (str[h][l+1] =='.'))
					a[h][l+1] *= 2;
			}
		}
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
			{
				if (a[i][j] >= 2)
					str [i][j] = '@';
			}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			if (a[i][j] >= 2)
				num++;
		}
	}
	cout << num << endl;
	return 0;
}
int main(){
	int n,m,i,j,k,count=0;//k????
	cin>>n;
	char a[110][110][110];
	for(i=1;i<n+1;i++)
		for(j=1;j<n+1;j++)
			cin>>a[1][i][j];//???????
	cin>>m;
	for(k=1;k<m;k++){
		for(i=1;i<n+1;i++)
			for(j=1;j<n+1;j++)
			{
				a[k+1][i][j]=a[k][i][j];//??k????????k+1?
			}
		for(i=1;i<n+1;i++)
			for(j=1;j<n+1;j++)
			{
				if(a[k][i][j]=='@')//????????????????????????
			    {
					if(a[k][i-1][j]=='.') a[k+1][i-1][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][j+1]=='.') a[k+1][i][j+1]='@';
				}
			}
	}
	for(i=1;i<n+1;i++)
			for(j=1;j<n+1;j++)
			{
				if(a[m][i][j]=='@') count++;
			}
		cout<<count;
	return 0;
}
int main(){
	int n,m,sum=0;
	cin>>n;
	char a[n+2][n+2],b[n+2][n+2];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)cin>>a[i][j];
	cin>>m;
	for(int i=1;i<m;i++){
		memcpy(b,a,sizeof(a));
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				if(a[j][k]=='@'){
					if(a[j][k-1]=='.')b[j][k-1]='@';
					if(a[j][k+1]=='.')b[j][k+1]='@';
					if(a[j+1][k]=='.')b[j+1][k]='@';
					if(a[j-1][k]=='.')b[j-1][k]='@';
				}
		memcpy(a,b,sizeof(a));
	}
	for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(a[i][j]=='@')sum++;
	cout<<sum<<endl;
	return 0;
}
/*??? 1200012866 11.11*/
int main(){
	int n,count=0,m;
	char a[105][105],b[105][105];
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			cin>>a[i][j];
			b[i][j]=a[i][j];
		}
	cin>>m;
	for(int z=0;z<m-1;z++){//m-1?
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)//??
				if(a[i][j]=='@'){
					if(i>0&&a[i-1][j]!='#')
						b[i-1][j]='@';
					if(j>0&&a[i][j-1]!='#')
						b[i][j-1]='@';
					if(i<n-1&&a[i+1][j]!='#')
						b[i+1][j]='@';
					if(j<n-1&&a[i][j+1]!='#')
						b[i][j+1]='@';
				}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)//????
				a[i][j]=b[i][j];
	}
	for(int i=0;i<n;i++)//??
		for(int j=0;j<n;j++)
			if(a[i][j]=='@')
				count++;
	cout<<count<<endl;

	return 0;
}
int main()
{
	char a[102][102] , b [102][102];
	int n , m , i , j , k ;
	cin >> n ;
	for (i = 1 ; i <= n ; i ++)
	{
		for (j = 1 ; j <= n ; j ++)
		{
			cin >> a[i][j] ;
		}
	}
	cin >> m ;
	for (i = 1 ; i <= n ; i ++)
	{
		for (j = 1 ; j <= n ; j ++)
		{
			b[i][j] = a[i][j] ;
		}
	}
	for ( ; m > 1 ; m --)
	{
		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 + 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 = 1 ; i <= n ; i ++)
		{
			for (j = 1 ; j <= n ; j ++)
			{
				a[i][j] = b[i][j];
			}
		}
	}
	k = 0 ;
	for (i = 1 ; i <= n ; i ++)
	{
		for (j = 1 ; j <= n ; j ++)
		{
			if(a[i][j] == '@')
				k ++;
		}
	}
	cout << k << endl;
	return 0 ;
}
int main(){
  int n,i,j,k,l;
  char aa[1000][1000];
  int m;
  cin>>n;
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
     cin>>aa[i][j];
   cin>>m;
  for(k=1;k<m;k++){
   for(i=0;i<n;i++){
    for(j=0;j<n;j++){
         if(aa[i][j]=='$')
               aa[i][j]='@';
      }
    }
   for(i=0;i<n;i++){
    for(j=0;j<n;j++){
     if(aa[i][j]=='@'){
          if((i-1>=0)&&(aa[i-1][j]=='.'))
              aa[i-1][j]='$';

           if((i+1<=n-1)&&(aa[i+1][j]=='.'))
              aa[i+1][j]='$';

              if((j-1>=0)&&(aa[i][j-1]=='.'))
              aa[i][j-1]='$';

               if((j+1<=n-1)&&(aa[i][j+1]=='.'))
              aa[i][j+1]='$';
}
}
}
}
    l=0;
       for(i=0;i<n;i++){
        for(j=0;j<n;j++){
      if(aa[i][j]=='@'||aa[i][j]=='$'){
          l++; 
}
}
}
  cout<<l<<endl;
return 0;
}
/*
 * work.cpp
 * function:????
 * Created on: 2012-12-3
 * Author: sear
 */
int n;			//n??????
char a[101][101];//????a???????
void judge(int i, int j) {//????????
	for (int d = -1; d <= 1; d += 2) {//??????????????"$"
		if ((i + d >= 0) && (i + d < n) && (a[i + d][j] == '.'))
			a[i + d][j] = '$';
		if ((j + d >= 0) && (j + d < n) && (a[i][j + d] == '.'))
			a[i][j + d] = '$';
	}
}
int main() {
	int m, num = 0, i, j, k;//m????,,
							//i,j,k	?????
	cin >> n;				//??n
	for (i = 0; i < n; i++)//?????????
		for (j = 0; j < n; j++)
			cin >> a[i][j];
	cin >> m;				//????m
	for (k = 1; k <= m; k++){//m-1??????m?
		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] == '@') {//????
					judge(i, j);//??????
					num++;	//?????1
					a[i][j] = '#';
							//???????????????
				}
	}
	cout << num;		//????
	return 0;
}
//********************************
//*???????     **
//*?????? 1300012887 **
//*???2013.11.03 **
//********************************
int main()
{
	char a[102][102];
	int b[102][102], n, m, i, j, k, l = 0;
	cin >> n; 
	cin.get();
	for (i = 0; i <= n-1; i++) 
	{
		for (j = 0; j <= n-2; j++)
			cin >> a[i][j];    //???????
		cin >> a[i][j];
		cin.get();
	}
	cin >> m;
	for (i = 0; i <= n-1; i++)
		for (j = 0; j <= n-1; j++)
			if(a[i][j] == '@')    //????????
				b[i][j] = 1;
	for (k = 2; k <= m; k++)    //????????
	{
		l = 0;
    	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] = 1;
			        if (a[i+1][j] == '.')
				        b[i+1][j] = 1;
			        if (a[i][j-1] == '.')
				        b[i][j-1] = 1;
			        if (a[i][j+1] == '.')
				        b[i][j+1] = 1;
				}
			}
		}
	for (i = 0; i <= n-1; i++)
		for (j = 0; j <= n-1; j++)
		   	if (b[i][j] == 1)
			{
				a[i][j] = '@';
            	l++;    //???m????????
			}  
	}
	cout << l;    //????
	return 0;
}
int main()
{
	int i,j,k,m,n,sum;
	char a[110][110];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s",a[i]);
	scanf("%d",&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((i+1<n)&&(i+1>=0)&&(a[i+1][j]=='.'))
						a[i+1][j]='!';
					if((i-1<n)&&(i-1>=0)&&(a[i-1][j]=='.'))
						a[i-1][j]='!';
					if((j+1<n)&&(j+1>=0)&&(a[i][j+1]=='.'))
						a[i][j+1]='!';
					if((j-1<n)&&(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]='@';
			}
	}
	sum=0;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
				sum=sum+1;
		}
		printf("%d",sum);
	
	return 0;
}
int main(){
int n,i,j,m,k=0,l,a,b;
scanf("%d\n",&n);
char s[102][102]={' '};


for(i=1;i<=n;i++){
	for(j=1;j<=n;j++){
	   scanf("%c\n",&s[i][j]);
	}
}
scanf("%d",&m);
for(l=0;l<m;l++){ 
	
	for(a=1;a<=n;a++){
		for(b=1;b<=n;b++){
	       if(s[a][b]=='-'){
			s[a][b]='@';
			}
		}
	}
for(i=1;i<=n;i++){
	for(j=1;j<=n;j++){
		
		if(s[i][j]=='@'){
		
			if(s[i-1][j]=='.') s[i-1][j]='-';
			if(s[i+1][j]=='.') s[i+1][j]='-';
			if(s[i][j+1]=='.') s[i][j+1]='-';
			if(s[i][j-1]=='.') s[i][j-1]='-';
		}
	}
}
}
for(i=1;i<=n;i++){
	for(j=1;j<=n;j++){
		if(s[i][j]=='@'){
			k++;
		}
	}
}
printf("%d",k);
return 0;
}
char a[105][105]={'\0'},b[105][105]={'\0'};
int n;
void renshu(int m,char a[105][105])
 {
     int t=0,i,j;
if(m==1)
{   
  t=0;
   for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
     {
      if(a[i][j]=='@')
       {t++;}
      }
       cout<<t<<endl;
}
 else
  {
   for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
     if(a[i][j]=='@')
       {  b[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=1;i<=n;i++)
    for(j=1;j<=n;j++)
     if(b[i][j]=='@')
       {  
         a[i][j]=b[i][j];
        }
    renshu(m-1,a); 
  }
}
int main()
{ 
 int m,i,j;
 cin>>n;
 for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    {
      cin>>a[i][j];
    }
 cin>>m;
 renshu(m,a);
 
 return 0;
}
char map[102][102];
int queue[2][128*100+100+1],num[2];//????????????????????



int main()
{
	int i,j,N,m,sum;
	memset(map,'#',sizeof(map));

	//input
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{
		scanf("%s",&map[i][1]);
		for(j=1;j<=N;j++)
			if(map[i][j]=='@')
				queue[0][num[0]++]=(i<<7)+j;
		map[i][j]='#';
	}
	scanf("%d",&m);

	//iteration
	sum=num[0];
	for(j=0;j<m-1;j++)
	{
		int tmp=j&1;//????????
		for(i=0;i<num[tmp];i++)
		{
			int x,y;
			x=queue[tmp][i]>>7;
			y=queue[tmp][i]&127;
			INFECT(x-1,y,!tmp);
			INFECT(x+1,y,!tmp);
			INFECT(x,y-1,!tmp);
			INFECT(x,y+1,!tmp);
		}
		num[tmp]=0;//???????
		sum+=num[!tmp];
	}

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


	return 0;
}
/*
 * ???:p5.cpp
 * ??:???
 * ??:1200012749
 * ????:2012-11-11
 * ??:???m???????
 */



int main()
{
	const int dirx[4]={0,0,1,-1}, // ????
			  diry[4]={1,-1,0,0};
	int n,m,i,j,k,x,y,mtime,ans=0; // ans??????
	char room[200][200],newroom[200][200]; // room???????newroom??????
	cin >> n;
	cin.getline(room[0],sizeof(room[0])); // ????
	for (i=0;i<n;i++)
		cin.getline(room[i],sizeof(room[i])); // ????
	cin >> m;
	for (mtime=1;mtime<m;mtime++) // ????
	{
		for (i=0;i<n;i++) // ??????
			for (j=0;j<n;j++)
				newroom[i][j]=room[i][j];
		for (i=0;i<n;i++) // ????????
			for (j=0;j<n;j++)
				if (room[i][j]=='@')
					for (k=0;k<4;k++) // ??????
					{
						x=i+dirx[k];y=j+diry[k];
						if (0<=x && x<n && 0<=y && y<n && room[x][y]=='.')
							// ???????????
							newroom[x][y]='@'; // ??
					}
		for (i=0;i<n;i++) // ??????
			for (j=0;j<n;j++)
				room[i][j]=newroom[i][j];
	}
	for (i=0;i<n;i++) // ?????
		for (j=0;j<n;j++)
			if (room[i][j]=='@')
				ans++;
	cout << ans << endl; // ??
	return 0;
}
int main()
{
	int n,i,j,k,m,count = 0;
	char a[101][101],b[101][101];
	cin >> n;
	for(i = 0 ; i < n + 2; i++)
	{
		for(j = 0 ; j < n + 2; 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( k = 0 ; k < m - 1 ; k++)
	{
		for(i = 1 ; i <= n ; i++)
		{
			for(j = 1 ; j <= n ; j++)
			{
				if(b[i][j] == '@' && b[i+1][j] == '.')
					a[i+1][j] = '@';
				if(b[i][j] == '@' && b[i-1][j] == '.')
					a[i-1][j] = '@';
				if(b[i][j] == '@' && b[i][j+1] == '.')
					a[i][j+1] = '@';
				if(b[i][j] == '@' && b[i][j-1] == '.')
					a[i][j-1] = '@';
			}
		}
		for(i = 0 ; i < n + 2; i++)
		{
			for(j = 0 ; j < n + 2; j++)
			{
				b[i][j] = a[i][j];
			}
		}
	}
	for(i = 1 ; i <= n; i++)
	{
		for(j = 1 ; j <= n ; j++)
		{
			if(a[i][j] == '@')
				count++;
		}
	}
	cout << count;
	return 0;
}
int main()
{
	int i,j,n,m,k,sum=0;
	char s[110][110],t;
	scanf("%d",&n);
    for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("\n");
			scanf("%c",&s[i][j]);
		}
	}
	scanf("%d",&m);
	for(k=1;k<m;k++)
	{
		for(i=1;i<=n;i++)
		{
		for(j=1;j<=n;j++)
		{
			if(s[i][j]=='@')
			{
				if(s[i+1][j]!='#'&&s[i+1][j]!='@')
				{
                     s[i+1][j]='!';
				}
				if(s[i-1][j]!='#'&&s[i-1][j]!='@')
				{
					 s[i-1][j]='!';
				}
				if(s[i][j+1]!='#'&&s[i][j+1]!='@')
				{
					 s[i][j+1]='!';
				}
				if(s[i][j-1]!='#'&&s[i][j-1]!='@')
				{
					 s[i][j-1]='!';
				}
			}
		}
		}
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(s[i][j]=='!')
				{
					s[i][j]='@';
				}
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(s[i][j]=='@')
			{
				sum++;
			}
		}
	}
	printf("%d",sum);
	return 0;
}
int main (){
 	int n,m,h,l,i,e,a;
 	char s[200][200],w[200][200];
 	scanf("%d",&n);
 	for(h=0;h<n;h++){
 			scanf("%s",s[h]);
 		}
 	for(h=0;h<n;h++){
 		for(l=0;l<n;l++){
 			w[h+1][l+1]=s[h][l];
 		}
 	}
 	scanf("%d",&m);
 	for(e=1;e<m;e++){
 		for(h=1;h<n+1;h++){
 		    for(l=1;l<n+1;l++){
 			if(w[h][l]=='@'){
 				w[h][l]='^';
 			}
 		}
 	  }
 	  for(h=1;h<n+1;h++){
 		    for(l=1;l<n+1;l++){
 			if(w[h][l]=='^'){
 				if(w[h-1][l]=='.'){
 					w[h-1][l]='@';
 				}
 				if(w[h+1][l]=='.'){
 					w[h+1][l]='@';
 				}
 				if(w[h][l-1]=='.'){
 					w[h][l-1]='@';
 				}
 				if(w[h][l+1]=='.'){
 					w[h][l+1]='@';
 				}
 					w[h][l]='@';
 			}
 		}
 	  }
 	}
 	a=0;
 	for(h=1;h<n+1;h++){
 		for(l=1;l<n+1;l++){
 			if(w[h][l]=='@'){
 				a++;
 			}
 		}
 	}
 		 printf("%d\n",a);
  
   
	
	return 0;
}
int main()
{
	const int max=110;
	int n;
	cin>>n;
	char a[max][max],b[max][max];
	int i,j;
	for(i=0;i<max;i++){
		for(j=0;j<max;j++){
			b[i][j]='0';
		}
	}
	
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	
	int m;
	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]=='@')){
					a[i][j]='@';
				}
			}
		}

	}

	int sum=0;
	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 n;
 scanf("%d",&n);
 char zfc[n+2][n+2],temp[n+2][n+2];
 int a,b,s=0;
 for(a=1;a<n+1;a++){
     scanf("%*c");
     for(b=1;b<n+1;b++){
         scanf("%c",&zfc[a][b]);
     }
 }
 for(a=0;a<n+2;a++){
    zfc[a][0]='#';
    zfc[a][n+1]='#';
 }
 for(b=1;b<n+1;b++){
     zfc[0][b]='#';
     zfc[n+1][b]='#';
 }
 int m;
 scanf("%d",&m);
 for( int i=1;i<m;i++){
     for(a=0;a<n+2;a++){
         for(b=0;b<n+2;b++){
             temp[a][b]=zfc[a][b];
         }
     }
     for(a=1;a<n+1;a++){
         for(b=1;b<n+1;b++){
             if(temp[a][b]=='@'){
                 if(temp[a-1][b]=='.'){
                     zfc[a-1][b]='@';
                 }if(temp[a+1][b]=='.'){
                     zfc[a+1][b]='@';
                 }if(temp[a][b+1]=='.'){
                     zfc[a][b+1]='@';
                 }if(temp[a][b-1]=='.'){
                     zfc[a][b-1]='@';
                 }
             }
         }
     }
 }for(a=1;a<n+1;a++){
     for(b=1;b<n+1;b++){
         if(zfc[a][b]=='@'){
             s++;
         }
     }
 }
printf("%d",s);
return 0;
}
/*
 * exam.cpp
 *
 *  Created on: 2013-10-31
 *      Author: dyx
 */
int main()
{
	int n;
	cin >> n;
	char jz[n][n];
	int i,j,k;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			cin >> jz[i][j];

		}
	int jz1[100][n][n];
	for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
				if(jz[i][j]=='.')
					jz1[0][i][j]=0;
				if(jz[i][j]=='#')
					jz1[0][i][j]=-100000;
				if(jz[i][j]=='@')
					jz1[0][i][j]=1;
			}
	for(k=1;k<100;k++)
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				jz1[k][i][j]=jz1[0][i][j];

	int d;
	cin >> d;
	for(k=0;k<d-1;k++)
	{
		for(i=0;i<n;i++)
				for(j=0;j<n;j++)
				{
					if(jz1[k][i][j]>0)
					{
						if(i==0&&j==0)
						{
							jz1[k+1][1][0]++;
							jz1[k+1][0][1]++;
						}
						else if(i==n-1&&j==0)
						{
							jz1[k+1][n-2][0]++;
							jz1[k+1][n-1][1]++;
						}
						else if(i==0&&j==n-1)
						{
							jz1[k+1][1][n-1]++;
							jz1[k+1][0][n-2]++;
						}
						else if(i==n-1&&j==n-1)
						{
							jz1[k+1][n-2][n-1]++;
							jz1[k+1][n-1][n-2]++;
						}
						else if(i==0)
						{
							jz1[k+1][0][j+1]++;
							jz1[k+1][0][j-1]++;
							jz1[k+1][1][j]++;
						}
						else if(j==0)
						{
							jz1[k+1][i+1][j]++;
							jz1[k+1][i-1][j]++;
							jz1[k+1][i][j+1]++;
						}
						else if(i==n-1)
						{
							jz1[k+1][n-1][j+1]++;
							jz1[k+1][n-1][j-1]++;
							jz1[k+1][n-2][j]++;
						}
						else if(j==n-1)
						{
							jz1[k+1][i+1][n-1]++;
							jz1[k+1][i-1][n-1]++;
							jz1[k+1][i][n-2]++;
						}
						else
						{
							jz1[k+1][i+1][j]++;
							jz1[k+1][i-1][j]++;
							jz1[k+1][i][j+1]++;
							jz1[k+1][i][j-1]++;
						}
					}
				}
	}

	int jishu=0;
	for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{	//cout <<jz1[d-1][i][j]<<" ";
				if(jz1[d-1][i][j]>0)
					jishu++;


			}
	cout <<jishu;







return 0;

}
int main()
{
	int n,m,sum=0;
	char x,room[N][N],room2[N][N];;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
		{
			cin>>room[i][j];
		}
	}
	memcpy(room2,room,N*N);
		cin>>m;
		for(int f=1;f<=m-1;f++){
			for(int i=1;i<=n;i++){
		        for(int j=1;j<=n;j++){
			if(room[i][j]=='@'){
				if(room[i+1][j]=='.')room2[i+1][j]='@';
				if(room[i-1][j]=='.')room2[i-1][j]='@';
				if(room[i][j+1]=='.')room2[i][j+1]='@';
				if(room[i][j-1]=='.')room2[i][j-1]='@';
			        }
				}
			}
			memcpy(room,room2,N*N);
		}
		    for(int i=1;i<=n;i++)
			    for(int j=1;j<=n;j++){
					if(room2[i][j]=='@')sum++;
				}
				cout<<sum<<endl;
				return 0;

}
int DORM[MAXN][MAXN],N,SIGN[MAXN][MAXN];
void aff(int x,int y);

int main(){
    memset(DORM,0,sizeof(DORM));
    memset(SIGN,0,sizeof(SIGN));
    int M,sum=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin.get();
        for(int j=0;j<N;j++){
            char m;
            cin.get(m);
            switch(m){
                case '.':
                    DORM[i][j]=-1;
                    break;
                case '#':
                    DORM[i][j]=0;
                    break;
                case '@':
                    DORM[i][j]=1;
                    break;
            }
        }
    }
    cin>>M;
    for(int m=1;m<M;m++){
        memset(SIGN,0,sizeof(SIGN));
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(DORM[i][j]==1&&SIGN[i][j]==0){
                    aff(i,j+1);
                    aff(i,j-1);
                    aff(i+1,j);
                    aff(i-1,j);
                }
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(DORM[i][j]==1) sum++;
        }
    }
    cout<<sum;
    return 0;
}
void aff(int x,int y){
    if(x>=0&&x<N&&y>=0&&y<N){
        if(DORM[x][y]==-1&&SIGN[x][y]==0){
            DORM[x][y]=1;
            SIGN[x][y]=1;
        }
    }
}
int main()
{
    int dx[4]={1,0,0,-1};
    int dy[4]={0,1,-1,0};
	int n;
    cin>>n;
    char room[100][100]={0};
    int Room[100][100]={0};
    memset(room, '#', sizeof(room));
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            cin>>room[i][j];
        }
    }
    int day;
    cin>>day;
    for (int q=1; q<day; q++) {
        for (int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                if (room[i][j]=='@') {
                    for (int k=0; k<4; k++) {
                        int tx=i+dx[k],ty=j+dy[k];
                        if (room[tx][ty]=='.') {
                            Room[tx][ty]=1;
                        }
                    }
                }
            }
        }
        for (int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                if (Room[i][j]) {
                    room[i][j]='@';
                }
            }
        }
        memset(Room, 0, sizeof(Room));
    }
    int p=0;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (room[i][j]=='@') {
                p++;
            }
        }
    }
    cout<<p;
	return 0;
}
int main()
{
 int n,i=0,j=0;
 cin>>n;
 char res[101][101],res2[101][101];
 for(i=0;i<n;i++)
 {
  for(j=0;j<n;j++)
  {
   cin>>res[i][j];
  }
 }
 int sum=0;
 int m,k=1;
 cin>>m;
 for(k=1;k<m;k++)
 {
  for(int s = 0;s<n;s++)
  {
   for(int t = 0;t<n;t++)
   {
    res2[s][t] = res[s][t];
   }
  }
  for(i=0;i<n;i++)
  {
   for(j=0;j<n;j++)
   {
    if (res[i][j]=='@')
    {
     if(i-1>=0)
     {
      if(res[i-1][j]=='.') 
      {
       res2[i-1][j]='@';
       res2[i][j]='@';
      }
     }
     if(i+1<n)
     {
      if(res[i+1][j]=='.')   
      {
       res2[i+1][j]='@';
       res2[i][j]='@';
      }
     }
     if(j-1>=0)
     {
      if(res[i][j-1]=='.') 
      {
       res2[i][j-1]='@';
       res2[i][j]='@';
      }
     }
     if(j+1<n)
     {
      if(res[i][j+1]=='.') 
      {
       res2[i][j+1]='@';
       res2[i][j]='@';
      }
     }
    }
   }
  }
  for(i=0;i<n;i++)
  {
   for(j=0;j<n;j++)
    {
    res[i][j]=res2[i][j];
    }
  }
 }
 for(int i = 0;i<n;i++)
 {
  for(int j = 0;j<n;j++)
  {
   if(res[i][j]=='@')
   {
    sum+=1;
   }
  }
 }
 cout<<sum;
 return 0;
}
int main()
{
    int n,m;
	char house[110][110]={'\0'};
	int day;
    int i,j;//???? 

	cin>>n;
	cin.get();
	for(i=1;i<=n;i++)
	{
		cin.getline(house[i],100,'\n');
	}
	cin>>m;

	for(i=n;i>0;i--)
	{
		for(j=n;j>0;j--)
			house[i][j]=house[i][j-1];
		house[i][0]='\0';
	}

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

	int count=0;

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

	cout<<count;
    
    return 0;
}
int main(){
 char a[102][102];
   int n,m,i,j,k;
   int p[4][2]={{0,1},{0,-1},{1,0},{-1,0}};

         cin>>n;
     for (i=0;i<=n+1;i++)
      for (j=0;j<=n+1;j++)
        a[i][j]='#';

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

    while (m>1)
    { m--;
     for (i=1;i<=n;i++)
    	for (j=1;j<=n;j++)
    	 if (a[i][j]=='@')
    	 { for (k=0;k<4;k++)
    		if (a[i+p[k][0]][j+p[k][1]]=='.')  a[i+p[k][0]][j+p[k][1]]='*';
    	 }
     for (i=1;i<=n;i++)
        	for (j=1;j<=n;j++)
        		if (a[i][j]=='*') a[i][j]='@';
    }
    int ans=0;
    for (i=1;i<=n;i++)
        	for (j=1;j<=n;j++)
	if (a[i][j]=='@') ans++;
    cout<<ans;
        return 0;
}